diff --git a/applications/solvers/dfHighSpeedFoam/createFields.H b/applications/solvers/dfHighSpeedFoam/createFields.H index 3446fecd6..dcf09e117 100644 --- a/applications/solvers/dfHighSpeedFoam/createFields.H +++ b/applications/solvers/dfHighSpeedFoam/createFields.H @@ -137,6 +137,8 @@ dfChemistryModel* chemistry = combustion->chemistry(); PtrList& Y = chemistry->Y(); const word inertSpecie(chemistry->lookup("inertSpecie")); const label inertIndex(chemistry->species()[inertSpecie]); +chemistry->setEnergyName("ea"); +chemistry->updateEnergy(); chemistry->correctThermo(); Info<< "At initial time, min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; diff --git a/src/dfCanteraMixture/CanteraMixture.C b/src/dfCanteraMixture/CanteraMixture.C index ca06a6a18..7ed93b10a 100644 --- a/src/dfCanteraMixture/CanteraMixture.C +++ b/src/dfCanteraMixture/CanteraMixture.C @@ -49,7 +49,8 @@ Foam::CanteraMixture::CanteraMixture CanteraMechanismFile_(fileName(CanteraTorchProperties_.lookup("CanteraMechanismFile")).expand()), transportModelName_(CanteraTorchProperties_.lookup("transportModel")), Tref_(mesh.objectRegistry::lookupObject("T")), - pref_(mesh.objectRegistry::lookupObject("p")) + pref_(mesh.objectRegistry::lookupObject("p")), + energyName_("ha") { if(!isFile(CanteraMechanismFile_)) { diff --git a/src/dfCanteraMixture/CanteraMixture.H b/src/dfCanteraMixture/CanteraMixture.H index 94ff30619..09701e225 100644 --- a/src/dfCanteraMixture/CanteraMixture.H +++ b/src/dfCanteraMixture/CanteraMixture.H @@ -73,7 +73,7 @@ class CanteraMixture const volScalarField& Tref_; const volScalarField& pref_; mutable scalarList yTemp_; - + word energyName_; //- Construct as copy (not implemented) CanteraMixture(const CanteraMixture&); @@ -154,7 +154,8 @@ public: const scalar& T ) const { - return CanteraGas_->enthalpy_mass(); // J/kg + if(energyName_=="ha") return CanteraGas_->enthalpy_mass(); // J/kg + if(energyName_=="ea") return CanteraGas_->intEnergy_mass(); // J/kg } scalar Hc() const; // J/kg @@ -209,7 +210,7 @@ public: return CanteraGas_->meanMolecularWeight(); } - static inline word heName() {return "ha";} + inline word heName() {return energyName_;} PtrList& Y() {return Y_;} const PtrList& Y() const {return Y_;} @@ -323,6 +324,8 @@ public: //- Read dictionary void read(const dictionary&); + + void setEnergyName(word name){energyName_=name;} }; diff --git a/src/dfChemistryModel/dfChemistryModel.C b/src/dfChemistryModel/dfChemistryModel.C index f97c9a4e6..f1c84975f 100644 --- a/src/dfChemistryModel/dfChemistryModel.C +++ b/src/dfChemistryModel/dfChemistryModel.C @@ -382,7 +382,16 @@ void Foam::dfChemistryModel::correctThermo() yTemp_[i] = Y_[i][celli]; } CanteraGas_->setState_PY(p_[celli], yTemp_.begin()); - CanteraGas_->setState_HP(thermo_.he()[celli], p_[celli]); // setState_HP needs (J/kg) + if(mixture_.heName()=="ha") + { + CanteraGas_->setState_HP(thermo_.he()[celli], p_[celli]); // setState_HP needs (J/kg) + } + else if(mixture_.heName()=="ea") + { + scalar ha = thermo_.he()[celli] + p_[celli]/rho_[celli]; + CanteraGas_->setState_HP(ha, p_[celli]); + } + T_[celli] = CanteraGas_->temperature(); @@ -496,7 +505,15 @@ void Foam::dfChemistryModel::correctThermo() yTemp_[i] = Y_[i].boundaryField()[patchi][facei]; } CanteraGas_->setState_PY(pp[facei], yTemp_.begin()); - CanteraGas_->setState_HP(ph[facei], pp[facei]); + if(mixture_.heName()=="ha") + { + CanteraGas_->setState_HP(ph[facei], pp[facei]); + } + else if(mixture_.heName()=="ea") + { + scalar ha = ph[facei] + pp[facei]/prho[facei]; + CanteraGas_->setState_HP(ha, pp[facei]); + } pT[facei] = CanteraGas_->temperature(); diff --git a/src/dfChemistryModel/dfChemistryModel.H b/src/dfChemistryModel/dfChemistryModel.H index 32bd94f09..5502965c7 100644 --- a/src/dfChemistryModel/dfChemistryModel.H +++ b/src/dfChemistryModel/dfChemistryModel.H @@ -305,6 +305,37 @@ public: const CanteraMixture& mixture() {return mixture_;} + void setEnergyName(word name){ + mixture_.setEnergyName(name); + } + void updateEnergy() + { + scalarField& heCells = thermo_.he().primitiveFieldRef(); + const scalarField& pCells = p_; + const scalarField& TCells = T_; + + forAll(heCells, celli) + { + heCells[celli] = + mixture_.cellMixture(celli).HE(pCells[celli], TCells[celli]); + } + + volScalarField::Boundary& heBf = thermo_.he().boundaryFieldRef(); + + forAll(heBf, patchi) + { + fvPatchScalarField& phe = heBf[patchi]; + forAll(phe, facei) + { + phe[facei] = mixture_.patchFaceMixture(patchi,facei).HE + ( + p_.boundaryField()[patchi][facei], + T_.boundaryField()[patchi][facei] + ); + } + } + } + // profiling #if defined USE_LIBTORCH || defined USE_PYTORCH double time_allsolve() {return time_allsolve_;}