CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Inquiry Regarding Obtaining Chemical Time Scales in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 7, 2023, 05:23
Default Inquiry Regarding Obtaining Chemical Time Scales in OpenFOAM
  #1
Member
 
Niyas
Join Date: Apr 2013
Posts: 45
Rep Power: 13
niyas is on a distinguished road
Dear CFD Community,

I am currently working on a combustion simulation using OpenFOAM v06 and aiming to extract and analyze the distribution of chemical time scales within the simulated domain. I have employed the Eddy Dissipation Concept (EDC) combustion model for this purpose.

I would appreciate any expertise in guiding me through the process of obtaining and visualizing the chemical time scale data in OpenFOAM. Specifically, I am interested in understanding the steps involved in post-processing.

Any insights, examples, or references you could provide would be immensely helpful.

Thank you in advance for your assistance.
__________________
Regards,
Niyas
niyas is offline   Reply With Quote

Old   December 7, 2023, 19:52
Default
  #2
Member
 
Niyas
Join Date: Apr 2013
Posts: 45
Rep Power: 13
niyas is on a distinguished road
Any guidance on this topic would be appreciated !!!!
__________________
Regards,
Niyas
niyas is offline   Reply With Quote

Old   September 29, 2024, 18:14
Smile Extracting Chemical and Mixing Time Scale in PaSR Model
  #3
New Member
 
Harsh Anand
Join Date: May 2024
Posts: 12
Rep Power: 2
GeekCFD is on a distinguished road
Hi niyas,
I know my reply is a bit late, but it would be helpful for others.
I have successfully extracted the Chemical and Mixing Time Scales from the PaSR Model in OpenFOAM (renamed it as openFOAMPaSR).
I think a similar process can be employed for the EDC Model too.

I have provided the source code below for reference.
The input-output files for tauC and tauM have been created and the values are being written into it for each cell in the domain.


openFOAMPaSR.C File:
Code:
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "openFOAMPaSR.H"

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

