21const double T_c = 647.096;
23static const double P_c = 22.064E6;
29static const double R_water = 461.51805;
38static const double Rgas = 8.314371E3;
59 warn_deprecated(
"WaterPropsIAPWS::helmholtzFE",
"To be removed after Cantera 3.0. "
60 "This class provides mass-based values only.");
76 int phase,
double rhoguess)
84 double deltaGuess = 0.0;
85 if (rhoguess == -1.0) {
90 if (phase == WATER_GAS || phase == WATER_SUPERCRIT) {
92 }
else if (phase == WATER_LIQUID) {
96 }
else if (phase == WATER_UNSTABLELIQUID || phase == WATER_UNSTABLEGAS) {
98 "Unstable Branch finder is untested");
101 "unknown state: {}", phase);
111 deltaGuess = rhoguess /
Rho_c;
114 if (delta_retn <= 0) {
120 if (delta_retn > 0.0) {
124 density_retn = delta_retn *
Rho_c;
138 double deltaGuess = 0.0;
139 double deltaSave =
delta;
140 if (rhoguess == -1.0) {
145 if (phase == WATER_GAS || phase == WATER_SUPERCRIT) {
147 }
else if (phase == WATER_LIQUID) {
151 }
else if (phase == WATER_UNSTABLELIQUID || phase == WATER_UNSTABLEGAS) {
153 "Unstable Branch finder is untested");
156 "unknown state: {}", phase);
166 deltaGuess = rhoguess /
Rho_c;
173 if (delta_retn > 0.0) {
177 density_retn = delta_retn *
Rho_c;
204 static const double A[8] = {
221 double w = fabs(1.0-v);
223 for (
int i = 0; i < 8; i++) {
225 b += A[i] * pow(w, ((z+1.0)/2.0));
238 double dpdrho_val =
dpdrho();
240 return 1.0 / (dens * dpdrho_val);
260 return kappa * dens * R_water * beta;
265 warn_deprecated(
"WaterPropsIAPWS::Gibbs",
"To be removed after Cantera 3.0. "
266 "This class provides mass-based values only.");
273 double& densLiq,
double& densGas,
double& delGRT)
276 if (densLiq <= 0.0) {
278 "Error occurred trying to find liquid density at (T,P) = {} {}",
285 if (densGas <= 0.0) {
287 "Error occurred trying to find gas density at (T,P) = {} {}",
293 delGRT = gibbsLiqRT - gibbsGasRT;
297 double& densLiq,
double& densGas,
double& pcorr)
300 if (densLiq <= 0.0) {
302 "Error occurred trying to find liquid density at (T,P) = {} {}",
309 if (densGas <= 0.0) {
311 "Error occurred trying to find gas density at (T,P) = {} {}",
316 double rhs = (prL - prG) + log(densLiq/densGas);
317 rhs /= (1.0/densGas - 1.0/densLiq);
323 static int method = 1;
324 double densLiq = -1.0, densGas = -1.0, delGRT = 0.0;
332 for (
int i = 0; i < 30; i++) {
335 double delV = 1.0/densLiq - 1.0/densGas;
343 if ((method == 1) && delGRT < 1.0E-8) {
346 if (fabs(dp/p) < 1.0E-9) {
352 if (waterState == WATER_LIQUID) {
354 }
else if (waterState == WATER_GAS) {
358 "unknown water state input: {}", waterState);
371 double rhoMidAtm = 0.5 * (
OneAtm / (R_water * 373.15) + 1.0E3);
373 int iStateGuess = WATER_LIQUID;
375 iStateGuess = WATER_GAS;
382 double rhoDel = rho * 1.000001;
383 double deltaSave =
delta;
384 double deltaDel = rhoDel /
Rho_c;
389 double d2rhodp2 = (rhoDel * kappaDel - rho * kappa) / (rhoDel - rho);
390 if (d2rhodp2 > 0.0) {
391 iState = WATER_UNSTABLELIQUID;
393 iState = WATER_UNSTABLEGAS;
406 double delta_save =
delta;
414 double rho_low = 0.0;
415 double rho_high = 1000;
417 double dens_old = densSatLiq;
420 double dpdrho_old =
dpdrho();
421 if (dpdrho_old > 0.0) {
422 rho_high = std::min(dens_old, rho_high);
424 rho_low = std::max(rho_low, dens_old);
426 double dens_new = densSatLiq* (1.0001);
429 double dpdrho_new =
dpdrho();
430 if (dpdrho_new > 0.0) {
431 rho_high = std::min(dens_new, rho_high);
433 rho_low = std::max(rho_low, dens_new);
437 for (
int it = 0; it < 50; it++) {
438 double slope = (dpdrho_new - dpdrho_old)/(dens_new - dens_old);
440 slope = std::max(slope, dpdrho_new *5.0/ dens_new);
445 double delta_rho = - dpdrho_new / slope;
446 if (delta_rho > 0.0) {
447 delta_rho = std::min(delta_rho, dens_new * 0.1);
449 delta_rho = std::max(delta_rho, - dens_new * 0.1);
451 double dens_est = dens_new + delta_rho;
452 if (dens_est < rho_low) {
453 dens_est = 0.5 * (rho_low + dens_new);
455 if (dens_est > rho_high) {
456 dens_est = 0.5 * (rho_high + dens_new);
460 dpdrho_old = dpdrho_new;
466 if (dpdrho_new > 0.0) {
467 rho_high = std::min(dens_new, rho_high);
468 }
else if (dpdrho_new < 0.0) {
469 rho_low = std::max(rho_low, dens_new);
475 if (fabs(dpdrho_new) < 1.0E-5) {
482 throw CanteraError(
"WaterPropsIAPWS::densSpinodalWater",
483 "convergence failure");
494 double delta_save =
delta;
502 double rho_low = 0.0;
503 double rho_high = 1000;
505 double dens_old = densSatGas;
508 double dpdrho_old =
dpdrho();
509 if (dpdrho_old < 0.0) {
510 rho_high = std::min(dens_old, rho_high);
512 rho_low = std::max(rho_low, dens_old);
514 double dens_new = densSatGas * (0.99);
517 double dpdrho_new =
dpdrho();
518 if (dpdrho_new < 0.0) {
519 rho_high = std::min(dens_new, rho_high);
521 rho_low = std::max(rho_low, dens_new);
524 for (
int it = 0; it < 50; it++) {
525 double slope = (dpdrho_new - dpdrho_old)/(dens_new - dens_old);
530 slope = std::min(slope, dpdrho_new *5.0 / dens_new);
533 double delta_rho = - dpdrho_new / slope;
534 if (delta_rho > 0.0) {
535 delta_rho = std::min(delta_rho, dens_new * 0.1);
537 delta_rho = std::max(delta_rho, - dens_new * 0.1);
539 double dens_est = dens_new + delta_rho;
540 if (dens_est < rho_low) {
541 dens_est = 0.5 * (rho_low + dens_new);
543 if (dens_est > rho_high) {
544 dens_est = 0.5 * (rho_high + dens_new);
548 dpdrho_old = dpdrho_new;
553 if (dpdrho_new < 0.0) {
554 rho_high = std::min(dens_new, rho_high);
555 }
else if (dpdrho_new > 0.0) {
556 rho_low = std::max(rho_low, dens_new);
562 if (fabs(dpdrho_new) < 1.0E-5) {
569 throw CanteraError(
"WaterPropsIAPWS::densSpinodalSteam",
570 "convergence failure");
581 "To be removed after Cantera 3.0. Renamed to setState_TD.");
623 warn_deprecated(
"WaterPropsIAPWS::enthalpy",
"To be removed after Cantera 3.0. "
624 "This class provides mass-based values only.");
632 warn_deprecated(
"WaterPropsIAPWS::intEnergy",
"To be removed after Cantera 3.0. "
633 "This class provides mass-based values only.");
641 warn_deprecated(
"WaterPropsIAPWS::entropy",
"To be removed after Cantera 3.0. "
642 "This class provides mass-based values only.");
649 warn_deprecated(
"WaterPropsIAPWS::cv",
"To be removed after Cantera 3.0. "
650 "This class provides mass-based values only.");
657 warn_deprecated(
"WaterPropsIAPWS::cp",
"To be removed after Cantera 3.0. "
658 "This class provides mass-based values only.");
665 warn_deprecated(
"WaterPropsIAPWS::molarVolume",
"To be removed after Cantera 3.0. "
666 "This class provides mass-based values only.");
Headers for a class for calculating the equation of state of water from the IAPWS 1995 Formulation ba...
Base class for exceptions thrown by Cantera classes.
double cv() const
Calculate the constant volume heat capacity in mks units of J kmol-1 K-1 at the last temperature and ...
double coeffThermExp() const
Returns the coefficient of thermal expansion.
void setState_TR(double temperature, double rho)
Set the internal state of the object wrt temperature and density.
double densSpinodalSteam() const
Return the value of the density at the water spinodal point (on the gas side) for the current tempera...
double density() const
Returns the density (kg m-3)
void corr(double temperature, double pressure, double &densLiq, double &densGas, double &delGRT)
Utility routine in the calculation of the saturation pressure.
double enthalpy() const
Calculate the enthalpy in mks units of J kmol-1 using the last temperature and density.
double pressure() const
Calculates the pressure (Pascals), given the current value of the temperature and density.
void corr1(double temperature, double pressure, double &densLiq, double &densGas, double &pcorr)
Utility routine in the calculation of the saturation pressure.
double helmholtzFE() const
Calculate the Helmholtz free energy in mks units of J kmol-1 K-1, using the last temperature and dens...
double gibbs_mass() const
Get the Gibbs free energy (J/kg) at the current temperature and density.
double isothermalCompressibility() const
Returns the coefficient of isothermal compressibility for the state of the object.
double psat(double temperature, int waterState=WATER_LIQUID)
This function returns the saturation pressure given the temperature as an input parameter,...
double entropy() const
Calculate the entropy in mks units of J kmol-1 K-1.
double temperature() const
Returns the temperature (Kelvin)
double cv_mass() const
Get the constant volume heat capacity (J/kg/K) at the current temperature and density.
double entropy_mass() const
Get the entropy (J/kg/K) at the current temperature and density.
double Gibbs() const
Calculate the Gibbs free energy in mks units of J kmol-1 K-1.
double densSpinodalWater() const
Return the value of the density at the water spinodal point (on the liquid side) for the current temp...
double delta
Dimensionless density, delta = rho / rho_c.
double cp_mass() const
Get the constant pressure heat capacity (J/kg/K) at the current temperature and density.
double intEnergy_mass() const
Get the internal energy (J/kg) at the current temperature and density.
double coeffPresExp() const
Returns the isochoric pressure derivative wrt temperature.
int iState
Current state of the system.
double cp() const
Calculate the constant pressure heat capacity in mks units of J kmol-1 K-1 at the last temperature an...
void setState_TD(double temperature, double rho)
Set the internal state of the object wrt temperature and density.
double molarVolume() const
Calculate the molar volume (kmol m-3) at the last temperature and density.
double tau
Dimensionless temperature, tau = T_C / T.
WaterPropsIAPWSphi m_phi
pointer to the underlying object that does the calculations.
double intEnergy() const
Calculate the internal energy in mks units of J kmol-1.
double density_const(double pressure, int phase=-1, double rhoguess=-1.0) const
Calculates the density given the temperature and the pressure, and a guess at the density,...
void calcDim(double temperature, double rho)
Calculate the dimensionless temp and rho and store internally.
int phaseState(bool checkState=false) const
Returns the Phase State flag for the current state of the object.
double dpdrho() const
Returns the value of dp / drho at constant T for the state of the object.
double psat_est(double temperature) const
This function returns an estimated value for the saturation pressure.
double enthalpy_mass() const
Get the enthalpy (J/kg) at the current temperature and density.
double gibbs_RT() const
Calculate the dimensionless Gibbs free energy.
double cv_R() const
Calculate the dimensionless constant volume heat capacity, Cv/R.
double intEnergy_RT() const
Calculate the dimensionless internal energy, u/RT.
double enthalpy_RT() const
Calculate the dimensionless enthalpy, h/RT.
double phi(double tau, double delta)
Calculate the Phi function, which is the base function.
double entropy_R() const
Calculate the dimensionless entropy, s/R.
double phiR() const
Calculate Equation 6.6 for phiR, the residual part of the dimensionless Helmholtz free energy.
double pressureM_rhoRT(double tau, double delta)
Calculate the dimensionless pressure at tau and delta;.
double dimdpdrho(double tau, double delta)
Dimensionless derivative of p wrt rho at constant T.
double dfind(double p_red, double tau, double deltaGuess)
This function computes the reduced density, given the reduced pressure and the reduced temperature,...
double dimdpdT(double tau, double delta)
Dimensionless derivative of p wrt T at constant rho.
double cp_R() const
Calculate the dimensionless constant pressure heat capacity, Cv/R.
void tdpolycalc(double tau, double delta)
Calculates internal polynomials in tau and delta.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
const double OneAtm
One atmosphere [Pa].
Namespace for the Cantera kernel.
const double Rho_c
Value of the Density at the critical point (kg m-3)
const double T_c
Critical Temperature value (kelvin)
static const double P_c
Critical Pressure (Pascals)
static const double M_water
Molecular Weight of water that is consistent with the paper (kg kmol-1)
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
static const double Rgas
Gas constant that is quoted in the paper.
Contains declarations for string manipulation functions within Cantera.