CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Relation between enthalpy of single species and mixture

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Benben
  • 1 Post By zhangyan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 23, 2018, 11:37
Default Relation between enthalpy of single species and mixture
  #1
Member
 
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9
Benben is on a distinguished road
Hello,

I am using reactingFoam, on openfoam 6.0, and I have trouble to understand how exactly is the enthalpy of a single species calculated.

According to me, the energy (sensible enthalpy in my case) of the mixture is supposed to be the summ of the mass fractions, times the energy of singles species.

However, if i calculate the summ of sensible enthalpy of single species, i dont find the enthalpy of the mixture :
\Sigma_i \left( Y_i \times h_i \right) \neq h
Or with some simplified code :
Code:
basicSpecieMixture& composition = thermo.composition();
volScalarField h_summ = thermo.he()*0.;
forAll(Y,i)
{
   h_summ += composition.Y[i] * composition.Hs(i,p,T)
}
h_summ != thermo.he()
Why is it so ?
atulkjoy likes this.
Benben is offline   Reply With Quote

Old   October 23, 2018, 14:53
Default
  #2
Member
 
Vince
Join Date: Mar 2017
Posts: 45
Rep Power: 9
hyFoam is on a distinguished road
Hi Benoit,

thermo.he() and thermo.Hs() do no have the same units:
Code:
in thermo.H
//- Enthalpy/Internal energy [J/kmol]
 inline scalar he(const scalar p, const scalar T) const;
versus
Code:
in SpecieMixture.H
//- Sensible enthalpy [J/kg]
virtual scalar Hs
(
        const label speciei,
        const scalar p,
        const scalar T
) const;

You should be using thermo.Hs() instead for comparison.

Thanks,
Vince

Last edited by hyFoam; October 24, 2018 at 03:59. Reason: clarification
hyFoam is offline   Reply With Quote

Old   October 23, 2018, 21:38
Default
  #3
Senior Member
 
zhangyan's Avatar
 
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12
zhangyan is on a distinguished road
Hi,
In OpenFOAM, mixture_ is a special species, it's properties is calculated according to mass fraction weighted average.
If you are using a gasHThermoPhysics type of mixture_, then these properties are:
Code:
Y_ 
moleWeight_ 
Tcommon_ 
Thigh_ 
Tlow_ 
highCpCoeffs_ 
lowCpCoeffs_ 
As_ 
Ts_
Because there is a typedef:
Code:
typedef
sutherlandTransport
<
    species::thermo
    <
        janafThermo
        <
            perfectGas<specie>
        >,
        sensibleEnthalpy
    >
> gasHThermoPhysics;
And Y_ moleWeight_ come from Foam::specie;
Tcommon_ Thigh_ Tlow_ highCpCoeffs_ lowCpCoeffs_ come from janafThermo;
As_ Ts_ come from suterlandTransport.

After mixture_ gets these properties, it is easy to get its enthalpy.
zhangyan is offline   Reply With Quote

Old   October 24, 2018, 09:29
Default
  #4
Member
 
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9
Benben is on a distinguished road
Quote:
Originally Posted by hyFoam View Post
Hi Benoit,

thermo.he() and thermo.Hs() do no have the same units:
Code:
in thermo.H
//- Enthalpy/Internal energy [J/kmol]
inline scalar he(const scalar p, const scalar T) const;
versus
Code:
in SpecieMixture.H
//- Sensible enthalpy [J/kg]
virtual scalar Hs
(
        const label speciei,
        const scalar p,
        const scalar T
) const;
You should be using thermo.Hs() instead for comparison.

Thanks,
Vince
Thank you for your answer,

Unfortunately, there is no function Hs() in the class "hePsiThermo".
Furthermore, it doesnt seems to be an issue with units, as the documentation says that both basicSpecieMixture::Hs() and basicThermo::he() are documented to be in J/kg.

I made an experiment :
I used two species "a" and "b" with the same molar mass. I put them in a constant temperature/pressure mesh, and i ploted the mixture's enthalpy for various "Ya" : mass fraction of a.
(as the two species have the same molar mass, mass fraction is also molar fraction).
The sensible enthalpy at my reference temperature of species a is Ha = 22.4, and for my species b Hb = 3.18E5
I compared "thermo.he()" with "ya*Ha + (1-Ya)*Hb"
Here is the comparison plot i obtained :
CFDonline.png
Conclusion : thermo.he() is not a linear function of Ya. So i have no clue how to calculate it.
Benben is offline   Reply With Quote

Old   October 24, 2018, 09:50
Default
  #5