template<class ReactionThermo>
Foam::combustionModels::openFOAMPaSR<ReactionThermo>::openFOAMPaSR
(
    const word& modelType,
    ReactionThermo& thermo,
    const compressibleTurbulenceModel& turb,
    const word& combustionProperties
)
:
    laminar<ReactionThermo>(modelType, thermo, turb, combustionProperties),
    Cmix_(this->coeffs().getScalar("Cmix")),
    kappa_
    (
        IOobject
        (
            thermo.phasePropertyName(typeName + ":kappa"),
            this->mesh().time().timeName(),
            this->mesh(),
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        this->mesh(),
        dimensionedScalar(dimless, Zero)
    ),

    tauM_
    (
        IOobject
        (
            "mixingTimeScale",
            this->mesh().time().timeName(),
            this->mesh(),
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        this->mesh(),
        dimensionedScalar("mixingTimeScale", dimTime, 0)
    ),

    tauC_
    (
        IOobject
        (
            "chemTimeScale",
            this->mesh().time().timeName(),
            this->mesh(),
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        this->mesh(),
        dimensionedScalar("chemTimeScale", dimTime, 0)
    )
{}


// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //

template<class ReactionThermo>
Foam::combustionModels::openFOAMPaSR<ReactionThermo>::~openFOAMPaSR()
{}


// * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //

template<class ReactionThermo>
void Foam::combustionModels::openFOAMPaSR<ReactionThermo>::correct()
{
    if (this->active())
    {
        laminar<ReactionThermo>::correct();

	// Access turbulence quantities ---> epsilon and muEff
	tmp<volScalarField> tepsilon(this->turbulence().epsilon());
        const scalarField& epsilon = tepsilon();

        tmp<volScalarField> tmuEff(this->turbulence().muEff());
        const scalarField& muEff = tmuEff();

        // Access chemical time scale
        tmp<volScalarField> ttc(this->tc());
        const scalarField& tc = ttc();

        // Access density
        tmp<volScalarField> trho(this->rho());
        const scalarField& rho = trho();


        forAll(epsilon, i)
        {
            const scalar tauM_i = Cmix_ * sqrt(max(muEff[i] / rho[i] / (epsilon[i] + SMALL), 0));

            if (tauM_i > SMALL)
            {
                kappa_[i] = tc[i]/(tc[i] + tauM_i);
            }
            else
            {
                kappa_[i] = 1.0;
            }

	    // Store the computed 'tauC' and 'tauM' value for visualization
	    tauC_[i] = tc[i];
	    tauM_[i] = tauM_i;
        }
    }
}


template<class ReactionThermo>
Foam::tmp<Foam::fvScalarMatrix>
Foam::combustionModels::openFOAMPaSR<ReactionThermo>::R(volScalarField& Y) const
{
    return kappa_*laminar<ReactionThermo>::R(Y);
}


template<class ReactionThermo>
Foam::tmp<Foam::volScalarField>
Foam::combustionModels::openFOAMPaSR<ReactionThermo>::Qdot() const
{
    return tmp<volScalarField>
    (
        new volScalarField
        (
            this->thermo().phasePropertyName(typeName + ":Qdot"),
            kappa_*laminar<ReactionThermo>::Qdot()
        )
    );
}


template<class ReactionThermo>
bool Foam::combustionModels::openFOAMPaSR<ReactionThermo>::read()
{
    if (laminar<ReactionThermo>::read())
    {
        this->coeffs().readEntry("Cmix", Cmix_);
        return true;
    }
    else
    {
        return false;
    }
}


// ************************************************************************* //

openFOAMPaSR.H File:
Code:
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Class
    Foam::combustionModels::openFOAMPaSR

Group
    grpCombustionModels

Description
    Partially stirred reactor turbulent combustion model.

    This model calculates a finite rate, based on both turbulence and chemistry
    time scales.  Depending on mesh resolution, the Cmix parameter can be used
    to scale the turbulence mixing time scale.

    Mixing time scale is calculated as Cmix * sqrt(nuEff / epsilon)

SourceFiles
    openFOAMPaSR.C

\*---------------------------------------------------------------------------*/

#ifndef openFOAMPaSR_H
#define openFOAMPaSR_H

#include "../laminar/laminar.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace combustionModels
{

/*---------------------------------------------------------------------------*\
                            Class openFOAMPaSR Declaration
\*---------------------------------------------------------------------------*/

template<class ReactionThermo>
class openFOAMPaSR
:
    public laminar<ReactionThermo>
{
    // Private data

        //- Mixing constant
        scalar Cmix_;

        //- Mixing parameter
        volScalarField kappa_;

	// Field for mixing time scale
	volScalarField tauM_;

	// Field for chemical time scale
	volScalarField tauC_;


    // Private Member Functions

        //- No copy construct
        openFOAMPaSR(const openFOAMPaSR&) = delete;

        //- No copy assignment
        void operator=(const openFOAMPaSR&) = delete;


public:

    //- Runtime type information
    TypeName("openFOAMPaSR");


    // Constructors

        //- Construct from components
        openFOAMPaSR
        (
            const word& modelType,
            ReactionThermo& thermo,
            const compressibleTurbulenceModel& turb,
            const word& combustionProperties
        );


    //- Destructor
    virtual ~openFOAMPaSR();


    // Member Functions

        //- Correct combustion rate
        virtual void correct();

        //- Fuel consumption rate matrix.
        virtual tmp<fvScalarMatrix> R(volScalarField& Y) const;

        //- Heat release rate [kg/m/s3]
        virtual tmp<volScalarField> Qdot() const;

        //- Update properties from given dictionary
        virtual bool read();
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace combustionModels
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#ifdef NoRepository
    #include "openFOAMPaSR.C"
#endif

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //

The openFOAMPaSRs.C file would remain the same as before.
Code:
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011-2017 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "makeCombustionTypes.H"

#include "psiReactionThermo.H"
#include "rhoReactionThermo.H"
#include "openFOAMPaSR.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

makeCombustionTypes(openFOAMPaSR, psiReactionThermo);
makeCombustionTypes(openFOAMPaSR, rhoReactionThermo);

}

// ************************************************************************* //
GeekCFD is offline   Reply With Quote

Reply

Tags
combustion, edc, openfoam, timescale


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Postprocess: sampleDict works but creates no output folder shock77 OpenFOAM Post-Processing 14 November 15, 2021 09:27
LES, Courant Number, Crash, Sudden Alhasan OpenFOAM Running, Solving & CFD 5 November 22, 2019 03:05
pimpleDyMFoam computation randomly stops babapeti OpenFOAM Running, Solving & CFD 5 January 24, 2018 06:28
Micro Scale Pore, icoFoam gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 14:58
dynamic Mesh is faster than MRF???? sharonyue OpenFOAM Running, Solving & CFD 14 August 26, 2013 08:47


All times are GMT -4. The time now is 10:02.