File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments