multicomponentThermo: Dimensioned constant specie properties

The specie molecular mass (Wi) and formation enthalpy (hfi) methods now
return dimensioned scalars. This permits their direct inclusion into
dimensioned field expressions. Non-dimensioned methods have been
retained with a "Value" suffix (i.e., WiValue and hfiValue).
This commit is contained in:
Will Bainbridge
2023-12-06 17:13:25 +00:00
parent 2bc91ecff0
commit 947dd44188
26 changed files with 107 additions and 103 deletions

View File

@ -171,26 +171,12 @@ void Foam::interfaceCompositionModels::nonRandomTwoLiquid::update
const volScalarField X1
(
thermo().Y(species1Index_)
*W
/dimensionedScalar
(
"W",
dimMass/dimMoles,
thermo().Wi(species1Index_)
)
thermo().Y(species1Index_)*W/thermo().Wi(species1Index_)
);
const volScalarField X2
(
thermo().Y(species2Index_)
*W
/dimensionedScalar
(
"W",
dimMass/dimMoles,
thermo().Wi(species2Index_)
)
thermo().Y(species2Index_)*W/thermo().Wi(species2Index_)
);
const volScalarField alpha12(alpha12_ + Tf*beta12_);

View File

@ -48,14 +48,7 @@ namespace interfaceCompositionModels
Foam::tmp<Foam::volScalarField>
Foam::interfaceCompositionModels::saturated::wRatioByP() const
{
const dimensionedScalar Wi
(
"W",
dimMass/dimMoles,
thermo().Wi(saturatedIndex_)
);
return Wi/thermo().W()/thermo().p();
return thermo().Wi(saturatedIndex_)/thermo().W()/thermo().p();
}

View File

@ -32,7 +32,7 @@ scalarList W(const fluidMulticomponentThermo& thermo)
forAll(W, i)
{
W[i] = thermo.Wi(i);
W[i] = thermo.Wi(i).value();
}
return W;

View File

@ -78,12 +78,7 @@ void Fickian<BasicThermophysicalTransportModel>::updateDm() const
sumXbyD +=
Y[j]
/(
dimensionedScalar
(
"Wj",
Wm.dimensions(),
this->thermo().Wi(j)
)
this->thermo().Wi(j)
*(
i < j
? evaluate(DFuncs_[i][j], dimViscosity, p, T)
@ -96,16 +91,8 @@ void Fickian<BasicThermophysicalTransportModel>::updateDm() const
Dm_.set
(
i,
(
1/Wm
- Y[i]
/dimensionedScalar
(
"Wi",
Wm.dimensions(),
this->thermo().Wi(i)
)
)/max(sumXbyD, dimensionedScalar(sumXbyD.dimensions(), small))
(1/Wm - Y[i]/this->thermo().Wi(i))
/max(sumXbyD, dimensionedScalar(sumXbyD.dimensions(), small))
);
}
}

View File

@ -384,7 +384,7 @@ MaxwellStefan<BasicThermophysicalTransportModel>::MaxwellStefan
// Set the molecular weights of the species
forAll(W, i)
{
W[i] = this->thermo().Wi(i);
W[i] = this->thermo().Wi(i).value();
}
}

View File

@ -106,7 +106,7 @@ Foam::radiationModels::sootModels::mixtureFraction::mixtureFraction
const label speciei = singleReaction.rhs()[i].index;
const scalar stoichCoeff = singleReaction.rhs()[i].stoichCoeff;
Xi[i] = mag(stoichCoeff)/totalMol;
Wm += Xi[i]*combustion.thermo().Wi(speciei);
Wm += Xi[i]*combustion.thermo().WiValue(speciei);
}
scalarList Yprod0(combustion.thermo().species().size(), 0.0);
@ -114,7 +114,7 @@ Foam::radiationModels::sootModels::mixtureFraction::mixtureFraction
forAll(singleReaction.rhs(), i)
{
const label speciei = singleReaction.rhs()[i].index;
Yprod0[speciei] = combustion.thermo().Wi(speciei)/Wm*Xi[i];
Yprod0[speciei] = combustion.thermo().WiValue(speciei)/Wm*Xi[i];
}
const scalar XSoot = nuSoot_/totalMol;

View File

