Commit 54ebe724 authored by sergio's avatar sergio Committed by Andrew Heather
Browse files

ENH: Derivative of B in thermo.H (dKcdTbyKc) calculated from S and G instead of dGdT

Member function dKcdTbyKc in thermo.H is calculated from S and G at Pstd.
Thus dGdT was removed from the thermos.

- Add optional hRef, eRef and Tref as optional.

- Use new thermo to multiphase solver icoReactingMuliPhaseFoam

- Remove hRefConst and eRefConst thermos.

TUT: Updated tutorials
parent 0dd91a9d
......@@ -79,6 +79,8 @@ makeBaseTurbulenceModel
#include "Stokes.H"
makeLaminarModel(Stokes);
#include "generalizedNewtonian.H"
makeLaminarModel(generalizedNewtonian);
// -------------------------------------------------------------------------- //
// RAS models
......
......@@ -11,8 +11,6 @@ multiphaseSystem/multiphaseSystem.C
multiphaseSystem/multiphaseSystemNew.C
multiphaseSystem/multiphaseSystems.C
reactionThermo/hRefConstThermos.C
diameter = diameterModels
$(diameter)/diameterModel/diameterModel.C
$(diameter)/constantDiameter/constantDiameter.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2018 OpenFOAM Foundation
-------------------------------------------------------------------------------
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 "makeReactionThermo.H"
#include "makeThermo.H"
#include "rhoReactionThermo.H"
#include "heRhoThermo.H"
#include "specie.H"
#include "perfectGas.H"
#include "rPolynomial.H"
#include "perfectFluid.H"
#include "rhoConst.H"
#include "sensibleEnthalpy.H"
#include "hRefConstThermo.H"
#include "eRefConstThermo.H"
#include "constTransport.H"
#include "pureMixture.H"
#include "multiComponentMixture.H"
#include "thermoPhysicsTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Thermo type typedefs:
typedef
constTransport
<
species::thermo
<
hRefConstThermo
<
perfectGas<specie>
>,
sensibleEnthalpy
>
> constRefGasHThermoPhysics;
typedef
constTransport
<
species::thermo
<
hRefConstThermo
<
perfectFluid<specie>
>,
sensibleEnthalpy
>
> constRefFluidHThermoPhysics;
typedef
constTransport
<
species::thermo
<
hRefConstThermo
<
rPolynomial<specie>
>,
sensibleEnthalpy
>
> constRefrPolFluidHThermoPhysics;
typedef
constTransport
<
species::thermo
<
eRefConstThermo
<
perfectGas<specie>
>,
sensibleInternalEnergy
>
> constRefGasEThermoPhysics;
typedef
constTransport
<
species::thermo
<
eRefConstThermo
<
perfectFluid<specie>
>,
sensibleInternalEnergy
>
> constRefFluidEThermoPhysics;
typedef
constTransport
<
species::thermo
<
eRefConstThermo
<
rPolynomial<specie>
>,
sensibleInternalEnergy
>
> constRefrPolFluidEThermoPhysics;
typedef
constTransport
<
species::thermo
<
eRefConstThermo
<
rhoConst<specie>
>,
sensibleInternalEnergy
>
> constRefRhoConstEThermoPhysics;
typedef
constTransport
<
species::thermo
<
hRefConstThermo
<
rhoConst<specie>
>,
sensibleEnthalpy
>
> constRefRhoConstHThermoPhysics;
// pureMixture, sensibleEnthalpy:
makeThermos
(
rhoThermo,
heRhoThermo,
pureMixture,
constTransport,
sensibleEnthalpy,
hRefConstThermo,
perfectGas,
specie
);
makeThermos
(
rhoThermo,
heRhoThermo,
pureMixture,
constTransport,
sensibleEnthalpy,
hRefConstThermo,
rPolynomial,
specie
);
makeThermos
(
rhoThermo,
heRhoThermo,
pureMixture,
constTransport,
sensibleEnthalpy,
hRefConstThermo,
perfectFluid,
specie
);
makeThermos
(
rhoThermo,
heRhoThermo,
pureMixture,
constTransport,
sensibleEnthalpy,
hRefConstThermo,
rhoConst,
specie
);
// pureMixture, sensibleInternalEnergy:
makeThermos
(
rhoThermo,
heRhoThermo,
pureMixture,
constTransport,
sensibleInternalEnergy,
eRefConstThermo,
perfectGas,
specie
);
makeThermos
(
rhoThermo,
heRhoThermo,
pureMixture,
constTransport,
sensibleInternalEnergy,
eRefConstThermo,
rPolynomial,
specie
);
makeThermos
(
rhoThermo,
heRhoThermo,
pureMixture,
constTransport,
sensibleInternalEnergy,
eRefConstThermo,
perfectFluid,
specie
);
makeThermos
(
rhoThermo,
heRhoThermo,
pureMixture,
constTransport,
sensibleInternalEnergy,
eRefConstThermo,
rhoConst,
specie
);
// multiComponentMixture, sensibleInternalEnergy:
makeThermoPhysicsReactionThermos
(
rhoThermo,
rhoReactionThermo,
heRhoThermo,
multiComponentMixture,
constRefGasEThermoPhysics
);
makeThermoPhysicsReactionThermos
(
rhoThermo,
rhoReactionThermo,
heRhoThermo,
multiComponentMixture,
constRefFluidEThermoPhysics
);
makeThermoPhysicsReactionThermos
(
rhoThermo,
rhoReactionThermo,
heRhoThermo,
multiComponentMixture,
constRefrPolFluidEThermoPhysics
);
makeThermoPhysicsReactionThermos
(
rhoThermo,
rhoReactionThermo,
heRhoThermo,
multiComponentMixture,
constRefRhoConstEThermoPhysics
);
// multiComponentMixture, sensibleEnthalpy:
makeThermoPhysicsReactionThermos
(
rhoThermo,
rhoReactionThermo,
heRhoThermo,
multiComponentMixture,
constRefRhoConstHThermoPhysics
);
makeThermoPhysicsReactionThermos
(
rhoThermo,
rhoReactionThermo,
heRhoThermo,
multiComponentMixture,
constRefFluidHThermoPhysics
);
makeThermoPhysicsReactionThermos
(
rhoThermo,
rhoReactionThermo,
heRhoThermo,
multiComponentMixture,
constRefrPolFluidHThermoPhysics
);
makeThermoPhysicsReactionThermos
(
rhoThermo,
rhoReactionThermo,
heRhoThermo,
multiComponentMixture,
constRefGasHThermoPhysics
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -501,6 +501,18 @@ makeThermos
specie
);
makeThermos
(
rhoThermo,
heRhoThermo,
pureMixture,
constTransport,
sensibleInternalEnergy,
eConstThermo,
perfectGas,
specie
);
makeThermos
(
rhoThermo,
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -35,7 +36,9 @@ Foam::eConstThermo<EquationOfState>::eConstThermo(const dictionary& dict)
:
EquationOfState(dict),
Cv_(dict.subDict("thermodynamics").get<scalar>("Cv")),
Hf_(dict.subDict("thermodynamics").get<scalar>("Hf"))
Hf_(dict.subDict("thermodynamics").get<scalar>("Hf")),
Tref_(dict.subDict("thermodynamics").getOrDefault<scalar>("Tref", Tstd)),
Esref_(dict.subDict("thermodynamics").getOrDefault<scalar>("Eref", 0))
{}
......@@ -51,6 +54,8 @@ void Foam::eConstThermo<EquationOfState>::write(Ostream& os) const
os.beginBlock("thermodynamics");
os.writeEntry("Cv", Cv_);
os.writeEntry("Hf", Hf_);
os.writeEntryIfDifferent<scalar>("Tref", Tstd, Tref_);
os.writeEntryIfDifferent<scalar>("Eref", 0, Esref_);
os.endBlock();
}
}
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -101,6 +102,12 @@ class eConstThermo
// Note: input in [J/kg], but internally uses [J/kmol]
scalar Hf_;
//- Reference temperature around which to linearise [K]
scalar Tref_;
//- Reference sensible enthalpy around which to linearise [J/kg]
scalar Esref_;
// Private Member Functions
......@@ -109,7 +116,9 @@ class eConstThermo
(
const EquationOfState& st,
const scalar cv,
const scalar hf
const scalar hf,
const scalar Tref,
const scalar Esref
);
......@@ -159,13 +168,14 @@ public:
//- Entropy [J/(kg K)]
inline scalar S(const scalar p, const scalar T) const;
//- Gibbs free energy of the mixture in the standard state [J/kg]
inline scalar Gstd(const scalar T) const;
#include "EtoHthermo.H"
// Derivative term used for Jacobian
//- Derivative of Gibbs free energy w.r.t. temperature
inline scalar dGdT(const scalar p, const scalar T) const;
//- Temperature derivative of heat capacity at constant pressure
inline scalar dCpdT(const scalar p, const scalar T) const;
......
......@@ -32,12 +32,16 @@ inline Foam::eConstThermo<EquationOfState>::eConstThermo
(
const EquationOfState& st,
const scalar cv,
const scalar hf
const scalar hf,
const scalar Tref,
const scalar Esref
)
:
EquationOfState(st),
Cv_(cv),
Hf_(hf)
Hf_(hf),
Tref_(Tref),
Esref_(Esref)
{}
......@@ -52,7 +56,9 @@ inline Foam::eConstThermo<EquationOfState>::eConstThermo
:
EquationOfState(name, ct),
Cv_(ct.Cv_),
Hf_(ct.Hf_)
Hf_(ct.Hf_),
Tref_(ct.Tref_),
Esref_(ct.Esref_)
{}
......@@ -102,7 +108,7 @@ inline Foam::scalar Foam::eConstThermo<EquationOfState>::Es
const scalar T
) const
{
return Cv_*T + EquationOfState::E(p, T);
return Cv_*(T - Tref_) + Esref_ + EquationOfState::E(p, T);
}
......@@ -136,13 +142,14 @@ inline Foam::scalar Foam::eConstThermo<EquationOfState>::S
template<class EquationOfState>
inline Foam::scalar Foam::eConstThermo<EquationOfState>::dGdT
inline Foam::scalar Foam::eConstThermo<EquationOfState>::Gstd
(
const scalar p,
const scalar T
) const
{
return 0;
return
Cv_*(T - Tref_) + Esref_ + Hc() + Pstd/EquationOfState::rho(Pstd, T)
- S(Pstd, T)*T;
}
......@@ -153,6 +160,7 @@ inline Foam::scalar Foam::eConstThermo<EquationOfState>::dCpdT
const scalar T
) const
{
NotImplemented;
return 0;
}
......@@ -175,6 +183,7 @@ inline void Foam::eConstThermo<EquationOfState>::operator+=
Cv_ = Y1*Cv_ + Y2*ct.Cv_;
Hf_ = Y1*Hf_ + Y2*ct.Hf_;
Esref_ = Y1*Esref_ + Y2*ct.Esref_;
}
}
......@@ -200,7 +209,9 @@ inline Foam::eConstThermo<EquationOfState> Foam::operator+
(
eofs,
ct1.Cv_,
ct1.Hf_
ct1.Hf_,
ct1.Tref_,
ct1.Esref_
);
}
else
......@@ -211,7 +222,10 @@ inline Foam::eConstThermo<EquationOfState> Foam::operator+
ct1.Y()/eofs.Y()*ct1.Cv_
+ ct2.Y()/eofs.Y()*ct2.Cv_,
ct1.Y()/eofs.Y()*ct1.Hf_
+ ct2.Y()/eofs.Y()*ct2.Hf_
+ ct2.Y()/eofs.Y()*ct2.Hf_,
ct1.Tref_,
ct1.Y()/eofs.Y()*ct1.Esref_
+ ct2.Y()/eofs.Y()*ct2.Esref_
);
}
}
......@@ -228,7 +242,9 @@ inline Foam::eConstThermo<EquationOfState> Foam::operator*
(
s*static_cast<const EquationOfState&>(ct),
ct.Cv_,
ct.Hf_
ct.Hf_,
ct.Tref_,
ct.Esref_
);
}
......@@ -252,7 +268,10 @@ inline Foam::eConstThermo<EquationOfState> Foam::operator==
ct2.Y()/eofs.Y()*ct2.Cv_
- ct1.Y()/eofs.Y()*ct1.Cv_,
ct2.Y()/eofs.Y()*ct2.Hf_
- ct1.Y()/eofs.Y()*ct1.Hf_
- ct1.Y()/eofs.Y()*ct1.Hf_,
ct1.Tref_,
ct2.Y()/eofs.Y()*ct2.Esref_
- ct1.Y()/eofs.Y()*ct1.Esref_
);
}
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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.