Commit abc50e21 authored by Henry Weller's avatar Henry Weller

thermophysicalModels: Changed specie thermodynamics from mole to mass basis

The fundamental properties provided by the specie class hierarchy were
mole-based, i.e. provide the properties per mole whereas the fundamental
properties provided by the liquidProperties and solidProperties classes are
mass-based, i.e. per unit mass.  This inconsistency made it impossible to
instantiate the thermodynamics packages (rhoThermo, psiThermo) used by the FV
transport solvers on liquidProperties.  In order to combine VoF with film and/or
Lagrangian models it is essential that the physical propertied of the three
representations of the liquid are consistent which means that it is necessary to
instantiate the thermodynamics packages on liquidProperties.  This requires
either liquidProperties to be rewritten mole-based or the specie classes to be
rewritten mass-based.  Given that most of OpenFOAM solvers operate
mass-based (solve for mass-fractions and provide mass-fractions to sub-models it
is more consistent and efficient if the low-level thermodynamics is also
mass-based.

This commit includes all of the changes necessary for all of the thermodynamics
in OpenFOAM to operate mass-based and supports the instantiation of
thermodynamics packages on liquidProperties.

Note that most users, developers and contributors to OpenFOAM will not notice
any difference in the operation of the code except that the confusing

    nMoles     1;

entries in the thermophysicalProperties files are no longer needed or used and
have been removed in this commet.  The only substantial change to the internals
is that species thermodynamics are now "mixed" with mass rather than mole
fractions.  This is more convenient except for defining reaction equilibrium
thermodynamics for which the molar rather than mass composition is usually know.
The consequence of this can be seen in the adiabaticFlameT, equilibriumCO and
equilibriumFlameT utilities in which the species thermodynamics are
pre-multiplied by their molecular mass to effectively convert them to mole-basis
to simplify the definition of the reaction equilibrium thermodynamics, e.g. in
equilibriumCO

    // Reactants (mole-based)
    thermo FUEL(thermoData.subDict(fuelName)); FUEL *= FUEL.W();

    // Oxidant (mole-based)
    thermo O2(thermoData.subDict("O2")); O2 *= O2.W();
    thermo N2(thermoData.subDict("N2")); N2 *= N2.W();

    // Intermediates (mole-based)
    thermo H2(thermoData.subDict("H2")); H2 *= H2.W();

    // Products (mole-based)
    thermo CO2(thermoData.subDict("CO2")); CO2 *= CO2.W();
    thermo H2O(thermoData.subDict("H2O")); H2O *= H2O.W();
    thermo CO(thermoData.subDict("CO")); CO *= CO.W();

    // Product dissociation reactions

    thermo CO2BreakUp
    (
        CO2 == CO + 0.5*O2
    );

    thermo H2OBreakUp
    (
        H2O == H2 + 0.5*O2
    );

Please report any problems with this substantial but necessary rewrite of the
thermodynamic at https://bugs.openfoam.org

Henry G. Weller
CFD Direct Ltd.
parent 2d4bec32
......@@ -14,9 +14,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/solidChemistryModel/lnInclude \
-I$(LIB_SRC)/combustionModels/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
......@@ -39,7 +37,6 @@ EXE_LIBS = \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lsolidProperties \
-lsolidMixtureProperties \
-lthermophysicalFunctions \
-lreactionThermophysicalModels \
-lSLGThermo \
......
{
volScalarField& he = thermo.he();
fvScalarMatrix EEqn
(
fvm::div(phi, he)
+ (
he.name() == "e"
? fvc::div(phi, volScalarField("Ekp", 0.5*magSqr(U) + p/rho))
: fvc::div(phi, volScalarField("K", 0.5*magSqr(U)))
)
- fvm::laplacian(turbulence->alphaEff(), he)
==
fvOptions(rho, he)
);
EEqn.relax();
fvOptions.constrain(EEqn);
EEqn.solve();
fvOptions.correct(he);
thermo.correct();
}
......@@ -67,6 +67,17 @@ dimensionedScalar rhoMin
)
);
dimensionedScalar pMin
(
dimensionedScalar::lookupOrDefault
(
"pMin",
simple.dict(),
dimPressure,
10
)
);
Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::turbulenceModel> turbulence
(
......
......@@ -83,6 +83,8 @@
/fvc::domainIntegrate(psi);
}
p = max(p, pMin);
rho = thermo.rho();
rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
......
......@@ -11,9 +11,7 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
......@@ -39,9 +37,7 @@ EXE_LIBS = \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lliquidProperties \
-lliquidMixtureProperties \
-lsolidProperties \
-lsolidMixtureProperties \
-lthermophysicalFunctions \
-lreactionThermophysicalModels \
-lSLGThermo \
......
......@@ -10,9 +10,7 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
......@@ -37,7 +35,6 @@ EXE_LIBS = \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lsolidProperties \
-lsolidMixtureProperties \
-lthermophysicalFunctions \
-lreactionThermophysicalModels \
-lSLGThermo \
......
......@@ -12,9 +12,7 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
......@@ -40,9 +38,7 @@ EXE_LIBS = \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lliquidProperties \
-lliquidMixtureProperties \
-lsolidProperties \
-lsolidMixtureProperties \
-lthermophysicalFunctions \
-lreactionThermophysicalModels \
-lSLGThermo \
......
......@@ -12,9 +12,7 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
......@@ -40,9 +38,7 @@ EXE_LIBS = \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lliquidProperties \
-lliquidMixtureProperties \
-lsolidProperties \
-lsolidMixtureProperties \
-lthermophysicalFunctions \
-lreactionThermophysicalModels \
-lSLGThermo \
......
......@@ -14,9 +14,7 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
......@@ -38,9 +36,7 @@ EXE_LIBS = \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lliquidProperties \
-lliquidMixtureProperties \
-lsolidProperties \
-lsolidMixtureProperties \
-lthermophysicalFunctions \
-lreactionThermophysicalModels \
-lSLGThermo \
......
......@@ -15,9 +15,7 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
......@@ -42,9 +40,7 @@ EXE_LIBS = \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lliquidProperties \
-lliquidMixtureProperties \
-lsolidProperties \
-lsolidMixtureProperties \
-lthermophysicalFunctions \
-lreactionThermophysicalModels \
-lSLGThermo \
......
......@@ -16,9 +16,7 @@ EXE_INC = \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
......@@ -45,9 +43,7 @@ EXE_LIBS = \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lliquidProperties \
-lliquidMixtureProperties \
-lsolidProperties \
-lsolidMixtureProperties \
-lthermophysicalFunctions \
-lreactionThermophysicalModels \
-lSLGThermo \
......
......@@ -3,9 +3,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
......
......@@ -2,7 +2,6 @@ specie1
{
specie
{
nMoles 1;
molWeight 1;
}
......@@ -24,7 +23,6 @@ specie2
{
specie
{
nMoles 1;
molWeight 0.5;
}
......
......@@ -49,7 +49,6 @@ EXE_LIBS = \
-llagrangianSpray \
-llagrangianTurbulence \
-llaminarFlameSpeedModels \
-lliquidMixtureProperties \
-lliquidProperties \
-lmeshTools \
-lmolecularMeasurements \
......@@ -81,7 +80,6 @@ EXE_LIBS = \
-lSLGThermo \
-lsnappyHexMesh \
-lsolidChemistryModel \
-lsolidMixtureProperties \
-lsolidParticle \
-lsolidProperties \
-lsolidSpecie \
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -97,28 +97,59 @@ int main(int argc, char *argv[])
scalar stoicO2 = n + m/4.0;
scalar stoicN2 = (0.79/0.21)*(n + m/4.0);
scalar stoicN2 = (0.79/0.21)*stoicO2;
scalar stoicCO2 = n;
scalar stoicH2O = m/2.0;
thermo fuel
thermo FUEL
(
"fuel",
thermo(thermoData.subDict(fuelName))
);
Info<< "fuel " << FUEL << ';' << endl;
FUEL *= FUEL.W();
thermo O2
(
"O2",
thermo(thermoData.subDict("O2"))
);
O2 *= O2.W();
thermo N2
(
"N2",
thermo(thermoData.subDict("N2"))
);
N2 *= N2.W();
thermo CO2
(
"CO2",
thermo(thermoData.subDict("CO2"))
);
CO2 *= CO2.W();
thermo H2O
(
"H2O",
thermo(thermoData.subDict("H2O"))
);
H2O *= H2O.W();
thermo oxidant
(
"oxidant",
stoicO2*thermo(thermoData.subDict("O2"))
+ stoicN2*thermo(thermoData.subDict("N2"))
stoicO2*O2
+ stoicN2*N2
);
Info<< "oxidant " << (1/oxidant.Y())*oxidant << ';' << endl;
dimensionedScalar stoichiometricAirFuelMassRatio
(
"stoichiometricAirFuelMassRatio",
dimless,
(oxidant.W()*oxidant.nMoles())/fuel.W()
oxidant.Y()/FUEL.W()
);
Info<< "stoichiometricAirFuelMassRatio "
......@@ -138,49 +169,34 @@ int main(int argc, char *argv[])
scalar ores = max(1.0/equiv - 1.0, 0.0);
scalar fburnt = 1.0 - fres;
thermo fuel
(
"fuel",
thermo(thermoData.subDict(fuelName))
);
Info<< "fuel " << fuel << ';' << endl;
thermo oxidant
(
"oxidant",
o2*thermo(thermoData.subDict("O2"))
+ n2*thermo(thermoData.subDict("N2"))
);
Info<< "oxidant " << (1/oxidant.nMoles())*oxidant << ';' << endl;
thermo reactants
(
"reactants",
fuel + oxidant
FUEL + (1.0/equiv)*oxidant
);
Info<< "reactants " << (1/reactants.nMoles())*reactants << ';' << endl;
Info<< "reactants " << (1/reactants.Y())*reactants << ';' << endl;
thermo burntProducts
(
"burntProducts",
+ (n2 - (0.79/0.21)*ores*stoicO2)*thermo(thermoData.subDict("N2"))
+ fburnt*stoicCO2*thermo(thermoData.subDict("CO2"))
+ fburnt*stoicH2O*thermo(thermoData.subDict("H2O"))
+ (n2 - (0.79/0.21)*ores*stoicO2)*N2
+ fburnt*stoicCO2*CO2
+ fburnt*stoicH2O*H2O
);
Info<< "burntProducts "
<< (1/burntProducts.nMoles())*burntProducts << ';' << endl;
<< (1/burntProducts.Y())*burntProducts << ';' << endl;
thermo products
(
"products",
fres*fuel
+ n2*thermo(thermoData.subDict("N2"))
+ fburnt*stoicCO2*thermo(thermoData.subDict("CO2"))
+ fburnt*stoicH2O*thermo(thermoData.subDict("H2O"))
+ ores*stoicO2*thermo(thermoData.subDict("O2"))
fres*FUEL
+ n2*N2
+ fburnt*stoicCO2*CO2
+ fburnt*stoicH2O*H2O
+ ores*stoicO2*O2
);
Info<< "products " << (1/products.nMoles())*products << ';' << endl;
Info<< "products " << (1/products.Y())*products << ';' << endl;
scalar Tad = products.THa(reactants.Ha(P, T0), P, 1000.0);
Info<< "Tad = " << Tad << nl << endl;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -73,52 +73,44 @@ int main(int argc, char *argv[])
scalar P = 1e5;
scalar T = 3000.0;
const scalar P = 1e5;
const scalar T = 3000.0;
// Oxidant (mole-based)
thermo O2(thermoData.subDict("O2")); O2 *= O2.W();
thermo N2(thermoData.subDict("N2")); N2 *= N2.W();
// Intermediates (mole-based)
thermo H2(thermoData.subDict("H2")); H2 *= H2.W();
thermo OH(thermoData.subDict("OH")); OH *= OH.W();
thermo H(thermoData.subDict("H")); H *= H.W();
thermo O(thermoData.subDict("O")); O *= O.W();
// Products (mole-based)
thermo CO2(thermoData.subDict("CO2")); CO2 *= CO2.W();
thermo H2O(thermoData.subDict("H2O")); H2O *= H2O.W();
thermo CO(thermoData.subDict("CO")); CO *= CO.W();
SLPtrList<thermo> EQreactions;
EQreactions.append
(
new thermo
(
thermo(thermoData.subDict("CO2"))
==
thermo(thermoData.subDict("CO"))
+ 0.5*thermo(thermoData.subDict("O2"))
)
new thermo(CO2 == CO + 0.5*O2)
);
EQreactions.append
(
new thermo
(
thermo(thermoData.subDict("O2"))
==
2.0*thermo(thermoData.subDict("O"))
)
new thermo(O2 == 2*O)
);
EQreactions.append
(
new thermo
(
thermo(thermoData.subDict("H2O"))
==
thermo(thermoData.subDict("H2"))
+ 0.5*thermo(thermoData.subDict("O2"))
)
new thermo(H2O == H2 + 0.5*O2)
);
EQreactions.append
(
new thermo
(
thermo(thermoData.subDict("H2O"))
==
thermo(thermoData.subDict("H"))
+ thermo(thermoData.subDict("OH"))
)
new thermo(H2O == H + OH)
);
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -100,25 +100,27 @@ int main(int argc, char *argv[])
Info<< nl << "Reading thermodynamic data for relevant species"
<< nl << endl;
// Reactants
thermo FUEL(thermoData.subDict(fuelName));
thermo O2(thermoData.subDict("O2"));
thermo N2(thermoData.subDict("N2"));
// Reactants (mole-based)
thermo FUEL(thermoData.subDict(fuelName)); FUEL *= FUEL.W();
// Products
thermo CO2(thermoData.subDict("CO2"));
thermo H2O(thermoData.subDict("H2O"));
// Oxidant (mole-based)
thermo O2(thermoData.subDict("O2")); O2 *= O2.W();
thermo N2(thermoData.subDict("N2")); N2 *= N2.W();
// Product fragments
thermo CO(thermoData.subDict("CO"));
thermo H2(thermoData.subDict("H2"));
// Intermediates (mole-based)
thermo H2(thermoData.subDict("H2")); H2 *= H2.W();
// Products (mole-based)
thermo CO2(thermoData.subDict("CO2")); CO2 *= CO2.W();
thermo H2O(thermoData.subDict("H2O")); H2O *= H2O.W();
thermo CO(thermoData.subDict("CO")); CO *= CO.W();
// Product dissociation reactions
thermo CO2BreakUp
(
CO2 == CO + 0.5* O2
CO2 == CO + 0.5*O2
);
thermo H2OBreakUp
......@@ -145,7 +147,7 @@ int main(int argc, char *argv[])
(
"stoichiometricAirFuelMassRatio",
dimless,
(oxidant.W()*oxidant.nMoles())/FUEL.W()