@ -32,7 +32,7 @@ License
void Foam::combustionModels::singleStepCombustion::calculateqFuel()
{
const scalar Wu = thermo_.Wi(fuelIndex_);
const scalar Wu = thermo_.WiValue(fuelIndex_);
forAll(reaction_.lhs(), i)
{
@ -40,7 +40,7 @@ void Foam::combustionModels::singleStepCombustion::calculateqFuel()
const scalar stoichCoeff = reaction_.lhs()[i].stoichCoeff;
specieStoichCoeffs_[speciei] = -stoichCoeff;
qFuel_.value() +=
thermo_.hfi(speciei)*thermo_.Wi(speciei)*stoichCoeff/Wu;
thermo_.hfiValue(speciei)*thermo_.WiValue(speciei)*stoichCoeff/Wu;
}
forAll(reaction_.rhs(), i)
@ -49,7 +49,7 @@ void Foam::combustionModels::singleStepCombustion::calculateqFuel()
const scalar stoichCoeff = reaction_.rhs()[i].stoichCoeff;
specieStoichCoeffs_[speciei] = stoichCoeff;
qFuel_.value() -=
thermo_.hfi(speciei)*thermo_.Wi(speciei)*stoichCoeff/Wu;
thermo_.hfiValue(speciei)*thermo_.WiValue(speciei)*stoichCoeff/Wu;
specieProd_[speciei] = -1;
}
@ -60,16 +60,16 @@ void Foam::combustionModels::singleStepCombustion::calculateqFuel()
void Foam::combustionModels::singleStepCombustion::massAndAirStoichRatios()
{
const label O2Index = thermo_.species()["O2"];
const scalar Wu = thermo_.Wi(fuelIndex_);
const scalar Wu = thermo_.WiValue(fuelIndex_);
stoicRatio_ =
(
thermo_.Wi(thermo_.defaultSpecie())
thermo_.WiValue(thermo_.defaultSpecie())
*specieStoichCoeffs_[thermo_.defaultSpecie()]
+ thermo_.Wi(O2Index)*mag(specieStoichCoeffs_[O2Index])
+ thermo_.WiValue(O2Index)*mag(specieStoichCoeffs_[O2Index])
)/(Wu*mag(specieStoichCoeffs_[fuelIndex_]));
s_ = thermo_.Wi(O2Index)*mag(specieStoichCoeffs_[O2Index])
s_ = thermo_.WiValue(O2Index)*mag(specieStoichCoeffs_[O2Index])
/(Wu*mag(specieStoichCoeffs_[fuelIndex_]));
Info << "stoichiometric air-fuel ratio: " << stoicRatio_.value() << endl;
@ -93,13 +93,13 @@ void Foam::combustionModels::singleStepCombustion::calculateMaxProducts()
{
const label speciei = reaction_.rhs()[i].index;
Xi[i] = mag(specieStoichCoeffs_[speciei])/totalMol;
Wm += Xi[i]*thermo_.Wi(speciei);
Wm += Xi[i]*thermo_.WiValue(speciei);
}
forAll(reaction_.rhs(), i)
{
const label speciei = reaction_.rhs()[i].index;
Yprod0_[speciei] = thermo_.Wi(speciei)/Wm*Xi[i];
Yprod0_[speciei] = thermo_.WiValue(speciei)/Wm*Xi[i];
}
Info << "Maximum products mass concentrations: " << nl;
@ -115,8 +115,8 @@ void Foam::combustionModels::singleStepCombustion::calculateMaxProducts()
forAll(specieStoichCoeffs_, i)
{
specieStoichCoeffs_[i] =
specieStoichCoeffs_[i]*thermo_.Wi(i)
/(thermo_.Wi(fuelIndex_)*mag(specieStoichCoeffs_[fuelIndex_]));
specieStoichCoeffs_[i]*thermo_.WiValue(i)
/(thermo_.WiValue(fuelIndex_)*mag(specieStoichCoeffs_[fuelIndex_]));
}
}

View File