Member
 
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9
Benben is on a distinguished road
Quote:
Originally Posted by zhangyan View Post
Hi,
In OpenFOAM, mixture_ is a special species, it's properties is calculated according to mass fraction weighted average.
If you are using a gasHThermoPhysics type of mixture_, then these properties are:
Code:
Y_ 
moleWeight_ 
Tcommon_ 
Thigh_ 
Tlow_ 
highCpCoeffs_ 
lowCpCoeffs_ 
As_ 
Ts_
Because there is a typedef:
Code:
typedef
sutherlandTransport
<
    species::thermo
    <
        janafThermo
        <
            perfectGas<specie>
        >,
        sensibleEnthalpy
    >
> gasHThermoPhysics;
And Y_ moleWeight_ come from Foam::specie;
Tcommon_ Thigh_ Tlow_ highCpCoeffs_ lowCpCoeffs_ come from janafThermo;
As_ Ts_ come from suterlandTransport.

After mixture_ gets these properties, it is easy to get its enthalpy.
Hello, thank you for your answer.

Here is an extract of my "thermophysicalProperties" dictionnary :
Code:
thermoType
{
    type            hePsiThermo;
    mixture         reactingMixture;
    transport       sutherland;
    thermo          janaf;
    energy          sensibleEnthalpy;
    equationOfState perfectGas;
    specie          specie;
}
I was unable to find how my "hePsiThermo" computes he() from the mixture.
According to the doc, hePsiThermo::he(p,T) is defined at line 164 of "heThermo.C", and it essentially do :
Code:
heCells[celli] = this->cellMixture(celli).HE(pCells[celli], TCells[celli]);
There is no function "cellMixture" in the class "hePsiThermo", so i guess this piece of code somehow calls it from the "MixtureType" template (hePsiThermo<BasicPsiThermo, MixtureType>).
I guess that cellMixture is the function of "reactingMixture", inherited from "multiComponentMixture". It is defined at line 130 of "multicomponentMixture.C".
Code:
const ThermoType& Foam::multiComponentMixture<ThermoType>::cellMixture
(
    const label celli
) const
{
    mixture_ = Y_[0][celli]*speciesData_[0];
    for (label n=1; n<Y_.size(); n++)
    {
        mixture_ += Y_[n][celli]*speciesData_[n];
    }
    return mixture_;
}
I am guessing that this template class "ThermoType" the function returns an object of, might be the class "sensibleEnthalpy" (according to my "thermoProperties" dictionnary). In which case "he" is calculated as :
Code:
sensibleEnthalpy mixture_ = multiComponentMixture::cellMixture(celli);
heCells[celli] = mixture_.HE(pCells[celli], TCells[celli]);
The function "sensiblenthalpy::He()"is defined at line 96 of "sensibleEnthalpy.H" :
Code:
scalar HE
(
   const Thermo& thermo,
   const scalar p,
   const scalar T
) const
{
    return thermo.Hs(p, T);
}
But this function takes one more parameter than expected : the parameter "const Thermo& thermo", so I am probably wrong somewhere ... And if I am right, what is this "Thermo" class that is beeing used ?

Last edited by Benben; October 25, 2018 at 05:03.
Benben is offline   Reply With Quote

Old   October 24, 2018, 21:33
Default
  #6
Senior Member
 
zhangyan's Avatar
 
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12
zhangyan is on a distinguished road
https://openfoam.top/en/mixture/
https://openfoam.top/en/thermodynamicLIB/
zhangyan is offline   Reply With Quote

Old   October 25, 2018, 03:30
Default
  #7
Member
 
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9
Benben is on a distinguished road
Hello, thank you again for your help.

According to your links, the object "mixture_" in :
Code:
const ThermoType& Foam::multiComponentMixture<ThermoType>::cellMixture
(
    const label celli
) const
{
    mixture_ = Y_[0][celli]*speciesData_[0];
    for (label n=1; n<Y_.size(); n++)
    {
        mixture_ += Y_[n][celli]*speciesData_[n];
    }
    return mixture_;
}
Is of type :
Code:
sutherlandTransport<species::thermo<janafThermo<perfectGas<specie>>,sensibleEnthalpy>>
And not of type "sensibleEnthalpy".

I looked up to find the exact template types of my "hePsiThermo" object, and i couldn't go to the end of the rabbit hole. The way it is constructed from my solver's "createFields.H" led me to "basicThermoTemplates.C", in the function "Foam::basicThermo::lookupThermo", where some macro dark magic happens (more info here).

However, i found this :
Code:
#define typedefThermoPhysics(Transport,Type,Thermo,EqnOfState,Specie)          \
                                                                               \
    typedef                                                                    \
        Transport                                                              \
        <                                                                      \
            species::thermo                                                    \
            <                                                                  \
                Thermo                                                         \
                <                                                              \
                    EqnOfState                                                 \
                    <                                                          \
                        Specie                                                 \
                    >                                                          \
                >,                                                             \
                Type                                                           \
            >                                                                  \
        >                                                                      \
        Transport##Type##Thermo##EqnOfState##Specie
 
