From a7090d8f9ed85040437df95f3dc1e9a10f268495 Mon Sep 17 00:00:00 2001 From: henry Date: Mon, 27 Oct 2008 10:45:45 +0000 Subject: [PATCH] Added sensible enthalpy (hs, Hs) and chemical enthalpy (hc, Hc) to the thermodynamics package. Absolute enthalpy h = hs + hc. --- src/thermophysicalModels/basic/Make/files | 9 +- .../basic/basicThermo/basicThermo.C | 54 +++++- .../basic/basicThermo/basicThermo.H | 66 +++++-- .../basic/basicThermo/makeBasicThermo.H | 8 - .../basic/hThermo/hThermo.C | 44 +++-- .../basic/hThermo/hThermo.H | 38 ++-- .../hCombustionThermo/hCombustionThermo.H | 15 +- .../hhuCombustionThermo/hhuCombustionThermo.H | 11 +- .../hMixtureThermo/hMixtureThermo.C | 151 +++++++++++++--- .../hMixtureThermo/hMixtureThermo.H | 26 ++- .../hhuMixtureThermo/hhuMixtureThermo.C | 162 +++++++++++++++--- .../hhuMixtureThermo/hhuMixtureThermo.H | 41 +++-- .../specie/specie/specie.C | 22 +-- .../specie/thermo/eConst/eConstThermo.C | 23 +-- .../specie/thermo/eConst/eConstThermo.H | 13 +- .../specie/thermo/eConst/eConstThermoI.H | 45 +++-- .../specie/thermo/hConst/hConstThermo.C | 27 +-- .../specie/thermo/hConst/hConstThermo.H | 12 +- .../specie/thermo/hConst/hConstThermoI.H | 68 ++++++-- .../specie/thermo/janaf/janafThermo.C | 20 +-- .../specie/thermo/janaf/janafThermo.H | 6 + .../specie/thermo/janaf/janafThermoI.H | 34 +++- .../specie/thermo/specieThermo/specieThermo.C | 22 +-- .../specie/thermo/specieThermo/specieThermo.H | 15 ++ .../thermo/specieThermo/specieThermoI.H | 161 +++++++++-------- 25 files changed, 750 insertions(+), 343 deletions(-) diff --git a/src/thermophysicalModels/basic/Make/files b/src/thermophysicalModels/basic/Make/files index e88b8bf660..4cea8bf57d 100644 --- a/src/thermophysicalModels/basic/Make/files +++ b/src/thermophysicalModels/basic/Make/files @@ -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 diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.C b/src/thermophysicalModels/basic/basicThermo/basicThermo.C index dffda25d69..e2e92ed434 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.C @@ -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(tbf[patchi])) + { + ebt[patchi] = fixedInternalEnergyFvPatchScalarField::typeName; + } + else if + ( + isA(tbf[patchi]) + || isA(tbf[patchi]) + ) + { + ebt[patchi] = gradientInternalEnergyFvPatchScalarField::typeName; + } + else if (isA(tbf[patchi])) + { + ebt[patchi] = mixedInternalEnergyFvPatchScalarField::typeName; + } + } + + return ebt; +} + +void basicThermo::eBoundaryCorrection(volScalarField& e) +{ + volScalarField::GeometricBoundaryField& ebf = e.boundaryField(); + + forAll(ebf, patchi) + { + if (isA(ebf[patchi])) + { + refCast(ebf[patchi]) + .gradient() = ebf[patchi].fvPatchField::snGrad(); + } + else if (isA(ebf[patchi])) + { + refCast(ebf[patchi]) + .refGrad() = ebf[patchi].fvPatchField::snGrad(); + } + } +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.H b/src/thermophysicalModels/basic/basicThermo/basicThermo.H index 30e8aa65a2..da1cf8ea30 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.H +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.H @@ -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 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 e + ( + const scalarField& T, + const labelList& cells + ) const + { + notImplemented + ( + "basicThermo::e" + "(const scalarField& T, const labelList& cells) const" + ); + return tmp(NULL); + } + + //-Internal energy for patch [J/kg] + virtual tmp e + ( + const scalarField& T, + const label patchi + ) const + { + notImplemented + ( + "basicThermo::e" + "(const scalarField& T, const label patchi) const" + ); + return tmp(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 rho() const + virtual tmp 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 Cv + ( + const scalarField& T, + const label patchi + ) const + { + notImplemented + ( + "basicThermo::Cv" + "(const scalarField& T, const label patchi) const" + ); + return tmp(NULL); + } + //- Heat capacity at constant volume [J/kg/K] virtual tmp 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_; } diff --git a/src/thermophysicalModels/basic/basicThermo/makeBasicThermo.H b/src/thermophysicalModels/basic/basicThermo/makeBasicThermo.H index e37bfc7b05..13a1bb853c 100644 --- a/src/thermophysicalModels/basic/basicThermo/makeBasicThermo.H +++ b/src/thermophysicalModels/basic/basicThermo/makeBasicThermo.H @@ -38,13 +38,6 @@ Description #define makeBasicThermo(Cthermo,Mixture,Transport,Thermo,EqnOfState) \ \ -typedef Mixture > > > \ - Mixture##Transport##Thermo##EqnOfState; \ - \ -defineTemplateTypeNameAndDebugWithName \ - (Mixture##Transport##Thermo##EqnOfState, \ - #Mixture"<"#Transport">>>", 0) \ - \ typedef Cthermo > > > > \ Cthermo##Mixture##Transport##Thermo##EqnOfState; \ \ @@ -60,7 +53,6 @@ addToRunTimeSelectionTable \ fvMesh \ ) - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/thermophysicalModels/basic/hThermo/hThermo.C b/src/thermophysicalModels/basic/hThermo/hThermo.C index 7e32f7a063..988a790ce4 100644 --- a/src/thermophysicalModels/basic/hThermo/hThermo.C +++ b/src/thermophysicalModels/basic/hThermo/hThermo.C @@ -205,7 +205,6 @@ Foam::tmp Foam::hThermo::h return th; } - template Foam::tmp Foam::hThermo::Cp ( @@ -224,7 +223,6 @@ Foam::tmp Foam::hThermo::Cp return tCp; } - template Foam::tmp Foam::hThermo::Cp() const { @@ -243,7 +241,8 @@ Foam::tmp Foam::hThermo::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::hThermo::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 +Foam::tmp Foam::hThermo::Cv +( + const scalarField& T, + const label patchi +) const +{ + tmp tCv(new scalarField(T.size())); + scalarField& cv = tCv(); + + forAll(T, facei) + { + cv[facei] = this->patchFaceMixture(patchi, facei).Cv(T[facei]); + } + + return tCv; +} + + template Foam::tmp Foam::hThermo::Cv() const { @@ -281,8 +305,7 @@ Foam::tmp Foam::hThermo::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::hThermo::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 bool Foam::hThermo::read() { diff --git a/src/thermophysicalModels/basic/hThermo/hThermo.H b/src/thermophysicalModels/basic/hThermo/hThermo.H index b7effc7f70..6ed34db0b8 100644 --- a/src/thermophysicalModels/basic/hThermo/hThermo.H +++ b/src/thermophysicalModels/basic/hThermo/hThermo.H @@ -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 h + virtual tmp h ( const scalarField& T, const labelList& cells ) const; //- Enthalpy for patch [J/kg] - tmp h + virtual tmp h ( const scalarField& T, const label patchi ) const; //- Heat capacity at constant pressure for patch [J/kg/K] - tmp Cp(const scalarField& T, const label patchi) const; + virtual tmp Cp + ( + const scalarField& T, + const label patchi + ) const; //- Heat capacity at constant pressure [J/kg/K] - tmp Cp() const; + virtual tmp Cp() const; + + //- Heat capacity at constant volume for patch [J/kg/K] + virtual tmp Cv + ( + const scalarField& T, + const label patchi + ) const; //- Heat capacity at constant volume [J/kg/K] - tmp Cv() const; + virtual tmp Cv() const; //- Read thermophysicalProperties dictionary - bool read(); + virtual bool read(); }; diff --git a/src/thermophysicalModels/combustion/hCombustionThermo/hCombustionThermo.H b/src/thermophysicalModels/combustion/hCombustionThermo/hCombustionThermo.H index c1dd274813..1ba8809838 100644 --- a/src/thermophysicalModels/combustion/hCombustionThermo/hCombustionThermo.H +++ b/src/thermophysicalModels/combustion/hCombustionThermo/hCombustionThermo.H @@ -92,9 +92,8 @@ public: static autoPtr 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 hs() const = 0; + + //- Chemical enthalpy [J/kg] + virtual tmp hc() const = 0; + //- Update properties virtual void correct() = 0; }; diff --git a/src/thermophysicalModels/combustion/hhuCombustionThermo/hhuCombustionThermo.H b/src/thermophysicalModels/combustion/hhuCombustionThermo/hhuCombustionThermo.H index ffc9f27f5a..0f235d5dd7 100644 --- a/src/thermophysicalModels/combustion/hhuCombustionThermo/hhuCombustionThermo.H +++ b/src/thermophysicalModels/combustion/hhuCombustionThermo/hhuCombustionThermo.H @@ -96,9 +96,8 @@ public: static autoPtr 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_; } diff --git a/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C b/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C index 064e7c3eba..936973abda 100644 --- a/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C +++ b/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.C @@ -134,7 +134,120 @@ void Foam::hMixtureThermo::calculate() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -Foam::tmp Foam::hMixtureThermo::h +void Foam::hMixtureThermo::correct() +{ + if (debug) + { + Info<< "entering hMixtureThermo::correct()" << endl; + } + + // force the saving of the old-time values + psi_.oldTime(); + + calculate(); + + if (debug) + { + Info<< "exiting hMixtureThermo::correct()" << endl; + } +} + + +template +Foam::tmp +Foam::hMixtureThermo::hs() const +{ + const fvMesh& mesh = T_.mesh(); + + tmp 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 +Foam::tmp +Foam::hMixtureThermo::hc() const +{ + const fvMesh& mesh = T_.mesh(); + + tmp thc + ( + new volScalarField + ( + IOobject + ( + "hc", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + h_.dimensions() + ) + ); + + volScalarField& hcf = thc(); + scalarField& hcCells = hcf.internalField(); + + forAll(hcCells, celli) + { + hcCells[celli] = this->cellMixture(celli).Hc(); + } + + forAll(hcf.boundaryField(), patchi) + { + scalarField& hcp = hcf.boundaryField()[patchi]; + + forAll(hcp, facei) + { + hcp[facei] = this->patchFaceMixture(patchi, facei).Hc(); + } + } + + return thc; +} + + +template +Foam::tmp +Foam::hMixtureThermo::h ( const scalarField& T, const labelList& cells @@ -153,7 +266,8 @@ Foam::tmp Foam::hMixtureThermo::h template -Foam::tmp Foam::hMixtureThermo::h +Foam::tmp +Foam::hMixtureThermo::h ( const scalarField& T, const label patchi @@ -172,7 +286,8 @@ Foam::tmp Foam::hMixtureThermo::h template -Foam::tmp Foam::hMixtureThermo::Cp +Foam::tmp +Foam::hMixtureThermo::Cp ( const scalarField& T, const label patchi @@ -192,7 +307,8 @@ Foam::tmp Foam::hMixtureThermo::Cp template -Foam::tmp Foam::hMixtureThermo::Cp() const +Foam::tmp +Foam::hMixtureThermo::Cp() const { const fvMesh& mesh = T_.mesh(); @@ -215,9 +331,12 @@ Foam::tmp Foam::hMixtureThermo::Cp() const volScalarField& cp = tCp(); - forAll(T_, celli) + scalarField& cpCells = cp.internalField(); + const scalarField& TCells = T_.internalField(); + + forAll(TCells, celli) { - cp[celli] = this->cellMixture(celli).Cp(T_[celli]); + cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]); } forAll(T_.boundaryField(), patchi) @@ -229,26 +348,6 @@ Foam::tmp Foam::hMixtureThermo::Cp() const } -template -void Foam::hMixtureThermo::correct() -{ - if (debug) - { - Info<< "entering hMixtureThermo::correct()" << endl; - } - - // force the saving of the old-time values - psi_.oldTime(); - - calculate(); - - if (debug) - { - Info<< "exiting hMixtureThermo::correct()" << endl; - } -} - - template bool Foam::hMixtureThermo::read() { diff --git a/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.H b/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.H index 2436ff833d..e1b231bac2 100644 --- a/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.H +++ b/src/thermophysicalModels/combustion/mixtureThermos/hMixtureThermo/hMixtureThermo.H @@ -73,21 +73,20 @@ public: hMixtureThermo(const fvMesh&); - // Destructor - - virtual ~hMixtureThermo(); + //- Destructor + virtual ~hMixtureThermo(); // Member functions //- Return the compostion of the combustion mixture - combustionMixture& composition() + virtual combustionMixture& composition() { return *this; } //- Return the compostion of the combustion mixture - const combustionMixture& composition() const + virtual const combustionMixture& composition() const { return *this; } @@ -95,28 +94,37 @@ public: //- Update properties virtual void correct(); + //- Sensible enthalpy [J/kg] + virtual tmp hs() const; + + //- Chemical enthalpy [J/kg] + virtual tmp hc() const; // Fields derived from thermodynamic state variables //- Enthalpy for cell-set [J/kg] - tmp h + virtual tmp h ( const scalarField& T, const labelList& cells ) const; //- Enthalpy for patch [J/kg] - tmp h + virtual tmp h ( const scalarField& T, const label patchi ) const; //- Heat capacity at constant pressure for patch [J/kg/K] - tmp Cp(const scalarField& T, const label patchi) const; + virtual tmp Cp + ( + const scalarField& T, + const label patchi + ) const; //- Heat capacity at constant pressure [J/kg/K] - tmp Cp() const; + virtual tmp Cp() const; //- Read thermophysicalProperties dictionary diff --git a/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C b/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C index 0086e8cd14..694d2e3b60 100644 --- a/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C +++ b/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C @@ -173,6 +173,100 @@ void Foam::hhuMixtureThermo::correct() } } + +template +Foam::tmp +Foam::hhuMixtureThermo::hs() const +{ + const fvMesh& mesh = T_.mesh(); + + tmp 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 +Foam::tmp +Foam::hhuMixtureThermo::hc() const +{ + const fvMesh& mesh = T_.mesh(); + + tmp thc + ( + new volScalarField + ( + IOobject + ( + "hc", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + h_.dimensions() + ) + ); + + volScalarField& hcf = thc(); + scalarField& hcCells = hcf.internalField(); + + forAll(hcCells, celli) + { + hcCells[celli] = this->cellMixture(celli).Hc(); + } + + forAll(hcf.boundaryField(), patchi) + { + scalarField& hcp = hcf.boundaryField()[patchi]; + + forAll(hcp, facei) + { + hcp[facei] = this->patchFaceMixture(patchi, facei).Hc(); + } + } + + return thc; +} + + template Foam::tmp Foam::hhuMixtureThermo::h ( @@ -232,7 +326,8 @@ Foam::tmp Foam::hhuMixtureThermo::Cp template -Foam::tmp Foam::hhuMixtureThermo::Cp() const +Foam::tmp +Foam::hhuMixtureThermo::Cp() const { const fvMesh& mesh = T_.mesh(); @@ -254,10 +349,12 @@ Foam::tmp Foam::hhuMixtureThermo::Cp() const ); volScalarField& cp = tCp(); + scalarField& cpCells = cp.internalField(); + const scalarField& TCells = T_.internalField(); - forAll(T_, celli) + forAll(TCells, celli) { - cp[celli] = this->cellMixture(celli).Cp(T_[celli]); + cpCells[celli] = this->cellMixture(celli).Cp(TCells[celli]); } forAll(T_.boundaryField(), patchi) @@ -269,9 +366,9 @@ Foam::tmp Foam::hhuMixtureThermo::Cp() const } - template -Foam::tmp Foam::hhuMixtureThermo::hu +Foam::tmp +Foam::hhuMixtureThermo::hu ( const scalarField& Tu, const labelList& cells @@ -290,7 +387,8 @@ Foam::tmp Foam::hhuMixtureThermo::hu template -Foam::tmp Foam::hhuMixtureThermo::hu +Foam::tmp +Foam::hhuMixtureThermo::hu ( const scalarField& Tu, const label patchi @@ -309,7 +407,8 @@ Foam::tmp Foam::hhuMixtureThermo::hu template -Foam::tmp Foam::hhuMixtureThermo::Tb() const +Foam::tmp +Foam::hhuMixtureThermo::Tb() const { tmp tTb ( @@ -328,10 +427,14 @@ Foam::tmp Foam::hhuMixtureThermo::Tb() const ); volScalarField& Tb_ = tTb(); + scalarField& TbCells = Tb_.internalField(); + const scalarField& TCells = T_.internalField(); + const scalarField& hCells = h_.internalField(); - forAll(Tb_, celli) + forAll(TbCells, celli) { - Tb_[celli] = this->cellProducts(celli).TH(h_[celli], T_[celli]); + TbCells[celli] = + this->cellProducts(celli).TH(hCells[celli], TCells[celli]); } forAll(Tb_.boundaryField(), patchi) @@ -344,7 +447,8 @@ Foam::tmp Foam::hhuMixtureThermo::Tb() const forAll(pTb, facei) { pTb[facei] = - this->patchFaceProducts(patchi, facei).TH(ph[facei], pT[facei]); + this->patchFaceProducts(patchi, facei) + .TH(ph[facei], pT[facei]); } } @@ -374,10 +478,14 @@ Foam::hhuMixtureThermo::psiu() const ); volScalarField& psiu = tpsiu(); + scalarField& psiuCells = psiu.internalField(); + const scalarField& TuCells = Tu_.internalField(); + const scalarField& pCells = p_.internalField(); - forAll(psiu, celli) + forAll(psiuCells, celli) { - psiu[celli] = this->cellReactants(celli).psi(p_[celli], Tu_[celli]); + psiuCells[celli] = + this->cellReactants(celli).psi(pCells[celli], TuCells[celli]); } forAll(psiu.boundaryField(), patchi) @@ -421,12 +529,15 @@ Foam::hhuMixtureThermo::psib() const ); volScalarField& psib = tpsib(); - + scalarField& psibCells = psib.internalField(); volScalarField Tb_ = Tb(); + const scalarField& TbCells = Tb_.internalField(); + const scalarField& pCells = p_.internalField(); - forAll(psib, celli) + forAll(psibCells, celli) { - psib[celli] = this->cellReactants(celli).psi(p_[celli], Tb_[celli]); + psibCells[celli] = + this->cellReactants(celli).psi(pCells[celli], TbCells[celli]); } forAll(psib.boundaryField(), patchi) @@ -449,7 +560,8 @@ Foam::hhuMixtureThermo::psib() const template -Foam::tmp Foam::hhuMixtureThermo::muu() const +Foam::tmp +Foam::hhuMixtureThermo::muu() const { tmp tmuu ( @@ -469,10 +581,12 @@ Foam::tmp Foam::hhuMixtureThermo::muu() const ); volScalarField& muu_ = tmuu(); + scalarField& muuCells = muu_.internalField(); + const scalarField& TuCells = Tu_.internalField(); - forAll(muu_, celli) + forAll(muuCells, celli) { - muu_[celli] = this->cellReactants(celli).mu(Tu_[celli]); + muuCells[celli] = this->cellReactants(celli).mu(TuCells[celli]); } forAll(muu_.boundaryField(), patchi) @@ -492,7 +606,8 @@ Foam::tmp Foam::hhuMixtureThermo::muu() const template -Foam::tmp Foam::hhuMixtureThermo::mub() const +Foam::tmp +Foam::hhuMixtureThermo::mub() const { tmp tmub ( @@ -512,11 +627,13 @@ Foam::tmp Foam::hhuMixtureThermo::mub() const ); volScalarField& mub_ = tmub(); + scalarField& mubCells = mub_.internalField(); volScalarField Tb_ = Tb(); + const scalarField& TbCells = Tb_.internalField(); - forAll(mub_, celli) + forAll(mubCells, celli) { - mub_[celli] = this->cellProducts(celli).mu(Tb_[celli]); + mubCells[celli] = this->cellProducts(celli).mu(TbCells[celli]); } forAll(mub_.boundaryField(), patchi) @@ -526,7 +643,8 @@ Foam::tmp Foam::hhuMixtureThermo::mub() const forAll(pMub, facei) { - pMub[facei] = this->patchFaceProducts(patchi, facei).mu(pTb[facei]); + pMub[facei] = + this->patchFaceProducts(patchi, facei).mu(pTb[facei]); } } diff --git a/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.H b/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.H index a5b3855599..7f3997ceee 100644 --- a/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.H +++ b/src/thermophysicalModels/combustion/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.H @@ -73,21 +73,20 @@ public: hhuMixtureThermo(const fvMesh&); - // Destructor - - virtual ~hhuMixtureThermo(); + //- Destructor + virtual ~hhuMixtureThermo(); // Member functions //- Return the compostion of the combustion mixture - combustionMixture& composition() + virtual combustionMixture& composition() { return *this; } //- Return the compostion of the combustion mixture - const combustionMixture& composition() const + virtual const combustionMixture& composition() const { return *this; } @@ -95,38 +94,48 @@ public: //- Update properties virtual void correct(); + //- Sensible enthalpy [J/kg] + virtual tmp hs() const; + + //- Chemical enthalpy [J/kg] + virtual tmp hc() const; + // Fields derived from thermodynamic state variables //- Enthalpy for cell-set [J/kg] - tmp h + virtual tmp h ( const scalarField& T, const labelList& cells ) const; //- Enthalpy for patch [J/kg] - tmp h + virtual tmp h ( const scalarField& T, const label patchi ) const; //- Heat capacity at constant pressure for patch [J/kg/K] - tmp Cp(const scalarField& T, const label patchi) const; + virtual tmp Cp + ( + const scalarField& T, + const label patchi + ) const; //- Heat capacity at constant pressure [J/kg/K] - tmp Cp() const; + virtual tmp Cp() const; //- Unburnt gas enthalpy for cell-set [J/kg] - tmp hu + virtual tmp hu ( const scalarField& T, const labelList& cells ) const; //- Unburnt gas enthalpy for patch [J/kg] - tmp hu + virtual tmp hu ( const scalarField& T, const label patchi @@ -134,22 +143,22 @@ public: //- Burnt gas temperature [K] - tmp Tb() const; + virtual tmp Tb() const; //- Unburnt gas compressibility [s^2/m^2] - tmp psiu() const; + virtual tmp psiu() const; //- Burnt gas compressibility [s^2/m^2] - tmp psib() const; + virtual tmp psib() const; // Access to transport variables //- Dynamic viscosity of unburnt gas [kg/ms] - tmp muu() const; + virtual tmp muu() const; //- Dynamic viscosity of burnt gas [kg/ms] - tmp mub() const; + virtual tmp mub() const; //- Read thermophysicalProperties dictionary diff --git a/src/thermophysicalModels/specie/specie/specie.C b/src/thermophysicalModels/specie/specie/specie.C index ff2b2f67e1..18941b6aea 100644 --- a/src/thermophysicalModels/specie/specie/specie.C +++ b/src/thermophysicalModels/specie/specie/specie.C @@ -22,35 +22,27 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - Base class of the thermophysical property types. - \*---------------------------------------------------------------------------*/ #include "specie.H" #include "IOstreams.H" #include "dimensionedConstants.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - /* * * * * * * * * * * * * public constants * * * * * * * * * * * * */ //- Universal gas constant (default in [J/(kmol K)]) -const scalar specie::RR = dimensionedConstant("R", 8314.51); +const Foam::scalar Foam::specie::RR = dimensionedConstant("R", 8314.51); //- Standard pressure (default in [Pa]) -const scalar specie::Pstd = dimensionedConstant("Pstd", 1.0e5); +const Foam::scalar Foam::specie::Pstd = dimensionedConstant("Pstd", 1.0e5); //- Standard temperature (default in [K]) -const scalar specie::Tstd = dimensionedConstant("Tstd", 298.15); +const Foam::scalar Foam::specie::Tstd = dimensionedConstant("Tstd", 298.15); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -specie::specie(Istream& is) +Foam::specie::specie(Istream& is) : name_(is), nMoles_(readScalar(is)), @@ -62,7 +54,7 @@ specie::specie(Istream& is) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // -Ostream& operator<<(Ostream& os, const specie& st) +Foam::Ostream& Foam::operator<<(Ostream& os, const specie& st) { os << st.name_ << tab << st.nMoles_ << tab @@ -73,8 +65,4 @@ Ostream& operator<<(Ostream& os, const specie& st) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C index a2870c86ab..4c0dcb5b5a 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.C @@ -22,27 +22,18 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - Constant properties thermodynamics package derived from the basic - thermo package data type specieThermo. - \*---------------------------------------------------------------------------*/ #include "eConstThermo.H" #include "IOstreams.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -eConstThermo::eConstThermo(Istream& is) +Foam::eConstThermo::eConstThermo(Istream& is) : specieThermo(is), - CV(readScalar(is)), - Hf(readScalar(is)) + Cv_(readScalar(is)), + Hf_(readScalar(is)) { is.check("eConstThermo::eConstThermo(Istream& is)"); } @@ -50,17 +41,13 @@ eConstThermo::eConstThermo(Istream& is) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // -Ostream& operator<<(Ostream& os, const eConstThermo& ct) +Foam::Ostream& Foam::operator<<(Ostream& os, const eConstThermo& ct) { - os << (const specieThermo&)ct << tab << ct.CV << tab << ct.Hf; + os << (const specieThermo&)ct << tab << ct.Cv_ << tab << ct.Hf_; os.check("Ostream& operator<<(Ostream& os, const eConstThermo& ct)"); return os; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H index fa8e624946..4cb1217c0e 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermo.H @@ -95,13 +95,13 @@ class eConstThermo { // Private data - scalar CV; - scalar Hf; + scalar Cv_; + scalar Hf_; // Private member functions - //- construct from components + //- Construct from components inline eConstThermo ( const specieThermo& st, @@ -109,6 +109,7 @@ class eConstThermo const scalar hf ); + public: // Constructors @@ -136,6 +137,12 @@ public: //- Enthalpy [J/kmol] inline scalar h(const scalar T) const; + //- Sensible Enthalpy [J/kmol] + inline scalar hs(const scalar T) const; + + //- Chemical enthalpy [J/kmol] + inline scalar hc() const; + //- Entropy [J/(kmol K)] inline scalar s(const scalar T) const; diff --git a/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H b/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H index 2f7d1faf4c..ce40ccbd94 100644 --- a/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H +++ b/src/thermophysicalModels/specie/thermo/eConst/eConstThermoI.H @@ -34,8 +34,8 @@ inline Foam::eConstThermo::eConstThermo ) : specieThermo(st), - CV(cv), - Hf(hf) + Cv_(cv), + Hf_(hf) {} @@ -48,8 +48,8 @@ inline Foam::eConstThermo::eConstThermo ) : specieThermo(name, ct), - CV(ct.CV), - Hf(ct.Hf) + Cv_(ct.Cv_), + Hf_(ct.Hf_) {} @@ -79,13 +79,26 @@ Foam::eConstThermo::New(Istream& is) inline Foam::scalar Foam::eConstThermo::cp(const scalar) const { - return CV*W() + RR; + return Cv_*W() + RR; } inline Foam::scalar Foam::eConstThermo::h(const scalar T) const { - return cp(T)*T + Hf*W(); + return cp(T)*T + Hf_*W(); +} + + +inline Foam::scalar Foam::eConstThermo::hs(const scalar T) const +{ + return cp(T)*T; +} + + +template +inline Foam::scalar Foam::eConstThermo::hc() const +{ + return Hf_*this->W(); } @@ -102,7 +115,7 @@ inline Foam::scalar Foam::eConstThermo::TH const scalar T0 ) const { - return (h - Hf)/Cp(T0); + return (h - Hf_)/Cp(T0); } @@ -112,7 +125,7 @@ inline Foam::scalar Foam::eConstThermo::TE const scalar ) const { - return (e - Hf)/CV; + return (e - Hf_)/Cv_; } @@ -125,8 +138,8 @@ inline Foam::eConstThermo& Foam::eConstThermo::operator= { specieThermo::operator=(ct); - CV = ct.CV; - Hf = ct.Hf; + Cv_ = ct.Cv_; + Hf_ = ct.Hf_; return *this; } @@ -145,8 +158,8 @@ inline Foam::eConstThermo Foam::operator+ return eConstThermo ( st, - ct1.nMoles()/st.nMoles()*ct1.CV + ct2.nMoles()/st.nMoles()*ct2.CV, - ct1.nMoles()/st.nMoles()*ct1.Hf + ct2.nMoles()/st.nMoles()*ct2.Hf + ct1.nMoles()/st.nMoles()*ct1.Cv_ + ct2.nMoles()/st.nMoles()*ct2.Cv_, + ct1.nMoles()/st.nMoles()*ct1.Hf_ + ct2.nMoles()/st.nMoles()*ct2.Hf_ ); } @@ -162,8 +175,8 @@ inline Foam::eConstThermo Foam::operator- return eConstThermo ( st, - ct1.nMoles()/st.nMoles()*ct1.CV - ct2.nMoles()/st.nMoles()*ct2.CV, - ct1.nMoles()/st.nMoles()*ct1.Hf - ct2.nMoles()/st.nMoles()*ct2.Hf + ct1.nMoles()/st.nMoles()*ct1.Cv_ - ct2.nMoles()/st.nMoles()*ct2.Cv_, + ct1.nMoles()/st.nMoles()*ct1.Hf_ - ct2.nMoles()/st.nMoles()*ct2.Hf_ ); } @@ -177,8 +190,8 @@ inline Foam::eConstThermo Foam::operator* return eConstThermo ( s*((const specieThermo&)ct), - ct.CV, - ct.Hf + ct.Cv_, + ct.Hf_ ); } diff --git a/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.C b/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.C index 8b4736a051..912ae4892f 100644 --- a/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.C +++ b/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.C @@ -22,28 +22,19 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - Constant properties thermodynamics package - templated ito the equationOfState. - \*---------------------------------------------------------------------------*/ #include "hConstThermo.H" #include "IOstreams.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -hConstThermo::hConstThermo(Istream& is) +Foam::hConstThermo::hConstThermo(Istream& is) : equationOfState(is), - CP(readScalar(is)), - Hf(readScalar(is)) + Cp_(readScalar(is)), + Hf_(readScalar(is)) { is.check("hConstThermo::hConstThermo(Istream& is)"); } @@ -52,18 +43,18 @@ hConstThermo::hConstThermo(Istream& is) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // template -Ostream& operator<<(Ostream& os, const hConstThermo& ct) +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const hConstThermo& ct +) { os << static_cast(ct) << tab - << ct.CP << tab << ct.Hf; + << ct.Cp_ << tab << ct.Hf_; os.check("Ostream& operator<<(Ostream& os, const hConstThermo& ct)"); return os; } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.H b/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.H index 1355cb67d3..f1d9018446 100644 --- a/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.H +++ b/src/thermophysicalModels/specie/thermo/hConst/hConstThermo.H @@ -94,13 +94,13 @@ class hConstThermo { // Private data - scalar CP; - scalar Hf; + scalar Cp_; + scalar Hf_; // Private member functions - //- construct from components + //- Construct from components inline hConstThermo ( const equationOfState& st, @@ -136,6 +136,12 @@ public: //- Enthalpy [J/kmol] inline scalar h(const scalar T) const; + //- Sensible enthalpy [J/kmol] + inline scalar hs(const scalar T) const; + + //- Chemical enthalpy [J/kmol] + inline scalar hc() const; + //- Entropy [J/(kmol K)] inline scalar s(const scalar T) const; diff --git a/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H b/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H index acc976de05..b628384eb9 100644 --- a/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H +++ b/src/thermophysicalModels/specie/thermo/hConst/hConstThermoI.H @@ -35,8 +35,8 @@ inline Foam::hConstThermo::hConstThermo ) : equationOfState(st), - CP(cp), - Hf(hf) + Cp_(cp), + Hf_(hf) {} @@ -50,8 +50,8 @@ inline Foam::hConstThermo::hConstThermo ) : equationOfState(name, ct), - CP(ct.CP), - Hf(ct.Hf) + Cp_(ct.Cp_), + Hf_(ct.Hf_) {} @@ -80,21 +80,47 @@ Foam::hConstThermo::New(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline Foam::scalar Foam::hConstThermo::cp(const scalar) const +inline Foam::scalar Foam::hConstThermo::cp +( + const scalar +) const { - return CP*this->W(); + return Cp_*this->W(); } template -inline Foam::scalar Foam::hConstThermo::h(const scalar T) const +inline Foam::scalar Foam::hConstThermo::h +( + const scalar T +) const { - return (CP*T + Hf)*this->W(); + return (Cp_*T + Hf_)*this->W(); } template -inline Foam::scalar Foam::hConstThermo::s(const scalar T) const +inline Foam::scalar Foam::hConstThermo::hs +( + const scalar T +) const +{ + return Cp_*T*this->W(); +} + + +template +inline Foam::scalar Foam::hConstThermo::hc() const +{ + return Hf_*this->W(); +} + + +template +inline Foam::scalar Foam::hConstThermo::s +( + const scalar T +) const { notImplemented ( @@ -119,8 +145,8 @@ inline void Foam::hConstThermo::operator+= molr1 /= this->nMoles(); scalar molr2 = ct.nMoles()/this->nMoles(); - CP = molr1*CP + molr2*ct.CP; - Hf = molr1*Hf + molr2*ct.Hf; + Cp_ = molr1*Cp_ + molr2*ct.Cp_; + Hf_ = molr1*Hf_ + molr2*ct.Hf_; } @@ -137,8 +163,8 @@ inline void Foam::hConstThermo::operator-= molr1 /= this->nMoles(); scalar molr2 = ct.nMoles()/this->nMoles(); - CP = molr1*CP - molr2*ct.CP; - Hf = molr1*Hf - molr2*ct.Hf; + Cp_ = molr1*Cp_ - molr2*ct.Cp_; + Hf_ = molr1*Hf_ - molr2*ct.Hf_; } @@ -160,8 +186,10 @@ inline Foam::hConstThermo Foam::operator+ return hConstThermo ( eofs, - ct1.nMoles()/eofs.nMoles()*ct1.CP + ct2.nMoles()/eofs.nMoles()*ct2.CP, - ct1.nMoles()/eofs.nMoles()*ct1.Hf + ct2.nMoles()/eofs.nMoles()*ct2.Hf + ct1.nMoles()/eofs.nMoles()*ct1.Cp_ + + ct2.nMoles()/eofs.nMoles()*ct2.Cp_, + ct1.nMoles()/eofs.nMoles()*ct1.Hf_ + + ct2.nMoles()/eofs.nMoles()*ct2.Hf_ ); } @@ -182,8 +210,10 @@ inline Foam::hConstThermo Foam::operator- return hConstThermo ( eofs, - ct1.nMoles()/eofs.nMoles()*ct1.CP - ct2.nMoles()/eofs.nMoles()*ct2.CP, - ct1.nMoles()/eofs.nMoles()*ct1.Hf - ct2.nMoles()/eofs.nMoles()*ct2.Hf + ct1.nMoles()/eofs.nMoles()*ct1.Cp_ + - ct2.nMoles()/eofs.nMoles()*ct2.Cp_, + ct1.nMoles()/eofs.nMoles()*ct1.Hf_ + - ct2.nMoles()/eofs.nMoles()*ct2.Hf_ ); } @@ -198,8 +228,8 @@ inline Foam::hConstThermo Foam::operator* return hConstThermo ( s*static_cast(ct), - ct.CP, - ct.Hf + ct.Cp_, + ct.Hf_ ); } diff --git a/src/thermophysicalModels/specie/thermo/janaf/janafThermo.C b/src/thermophysicalModels/specie/thermo/janaf/janafThermo.C index 5a3d05b848..13002ecc08 100644 --- a/src/thermophysicalModels/specie/thermo/janaf/janafThermo.C +++ b/src/thermophysicalModels/specie/thermo/janaf/janafThermo.C @@ -22,23 +22,15 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - JANAF tables based thermodynamics package templated ito the equationOfState. - \*---------------------------------------------------------------------------*/ #include "janafThermo.H" #include "IOstreams.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -janafThermo::janafThermo(Istream& is) +Foam::janafThermo::janafThermo(Istream& is) : equationOfState(is), Tlow_(readScalar(is)), @@ -103,7 +95,11 @@ janafThermo::janafThermo(Istream& is) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // template -Ostream& operator<<(Ostream& os, const janafThermo& jt) +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const janafThermo& jt +) { os << static_cast(jt) << nl << " " << jt.Tlow_ @@ -145,8 +141,4 @@ Ostream& operator<<(Ostream& os, const janafThermo& jt) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/janaf/janafThermo.H b/src/thermophysicalModels/specie/thermo/janaf/janafThermo.H index db7807a642..e9f455b0a8 100644 --- a/src/thermophysicalModels/specie/thermo/janaf/janafThermo.H +++ b/src/thermophysicalModels/specie/thermo/janaf/janafThermo.H @@ -150,6 +150,12 @@ public: //- Enthalpy [J/kmol] inline scalar h(const scalar T) const; + //- Sensible enthalpy [J/kmol] + inline scalar hs(const scalar T) const; + + //- Chemical enthalpy [J/kmol] + inline scalar hc() const; + //- Entropy [J/(kmol K)] inline scalar s(const scalar T) const; diff --git a/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H b/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H index f9dc5e7a0e..754996f27c 100644 --- a/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H +++ b/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H @@ -25,6 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "janafThermo.H" +#include "specie.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -130,8 +131,7 @@ inline Foam::scalar Foam::janafThermo::h ) const { const coeffArray& a = coeffs(T); - return - this->RR* + return this->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] @@ -139,6 +139,36 @@ inline Foam::scalar Foam::janafThermo::h } +template +inline Foam::scalar Foam::janafThermo::hs +( + const scalar T +) const +{ + const coeffArray& a = coeffs(T); + scalar Tr = T - specie::Tstd; + return this->RR* + ( + ((((a[4]/5.0*Tr + a[3]/4.0)*Tr + a[2]/3.0)*Tr + a[1]/2.0)*Tr + a[0])*Tr + ); +} + + +template +inline Foam::scalar Foam::janafThermo::hc() const +{ + const coeffArray& a = lowCpCoeffs_; + const scalar& Tstd = specie::Tstd; + return this->RR* + ( + ( + (((a[4]/5.0*Tstd + a[3]/4.0)*Tstd + a[2]/3.0)*Tstd + a[1]/2.0)*Tstd + + a[0] + )*Tstd + ); +} + + template inline Foam::scalar Foam::janafThermo::s ( diff --git a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.C b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.C index a2aedda84a..3fcf489771 100644 --- a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.C +++ b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.C @@ -22,34 +22,24 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - Basic thermodynamics type based on the use of fitting functions for - cp, h, s obtained from the template argument type thermo. All other - properties are derived from these primitive functions. - \*---------------------------------------------------------------------------*/ #include "specieThermo.H" #include "IOstreams.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - /* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */ template -const scalar specieThermo::tol_ = 1.0e-4; +const Foam::scalar Foam::specieThermo::tol_ = 1.0e-4; template -const int specieThermo::maxIter_ = 100; +const int Foam::specieThermo::maxIter_ = 100; // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -specieThermo::specieThermo(Istream& is) +Foam::specieThermo::specieThermo(Istream& is) : thermo(is) { @@ -60,7 +50,7 @@ specieThermo::specieThermo(Istream& is) // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // template -Ostream& operator<<(Ostream& os, const specieThermo& st) +Foam::Ostream& Foam::operator<<(Ostream& os, const specieThermo& st) { os << static_cast(st); @@ -69,8 +59,4 @@ Ostream& operator<<(Ostream& os, const specieThermo& st) } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H index c0d4802c74..ba92b6da15 100644 --- a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H +++ b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H @@ -140,6 +140,12 @@ public: // Enthalpy [J/kmol] //scalar h(const scalar) const; + // Sensible enthalpy [J/kmol] + //scalar hs(const scalar) const; + + // Chemical enthalpy [J/kmol] + //scalar hc(const scalar) const; + // Entropy [J/(kmol K)] //scalar s(const scalar) const; @@ -158,6 +164,9 @@ public: //- Internal energy [J/kmol] inline scalar e(const scalar T) const; + //- Sensible internal energy [J/kmol] + inline scalar es(const scalar T) const; + //- Gibbs free energy [J/kmol] inline scalar g(const scalar T) const; @@ -176,6 +185,12 @@ public: //- Enthalpy [J/kg] inline scalar H(const scalar T) const; + //- Sensible enthalpy [J/kg] + inline scalar Hs(const scalar T) const; + + //- Chemical enthalpy [J/kg] + inline scalar Hc() const; + //- Entropy [J/(kg K)] inline scalar S(const scalar T) const; diff --git a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermoI.H b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermoI.H index 30f11baf42..13adec738b 100644 --- a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermoI.H +++ b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermoI.H @@ -24,20 +24,12 @@ License \*---------------------------------------------------------------------------*/ -#include "error.H" - #include "specieThermo.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// construct from components template -inline specieThermo::specieThermo +inline Foam::specieThermo::specieThermo ( const thermo& sp ) @@ -46,10 +38,8 @@ inline specieThermo::specieThermo {} -// return the temperature corresponding to the value of the -// thermodynamic property f, given the function f = F(T) and dF(T)/dT template -inline scalar specieThermo::T +inline Foam::scalar Foam::specieThermo::T ( scalar f, scalar T0, @@ -87,9 +77,8 @@ inline scalar specieThermo::T // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct as named copy template -inline specieThermo::specieThermo +inline Foam::specieThermo::specieThermo ( const word& name, const specieThermo& st @@ -101,105 +90,114 @@ inline specieThermo::specieThermo // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// Calculate and return derived properties -// (These functions need not provided in derived types) - -// mole specific properties - -// Heat capacities [J/(kmol K)] template -inline scalar specieThermo::cv(const scalar T) const +inline Foam::scalar Foam::specieThermo::cv(const scalar T) const { return this->cp(T) - this->RR; } -// gamma = cp/cv [] + template -inline scalar specieThermo::gamma(const scalar T) const +inline Foam::scalar Foam::specieThermo::gamma(const scalar T) const { scalar CP = this->cp(T); return CP/(CP - this->RR); } -// Internal energy [J/kmol] + template -inline scalar specieThermo::e(const scalar T) const +inline Foam::scalar Foam::specieThermo::e(const scalar T) const { return this->h(T) - this->RR*(T - this->Tstd); } -// Gibbs free energy [J/kmol] + template -inline scalar specieThermo::g(const scalar T) const +inline Foam::scalar Foam::specieThermo::es(const scalar T) const +{ + return this->hs(T) - this->RR*(T - this->Tstd); +} + + +template +inline Foam::scalar Foam::specieThermo::g(const scalar T) const { return this->h(T) - T*this->s(T); } -// Helmholtz free energy [J/kmol] + template -inline scalar specieThermo::a(const scalar T) const +inline Foam::scalar Foam::specieThermo::a(const scalar T) const { return this->e(T) - T*this->s(T); } -// mass specific properties - -// Heat capacity at constant pressure [J/(kg K)] template -inline scalar specieThermo::Cp(const scalar T) const +inline Foam::scalar Foam::specieThermo::Cp(const scalar T) const { return this->cp(T)/this->W(); } -// Heat capacity at constant pressure [J/(kg K)] + template -inline scalar specieThermo::Cv(const scalar T) const +inline Foam::scalar Foam::specieThermo::Cv(const scalar T) const { return this->cv(T)/this->W(); } -// Enthalpy [J/kg] + template -inline scalar specieThermo::H(const scalar T) const +inline Foam::scalar Foam::specieThermo::H(const scalar T) const { return this->h(T)/this->W(); } -// Entropy [J/kg] + template -inline scalar specieThermo::S(const scalar T) const +inline Foam::scalar Foam::specieThermo::Hs(const scalar T) const +{ + return this->hs(T)/this->W(); +} + + +template +inline Foam::scalar Foam::specieThermo::Hc() const +{ + return this->hc()/this->W(); +} + + +template +inline Foam::scalar Foam::specieThermo::S(const scalar T) const { return this->s(T)/this->W(); } -// Internal energy [J/kg] + template -inline scalar specieThermo::E(const scalar T) const +inline Foam::scalar Foam::specieThermo::E(const scalar T) const { return this->e(T)/this->W(); } -// Gibbs free energy [J/kg] + template -inline scalar specieThermo::G(const scalar T) const +inline Foam::scalar Foam::specieThermo::G(const scalar T) const { return this->g(T)/this->W(); } -// Helmholtz free energy [J/kg] + template -inline scalar specieThermo::A(const scalar T) const +inline Foam::scalar Foam::specieThermo::A(const scalar T) const { return this->a(T)/this->W(); } -// Equilibrium reaction thermodynamics - -// Equilibrium constant [] template -inline scalar specieThermo::K(const scalar T) const +inline Foam::scalar Foam::specieThermo::K(const scalar T) const { scalar arg = -this->nMoles()*this->g(T)/(this->RR*T); @@ -213,21 +211,16 @@ inline scalar specieThermo::K(const scalar T) const } } -//- Equilibrium constant [] i.t.o. partial pressures -// = PIi(pi/Pstd)^nui -// For low pressures (where the gas mixture is near perfect) Kp = K + template -inline scalar specieThermo::Kp(const scalar T) const +inline Foam::scalar Foam::specieThermo::Kp(const scalar T) const { return K(T); } -//- Equilibrium constant i.t.o. concentration -// For low pressures (where the gas mixture is near perfect) -// Kc = Kp(pstd/(RR*T))^nu template -inline scalar specieThermo::Kc(const scalar T) const +inline Foam::scalar Foam::specieThermo::Kc(const scalar T) const { if (equal(this->nMoles(), SMALL)) { @@ -240,11 +233,12 @@ inline scalar specieThermo::Kc(const scalar T) const } -//- Equilibrium constant [] i.t.o. mole-fractions -// For low pressures (where the gas mixture is near perfect) -// Kx = Kp(pstd/p)^nui template -inline scalar specieThermo::Kx(const scalar T, const scalar p) const +inline Foam::scalar Foam::specieThermo::Kx +( + const scalar T, + const scalar p +) const { if (equal(this->nMoles(), SMALL)) { @@ -257,11 +251,8 @@ inline scalar specieThermo::Kx(const scalar T, const scalar p) const } -//- Equilibrium constant [] i.t.o. number of moles -// For low pressures (where the gas mixture is near perfect) -// Kn = Kp(n*pstd/p)^nui where n = number of moles in mixture template -inline scalar specieThermo::Kn +inline Foam::scalar Foam::specieThermo::Kn ( const scalar T, const scalar p, @@ -279,19 +270,23 @@ inline scalar specieThermo::Kn } -// Energy->temperature inversion functions - -// Temperature from Enthalpy given an initial temperature T0 template -inline scalar specieThermo::TH(const scalar h, const scalar T0) const +inline Foam::scalar Foam::specieThermo::TH +( + const scalar h, + const scalar T0 +) const { return T(h, T0, &specieThermo::H, &specieThermo::Cp); } -// Temperature from internal energy given an initial temperature T0 template -inline scalar specieThermo::TE(const scalar e, const scalar T0) const +inline Foam::scalar Foam::specieThermo::TE +( + const scalar e, + const scalar T0 +) const { return T(e, T0, &specieThermo::E, &specieThermo::Cv); } @@ -300,19 +295,25 @@ inline scalar specieThermo::TE(const scalar e, const scalar T0) const // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -inline void specieThermo::operator+=(const specieThermo& st) +inline void Foam::specieThermo::operator+= +( + const specieThermo& st +) { thermo::operator+=(st); } template -inline void specieThermo::operator-=(const specieThermo& st) +inline void Foam::specieThermo::operator-= +( + const specieThermo& st +) { thermo::operator-=(st); } template -inline void specieThermo::operator*=(const scalar s) +inline void Foam::specieThermo::operator*=(const scalar s) { thermo::operator*=(s); } @@ -321,7 +322,7 @@ inline void specieThermo::operator*=(const scalar s) // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // template -inline specieThermo operator+ +inline Foam::specieThermo Foam::operator+ ( const specieThermo& st1, const specieThermo& st2 @@ -335,7 +336,7 @@ inline specieThermo operator+ template -inline specieThermo operator- +inline Foam::specieThermo Foam::operator- ( const specieThermo& st1, const specieThermo& st2 @@ -349,7 +350,7 @@ inline specieThermo operator- template -inline specieThermo operator* +inline Foam::specieThermo Foam::operator* ( const scalar s, const specieThermo& st @@ -363,7 +364,7 @@ inline specieThermo operator* template -inline specieThermo operator== +inline Foam::specieThermo Foam::operator== ( const specieThermo& st1, const specieThermo& st2 @@ -373,8 +374,4 @@ inline specieThermo operator== } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* //