thermophysicalModels: Resolve issue with the construction of RR from physicoChemicalConstants which may or may not be already constructed
Solution: Move RR, Pstd and Tstd used by specie into thermodynamicConstants constructed in global.C in the OpenFOAM library
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,11 +28,12 @@ License
|
||||
// Constants supplied in the main controlDict
|
||||
#include "fundamentalConstants.C"
|
||||
|
||||
// Derived constants. Note:order is important
|
||||
// Derived constants.
|
||||
// Note: order is important
|
||||
#include "universalConstants.C"
|
||||
#include "electromagneticConstants.C"
|
||||
#include "atomicConstants.C"
|
||||
#include "physicoChemicalConstants.C"
|
||||
|
||||
#include "thermodynamicConstants.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-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -34,14 +34,9 @@ Description
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Dimensionless coefficents
|
||||
|
||||
// Mathematical constants
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
|
||||
// Dimensioned constants
|
||||
|
||||
// Fundamental constants
|
||||
#include "fundamentalConstants.H"
|
||||
|
||||
@ -50,6 +45,7 @@ Description
|
||||
#include "electromagneticConstants.H"
|
||||
#include "atomicConstants.H"
|
||||
#include "physicoChemicalConstants.H"
|
||||
#include "thermodynamicConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -66,7 +66,6 @@ namespace physicoChemical
|
||||
//- Second radiation constant: default SI units: [m.K]
|
||||
extern const dimensionedScalar c2;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace physicoChemical
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "thermodynamicConstants.H"
|
||||
#include "physicoChemicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace constant
|
||||
{
|
||||
namespace thermodynamic
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Note: the 1e3 converts from /mol to /kmol for consistency with the
|
||||
// SI choice of kg rather than g for mass.
|
||||
// This is not appropriate for USCS and will be changed to an entry in
|
||||
// the DimensionedConstants dictionary in etc/controlDict
|
||||
const scalar RR = 1e3*physicoChemical::R.value();
|
||||
|
||||
const scalar Pstd = standard::Pstd.value();
|
||||
const scalar Tstd = standard::Tstd.value();
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace thermodynamic
|
||||
} // End namespace constant
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 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/>.
|
||||
|
||||
Namespace
|
||||
Foam::constant::thermodynamic
|
||||
|
||||
Description
|
||||
Thermodynamic scalar constants
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef thermodynamicConstants_H
|
||||
#define thermodynamicConstants_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace constant
|
||||
{
|
||||
namespace thermodynamic
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Universal gas constant (default in [J/(kmol K)])
|
||||
extern const scalar RR;
|
||||
|
||||
//- Standard pressure (default in [Pa])
|
||||
extern const scalar Pstd;
|
||||
|
||||
//- Standard temperature (default in [K])
|
||||
extern const scalar Tstd;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace thermodynamic
|
||||
} // End namespace constant
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -187,7 +187,7 @@ Foam::scalar Foam::liquidMixtureProperties::Ppc(const scalarField& x) const
|
||||
Zc += x[i]*properties_[i].Zc();
|
||||
}
|
||||
|
||||
return specie::RR*Zc*Tpc(x)/Vc;
|
||||
return RR*Zc*Tpc(x)/Vc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ inline Foam::scalar Foam::solidProperties::Hf() const
|
||||
|
||||
inline Foam::scalar Foam::solidProperties::Hs(const scalar T) const
|
||||
{
|
||||
return Cp_*(T - specie::Tstd);
|
||||
return Cp_*(T - Tstd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1 @@
|
||||
LIB_LIBS = -lOpenFOAM
|
||||
|
||||
@ -55,7 +55,7 @@ Foam::PengRobinsonGas<Specie>::PengRobinsonGas
|
||||
Pc_(readScalar(dict.subDict("equationOfState").lookup("Pc"))),
|
||||
omega_(readScalar(dict.subDict("equationOfState").lookup("omega")))
|
||||
{
|
||||
Zc_ = Pc_*Vc_/(specie::RR*Tc_);
|
||||
Zc_ = Pc_*Vc_/(RR*Tc_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -201,7 +201,7 @@ inline Foam::scalar Foam::PengRobinsonGas<Specie>::cpMcv
|
||||
scalar T
|
||||
) const
|
||||
{
|
||||
return this->RR*Z(p, T);
|
||||
return RR*Z(p, T);
|
||||
}
|
||||
|
||||
|
||||
@ -222,7 +222,7 @@ inline void Foam::PengRobinsonGas<Specie>::operator+=
|
||||
Tc_ = molr1*Tc_ + molr2*pg.Tc_;
|
||||
Vc_ = molr1*Vc_ + molr2*pg.Vc_;
|
||||
Zc_ = molr1*Zc_ + molr2*pg.Zc_;
|
||||
Pc_ = specie::RR*Zc_*Tc_/Vc_;
|
||||
Pc_ = RR*Zc_*Tc_/Vc_;
|
||||
omega_ = molr1*omega_ + molr2*pg.omega_;
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ inline void Foam::PengRobinsonGas<Specie>::operator-=
|
||||
Tc_ = molr1*Tc_ - molr2*pg.Tc_;
|
||||
Vc_ = molr1*Vc_ - molr2*pg.Vc_;
|
||||
Zc_ = molr1*Zc_ - molr2*pg.Zc_;
|
||||
Pc_ = specie::RR*Zc_*Tc_/Vc_;
|
||||
Pc_ = RR*Zc_*Tc_/Vc_;
|
||||
omega_ = molr1*omega_ - molr2*pg.omega_;
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ Foam::PengRobinsonGas<Specie> Foam::operator+
|
||||
Tc,
|
||||
Vc,
|
||||
Zc,
|
||||
specie::RR*Zc*Tc/Vc,
|
||||
RR*Zc*Tc/Vc,
|
||||
molr1*pg1.omega_ + molr2*pg2.omega_
|
||||
);
|
||||
}
|
||||
@ -308,7 +308,7 @@ Foam::PengRobinsonGas<Specie> Foam::operator-
|
||||
Tc,
|
||||
Vc,
|
||||
Zc,
|
||||
specie::RR*Zc*Tc/Vc,
|
||||
RR*Zc*Tc/Vc,
|
||||
molr1*pg1.omega_ - molr2*pg2.omega_
|
||||
);
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ inline Foam::scalar Foam::incompressiblePerfectGas<Specie>::cpMcv
|
||||
scalar
|
||||
) const
|
||||
{
|
||||
return this->RR;
|
||||
return RR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -99,7 +99,7 @@ inline Foam::scalar Foam::perfectGas<Specie>::Z(scalar, scalar) const
|
||||
template<class Specie>
|
||||
inline Foam::scalar Foam::perfectGas<Specie>::cpMcv(scalar, scalar) const
|
||||
{
|
||||
return this->RR;
|
||||
return RR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,18 +29,9 @@ License
|
||||
|
||||
/* * * * * * * * * * * * * * * public constants * * * * * * * * * * * * * * */
|
||||
|
||||
//- Universal gas constant (default in [J/(kmol K)])
|
||||
const Foam::scalar Foam::specie::RR = constant::physicoChemical::R.value()*1000;
|
||||
|
||||
//- Standard pressure (default in [Pa])
|
||||
const Foam::scalar Foam::specie::Pstd = constant::standard::Pstd.value();
|
||||
|
||||
//- Standard temperature (default in [K])
|
||||
const Foam::scalar Foam::specie::Tstd = constant::standard::Tstd.value();
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(specie, 0);
|
||||
defineTypeNameAndDebug(specie, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -40,6 +40,9 @@ SourceFiles
|
||||
#include "scalar.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
#include "thermodynamicConstants.H"
|
||||
using namespace Foam::constant::thermodynamic;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -72,20 +75,6 @@ public:
|
||||
ClassName("specie");
|
||||
|
||||
|
||||
// Public constants
|
||||
|
||||
// Thermodynamic constants
|
||||
|
||||
//- Universal gas constant [J/(kmol K)]
|
||||
static const scalar RR;
|
||||
|
||||
//- Standard pressure [Pa]
|
||||
static const scalar Pstd;
|
||||
|
||||
//- Standard temperature [K]
|
||||
static const scalar Tstd;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
|
||||
|
||||
@ -156,7 +156,7 @@ inline Foam::scalar Foam::hExponentialThermo<equationOfState>::ha
|
||||
const scalar p, const scalar T
|
||||
) const
|
||||
{
|
||||
scalar hOffset = integrateCp(specie::Tstd);
|
||||
scalar hOffset = integrateCp(Tstd);
|
||||
|
||||
return
|
||||
(
|
||||
@ -171,7 +171,7 @@ inline Foam::scalar Foam::hExponentialThermo<equationOfState>::hs
|
||||
const scalar p, const scalar T
|
||||
) const
|
||||
{
|
||||
scalar hOffset = integrateCp(specie::Tstd);
|
||||
scalar hOffset = integrateCp(Tstd);
|
||||
return (integrateCp(T) - hOffset);
|
||||
}
|
||||
|
||||
|
||||
@ -49,10 +49,10 @@ Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
|
||||
sCoeffs_ = CpCoeffs_.integralMinus1();
|
||||
|
||||
// Offset h poly so that it is relative to the enthalpy at Tstd
|
||||
hCoeffs_[0] += Hf_ - hCoeffs_.value(specie::Tstd);
|
||||
hCoeffs_[0] += Hf_ - hCoeffs_.value(Tstd);
|
||||
|
||||
// Offset s poly so that it is relative to the entropy at Tstd
|
||||
sCoeffs_[0] += Sf_ - sCoeffs_.value(specie::Tstd);
|
||||
sCoeffs_[0] += Sf_ - sCoeffs_.value(Tstd);
|
||||
}
|
||||
|
||||
|
||||
@ -83,10 +83,10 @@ Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
|
||||
sCoeffs_ = CpCoeffs_.integralMinus1();
|
||||
|
||||
// Offset h poly so that it is relative to the enthalpy at Tstd
|
||||
hCoeffs_[0] += Hf_ - hCoeffs_.value(specie::Tstd);
|
||||
hCoeffs_[0] += Hf_ - hCoeffs_.value(Tstd);
|
||||
|
||||
// Offset s poly so that it is relative to the entropy at Tstd
|
||||
sCoeffs_[0] += Sf_ - sCoeffs_.value(specie::Tstd);
|
||||
sCoeffs_[0] += Sf_ - sCoeffs_.value(Tstd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -164,7 +164,7 @@ inline Foam::scalar Foam::janafThermo<EquationOfState>::cp
|
||||
) const
|
||||
{
|
||||
const coeffArray& a = coeffs(T);
|
||||
return this->RR*((((a[4]*T + a[3])*T + a[2])*T + a[1])*T + a[0]);
|
||||
return RR*((((a[4]*T + a[3])*T + a[2])*T + a[1])*T + a[0]);
|
||||
}
|
||||
|
||||
|
||||
@ -176,7 +176,7 @@ inline Foam::scalar Foam::janafThermo<EquationOfState>::ha
|
||||
) const
|
||||
{
|
||||
const coeffArray& a = coeffs(T);
|
||||
return this->RR*
|
||||
return RR*
|
||||
(
|
||||
((((a[4]/5.0*T + a[3]/4.0)*T + a[2]/3.0)*T + a[1]/2.0)*T + a[0])*T
|
||||
+ a[5]
|
||||
@ -199,8 +199,7 @@ template<class EquationOfState>
|
||||
inline Foam::scalar Foam::janafThermo<EquationOfState>::hc() const
|
||||
{
|
||||
const coeffArray& a = lowCpCoeffs_;
|
||||
const scalar Tstd = specie::Tstd;
|
||||
return this->RR*
|
||||
return RR*
|
||||
(
|
||||
(
|
||||
(((a[4]/5.0*Tstd + a[3]/4.0)*Tstd + a[2]/3.0)*Tstd + a[1]/2.0)*Tstd
|
||||
@ -219,7 +218,7 @@ inline Foam::scalar Foam::janafThermo<EquationOfState>::s
|
||||
{
|
||||
const coeffArray& a = coeffs(T);
|
||||
return
|
||||
this->RR*
|
||||
RR*
|
||||
(
|
||||
(((a[4]/4.0*T + a[3]/3.0)*T + a[2]/2.0)*T + a[1])*T + a[0]*::log(T)
|
||||
+ a[6]
|
||||
|
||||
@ -38,6 +38,9 @@ SourceFiles
|
||||
#ifndef thermo_H
|
||||
#define thermo_H
|
||||
|
||||
#include "thermodynamicConstants.H"
|
||||
using namespace Foam::constant::thermodynamic;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
|
||||
@ -290,7 +290,7 @@ 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(p, T)/(this->RR*T);
|
||||
scalar arg = -this->nMoles()*this->g(p, T)/(RR*T);
|
||||
|
||||
if (arg < 600.0)
|
||||
{
|
||||
@ -321,7 +321,7 @@ Foam::species::thermo<Thermo, Type>::Kc(const scalar p, const scalar T) const
|
||||
}
|
||||
else
|
||||
{
|
||||
return Kp(p, T)*pow(this->Pstd/(this->RR*T), this->nMoles());
|
||||
return Kp(p, T)*pow(Pstd/(RR*T), this->nMoles());
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,7 +339,7 @@ inline Foam::scalar Foam::species::thermo<Thermo, Type>::Kx
|
||||
}
|
||||
else
|
||||
{
|
||||
return Kp(p, T)*pow(this->Pstd/p, this->nMoles());
|
||||
return Kp(p, T)*pow(Pstd/p, this->nMoles());
|
||||
}
|
||||
}
|
||||
|
||||
@ -358,7 +358,7 @@ inline Foam::scalar Foam::species::thermo<Thermo, Type>::Kn
|
||||
}
|
||||
else
|
||||
{
|
||||
return Kp(p, T)*pow(n*this->Pstd/p, this->nMoles());
|
||||
return Kp(p, T)*pow(n*Pstd/p, this->nMoles());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user