#define defineThermoPhysicsThermo(BaseThermo,CThermo,Mixture,ThermoPhys)       \
                                                                               \
    typedef                                                                    \
        CThermo                                                                \
        <                                                                      \
            BaseThermo,                                                        \
            Mixture<ThermoPhys>                                                \
        >                                                                      \
        CThermo##Mixture##ThermoPhys;                                          \
                                                                               \
    defineTemplateTypeNameAndDebugWithName                                     \
    (                                                                          \
        CThermo##Mixture##ThermoPhys,                                          \
        (#CThermo"<" + Mixture<ThermoPhys>::typeName() + ">").c_str(),         \
        0                                                                      \
    )
In "makeThermo.H", which seems to be the macro that define my thermoProperties type on run time selection.
And, as my thermoProperties dictionnary looks like this :
Code:
thermoType
{
    type            hePsiThermo;
    mixture         reactingMixture;
    transport       sutherland;
    thermo          janaf;
    energy          sensibleEnthalpy;
    equationOfState perfectGas;
    specie          specie;
}
I am guessing that this means

that my mixture type ("ThermoPhysics" in the macro) is of type :
Which is coherent with your link.
And my "hePsiThermo" thermo object ("ThermoPhysicsThermo" in the macro) is of type

Last edited by Benben; October 25, 2018 at 05:08.
Benben is offline   Reply With Quote

Old   October 25, 2018, 05:05
Default
  #8
Senior Member
 
zhangyan's Avatar
 
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12
zhangyan is on a distinguished road
Sorry for that the website's original language is Chinese.
I found that thermo in reactingFoam is defined by defineThermoPhysicsReactionThermo macro function, instead of defineThermoPhysicsThermo.
And it's definition:
Code:
#define defineThermoPhysicsReactionThermo(BaseReactionThermo,CThermo,Mixture,ThermoPhys) \
    typedef CThermo//hePsiThermo                                                         \
    <                                                                                    \
        BaseReactionThermo,//psiReactionThermo                                           \
        SpecieMixture                                                                    \
        <                                                                                \
            Mixture//reactingMixture                                                     \
            <                                                                            \
                ThermoPhys//sutherlandTransport                                          \
            >                                                                            \
        >                                                                                \
    > CThermo##Mixture##ThermoPhys;                                                      \
                                                                                         \
    defineTemplateTypeNameAndDebugWithName                                               \
    (                                                                                    \
        CThermo##Mixture##ThermoPhys,                                                    \
        (#CThermo"<" + Mixture<ThermoPhys>::typeName() + ">").c_str(),                   \
        0                                                                                \
    )
After instantiation:
Code:
hePsiThermo
<
psiReactionThermo,
    SpecieMixture
    <
        reactingMixture
        <
            sutherlandTransport
            <
                species::thermo
                <
                    janafThermo<perfectGas<specie>>,sensibleEnthalpy
                >
            >
        >
    >
>
Benben likes this.
zhangyan is offline   Reply With Quote

Old   October 25, 2018, 05:33
Default
  #9
Member
 
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 9
Benben is on a distinguished road
God ... I just found out what was the problem
my initialization files were looking like this :

Species A :
Code:
internalField   uniform 0.1;
Species B :
Code:
internalField   uniform 1.;
As species B was the inert species, i thought that my initialization didnt matter (as for YEqn, Yb = (1-Ya) ).
However, it has an impact on the calculation of the initial enthalpy of the system ! Which then calculates some garbage initial value for the enthalpy ...
This is why i was'nt finding that \Sigma_i \left( Y_i \times h_i \right) == h

However, this relation is exact, when i corrected my initialization of mass fraction, things went ok again. This is probably a bug btw, it should'nt behave like that. The summ of fraction should be set back to 1. before calculating the internal energy.

Last edited by Benben; October 26, 2018 at 06:45.
Benben is offline   Reply With Quote

Reply


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
continuity problem in species of mixture Fluent esi1520 FLUENT 7 April 26, 2018 08:17
Selecting mixture of species as "mass-flow-inlet" on a surface using UDF Bharadwaj B S Fluent UDF and Scheme Programming 0 April 7, 2015 08:09
Enthalpy in a binary gas mixture ChrisA FLUENT 0 August 26, 2013 19:32
species transport model or mixture model?HELP zhhjll FLUENT 3 March 5, 2011 15:27
species transport model or mixture model? achaokaoyan Main CFD Forum 0 July 10, 2010 10:52


All times are GMT -4. The time now is 21:08.