Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions applications/solvers/dfHighSpeedFoam/createFields.H
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ dfChemistryModel<basicThermo>* chemistry = combustion->chemistry();
PtrList<volScalarField>& 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;
Expand Down
3 changes: 2 additions & 1 deletion src/dfCanteraMixture/CanteraMixture.C
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ Foam::CanteraMixture::CanteraMixture
CanteraMechanismFile_(fileName(CanteraTorchProperties_.lookup("CanteraMechanismFile")).expand()),
transportModelName_(CanteraTorchProperties_.lookup("transportModel")),
Tref_(mesh.objectRegistry::lookupObject<volScalarField>("T")),
pref_(mesh.objectRegistry::lookupObject<volScalarField>("p"))
pref_(mesh.objectRegistry::lookupObject<volScalarField>("p")),
energyName_("ha")
{
if(!isFile(CanteraMechanismFile_))
{
Expand Down
9 changes: 6 additions & 3 deletions src/dfCanteraMixture/CanteraMixture.H
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -209,7 +210,7 @@ public:
return CanteraGas_->meanMolecularWeight();
}

static inline word heName() {return "ha";}
inline word heName() {return energyName_;}

PtrList<volScalarField>& Y() {return Y_;}
const PtrList<volScalarField>& Y() const {return Y_;}
Expand Down Expand Up @@ -323,6 +324,8 @@ public:

//- Read dictionary
void read(const dictionary&);

void setEnergyName(word name){energyName_=name;}
};


Expand Down
21 changes: 19 additions & 2 deletions src/dfChemistryModel/dfChemistryModel.C
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,16 @@ void Foam::dfChemistryModel<ThermoType>::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();

Expand Down Expand Up @@ -496,7 +505,15 @@ void Foam::dfChemistryModel<ThermoType>::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();

Expand Down
31 changes: 31 additions & 0 deletions src/dfChemistryModel/dfChemistryModel.H
Original file line number Diff line number Diff line change
Expand Up @@ -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_;}
Expand Down