22 const doublereal
T_c = 647.096;
24 static const doublereal
P_c = 22.064E6;
28 static const doublereal
M_water = 18.015268;
37 static const doublereal
Rgas = 8.314371E3;
84 if (temperature >
T_c) {
112 int phase, doublereal rhoguess)
114 doublereal deltaGuess = 0.0;
115 if (rhoguess == -1.0) {
117 if (temperature >
T_c) {
120 if (phase == WATER_GAS || phase == WATER_SUPERCRIT) {
122 }
else if (phase == WATER_LIQUID) {
128 }
else if (phase == WATER_UNSTABLELIQUID || phase == WATER_UNSTABLEGAS) {
130 "Unstable Branch finder is untested");
146 deltaGuess = rhoguess /
Rho_c;
148 doublereal delta_retn =
m_phi->
dfind(p_red,
tau, deltaGuess);
149 doublereal density_retn;
150 if (delta_retn >0.0) {
156 density_retn = delta_retn *
Rho_c;
171 int phase, doublereal rhoguess)
const
174 doublereal deltaGuess = 0.0;
175 doublereal deltaSave =
delta;
176 if (rhoguess == -1.0) {
178 if (temperature >
T_c) {
181 if (phase == WATER_GAS || phase == WATER_SUPERCRIT) {
183 }
else if (phase == WATER_LIQUID) {
189 }
else if (phase == WATER_UNSTABLELIQUID || phase == WATER_UNSTABLEGAS) {
191 "Unstable Branch finder is untested");
207 deltaGuess = rhoguess /
Rho_c;
213 doublereal delta_retn =
m_phi->
dfind(p_red,
tau, deltaGuess);
214 doublereal density_retn;
215 if (delta_retn > 0.0) {
221 density_retn = delta_retn *
Rho_c;
244 static const doublereal A[8] = {
255 if (temperature < 314.) {
256 doublereal pl = 6.3573118E0 - 8858.843E0 / temperature
257 + 607.56335E0 * pow(temperature, -0.6);
260 doublereal v = temperature / 647.25;
261 doublereal w = fabs(1.0-v);
263 for (
int i = 0; i < 8; i++) {
264 doublereal z = i + 1;
265 b += A[i] * pow(w, ((z+1.0)/2.0));
267 doublereal q = b / v;
279 doublereal dpdrho_val =
dpdrho();
281 return 1.0 / (dens * dpdrho_val);
312 corr(doublereal temperature, doublereal pressure, doublereal& densLiq,
313 doublereal& densGas, doublereal& delGRT)
316 densLiq =
density(temperature, pressure, WATER_LIQUID, densLiq);
317 if (densLiq <= 0.0) {
319 "Error occurred trying to find liquid density at (T,P) = "
325 densGas =
density(temperature, pressure, WATER_GAS, densGas);
326 if (densGas <= 0.0) {
328 "Error occurred trying to find gas density at (T,P) = "
334 delGRT = gibbsLiqRT - gibbsGasRT;
338 corr1(doublereal temperature, doublereal pressure, doublereal& densLiq,
339 doublereal& densGas, doublereal& pcorr)
342 densLiq =
density(temperature, pressure, WATER_LIQUID, densLiq);
343 if (densLiq <= 0.0) {
345 "Error occurred trying to find liquid density at (T,P) = "
351 densGas =
density(temperature, pressure, WATER_GAS, densGas);
352 if (densGas <= 0.0) {
354 "Error occurred trying to find gas density at (T,P) = "
360 doublereal rhs = (prL - prG) + log(densLiq/densGas);
361 rhs /= (1.0/densGas - 1.0/densLiq);
368 static int method = 1;
369 doublereal densLiq = -1.0, densGas = -1.0, delGRT = 0.0;
370 doublereal dp, pcorr;
371 if (temperature >=
T_c) {
372 densGas =
density(temperature,
P_c, WATER_SUPERCRIT);
376 doublereal p =
psat_est(temperature);
377 for (
int i = 0; i < 30; i++) {
379 corr(temperature, p, densLiq, densGas, delGRT);
380 doublereal delV =
M_water * (1.0/densLiq - 1.0/densGas);
381 dp = - delGRT *
Rgas * temperature / delV;
383 corr1(temperature, p, densLiq, densGas, pcorr);
388 if ((method == 1) && delGRT < 1.0E-8) {
391 if (fabs(dp/p) < 1.0E-9) {
397 if (waterState == WATER_LIQUID) {
399 }
else if (waterState == WATER_GAS) {
418 doublereal rhoMid = Rho_c + (T -
T_c) * (Rho_c - rhoMidAtm) / (
T_c - 373.15);
419 int iStateGuess = WATER_LIQUID;
421 iStateGuess = WATER_GAS;
428 doublereal rhoDel = rho * 1.000001;
431 doublereal deltaSave =
delta;
432 doublereal deltaDel = rhoDel /
Rho_c;
437 doublereal d2rhodp2 = (rhoDel * kappaDel - rho * kappa) / (rhoDel - rho);
438 if (d2rhodp2 > 0.0) {
439 iState = WATER_UNSTABLELIQUID;
441 iState = WATER_UNSTABLEGAS;
456 doublereal delta_save =
delta;
460 if (temperature >=
T_c - 0.001) {
463 doublereal p =
psat_est(temperature);
464 doublereal rho_low = 0.0;
465 doublereal rho_high = 1000;
468 doublereal dens_old = densSatLiq;
471 doublereal dpdrho_old =
dpdrho();
472 if (dpdrho_old > 0.0) {
473 rho_high = std::min(dens_old, rho_high);
475 rho_low = std::max(rho_low, dens_old);
477 doublereal dens_new = densSatLiq* (1.0001);
480 doublereal dpdrho_new =
dpdrho();
481 if (dpdrho_new > 0.0) {
482 rho_high = std::min(dens_new, rho_high);
484 rho_low = std::max(rho_low, dens_new);
488 for (
int it = 0; it < 50; it++) {
489 doublereal slope = (dpdrho_new - dpdrho_old)/(dens_new - dens_old);
491 slope = std::max(slope, dpdrho_new *5.0/ dens_new);
497 doublereal delta_rho = - dpdrho_new / slope;
498 if (delta_rho > 0.0) {
499 delta_rho = std::min(delta_rho, dens_new * 0.1);
501 delta_rho = std::max(delta_rho, - dens_new * 0.1);
503 doublereal dens_est = dens_new + delta_rho;
504 if (dens_est < rho_low) {
505 dens_est = 0.5 * (rho_low + dens_new);
507 if (dens_est > rho_high) {
508 dens_est = 0.5 * (rho_high + dens_new);
513 dpdrho_old = dpdrho_new;
519 if (dpdrho_new > 0.0) {
520 rho_high = std::min(dens_new, rho_high);
521 }
else if (dpdrho_new < 0.0) {
522 rho_low = std::max(rho_low, dens_new);
528 if (fabs(dpdrho_new) < 1.0E-5) {
536 " convergence failure");
548 doublereal delta_save =
delta;
552 if (temperature >=
T_c - 0.001) {
555 doublereal p =
psat_est(temperature);
556 doublereal rho_low = 0.0;
557 doublereal rho_high = 1000;
560 doublereal dens_old = densSatGas;
563 doublereal dpdrho_old =
dpdrho();
564 if (dpdrho_old < 0.0) {
565 rho_high = std::min(dens_old, rho_high);
567 rho_low = std::max(rho_low, dens_old);
569 doublereal dens_new = densSatGas * (0.99);
572 doublereal dpdrho_new =
dpdrho();
573 if (dpdrho_new < 0.0) {
574 rho_high = std::min(dens_new, rho_high);
576 rho_low = std::max(rho_low, dens_new);
580 for (
int it = 0; it < 50; it++) {
581 doublereal slope = (dpdrho_new - dpdrho_old)/(dens_new - dens_old);
588 slope = std::min(slope, dpdrho_new *5.0 / dens_new);
591 doublereal delta_rho = - dpdrho_new / slope;
592 if (delta_rho > 0.0) {
593 delta_rho = std::min(delta_rho, dens_new * 0.1);
595 delta_rho = std::max(delta_rho, - dens_new * 0.1);
597 doublereal dens_est = dens_new + delta_rho;
598 if (dens_est < rho_low) {
599 dens_est = 0.5 * (rho_low + dens_new);
601 if (dens_est > rho_high) {
602 dens_est = 0.5 * (rho_high + dens_new);
607 dpdrho_old = dpdrho_new;
613 if (dpdrho_new < 0.0) {
614 rho_high = std::min(dens_new, rho_high);
615 }
else if (dpdrho_new > 0.0) {
616 rho_low = std::max(rho_low, dens_new);
622 if (fabs(dpdrho_new) < 1.0E-5) {
630 " convergence failure");
doublereal densSpinodalSteam() const
Return the value of the density at the water spinodal point (on the gas side) for the current tempera...
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
doublereal isothermalCompressibility() const
Returns the coefficient of isothermal compressibility for the state of the object.
doublereal psat_est(doublereal temperature) const
This function returns an estimated value for the saturation pressure.
doublereal delta
Dimensionless density.
const doublereal OneAtm
One atmosphere [Pa].
void setState_TR(doublereal temperature, doublereal rho)
Set the internal state of the object wrt temperature and density.
doublereal cv() const
Calculate the constant volume heat capacity in mks units of J kmol-1 K-1 at the last temperature and ...
doublereal gibbs_RT() const
Calculate the dimensionless gibbs free energy.
int phaseState(bool checkState=false) const
Returns the Phase State flag for the current state of the object.
Class for calculating the equation of state of water.
doublereal density_const(doublereal pressure, int phase=-1, doublereal rhoguess=-1.0) const
Calculates the density given the temperature and the pressure, and a guess at the density...
doublereal entropy_R() const
Calculate the dimensionless entropy, s/R.
WaterPropsIAPWS()
Base constructor.
const doublereal Rho_c
Value of the Density at the critical point (kg m-3)
doublereal Gibbs() const
Calculate the Gibbs free energy in mks units of J kmol-1 K-1.
doublereal density() const
Returns the density (kg m-3)
void corr(doublereal temperature, doublereal pressure, doublereal &densLiq, doublereal &densGas, doublereal &delGRT)
Utility routine in the calculation of the saturation pressure.
doublereal coeffThermExp() const
Returns the coefficient of thermal expansion.
doublereal densSpinodalWater() const
Return the value of the density at the water spinodal point (on the liquid side) for the current temp...
static const doublereal P_c
Critical Pressure (Pascals)
WaterPropsIAPWS & operator=(const WaterPropsIAPWS &right)
assignment constructor
doublereal dfind(doublereal p_red, doublereal tau, doublereal deltaGuess)
This function computes the reduced density, given the reduced pressure and the reduced temperature...
void calcDim(doublereal temperature, doublereal rho)
Calculate the dimensionless temp and rho and store internally.
doublereal entropy() const
Calculate the entropy in mks units of J kmol-1 K-1.
doublereal pressureM_rhoRT(doublereal tau, doublereal delta)
Calculate the dimensionless pressure at tau and delta;.
int iState
Current state of the system.
doublereal dpdrho() const
Returns the value of dp / drho at constant T for the state of the object.
doublereal molarVolume() const
Calculate the molar volume (kmol m-3) at the last temperature and density.
const doublereal T_c
Critical Temperature value (kelvin)
doublereal dimdpdrho(doublereal tau, doublereal delta)
Dimensionless derivative of p wrt rho at constant T.
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
doublereal enthalpy() const
Calculate the enthalpy in mks units of J kmol-1 using the last temperature and density.
doublereal dimdpdT(doublereal tau, doublereal delta)
Dimensionless derivative of p wrt T at constant rho.
static const doublereal Rgas
Gas constant that is quoted in the paper.
void tdpolycalc(doublereal tau, doublereal delta)
Calculates internal polynomials in tau and delta.
Base class for exceptions thrown by Cantera classes.
doublereal intEnergy() const
Calculate the internal energy in mks units of J kmol-1.
doublereal tau
Dimensionless temperature.
doublereal pressure() const
Calculates the pressure (Pascals), given the current value of the temperature and density...
doublereal enthalpy_RT() const
Calculate the dimensionless enthalpy, h/RT.
Low level class for the real description of water.
void corr1(doublereal temperature, doublereal pressure, doublereal &densLiq, doublereal &densGas, doublereal &pcorr)
Utility routine in the calculation of the saturation pressure.
doublereal cp_R() const
Calculate the dimensionless constant pressure heat capacity, Cv/R.
doublereal cv_R() const
Calculate the dimensionless constant volume heat capacity, Cv/R.
static const doublereal M_water
Molecular Weight of water that is consistent with the paper (kg kmol-1)
Contains declarations for string manipulation functions within Cantera.
doublereal cp() const
Calculate the constant pressure heat capacity in mks units of J kmol-1 K-1 at the last temperature an...
~WaterPropsIAPWS()
destructor
doublereal intEnergy_RT() const
Calculate the dimensionless internal energy, u/RT.
doublereal helmholtzFE() const
Calculate the Helmholtz free energy in mks units of J kmol-1 K-1, using the last temperature and dens...
doublereal phi(doublereal tau, doublereal delta)
Calculate the Phi function, which is the base function.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
doublereal temperature() const
Returns the temperature (Kelvin)
WaterPropsIAPWSphi * m_phi
pointer to the underlying object that does the calculations.
doublereal psat(doublereal temperature, int waterState=WATER_LIQUID)
This function returns the saturation pressure given the temperature as an input parameter, and sets the internal state to the saturated conditions.
doublereal coeffPresExp() const
Returns the isochoric pressure derivative wrt temperature.
Headers for a class for calculating the equation of state of water from the IAPWS 1995 Formulation ba...