Commit a7090d8f authored by henry's avatar henry
Browse files

Added sensible enthalpy (hs, Hs) and chemical enthalpy (hc, Hc) to the thermodynamics package.

Absolute enthalpy h = hs + hc.
parent 37ed8d9c
......@@ -2,14 +2,21 @@ basicMixture = mixtures/basicMixture
basicThermo = basicThermo
$(basicMixture)/basicMixture.C
$(basicMixture)/basicMixtures.C
$(basicThermo)/basicThermo.C
$(basicThermo)/newBasicThermo.C
$(basicThermo)/basicThermos.C
hThermo/hThermos.C
eThermo/eThermos.C
derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.C
derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.C
derivedFvPatchFields/mixedEnthalpy/mixedEnthalpyFvPatchScalarField.C
derivedFvPatchFields/fixedInternalEnergy/fixedInternalEnergyFvPatchScalarField.C
derivedFvPatchFields/gradientInternalEnergy/gradientInternalEnergyFvPatchScalarField.C
derivedFvPatchFields/mixedInternalEnergy/mixedInternalEnergyFvPatchScalarField.C
derivedFvPatchFields/wallHeatTransfer/wallHeatTransferFvPatchScalarField.C
LIB = $(FOAM_LIBBIN)/libbasicThermophysicalModels
......@@ -31,6 +31,9 @@ License
#include "fixedEnthalpyFvPatchScalarField.H"
#include "gradientEnthalpyFvPatchScalarField.H"
#include "mixedEnthalpyFvPatchScalarField.H"
#include "fixedInternalEnergyFvPatchScalarField.H"
#include "gradientInternalEnergyFvPatchScalarField.H"
#include "mixedInternalEnergyFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -74,9 +77,9 @@ wordList basicThermo::hBoundaryTypes()
return hbt;
}
void basicThermo::hBoundaryCorrection(volScalarField& h_)
void basicThermo::hBoundaryCorrection(volScalarField& h)
{
volScalarField::GeometricBoundaryField& hbf = h_.boundaryField();
volScalarField::GeometricBoundaryField& hbf = h.boundaryField();
forAll(hbf, patchi)
{
......@@ -93,6 +96,53 @@ void basicThermo::hBoundaryCorrection(volScalarField& h_)
}
}
wordList basicThermo::eBoundaryTypes()
{
const volScalarField::GeometricBoundaryField& tbf = T_.boundaryField();
wordList ebt = tbf.types();
forAll(tbf, patchi)
{
if (isA<fixedValueFvPatchScalarField>(tbf[patchi]))
{
ebt[patchi] = fixedInternalEnergyFvPatchScalarField::typeName;
}
else if
(
isA<zeroGradientFvPatchScalarField>(tbf[patchi])
|| isA<fixedGradientFvPatchScalarField>(tbf[patchi])
)
{
ebt[patchi] = gradientInternalEnergyFvPatchScalarField::typeName;
}
else if (isA<mixedFvPatchScalarField>(tbf[patchi]))
{
ebt[patchi] = mixedInternalEnergyFvPatchScalarField::typeName;
}
}
return ebt;
}
void basicThermo::eBoundaryCorrection(volScalarField& e)
{
volScalarField::GeometricBoundaryField& ebf = e.boundaryField();
forAll(ebf, patchi)
{
if (isA<gradientInternalEnergyFvPatchScalarField>(ebf[patchi]))
{
refCast<gradientInternalEnergyFvPatchScalarField>(ebf[patchi])
.gradient() = ebf[patchi].fvPatchField::snGrad();
}
else if (isA<mixedInternalEnergyFvPatchScalarField>(ebf[patchi]))
{
refCast<mixedInternalEnergyFvPatchScalarField>(ebf[patchi])
.refGrad() = ebf[patchi].fvPatchField::snGrad();
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......
......@@ -74,6 +74,9 @@ protected:
wordList hBoundaryTypes();
void hBoundaryCorrection(volScalarField& h);
wordList eBoundaryTypes();
void eBoundaryCorrection(volScalarField& e);
//- Construct as copy (not implemented)
basicThermo(const basicThermo&);
......@@ -107,9 +110,8 @@ public:
static autoPtr<basicThermo> New(const fvMesh&);
// Destructor
virtual ~basicThermo();
//- Destructor
virtual ~basicThermo();
// Member functions
......@@ -122,13 +124,13 @@ public:
//- Pressure [Pa]
// Non-const access allowed for transport equations
volScalarField& p()
virtual volScalarField& p()
{
return p_;
}
//- Pressure [Pa]
const volScalarField& p() const
virtual const volScalarField& p() const
{
return p_;
}
......@@ -193,23 +195,52 @@ public:
return volScalarField::null();
}
//- Internal energy for cell-set [J/kg]
virtual tmp<scalarField> e
(
const scalarField& T,
const labelList& cells
) const
{
notImplemented
(
"basicThermo::e"
"(const scalarField& T, const labelList& cells) const"
);
return tmp<scalarField>(NULL);
}
//-Internal energy for patch [J/kg]
virtual tmp<scalarField> e
(
const scalarField& T,
const label patchi
) const
{
notImplemented
(
"basicThermo::e"
"(const scalarField& T, const label patchi) const"
);
return tmp<scalarField>(NULL);
}
// Fields derived from thermodynamic state variables
//- Temperature [K]
const volScalarField& T() const
virtual const volScalarField& T() const
{
return T_;
}
//- Density [kg/m^3]
tmp<volScalarField> rho() const
virtual tmp<volScalarField> rho() const
{
return p_*psi();
}
//- Compressibility [s^2/m^2]
const volScalarField& psi() const
virtual const volScalarField& psi() const
{
return psi_;
}
......@@ -236,6 +267,21 @@ public:
return volScalarField::null();
}
//- Heat capacity at constant volume for patch [J/kg/K]
virtual tmp<scalarField> Cv
(
const scalarField& T,
const label patchi
) const
{
notImplemented
(
"basicThermo::Cv"
"(const scalarField& T, const label patchi) const"
);
return tmp<scalarField>(NULL);
}
//- Heat capacity at constant volume [J/kg/K]
virtual tmp<volScalarField> Cv() const
{
......@@ -247,13 +293,13 @@ public:
// Access to transport state variables
//- Dynamic viscosity of mixture [kg/ms]
const volScalarField& mu() const
virtual const volScalarField& mu() const
{
return mu_;
}
//- Thermal diffusivity for enthalpy of mixture [kg/ms]
const volScalarField& alpha() const
virtual const volScalarField& alpha() const
{
return alpha_;
}
......
......@@ -38,13 +38,6 @@ Description
#define makeBasicThermo(Cthermo,Mixture,Transport,Thermo,EqnOfState) \
\
typedef Mixture<Transport<specieThermo<Thermo<EqnOfState> > > > \
Mixture##Transport##Thermo##EqnOfState; \
\
defineTemplateTypeNameAndDebugWithName \
(Mixture##Transport##Thermo##EqnOfState, \
#Mixture"<"#Transport"<specieThermo<"#Thermo"<"#EqnOfState">>>>", 0) \
\
typedef Cthermo<Mixture<Transport<specieThermo<Thermo<EqnOfState> > > > > \
Cthermo##Mixture##Transport##Thermo##EqnOfState; \
\
......@@ -60,7 +53,6 @@ addToRunTimeSelectionTable \
fvMesh \
)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
......
......@@ -205,7 +205,6 @@ Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::h
return th;
}
template<class MixtureType>
Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::Cp
(
......@@ -224,7 +223,6 @@ Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::Cp
return tCp;
}
template<class MixtureType>
Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cp() const
{
......@@ -243,7 +241,8 @@ Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cp() const
IOobject::NO_WRITE
),
mesh,
dimensionSet(0, 2, -2, -1, 0)
dimensionSet(0, 2, -2, -1, 0),
T_.boundaryField().types()
)
);
......@@ -256,13 +255,38 @@ Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cp() const
forAll(T_.boundaryField(), patchi)
{
cp.boundaryField()[patchi] = Cp(T_.boundaryField()[patchi], patchi);
const fvPatchScalarField& pT = T_.boundaryField()[patchi];
fvPatchScalarField& pCp = cp.boundaryField()[patchi];
forAll(pT, facei)
{
pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(pT[facei]);
}
}
return tCp;
}
template<class MixtureType>
Foam::tmp<Foam::scalarField> Foam::hThermo<MixtureType>::Cv
(
const scalarField& T,
const label patchi
) const
{
tmp<scalarField> tCv(new scalarField(T.size()));
scalarField& cv = tCv();
forAll(T, facei)
{
cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]);
}
return tCv;
}
template<class MixtureType>
Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cv() const
{
......@@ -281,8 +305,7 @@ Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cv() const
IOobject::NO_WRITE
),
mesh,
dimensionSet(0, 2, -2, -1, 0),
T_.boundaryField().types()
dimensionSet(0, 2, -2, -1, 0)
)
);
......@@ -295,19 +318,12 @@ Foam::tmp<Foam::volScalarField> Foam::hThermo<MixtureType>::Cv() const
forAll(T_.boundaryField(), patchi)
{
const fvPatchScalarField& pT = T_.boundaryField()[patchi];
fvPatchScalarField& pCv = cv.boundaryField()[patchi];
forAll(pT, facei)
{
pCv[facei] = this->patchFaceMixture(patchi, facei).Cv(pT[facei]);
}
cv.boundaryField()[patchi] = Cv(T_.boundaryField()[patchi], patchi);
}
return tCv;
}
template<class MixtureType>
bool Foam::hThermo<MixtureType>::read()
{
......
......@@ -79,40 +79,39 @@ public:
hThermo(const fvMesh&);
// Destructor
~hThermo();
//- Destructor
virtual ~hThermo();
// Member functions
//- Return the compostion of the combustion mixture
basicMixture& composition()
virtual basicMixture& composition()
{
return *this;
}
//- Return the compostion of the combustion mixture
const basicMixture& composition() const
virtual const basicMixture& composition() const
{
return *this;
}
//- Update properties
void correct();
virtual void correct();
// Access to thermodynamic state variables
//- Enthalpy [J/kg]
// Non-const access allowed for transport equations
volScalarField& h()
virtual volScalarField& h()
{
return h_;
}
//- Enthalpy [J/kg]
const volScalarField& h() const
virtual const volScalarField& h() const
{
return h_;
}
......@@ -121,31 +120,42 @@ public:
// Fields derived from thermodynamic state variables
//- Enthalpy for cell-set [J/kg]
tmp<scalarField> h
virtual tmp<scalarField> h
(
const scalarField& T,
const labelList& cells
) const;
//- Enthalpy for patch [J/kg]
tmp<scalarField> h
virtual tmp<scalarField> h
(
const scalarField& T,
const label patchi
) const;
//- Heat capacity at constant pressure for patch [J/kg/K]
tmp<scalarField> Cp(const scalarField& T, const label patchi) const;
virtual tmp<scalarField> Cp
(
const scalarField& T,
const label patchi
) const;
//- Heat capacity at constant pressure [J/kg/K]
tmp<volScalarField> Cp() const;
virtual tmp<volScalarField> Cp() const;
//- Heat capacity at constant volume for patch [J/kg/K]
virtual tmp<scalarField> Cv
(
const scalarField& T,
const label patchi
) const;
//- Heat capacity at constant volume [J/kg/K]
tmp<volScalarField> Cv() const;
virtual tmp<volScalarField> Cv() const;
//- Read thermophysicalProperties dictionary
bool read();
virtual bool read();
};
......
......@@ -92,9 +92,8 @@ public:
static autoPtr<hCombustionThermo> New(const fvMesh&);
// Destructor
virtual ~hCombustionThermo();
//- Destructor
virtual ~hCombustionThermo();
// Member functions
......@@ -110,18 +109,24 @@ public:
//- Enthalpy [J/kg]
// Non-const access allowed for transport equations
volScalarField& h()
virtual volScalarField& h()
{
return h_;
}
//- Enthalpy [J/kg]
const volScalarField& h() const
virtual const volScalarField& h() const
{
return h_;
}
//- Sensible enthalpy [J/kg]
virtual tmp<volScalarField> hs() const = 0;
//- Chemical enthalpy [J/kg]
virtual tmp<volScalarField> hc() const = 0;
//- Update properties
virtual void correct() = 0;
};
......
......@@ -96,9 +96,8 @@ public:
static autoPtr<hhuCombustionThermo> New(const fvMesh&);
// Destructor
virtual ~hhuCombustionThermo();
//- Destructor
virtual ~hhuCombustionThermo();
// Member functions
......@@ -111,13 +110,13 @@ public:
//- Unburnt gas enthalpy [J/kg]
// Non-const access allowed for transport equations
volScalarField& hu()
virtual volScalarField& hu()
{
return hu_;
}
//- Unburnt gas enthalpy [J/kg]
const volScalarField& hu() const
virtual const volScalarField& hu() const
{
return hu_;
}
......@@ -140,7 +139,7 @@ public:
) const = 0;
//- Unburnt gas temperature [K]
const volScalarField& Tu() const
virtual const volScalarField& Tu() const
{
return Tu_;
}
......
......@@ -134,7 +134,120 @@ void Foam::hMixtureThermo<MixtureType>::calculate()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class MixtureType>
Foam::tmp<Foam::scalarField> Foam::hMixtureThermo<MixtureType>::h
void Foam::hMixtureThermo<MixtureType>::correct()
{
if (debug)
{
Info<< "entering hMixtureThermo<MixtureType>::correct()" << endl;
}
// force the saving of the old-time values
psi_.oldTime();
calculate();
if (debug)
{
Info<< "exiting hMixtureThermo<MixtureType>::correct()" << endl;
}
}
template<class MixtureType>
Foam::tmp<Foam::volScalarField>
Foam::hMixtureThermo<MixtureType>::hs() const
{
const fvMesh& mesh = T_.mesh();
tmp<volScalarField> ths
(
new volScalarField
(
IOobject
(
"hs",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
h_.dimensions()
)
);
volScalarField& hsf = ths();
scalarField& hsCells = hsf.internalField();
const scalarField& TCells = T_.internalField();
forAll(TCells, celli)
{
hsCells[celli] = this->cellMixture(celli).Hs(TCells[celli]);
}
forAll(T_.boundaryField(), patchi)
{
scalarField& hsp = hsf.boundaryField()[patchi];
const scalarField& Tp = T_.boundaryField()[patchi];
forAll(Tp, facei)
{
hsp[facei] = this->patchFaceMixture(patchi, facei).Hs(Tp[facei]);
}
}
return ths;
}
template<class MixtureType>
Foam::tmp<Foam::volScalarField>
Foam::hMixtureThermo<MixtureType>::hc() const
{
const fvMesh& mesh = T_.mesh();
tmp<volScalarField> thc
(
new volScalarField
(
IOobject
(
"hc",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE