View Issue Details

IDProjectCategoryView StatusLast Update
0002502OpenFOAMBugpublic2017-03-24 12:39
ReporterAMRBlack Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionsuspended 
PlatformGNU/LinuxOSUbuntuOS Version15.04
Summary0002502: bug in calculation of equilibrium constant of thermo package
DescriptionWhen check the impl of Foam::species::thermo::K(scalar p, scalar T), ie

>>>>>>>>>>
/// file: OpenFOAM-4.x/src/thermophysicalModels/specie/thermo/thermo/thermoI.H
/// line: 280
template<class Thermo, template<class> class Type>
inline Foam::scalar
Foam::species::thermo<Thermo, Type>::K(const scalar p, const scalar T) const
{
    scalar arg = -this->nMoles()*this->g(Pstd, T)/(RR*T);

    if (arg < 600.0)
    {
        return exp(arg);
    }
    else
    {
        return VGREAT;
    }
}
<<<<<<<<<<<
I found the first arg passed to g(...) may be p, not Pstd. Please check it. If that's true, it will results in erroneous results when calculating reversible chemical reactions.
TagsCombustion, thermo

Activities

henry

2017-03-17 08:12

manager   ~0007936

Thanks for bringing this up, I am uncertain about this term. The references I have use G to calculate the equilibrium contant at standard pressure which is then corrected for pressure effects in Kc:

    const scalar nm = this->Y()/this->W();

    if (equal(nm, SMALL))
    {
        return Kp(p, T);
    }
    else
    {
        return Kp(p, T)*pow(Pstd/(RR*T), nm);
    }

Are you sure G should be calculated with p rather than Pstd? Can you provide a good reference?

AMRBlack

2017-03-19 11:21

reporter   ~0007945

I am not sure abourt this. However I found that I may be misled into K(...) by another potential bug: "nMoles()" always return SMALL here in my test with reactingFoam. This will affect reversible reactions for Kc/Kp/Kx/Kn will be used, but no effects on irreversible reactions for "nMoles()" will not be called by the chemical packages. In other case of calling "nMoles()", such as calculation of psi/rho/mu/kappa and he for cellMixture and patchMixture, it will return the怀correct result. I guess this bug was caused by "thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.[CH]" for we may not get the local properties of mixtures which should be used by K(...).

henry

2017-03-19 15:33

manager   ~0007946

"nMoles()" is handled as a special case to avoid problems when the subractions of thermodynamics generates nMoles = 0. I am not aware of a bug in this treatment.

If you believe there is a problem can you provide an example case with results and correct results for comparison?

For "Kp" do you still think that the pressure should be "p"? If so can you provide a reference?

AMRBlack

2017-03-20 02:48

reporter   ~0007948

Can you tell me the reference you have? I would like to study it first for I know little about the theory of reversible chemical reactions.

What's more, I realized that the term "pow(Pstd/(RR*T), nm)" was introduced by entropy after reading the code in depth. I guess this term will not be true if the equation-of-state specified by user is not one of perfectGas and perfectFluid.

henry

2017-03-20 07:48

manager   ~0007949

Last edited: 2017-03-20 09:01

I have various books covering reversible chemical reactions

e.g. "The Properties of Gases & Liquids" Reid, Prausnitz and Poling. Chapter 6.

or you could start with Wikipedia or Web-search.

Can you provide the form of the correction to "pow(Pstd/(RR*T), nm)" for the other equations of state? If you could provide a patch it would help.

henry

2017-03-24 12:39

manager   ~0007976

Please re-open this report when you can provide a reference or derivation showing that the equilibrium constant should be evaluated using the local pressure and demonstration of the need for this.

Also if you can provide references describing and a patch to implement the changes needed to handle real-gas effects that would be useful.

Issue History

Date Modified Username Field Change
2017-03-17 01:32 AMRBlack New Issue
2017-03-17 01:32 AMRBlack Tag Attached: Combustion
2017-03-17 01:32 AMRBlack Tag Attached: thermo
2017-03-17 08:12 henry Note Added: 0007936
2017-03-19 11:21 AMRBlack Note Added: 0007945
2017-03-19 15:33 henry Note Added: 0007946
2017-03-20 02:48 AMRBlack Note Added: 0007948
2017-03-20 07:48 henry Note Added: 0007949
2017-03-20 09:01 henry Note Edited: 0007949
2017-03-24 12:39 henry Assigned To => henry
2017-03-24 12:39 henry Status new => closed
2017-03-24 12:39 henry Resolution open => suspended
2017-03-24 12:39 henry Note Added: 0007976