@ -599,7 +599,7 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calcDevolatilisation
{
const label id = composition.localToCarrierId(GAS, i);
const scalar Cp = composition.carrier().Cpi(id, td.pc(), Ts);
const scalar W = composition.carrier().Wi(id);
const scalar W = composition.carrier().WiValue(id);
const scalar Ni = dMassDV[i]/(this->areaS(d)*dt*W);
// Dab calc'd using API vapour mass diffusivity function

View File

@ -133,7 +133,7 @@ void Foam::ReactingParcel<ParcelType>::calcPhaseChange
const label cid = composition.localToCarrierId(idPhase, i);
const scalar Cp = composition.carrier().Cpi(cid, td.pc(), Tsdash);
const scalar W = composition.carrier().Wi(cid);
const scalar W = composition.carrier().WiValue(cid);
const scalar Ni = dMassPC[i]/(this->areaS(d)*dt*W);
const scalar Dab =
@ -304,7 +304,7 @@ void Foam::ReactingParcel<ParcelType>::correctSurfaceValues
forAll(Xinf, i)
{
Xinf[i] = carrierThermo.Y(i)[this->cell()]/carrierThermo.Wi(i);
Xinf[i] = carrierThermo.Y(i)[this->cell()]/carrierThermo.WiValue(i);
}
Xinf /= sum(Xinf);
@ -326,7 +326,7 @@ void Foam::ReactingParcel<ParcelType>::correctSurfaceValues
const scalar Csi = Cs[i] + Xsff*Xinf[i]*CsTot;
Xs[i] = (2.0*Csi + Xinf[i]*CsTot)/3.0;
Ys[i] = Xs[i]*carrierThermo.Wi(i);
Ys[i] = Xs[i]*carrierThermo.WiValue(i);
}
Xs /= sum(Xs);
Ys /= sum(Ys);
@ -341,7 +341,7 @@ void Foam::ReactingParcel<ParcelType>::correctSurfaceValues
forAll(Ys, i)
{
const scalar W = carrierThermo.Wi(i);
const scalar W = carrierThermo.WiValue(i);
const scalar sqrtW = sqrt(W);
const scalar cbrtW = cbrt(W);

View File

@ -279,7 +279,7 @@ Foam::scalarField Foam::CompositionModel<CloudType>::X
forAll(Y, i)
{
label cid = props.carrierId(i);
X[i] = Y[i]/carrierMcThermoPtr_->Wi(cid);
X[i] = Y[i]/carrierMcThermoPtr_->WiValue(cid);
WInv += X[i];
}
break;

View File

@ -42,7 +42,7 @@ Foam::tmp<Foam::scalarField> Foam::LiquidEvaporation<CloudType>::calcXc
{
Xc[i] =
this->owner().composition().carrier().Y()[i][celli]
/this->owner().composition().carrier().Wi(i);
/this->owner().composition().carrier().WiValue(i);
}
return Xc/sum(Xc);

View File

@ -43,7 +43,7 @@ Foam::tmp<Foam::scalarField> Foam::LiquidEvaporationBoil<CloudType>::calcXc
{
Xc[i] =
this->owner().composition().carrier().Y()[i][celli]
/this->owner().composition().carrier().Wi(i);
/this->owner().composition().carrier().WiValue(i);
}
return Xc/sum(Xc);

View File

@ -52,11 +52,11 @@ Foam::COxidationDiffusionLimitedRate<CloudType>::COxidationDiffusionLimitedRate
CsLocalId_ = owner.composition().localId(idSolid, "C");
// Set local copies of thermo properties
WO2_ = owner.composition().carrier().Wi(O2GlobalId_);
const scalar WCO2 = owner.composition().carrier().Wi(CO2GlobalId_);
WO2_ = owner.composition().carrier().WiValue(O2GlobalId_);
const scalar WCO2 = owner.composition().carrier().WiValue(CO2GlobalId_);
WC_ = WCO2 - WO2_;
HcCO2_ = owner.composition().carrier().hfi(CO2GlobalId_);
HcCO2_ = owner.composition().carrier().hfiValue(CO2GlobalId_);
if (Sb_ < 0)
{

View File

@ -52,11 +52,11 @@ Foam::COxidationHurtMitchell<CloudType>::COxidationHurtMitchell
ashLocalId_ = owner.composition().localId(idSolid, "ash", true);
// Set local copies of thermo properties
WO2_ = owner.composition().carrier().Wi(O2GlobalId_);
const scalar WCO2 = owner.composition().carrier().Wi(CO2GlobalId_);
WO2_ = owner.composition().carrier().WiValue(O2GlobalId_);
const scalar WCO2 = owner.composition().carrier().WiValue(CO2GlobalId_);
WC_ = WCO2 - WO2_;
HcCO2_ = owner.composition().carrier().hfi(CO2GlobalId_);
HcCO2_ = owner.composition().carrier().hfiValue(CO2GlobalId_);
const scalar YCloc = owner.composition().Y0(idSolid)[CsLocalId_];
const scalar YSolidTot = owner.composition().YMixture0()[idSolid];

View File

@ -58,11 +58,11 @@ Foam::COxidationIntrinsicRate<CloudType>::COxidationIntrinsicRate
CsLocalId_ = owner.composition().localId(idSolid, "C");
// Set local copies of thermo properties
WO2_ = owner.composition().carrier().Wi(O2GlobalId_);
const scalar WCO2 = owner.composition().carrier().Wi(CO2GlobalId_);
WO2_ = owner.composition().carrier().WiValue(O2GlobalId_);
const scalar WCO2 = owner.composition().carrier().WiValue(CO2GlobalId_);
WC_ = WCO2 - WO2_;
HcCO2_ = owner.composition().carrier().hfi(CO2GlobalId_);
HcCO2_ = owner.composition().carrier().hfiValue(CO2GlobalId_);
if (Sb_ < 0)
{

View File

@ -53,11 +53,11 @@ COxidationKineticDiffusionLimitedRate
CsLocalId_ = owner.composition().localId(idSolid, "C");
// Set local copies of thermo properties
WO2_ = owner.composition().carrier().Wi(O2GlobalId_);
const scalar WCO2 = owner.composition().carrier().Wi(CO2GlobalId_);
WO2_ = owner.composition().carrier().WiValue(O2GlobalId_);
const scalar WCO2 = owner.composition().carrier().WiValue(CO2GlobalId_);
WC_ = WCO2 - WO2_;
HcCO2_ = owner.composition().carrier().hfi(CO2GlobalId_);
HcCO2_ = owner.composition().carrier().hfiValue(CO2GlobalId_);
const scalar YCloc = owner.composition().Y0(idSolid)[CsLocalId_];
const scalar YSolidTot = owner.composition().YMixture0()[idSolid];

View File

@ -65,11 +65,11 @@ Foam::COxidationMurphyShaddix<CloudType>::COxidationMurphyShaddix
CsLocalId_ = owner.composition().localId(idSolid, "C");
// Set local copies of thermo properties
WO2_ = owner.composition().carrier().Wi(O2GlobalId_);
const scalar WCO2 = owner.composition().carrier().Wi(CO2GlobalId_);
WO2_ = owner.composition().carrier().WiValue(O2GlobalId_);
const scalar WCO2 = owner.composition().carrier().WiValue(CO2GlobalId_);
WC_ = WCO2 - WO2_;
HcCO2_ = owner.composition().carrier().hfi(CO2GlobalId_);
HcCO2_ = owner.composition().carrier().hfiValue(CO2GlobalId_);
const scalar YCloc = owner.composition().Y0(idSolid)[CsLocalId_];
const scalar YSolidTot = owner.composition().YMixture0()[idSolid];

View File

@ -221,11 +221,13 @@ Foam::radiationModels::absorptionEmissionModels::greyMean::aCont
scalar invWt = 0.0;
forAll(mcThermo.Y(), s)
{
invWt += mcThermo.Y(s)[celli]/mcThermo.Wi(s);
invWt += mcThermo.Y(s)[celli]/mcThermo.WiValue(s);
}
label index = mcThermo.species()[iter.key()];
scalar Xk = mcThermo.Y(index)[celli]/(mcThermo.Wi(index)*invWt);
const label index = mcThermo.species()[iter.key()];
const scalar Xk =
mcThermo.Y(index)[celli]/(mcThermo.WiValue(index)*invWt);
Xipi = Xk*paToAtm(p[celli]);
}

View File

@ -241,13 +241,13 @@ Foam::radiationModels::absorptionEmissionModels::wideBand::aCont
scalar invWt = 0;
forAll(mcThermo.Y(), s)
{
invWt += mcThermo.Y(s)[celli]/mcThermo.Wi(s);
invWt += mcThermo.Y(s)[celli]/mcThermo.WiValue(s);
}
const label index = mcThermo.species()[iter.key()];
const scalar Xk =
mcThermo.Y(index)[celli]/(mcThermo.Wi(index)*invWt);
mcThermo.Y(index)[celli]/(mcThermo.WiValue(index)*invWt);
Xipi = Xk*paToAtm(p[celli]);
}

View File

@ -101,7 +101,7 @@ Foam::adsorptionMassFractionFvPatchScalarField::calcPhiYp() const
if (property_ != massFraction)
{
const fluidMulticomponentThermo& thermo = this->thermo(db());
Wi = thermo.Wi(thermo.species()[YName]);
Wi = thermo.Wi(thermo.species()[YName]).value();
}
// Get the mixture molecular weights, if needed

View File

@ -135,7 +135,7 @@ Foam::semiPermeableBaffleMassFractionFvPatchScalarField::calcPhiYp() const
if (property_ != massFraction)
{
const fluidMulticomponentThermo& thermo = this->thermo(db());
Wi = thermo.Wi(thermo.species()[YName]);
Wi = thermo.Wi(thermo.species()[YName]).value();
}
// Get the mixture molecular weights, if needed

View File

@ -145,7 +145,7 @@ bool Foam::functionObjects::massFractions::execute()
// Construct lists of specie molar mass, fields of specie mass, and a field
// of total mass
List<dimensionedScalar> W(Y.size());
PtrList<dimensionedScalar> W(Y.size());
PtrList<volScalarField> m(Y.size());
volScalarField mTotal
(
@ -156,8 +156,7 @@ bool Foam::functionObjects::massFractions::execute()
bool fromMoleFractions = false, fromMoles = false;
forAll(Y, i)
{
W[i].dimensions().reset(dimMass/dimMoles);
W[i].value() = thermo.Wi(i);
W.set(i, new dimensionedScalar(thermo.Wi(i)));
typeIOobject<volScalarField> YIo
(

View File

@ -116,14 +116,7 @@ bool Foam::functionObjects::moleFractions::execute()
// Calculate the mole fractions
forAll(Y, i)
{
const dimensionedScalar Wi
(
"Wi",
dimMass/dimMoles,
thermo.Wi(i)
);
X_[i] = Y[i]*W/Wi;
X_[i] = Y[i]*W/thermo.Wi(i);
}
return true;

View File

@ -128,7 +128,7 @@ Foam::MulticomponentThermo<BaseThermo>::~MulticomponentThermo()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BaseThermo>
Foam::scalar Foam::MulticomponentThermo<BaseThermo>::Wi
Foam::scalar Foam::MulticomponentThermo<BaseThermo>::WiValue
(
const label speciei
) const
@ -137,6 +137,22 @@ Foam::scalar Foam::MulticomponentThermo<BaseThermo>::Wi
}
template<class BaseThermo>
Foam::dimensionedScalar Foam::MulticomponentThermo<BaseThermo>::Wi
(
const label speciei
) const
{
return
dimensionedScalar
(
"W",
dimMass/dimMoles,
this->specieThermo(speciei).W()
);
}
template<class BaseThermo>
Foam::scalar Foam::MulticomponentThermo<BaseThermo>::rhoi
(
@ -357,7 +373,23 @@ Foam::MulticomponentThermo<BaseThermo>::hai
template<class BaseThermo>
Foam::scalar Foam::MulticomponentThermo<BaseThermo>::hfi
Foam::dimensionedScalar Foam::MulticomponentThermo<BaseThermo>::hfi
(
const label speciei
) const
{
return
dimensionedScalar
(
"hf",
dimEnergy/dimMass,
this->specieThermo(speciei).hf()
);
}
template<class BaseThermo>
Foam::scalar Foam::MulticomponentThermo<BaseThermo>::hfiValue
(
const label speciei
) const

View File

@ -97,7 +97,10 @@ public:
// Specie molecular properties
//- Molecular weight [kg/kmol]
virtual scalar Wi(const label speciei) const;
virtual scalar WiValue(const label speciei) const;
//- Molecular weight [kg/kmol]
virtual dimensionedScalar Wi(const label speciei) const;
// Specie thermodynamic properties
@ -207,7 +210,10 @@ public:
) const;
//- Enthalpy of formation [J/kg]
virtual scalar hfi(const label speciei) const;
virtual scalar hfiValue(const label speciei) const;
//- Enthalpy of formation [J/kg]
virtual dimensionedScalar hfi(const label speciei) const;
// Specie transport properties

View File

@ -132,10 +132,10 @@ public:
// Specie molecular properties
//- Molecular weight [kg/kmol]
virtual scalar Wi(const label speciei) const = 0;
virtual scalar WiValue(const label speciei) const = 0;
//- Enthalpy of formation [J/kg]
virtual scalar hfi(const label speciei) const = 0;
//- Molecular weight [kg/kmol]
virtual dimensionedScalar Wi(const label speciei) const = 0;
// Specie thermodynamic properties
@ -244,6 +244,12 @@ public:
const volScalarField& T
) const = 0;
//- Enthalpy of formation [J/kg]
virtual scalar hfiValue(const label speciei) const = 0;
//- Enthalpy of formation [J/kg]
virtual dimensionedScalar hfi(const label speciei) const = 0;
// Specie transport properties