CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Heat capacity of species (https://www.cfd-online.com/Forums/openfoam-programming-development/141598-heat-capacity-species.html)

atoof September 11, 2014 09:37

Heat capacity of species
 
Dears,

I am going to implement a new model for calculating viscosity that needs to heat capacity of each species. The new solver is based on reactingFoam.

Is it possible to get heat capacity of all species in all computational cells of the domain?

I used the following with no success.

Code:

volScalarField cpi = composition.Cp(i,T);
where
i is the label of species and
Code:

basicMultiComponentMixture& composition = thermo.composition();
Thank you in advance,

Hossein

mturcios777 September 11, 2014 17:24

If you look at the documentation, the return value for the Cp is a single scalar, and the inputs are single scalars as well. To get Cp for a single field like this you will need to go through each species, and each cell, and calculate the mass weighted Cp.

Or you can use the cp function from the thermo class that does this already:

Code:

volScalarField cp = thermo.cp();

atoof September 12, 2014 23:32

Thanks Marco,



How can I go through each species? I'm using OF2.1.x. In the documentation of basicMultiComponentMixture.H we read:

Code:

//- Heat capacity at constant pressure [J/(kg K)]
            virtual scalar Cp(const label specieI, const scalar T) const = 0;

But I can not reach and I encounter the following error:

Code:

YEqn.H:53:52: error: no matching function for call to  ‘Foam::basicMultiComponentMixture::Cp(Foam::label&, const  volScalarField&)’
YEqn.H:53:52: note: candidate is:
In file  included from  /home/mohammad/OpenFOAM/OpenFOAM-2.1.x/src/thermophysicalModels/reactionThermo/lnInclude/hsCombustionThermo.H:39:0,
                  from  /home/mohammad/OpenFOAM/OpenFOAM-2.1.x/src/thermophysicalModels/chemistryModel/lnInclude/psiChemistryModel.H:43,
                from /home/mohammad/OpenFOAM/OpenFOAM-2.1.x/src/combustionModels/lnInclude/psiChemistryCombustionModel.H:43,
                from myReactingFoam.C:35:
/home/mohammad/OpenFOAM/OpenFOAM-2.1.x/src/thermophysicalModels/reactionThermo/lnInclude/basicMultiComponentMixture.H:134:28:  note: virtual Foam::scalar  Foam::basicMultiComponentMixture::Cp(Foam::label, Foam::scalar) const
/home/mohammad/OpenFOAM/OpenFOAM-2.1.x/src/thermophysicalModels/reactionThermo/lnInclude/basicMultiComponentMixture.H:134:28:  note:  no known conversion for argument 2 from ‘const volScalarField  {aka const Foam::GeometricField<double, Foam::fvPatchField,  Foam::volMesh>}’ to ‘Foam::scalar {aka double}’

Because it needs scalar instead of volScalarField. Is there any way to extract Cp value from a volScalarField value (temperature)?
Your second suggestion gives the heat capacity of each cell but not each species. Also,
Code:

thermo.cp();
leads to
Code:

class Foam::hsCombustionThermo’ has no member named ‘cp’
cp shold be replaced by Cp

atoof September 13, 2014 03:59

I used the following to get the species' heat capacities:
In createFields:
Code:

PtrList<volScalarField>& cpi = Y;
forAll( cpi, rowI){
      cpi[rowI].setSize(mesh.cells().size(), 0);
}

and in YEqn.H:
Code:

    forAll(T, cellI)
    { 
        forAll(Y, specieI)
        {
            cpi[specieI][cellI] = composition.Cp(specieI,T[cellI]);
        }
    }

Any Comments?

mturcios777 September 15, 2014 12:31

Looks good to me.


All times are GMT -4. The time now is 09:42.