From 83c61b0510ae0e32d0d3c0cfb6c852b6bf5f87ac Mon Sep 17 00:00:00 2001 From: Henry <Henry> Date: Tue, 30 Oct 2012 11:04:08 +0000 Subject: [PATCH] Thermodynamics: Changed internal representation of thermo properties in hConst/eConstThermo to mole-based --- applications/test/thermoMixture/Make/files | 3 + applications/test/thermoMixture/Make/options | 5 ++ .../test/thermoMixture/Test-thermoMixture.C | 79 +++++++++++++++++++ applications/test/thermoMixture/thermoDict | 43 ++++++++++ .../specie/thermo/eConst/eConstThermo.C | 16 ++-- .../specie/thermo/eConst/eConstThermo.H | 5 ++ .../specie/thermo/eConst/eConstThermoI.H | 6 +- .../specie/thermo/hConst/hConstThermo.C | 16 ++-- .../specie/thermo/hConst/hConstThermoI.H | 8 +- .../thermo/hPolynomial/hPolynomialThermo.C | 6 +- 10 files changed, 167 insertions(+), 20 deletions(-) create mode 100644 applications/test/thermoMixture/Make/files create mode 100644 applications/test/thermoMixture/Make/options create mode 100644 applications/test/thermoMixture/Test-thermoMixture.C create mode 100644 applications/test/thermoMixture/thermoDict diff --git a/applications/test/thermoMixture/Make/files b/applications/test/thermoMixture/Make/files new file mode 100644 index 00000000000..ffef7378665 --- /dev/null +++ b/applications/test/thermoMixture/Make/files @@ -0,0 +1,3 @@ +Test-thermoMixture.C + +EXE = $(FOAM_USER_APPBIN)/Test-thermoMixture diff --git a/applications/test/thermoMixture/Make/options b/applications/test/thermoMixture/Make/options new file mode 100644 index 00000000000..98bf79aaa43 --- /dev/null +++ b/applications/test/thermoMixture/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude + +EXE_LIBS = \ + -lspecie diff --git a/applications/test/thermoMixture/Test-thermoMixture.C b/applications/test/thermoMixture/Test-thermoMixture.C new file mode 100644 index 00000000000..1a2883cb0ac --- /dev/null +++ b/applications/test/thermoMixture/Test-thermoMixture.C @@ -0,0 +1,79 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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/>. + +Application + ThermoMixture + +Description + +\*---------------------------------------------------------------------------*/ + +#include "dictionary.H" +#include "IFstream.H" +#include "specie.H" +#include "perfectGas.H" +#include "hConstThermo.H" +#include "sensibleEnthalpy.H" +#include "thermo.H" +#include "constTransport.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + typedef constTransport + < + species::thermo + < + hConstThermo<perfectGas<specie> >, + sensibleEnthalpy + > + > ThermoType; + + dictionary dict(IFstream("thermoDict")()); + + ThermoType t1(dict.subDict("specie1")); + ThermoType t2(dict.subDict("specie2")); + + Info<< "Checking Cp of mixture of hConstThermo" << endl; + + Info<< "W 1, 2, (1 + 2) = " << t1.W() << " " << t2.W() << " " + << (t1 + t2).W() << endl; + + Info<< "Cp 1, 2, 1 + 2 = " << t1.cp(1, 1) << " " << t2.cp(1, 1) << " " + << (t1 + t2).cp(1, 1) << endl; + + ThermoType t3(t1); + t3 += t2; + Info<< "Cp (1 += 2) = " << t3.cp(1, 1) << endl; + + Info<< "\nEnd\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/thermoMixture/thermoDict b/applications/test/thermoMixture/thermoDict new file mode 100644 index 00000000000..426ae0a9f37 --- /dev/null +++ b/applications/test/thermoMixture/thermoDict @@ -0,0 +1,43 @@ +specie1 +{ + specie + { + nMoles 1; + molWeight 1; + } + + thermodynamics + { + Cp 1; + Cv 1; + Hf 0; + } + + transport + { + mu 1; + Pr 1; + } +} + +specie2 +{ + specie + { + nMoles 1; + molWeight 0.5; + } + + thermodynamics + { + Cp 2; + Cv 2; + Hf 0; + } + + transport + { + mu 1; + Pr 1; + } +} diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C index bd942515e9b..a004ed0e62b 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,6 +36,9 @@ Foam::eConstThermo<EquationOfState>::eConstThermo(Istream& is) Hf_(readScalar(is)) { is.check("eConstThermo<EquationOfState>::eConstThermo(Istream&)"); + + Cv_ *= this->W(); + Hf_ *= this->W(); } @@ -45,7 +48,10 @@ Foam::eConstThermo<EquationOfState>::eConstThermo(const dictionary& dict) EquationOfState(dict), Cv_(readScalar(dict.subDict("thermodynamics").lookup("Cv"))), Hf_(readScalar(dict.subDict("thermodynamics").lookup("Hf"))) -{} +{ + Cv_ *= this->W(); + Hf_ *= this->W(); +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -56,8 +62,8 @@ void Foam::eConstThermo<EquationOfState>::write(Ostream& os) const EquationOfState::write(os); dictionary dict("thermodynamics"); - dict.add("Cv", Cv_); - dict.add("Hf", Hf_); + dict.add("Cv", Cv_/this->W()); + dict.add("Hf", Hf_/this->W()); os << indent << dict.dictName() << dict; } @@ -72,7 +78,7 @@ Foam::Ostream& Foam::operator<< ) { os << static_cast<const EquationOfState&>(ct) << tab - << ct.Cv_ << tab << ct.Hf_; + << ct.Cv_/ct.W() << tab << ct.Hf_/ct.W(); os.check("Ostream& operator<<(Ostream&, const eConstThermo&)"); return os; diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H index 7e0781cc401..fea19e2cc6a 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H @@ -95,7 +95,12 @@ class eConstThermo { // Private data + //- Heat capacity at constant volume + // Note: input in [J/(kg K)], but internally uses [J/(kmol K)] scalar Cv_; + + //- Heat of formation + // Note: input in [J/kg], but internally uses [J/kmol] scalar Hf_; diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H b/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H index b465f80497f..687ebae3558 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H @@ -106,7 +106,7 @@ inline Foam::scalar Foam::eConstThermo<EquationOfState>::cp const scalar T ) const { - return Cv_*this->W() + this->cpMcv(p, T); + return Cv_ + this->cpMcv(p, T); } @@ -117,7 +117,7 @@ inline Foam::scalar Foam::eConstThermo<EquationOfState>::ha const scalar T ) const { - return cp(p, T)*T + Hf_*this->W(); + return cp(p, T)*T + Hf_; } @@ -135,7 +135,7 @@ inline Foam::scalar Foam::eConstThermo<EquationOfState>::hs template<class EquationOfState> inline Foam::scalar Foam::eConstThermo<EquationOfState>::hc() const { - return Hf_*this->W(); + return Hf_; } diff --git a/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.C b/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.C index 3f2a7cf1c4d..b117f82bc70 100644 --- a/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.C +++ b/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,6 +36,9 @@ Foam::hConstThermo<equationOfState>::hConstThermo(Istream& is) Hf_(readScalar(is)) { is.check("hConstThermo::hConstThermo(Istream& is)"); + + Cp_ *= this->W(); + Hf_ *= this->W(); } @@ -45,7 +48,10 @@ Foam::hConstThermo<equationOfState>::hConstThermo(const dictionary& dict) equationOfState(dict), Cp_(readScalar(dict.subDict("thermodynamics").lookup("Cp"))), Hf_(readScalar(dict.subDict("thermodynamics").lookup("Hf"))) -{} +{ + Cp_ *= this->W(); + Hf_ *= this->W(); +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -56,8 +62,8 @@ void Foam::hConstThermo<equationOfState>::write(Ostream& os) const equationOfState::write(os); dictionary dict("thermodynamics"); - dict.add("Cp", Cp_); - dict.add("Hf", Hf_); + dict.add("Cp", Cp_/this->W()); + dict.add("Hf", Hf_/this->W()); os << indent << dict.dictName() << dict; } @@ -72,7 +78,7 @@ Foam::Ostream& Foam::operator<< ) { os << static_cast<const equationOfState&>(ct) << tab - << ct.Cp_ << tab << ct.Hf_; + << ct.Cp_/ct.W() << tab << ct.Hf_/ct.W(); os.check("Ostream& operator<<(Ostream& os, const hConstThermo& ct)"); return os; diff --git a/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H b/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H index b7eda522b4c..3fda6268c33 100644 --- a/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H +++ b/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H @@ -106,7 +106,7 @@ inline Foam::scalar Foam::hConstThermo<equationOfState>::cp const scalar T ) const { - return Cp_*this->W(); + return Cp_; } @@ -116,7 +116,7 @@ inline Foam::scalar Foam::hConstThermo<equationOfState>::ha const scalar p, const scalar T ) const { - return (Cp_*T + Hf_)*this->W(); + return Cp_*T + Hf_; } @@ -126,14 +126,14 @@ inline Foam::scalar Foam::hConstThermo<equationOfState>::hs const scalar p, const scalar T ) const { - return Cp_*T*this->W(); + return Cp_*T; } template<class equationOfState> inline Foam::scalar Foam::hConstThermo<equationOfState>::hc() const { - return Hf_*this->W(); + return Hf_; } diff --git a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C index 5543878eeaf..4824b997d54 100644 --- a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C +++ b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -101,8 +101,8 @@ void Foam::hPolynomialThermo<EquationOfState, PolySize>::write EquationOfState::write(os); dictionary dict("thermodynamics"); - dict.add("Hf", Hf_); - dict.add("Sf", Sf_); + dict.add("Hf", Hf_/this->W()); + dict.add("Sf", Sf_/this->W()); dict.add ( word("CpCoeffs<" + Foam::name(PolySize) + '>'), -- GitLab