Skip to content

Commit c6a7132

Browse files
authored
Update compressibility calculation for real fluid in CanteraMixture.H (#303)
the compressibility for constant enthalpy was used
1 parent 71b8115 commit c6a7132

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/dfCanteraMixture/CanteraMixture.H

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,24 @@ public:
119119
const scalar& T
120120
) const
121121
{
122-
// for ideal gas, psi = CanteraGas_->density()/p = 1/RT
123-
return CanteraGas_->density()/p;
122+
const Cantera::AnyMap& map = CanteraGas_->input();
123+
if(map["thermo"].asString()=="Peng-Robinson" || map["thermo"].asString()=="Redlich-Kwong")
124+
{
125+
// for non-ideal EoS, psi = \partial rho/ \partial p at constant enthalpy
126+
// Currently, Peng-Robinson and Redlich-Kwong are available in Cantera
127+
// The partial derivative was approximated using backward difference with a step size dx
128+
double h0 = CanteraGas_->enthalpy_mass();
129+
double dx = 0.0001;
130+
double rho1 = CanteraGas_->density();
131+
CanteraGas_->setState_HP(h0,p*(1-dx));
132+
double rho2 = CanteraGas_->density();
133+
return (rho1-rho2)/(dx*p);
134+
}
135+
else
136+
{
137+
// for ideal gas, psi = W/RT
138+
return CanteraGas_->meanMolecularWeight()/CanteraGas_->RT();
139+
}
124140
}
125141

126142
scalar rho

0 commit comments

Comments
 (0)