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 doublereal& densLiq, doublereal& densGas, doublereal& delGRT)
315 densLiq =
density(temperature, pressure, WATER_LIQUID, densLiq);
316 if (densLiq <= 0.0) {
318 "Error occurred trying to find liquid density at (T,P) = "
324 densGas =
density(temperature, pressure, WATER_GAS, densGas);
325 if (densGas <= 0.0) {
327 "Error occurred trying to find gas density at (T,P) = "
333 delGRT = gibbsLiqRT - gibbsGasRT;
337 doublereal& densLiq, doublereal& densGas, doublereal& pcorr)
340 densLiq =
density(temperature, pressure, WATER_LIQUID, densLiq);
341 if (densLiq <= 0.0) {
343 "Error occurred trying to find liquid density at (T,P) = "
349 densGas =
density(temperature, pressure, WATER_GAS, densGas);
350 if (densGas <= 0.0) {
352 "Error occurred trying to find gas density at (T,P) = "
358 doublereal rhs = (prL - prG) + log(densLiq/densGas);
359 rhs /= (1.0/densGas - 1.0/densLiq);
366 static int method = 1;
367 doublereal densLiq = -1.0, densGas = -1.0, delGRT = 0.0;
368 doublereal dp, pcorr;
369 if (temperature >=
T_c) {
370 densGas =
density(temperature,
P_c, WATER_SUPERCRIT);
374 doublereal p =
psat_est(temperature);
375 for (
int i = 0; i < 30; i++) {
377 corr(temperature, p, densLiq, densGas, delGRT);
378 doublereal delV =
M_water * (1.0/densLiq - 1.0/densGas);
379 dp = - delGRT *
Rgas * temperature / delV;
381 corr1(temperature, p, densLiq, densGas, pcorr);
386 if ((method == 1) && delGRT < 1.0E-8) {
389 if (fabs(dp/p) < 1.0E-9) {
395 if (waterState == WATER_LIQUID) {
397 }
else if (waterState == WATER_GAS) {
415 doublereal rhoMid = Rho_c + (T -
T_c) * (Rho_c - rhoMidAtm) / (
T_c - 373.15);
416 int iStateGuess = WATER_LIQUID;
418 iStateGuess = WATER_GAS;
425 doublereal rhoDel = rho * 1.000001;
426 doublereal deltaSave =
delta;
427 doublereal deltaDel = rhoDel /
Rho_c;
432 doublereal d2rhodp2 = (rhoDel * kappaDel - rho * kappa) / (rhoDel - rho);
433 if (d2rhodp2 > 0.0) {
434 iState = WATER_UNSTABLELIQUID;
436 iState = WATER_UNSTABLEGAS;
450 doublereal delta_save =
delta;
454 if (temperature >=
T_c - 0.001) {
457 doublereal p =
psat_est(temperature);
458 doublereal rho_low = 0.0;
459 doublereal rho_high = 1000;
462 doublereal dens_old = densSatLiq;
465 doublereal dpdrho_old =
dpdrho();
466 if (dpdrho_old > 0.0) {
467 rho_high = std::min(dens_old, rho_high);
469 rho_low = std::max(rho_low, dens_old);
471 doublereal dens_new = densSatLiq* (1.0001);
474 doublereal dpdrho_new =
dpdrho();
475 if (dpdrho_new > 0.0) {
476 rho_high = std::min(dens_new, rho_high);
478 rho_low = std::max(rho_low, dens_new);
482 for (
int it = 0; it < 50; it++) {
483 doublereal slope = (dpdrho_new - dpdrho_old)/(dens_new - dens_old);
485 slope = std::max(slope, dpdrho_new *5.0/ dens_new);
490 doublereal delta_rho = - dpdrho_new / slope;
491 if (delta_rho > 0.0) {
492 delta_rho = std::min(delta_rho, dens_new * 0.1);
494 delta_rho = std::max(delta_rho, - dens_new * 0.1);
496 doublereal dens_est = dens_new + delta_rho;
497 if (dens_est < rho_low) {
498 dens_est = 0.5 * (rho_low + dens_new);
500 if (dens_est > rho_high) {
501 dens_est = 0.5 * (rho_high + dens_new);
506 dpdrho_old = dpdrho_new;
512 if (dpdrho_new > 0.0) {
513 rho_high = std::min(dens_new, rho_high);
514 }
else if (dpdrho_new < 0.0) {
515 rho_low = std::max(rho_low, dens_new);
521 if (fabs(dpdrho_new) < 1.0E-5) {
529 " convergence failure");
541 doublereal delta_save =
delta;
545 if (temperature >=
T_c - 0.001) {
548 doublereal p =
psat_est(temperature);
549 doublereal rho_low = 0.0;
550 doublereal rho_high = 1000;
553 doublereal dens_old = densSatGas;
556 doublereal dpdrho_old =
dpdrho();
557 if (dpdrho_old < 0.0) {
558 rho_high = std::min(dens_old, rho_high);
560 rho_low = std::max(rho_low, dens_old);
562 doublereal dens_new = densSatGas * (0.99);
565 doublereal dpdrho_new =
dpdrho();
566 if (dpdrho_new < 0.0) {
567 rho_high = std::min(dens_new, rho_high);
569 rho_low = std::max(rho_low, dens_new);
573 for (
int it = 0; it < 50; it++) {
574 doublereal slope = (dpdrho_new - dpdrho_old)/(dens_new - dens_old);
579 slope = std::min(slope, dpdrho_new *5.0 / dens_new);
582 doublereal delta_rho = - dpdrho_new / slope;
583 if (delta_rho > 0.0) {
584 delta_rho = std::min(delta_rho, dens_new * 0.1);
586 delta_rho = std::max(delta_rho, - dens_new * 0.1);
588 doublereal dens_est = dens_new + delta_rho;
589 if (dens_est < rho_low) {
590 dens_est = 0.5 * (rho_low + dens_new);
592 if (dens_est > rho_high) {
593 dens_est = 0.5 * (rho_high + dens_new);
598 dpdrho_old = dpdrho_new;
604 if (dpdrho_new < 0.0) {
605 rho_high = std::min(dens_new, rho_high);
606 }
else if (dpdrho_new > 0.0) {
607 rho_low = std::max(rho_low, dens_new);
613 if (fabs(dpdrho_new) < 1.0E-5) {
621 " 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...