From b635f73f51f533431f6c9364f98eb7210dad3f0d Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 12 Feb 2010 16:54:12 +0000 Subject: [PATCH] ENH: Further updates relating from vhange from total- to sensible enthalpy - Added chemical enthalpy access function to top level api. - Re-worked source term for enthalpy equation(s) in chemistry model, and - Re-worked heat release calculation STYLE: Using worded dimensions instead of dimensionSet(...) --- .../basic/basicThermo/basicThermo.C | 7 ++ .../basic/basicThermo/basicThermo.H | 3 + .../ODEChemistryModel/ODEChemistryModel.C | 89 ++++++++++++------- .../ODEChemistryModel/ODEChemistryModel.H | 3 + .../ODEChemistryModel/ODEChemistryModelI.H | 2 +- .../basicChemistryModel/basicChemistryModel.H | 7 +- .../hCombustionThermo/hCombustionThermo.H | 3 - .../hsCombustionThermo/hsCombustionThermo.H | 2 - .../hPsiMixtureThermo/hPsiMixtureThermo.C | 2 +- .../hPsiMixtureThermo/hPsiMixtureThermo.H | 6 +- .../hhuMixtureThermo/hhuMixtureThermo.C | 2 +- .../hsPsiMixtureThermo/hsPsiMixtureThermo.C | 14 +-- .../hsPsiMixtureThermo/hsPsiMixtureThermo.H | 6 +- .../hReactionThermo/hReactionThermo.H | 3 - .../hsReactionThermo/hsReactionThermo.H | 3 - .../hsRhoMixtureThermo/hsRhoMixtureThermo.H | 7 +- 16 files changed, 96 insertions(+), 63 deletions(-) diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.C b/src/thermophysicalModels/basic/basicThermo/basicThermo.C index f03bcc8289..67f0de7092 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.C @@ -343,6 +343,13 @@ Foam::tmp Foam::basicThermo::hs } +Foam::tmp Foam::basicThermo::hc() const +{ + notImplemented("basicThermo::hc()"); + return volScalarField::null(); +} + + Foam::volScalarField& Foam::basicThermo::e() { notImplemented("basicThermo::e()"); diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.H b/src/thermophysicalModels/basic/basicThermo/basicThermo.H index fe8384b3e1..4f28779a30 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.H +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.H @@ -183,6 +183,9 @@ public: const label patchi ) const; + //- Chemical enthalpy [J/kg] + virtual tmp hc() const; + //- Internal energy [J/kg] // Non-const access allowed for transport equations virtual volScalarField& e(); diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C index 1b9b15fc8e..bb44a1bb23 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C @@ -466,7 +466,7 @@ Foam::ODEChemistryModel::tc() const this->thermo().rho() ); - tmp tsource + tmp ttc ( new volScalarField ( @@ -484,7 +484,7 @@ Foam::ODEChemistryModel::tc() const ) ); - scalarField& t = tsource(); + scalarField& tc = ttc(); label nReaction = reactions_.size(); @@ -517,17 +517,59 @@ Foam::ODEChemistryModel::tc() const forAll(R.rhs(), s) { scalar sr = R.rhs()[s].stoichCoeff; - t[celli] += sr*pf*cf; + tc[celli] += sr*pf*cf; } } - t[celli] = nReaction*cSum/t[celli]; + tc[celli] = nReaction*cSum/tc[celli]; } } - tsource().correctBoundaryConditions(); + ttc().correctBoundaryConditions(); - return tsource; + return ttc; +} + + +template +Foam::tmp +Foam::ODEChemistryModel::Sh() const +{ + tmp trhodQ + ( + new volScalarField + ( + IOobject + ( + "Sh", + this->mesh_.time().timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + this->mesh_, + dimensionedScalar("zero", dimEnergy/dimTime/dimVolume, 0.0), + zeroGradientFvPatchScalarField::typeName + ) + ); + + if (this->chemistry_) + { + scalarField& rhodQ = trhodQ(); + + forAll(Y_, i) + { + forAll(rhodQ, cellI) + { + scalar Ti = this->thermo().T()[cellI]; + scalar hi = specieThermo_[i].H(Ti); + rhodQ[cellI] -= hi*RR_[i][cellI]; + } + } + } + + return trhodQ; } @@ -545,37 +587,19 @@ Foam::ODEChemistryModel::dQ() const this->mesh_.time().timeName(), this->mesh_, IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::NO_WRITE, + false ), this->mesh_, - dimensionedScalar - ( - "zero", - dimensionSet(0, 2, -3 , 0, 0, 0, 0), - 0.0 - ) + dimensionedScalar("dQ", dimEnergy/dimTime, 0.0), + zeroGradientFvPatchScalarField::typeName ) ); if (this->chemistry_) { - scalarField& dQ = tdQ(); - - scalarField rhoEff(dQ.size(), 0.0); - - forAll(Y_, i) - { - forAll(dQ, cellI) - { - scalar Ti = this->thermo().T()[cellI]; - scalar pi = this->thermo().p()[cellI]; - rhoEff[cellI] += Y_[i][cellI]*specieThermo_[i].rho(pi, Ti); - scalar hi = specieThermo_[i].H(Ti); - dQ[cellI] -= hi*RR_[i][cellI]; - } - } - - dQ /= rhoEff; + volScalarField& dQ = tdQ(); + dQ.dimensionedInternalField() = this->mesh_.V()*Sh()(); } return tdQ; @@ -678,6 +702,9 @@ Foam::scalar Foam::ODEChemistryModel::solve scalar deltaTMin = GREAT; + tmp thc = this->thermo().hc(); + const scalarField& hc = thc(); + forAll(rho, celli) { for (label i=0; i::solve scalar rhoi = rho[celli]; scalar Ti = this->thermo().T()[celli]; - scalar hi = this->thermo().h()[celli]; + scalar hi = this->thermo().hs()[celli] + hc[celli]; scalar pi = this->thermo().p()[celli]; scalarField c(nSpecie_); diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H index 05e0d08e64..59ab6baed5 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H @@ -182,6 +182,9 @@ public: //- Return the chemical time scale virtual tmp tc() const; + //- Return source for enthalpy equation [kg/m/s3] + virtual tmp Sh() const; + //- Return the heat release, i.e. enthalpy/sec [m2/s3] virtual tmp dQ() const; diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H index e73f325bff..712b067e29 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H @@ -97,7 +97,7 @@ Foam::ODEChemistryModel::RR IOobject::NO_WRITE ), this->mesh(), - dimensionedScalar("zero", dimensionSet(1, -3, -1, 0, 0), 0.0), + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0), zeroGradientFvPatchScalarField::typeName ) ); diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H index c8fcdd9863..290c3b62e1 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H @@ -120,7 +120,7 @@ public: // Fields - //- Return const access to chemical source terms + //- Return const access to chemical source terms [kg/m3/s] virtual tmp RR(const label i) const = 0; @@ -133,7 +133,10 @@ public: //- Return the chemical time scale virtual tmp tc() const = 0; - //- Return the heat release + //- Return source for enthalpy equation [kg/m/s3] + virtual tmp Sh() const = 0; + + //- Return the heat release, i.e. enthalpy/sec [m2/s3] virtual tmp dQ() const = 0; }; diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermo.H b/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermo.H index d6b1ff7069..cfcf5c3834 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermo.H +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermo.H @@ -128,9 +128,6 @@ public: } - //- Chemical enthalpy [J/kg] - virtual tmp hc() const = 0; - //- Update properties virtual void correct() = 0; }; diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermo.H b/src/thermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermo.H index bb34b41602..2d7be88a74 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermo.H +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermo.H @@ -127,8 +127,6 @@ public: return hs_; } - //- Chemical enthalpy [J/kg] - virtual tmp hc() const = 0; //- Update properties virtual void correct() = 0; diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.C b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.C index d354b3a986..b3623a7b17 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.C +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.C @@ -280,7 +280,7 @@ Foam::hPsiMixtureThermo::Cp() const IOobject::NO_WRITE ), mesh, - dimensionSet(0, 2, -2, -1, 0) + dimEnergy/dimMass/dimTemperature ) ); diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.H b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.H index a30a0c1465..bf932f8a9b 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.H +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hPsiMixtureThermo/hPsiMixtureThermo.H @@ -94,12 +94,12 @@ public: //- Update properties virtual void correct(); - //- Chemical enthalpy [J/kg] - virtual tmp hc() const; - // Fields derived from thermodynamic state variables + //- Chemical enthalpy [J/kg] + virtual tmp hc() const; + //- Enthalpy for cell-set [J/kg] virtual tmp h ( diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C index 6d7245c044..2f6de08965 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hhuMixtureThermo/hhuMixtureThermo.C @@ -296,7 +296,7 @@ Foam::hhuMixtureThermo::Cp() const IOobject::NO_WRITE ), mesh, - dimensionSet(0, 2, -2, -1, 0) + dimEnergy/dimMass/dimTemperature ) ); diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.C b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.C index 0e6b14e1b0..83a40c8349 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.C +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.C @@ -205,15 +205,15 @@ Foam::hsPsiMixtureThermo::hs const labelList& cells ) const { - tmp th(new scalarField(T.size())); - scalarField& hs = th(); + tmp ths(new scalarField(T.size())); + scalarField& hs = ths(); forAll(T, celli) { hs[celli] = this->cellMixture(cells[celli]).Hs(T[celli]); } - return th; + return ths; } @@ -225,15 +225,15 @@ Foam::hsPsiMixtureThermo::hs const label patchi ) const { - tmp th(new scalarField(T.size())); - scalarField& hs = th(); + tmp ths(new scalarField(T.size())); + scalarField& hs = ths(); forAll(T, facei) { hs[facei] = this->patchFaceMixture(patchi, facei).Hs(T[facei]); } - return th; + return ths; } @@ -277,7 +277,7 @@ Foam::hsPsiMixtureThermo::Cp() const IOobject::NO_WRITE ), mesh, - dimensionSet(0, 2, -2, -1, 0) + dimEnergy/dimMass/dimTemperature ) ); diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.H b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.H index 382226f72b..b022b0eeb2 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.H +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/mixtureThermos/hsPsiMixtureThermo/hsPsiMixtureThermo.H @@ -95,11 +95,11 @@ public: virtual void correct(); - //- Chemical enthalpy [J/kg] - virtual tmp hc() const; - // Fields derived from thermodynamic state variables + //- Chemical enthalpy [J/kg] + virtual tmp hc() const; + //- Sensible enthalpy for cell-set [J/kg] virtual tmp hs ( diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermo.H b/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermo.H index f2319efa4f..ef801b2e96 100644 --- a/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermo.H +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermo.H @@ -128,9 +128,6 @@ public: } - //- Chemical enthalpy [J/kg] - virtual tmp hc() const = 0; - //- Update properties virtual void correct() = 0; }; diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.H b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.H index 85a23c3a38..ae038b0b31 100644 --- a/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.H +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermo.H @@ -128,9 +128,6 @@ public: } - //- Chemical enthalpy [J/kg] - virtual tmp hc() const = 0; - //- Update properties virtual void correct() = 0; }; diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.H b/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.H index 86e86a40a2..f11b02e599 100644 --- a/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.H +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/mixtureThermos/hsRhoMixtureThermo/hsRhoMixtureThermo.H @@ -94,12 +94,13 @@ public: //- Update properties virtual void correct(); - //- Chemical enthalpy [J/kg] - virtual tmp hc() const; - // Fields derived from thermodynamic state variables + //- Chemical enthalpy [J/kg] + virtual tmp hc() const; + + //- Sensible nthalpy for cell-set [J/kg] virtual tmp hs (