Thermodynamics: Changed internal representation of thermo properties in hConst/eConstThermo to mole-based

This commit is contained in:
Henry
2012-10-30 11:04:08 +00:00
parent b544a4c361
commit 83c61b0510
10 changed files with 167 additions and 20 deletions

View File

@ -0,0 +1,3 @@
Test-thermoMixture.C
EXE = $(FOAM_USER_APPBIN)/Test-thermoMixture

View File

@ -0,0 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude
EXE_LIBS = \
-lspecie

View File

@ -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;
}
// ************************************************************************* //

View File

@ -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;
}
}

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,6 +36,9 @@ Foam::eConstThermo<EquationOfState>::eConstThermo(Istream& is)
Hf_(readScalar(is)) Hf_(readScalar(is))
{ {
is.check("eConstThermo<EquationOfState>::eConstThermo(Istream&)"); 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), EquationOfState(dict),
Cv_(readScalar(dict.subDict("thermodynamics").lookup("Cv"))), Cv_(readScalar(dict.subDict("thermodynamics").lookup("Cv"))),
Hf_(readScalar(dict.subDict("thermodynamics").lookup("Hf"))) Hf_(readScalar(dict.subDict("thermodynamics").lookup("Hf")))
{} {
Cv_ *= this->W();
Hf_ *= this->W();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -56,8 +62,8 @@ void Foam::eConstThermo<EquationOfState>::write(Ostream& os) const
EquationOfState::write(os); EquationOfState::write(os);
dictionary dict("thermodynamics"); dictionary dict("thermodynamics");
dict.add("Cv", Cv_); dict.add("Cv", Cv_/this->W());
dict.add("Hf", Hf_); dict.add("Hf", Hf_/this->W());
os << indent << dict.dictName() << dict; os << indent << dict.dictName() << dict;
} }
@ -72,7 +78,7 @@ Foam::Ostream& Foam::operator<<
) )
{ {
os << static_cast<const EquationOfState&>(ct) << tab 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&)"); os.check("Ostream& operator<<(Ostream&, const eConstThermo&)");
return os; return os;

View File

@ -95,7 +95,12 @@ class eConstThermo
{ {
// Private data // Private data
//- Heat capacity at constant volume
// Note: input in [J/(kg K)], but internally uses [J/(kmol K)]
scalar Cv_; scalar Cv_;
//- Heat of formation
// Note: input in [J/kg], but internally uses [J/kmol]
scalar Hf_; scalar Hf_;

View File

@ -106,7 +106,7 @@ inline Foam::scalar Foam::eConstThermo<EquationOfState>::cp
const scalar T const scalar T
) const ) 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 scalar T
) const ) 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> template<class EquationOfState>
inline Foam::scalar Foam::eConstThermo<EquationOfState>::hc() const inline Foam::scalar Foam::eConstThermo<EquationOfState>::hc() const
{ {
return Hf_*this->W(); return Hf_;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,6 +36,9 @@ Foam::hConstThermo<equationOfState>::hConstThermo(Istream& is)
Hf_(readScalar(is)) Hf_(readScalar(is))
{ {
is.check("hConstThermo::hConstThermo(Istream& 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), equationOfState(dict),
Cp_(readScalar(dict.subDict("thermodynamics").lookup("Cp"))), Cp_(readScalar(dict.subDict("thermodynamics").lookup("Cp"))),
Hf_(readScalar(dict.subDict("thermodynamics").lookup("Hf"))) Hf_(readScalar(dict.subDict("thermodynamics").lookup("Hf")))
{} {
Cp_ *= this->W();
Hf_ *= this->W();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -56,8 +62,8 @@ void Foam::hConstThermo<equationOfState>::write(Ostream& os) const
equationOfState::write(os); equationOfState::write(os);
dictionary dict("thermodynamics"); dictionary dict("thermodynamics");
dict.add("Cp", Cp_); dict.add("Cp", Cp_/this->W());
dict.add("Hf", Hf_); dict.add("Hf", Hf_/this->W());
os << indent << dict.dictName() << dict; os << indent << dict.dictName() << dict;
} }
@ -72,7 +78,7 @@ Foam::Ostream& Foam::operator<<
) )
{ {
os << static_cast<const equationOfState&>(ct) << tab 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)"); os.check("Ostream& operator<<(Ostream& os, const hConstThermo& ct)");
return os; return os;

View File

@ -106,7 +106,7 @@ inline Foam::scalar Foam::hConstThermo<equationOfState>::cp
const scalar T const scalar T
) const ) 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 scalar p, const scalar T
) const ) 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 scalar p, const scalar T
) const ) const
{ {
return Cp_*T*this->W(); return Cp_*T;
} }
template<class equationOfState> template<class equationOfState>
inline Foam::scalar Foam::hConstThermo<equationOfState>::hc() const inline Foam::scalar Foam::hConstThermo<equationOfState>::hc() const
{ {
return Hf_*this->W(); return Hf_;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -101,8 +101,8 @@ void Foam::hPolynomialThermo<EquationOfState, PolySize>::write
EquationOfState::write(os); EquationOfState::write(os);
dictionary dict("thermodynamics"); dictionary dict("thermodynamics");
dict.add("Hf", Hf_); dict.add("Hf", Hf_/this->W());
dict.add("Sf", Sf_); dict.add("Sf", Sf_/this->W());
dict.add dict.add
( (
word("CpCoeffs<" + Foam::name(PolySize) + '>'), word("CpCoeffs<" + Foam::name(PolySize) + '>'),