Cantera  3.1.0a1
Loading...
Searching...
No Matches
PDSS_Water.cpp
Go to the documentation of this file.
1/**
2 * @file PDSS_Water.cpp
3 */
4
5// This file is part of Cantera. See License.txt in the top-level directory or
6// at https://cantera.org/license.txt for license and copyright information.
7
12#include "cantera/base/global.h"
13
14namespace Cantera
15{
17 m_waterProps(&m_sub)
18{
19 m_minTemp = 200.;
20 m_maxTemp = 10000.;
22
23 // Set the baseline
24 double T = 298.15;
25 m_p0 = OneAtm;
26 double presLow = 1.0E-2;
27 double oneBar = 1.0E5;
28 double dens = 1.0E-9;
29 m_dens = m_sub.density(T, presLow, WATER_GAS, dens);
30 m_pres = presLow;
31 SW_Offset = 0.0;
32 double s = entropy_mole();
33 s -= GasConstant * log(oneBar/presLow);
34 if (s != 188.835E3) {
35 SW_Offset = 188.835E3 - s;
36 }
37 s = entropy_mole();
38 s -= GasConstant * log(oneBar/presLow);
39
40 double h = enthalpy_mole();
41 if (h != -241.826E6) {
42 EW_Offset = -241.826E6 - h;
43 }
44 h = enthalpy_mole();
45
46 // Set the initial state of the system to 298.15 K and 1 bar.
47 setTemperature(298.15);
48 m_dens = m_sub.density(298.15, OneAtm, WATER_LIQUID);
49 m_pres = OneAtm;
50}
51
53{
54 return m_sub.enthalpy_mass() * m_mw + EW_Offset;
55}
56
58{
60}
61
63{
64 return m_sub.entropy_mass() * m_mw + SW_Offset;
65}
66
68{
70}
71
72double PDSS_Water::cp_mole() const
73{
74 return m_sub.cp_mass() * m_mw;
75}
76
77double PDSS_Water::cv_mole() const
78{
79 return m_sub.cv_mass() * m_mw;
80}
81
83{
84 return m_mw / m_sub.density();
85}
86
88{
90 double h = m_sub.enthalpy_mass() * m_mw;
92 return (h + EW_Offset - SW_Offset * m_temp) / (m_temp * GasConstant);
93}
94
96{
98 double h = m_sub.enthalpy_mass() * m_mw;
100 return (h + EW_Offset) / (m_temp * GasConstant);
101}
102
104{
106 double s = m_sub.entropy_mass() * m_mw;
108 return (s + SW_Offset) / GasConstant;
109}
110
112{
114 double cp = m_sub.cp_mass() * m_mw;
116 return cp / GasConstant;
117}
118
120{
122 double mv = m_mw / m_sub.density();
124 return mv;
125}
126
128{
130 return m_pres;
131}
132
134{
135 // In this routine we must be sure to only find the water branch of the
136 // curve and not the gas branch
137 double T = m_temp;
138 double dens = m_dens;
139 int waterState = WATER_LIQUID;
140 if (T > m_sub.Tcrit()) {
141 waterState = WATER_SUPERCRIT;
142 }
143
144 double dd = m_sub.density(T, p, waterState, dens);
145 if (dd <= 0.0) {
146 throw CanteraError("PDSS_Water:setPressure",
147 "Failed to set water SS state: T = {} K and p = {} Pa", T, p);
148 }
149 m_dens = dd;
150 m_pres = p;
151
152 // We are only putting the phase check here because of speed considerations.
153 m_iState = m_sub.phaseState(true);
154 if (!m_allowGasPhase && m_iState != WATER_SUPERCRIT && m_iState != WATER_LIQUID && m_iState != WATER_UNSTABLELIQUID) {
155 throw CanteraError("PDSS_Water::setPressure",
156 "Water State isn't liquid or crit");
157 }
158}
159
161{
162 return m_sub.coeffThermExp();
163}
164
166{
167 double pres = pressure();
168 double dens_save = m_dens;
169 double tt = m_temp - 0.04;
170 double dd = m_sub.density(tt, pres, m_iState, m_dens);
171 if (dd < 0.0) {
172 throw CanteraError("PDSS_Water::dthermalExpansionCoeffdT",
173 "unable to solve for the density at T = {}, P = {}", tt, pres);
174 }
175 double vald = m_sub.coeffThermExp();
176 m_sub.setState_TD(m_temp, dens_save);
177 double val2 = m_sub.coeffThermExp();
178 return (val2 - vald) / 0.04;
179}
180
182{
184}
185
187{
188 return m_sub.Tcrit();
189}
190
192{
193 return m_sub.Pcrit();
194}
195
197{
198 return m_sub.Rhocrit();
199}
200
201void PDSS_Water::setDensity(double dens)
202{
203 m_dens = dens;
205}
206
208{
209 return m_dens;
210}
211
213{
214 m_temp = temp;
215 m_sub.setState_TD(temp, m_dens);
216}
217
218void PDSS_Water::setState_TP(double temp, double pres)
219{
220 m_temp = temp;
221 setPressure(pres);
222}
223
224double PDSS_Water::pref_safe(double temp) const
225{
226 if (temp < m_sub.Tcrit()) {
227 double pp = m_sub.psat_est(temp);
228 if (pp > OneAtm) {
229 return pp;
230 }
231 } else {
232 return m_sub.Pcrit();
233 }
234 return OneAtm;
235}
236
238{
239 double pp = m_sub.psat(t, WATER_LIQUID);
240 m_dens = m_sub.density();
241 m_temp = t;
242 return pp;
243}
244
246{
247 eosNode["model"] = "liquid-water-IAPWS95";
248}
249
250}
Contains the getElementWeight function and the definitions of element constraint types.
Implementation of a pressure dependent standard state virtual function for a Pure Water Phase (see Sp...
Headers for a class for calculating the equation of state of water from the IAPWS 1995 Formulation ba...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Base class for exceptions thrown by Cantera classes.
void setPressure(double pres) override
Sets the pressure in the object.
double molarVolume() const override
Return the molar volume at standard state.
void setTemperature(double temp) override
Set the internal temperature.
double enthalpy_mole() const override
Return the molar enthalpy in units of J kmol-1.
double thermalExpansionCoeff() const override
Return the volumetric thermal expansion coefficient. Units: 1/K.
WaterPropsIAPWS m_sub
Pointer to the WaterPropsIAPWS object, which does the actual calculations for the real equation of st...
Definition PDSS_Water.h:160
double pressure() const override
Returns the pressure (Pa)
double critPressure() const override
critical pressure
double SW_Offset
Offset constant used to obtain consistency with NIST convention.
Definition PDSS_Water.h:203
double critDensity() const override
critical density
double gibbs_RT_ref() const override
Return the molar Gibbs free energy divided by RT at reference pressure.
double critTemperature() const override
critical temperature
double isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
double entropy_R_ref() const override
Return the molar entropy divided by R at reference pressure.
double dthermalExpansionCoeffdT() const
Return the derivative of the volumetric thermal expansion coefficient.
double enthalpy_RT_ref() const override
Return the molar enthalpy divided by RT at reference pressure.
double cv_mole() const override
Return the molar const volume heat capacity in units of J kmol-1 K-1.
void getParameters(AnyMap &eosNode) const override
Store the parameters needed to reconstruct a copy of this PDSS object.
double EW_Offset
Offset constants used to obtain consistency with the NIST database.
Definition PDSS_Water.h:196
double intEnergy_mole() const override
Return the molar internal Energy in units of J kmol-1.
double entropy_mole() const override
Return the molar entropy in units of J kmol-1 K-1.
void setState_TP(double temp, double pres) override
Set the internal temperature and pressure.
int m_iState
state of the fluid
Definition PDSS_Water.h:189
double cp_mole() const override
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
double m_dens
State of the system - density.
Definition PDSS_Water.h:177
double pref_safe(double temp) const
Returns a reference pressure value that can be safely calculated by the underlying real equation of s...
double density() const override
Return the standard state density at standard state.
double gibbs_mole() const override
Return the molar Gibbs free energy in units of J kmol-1.
bool m_allowGasPhase
Since this phase represents a liquid phase, it's an error to return a gas-phase answer.
Definition PDSS_Water.h:212
double molarVolume_ref() const override
Return the molar volume at reference pressure.
void setDensity(double dens)
Set the density of the water phase.
PDSS_Water()
Default constructor.
double satPressure(double t) override
saturation pressure
double cp_R_ref() const override
Return the molar heat capacity divided by R at reference pressure.
double m_p0
Reference state pressure of the species.
Definition PDSS.h:404
double m_temp
Current temperature used by the PDSS object.
Definition PDSS.h:398
double m_pres
State of the system - pressure.
Definition PDSS.h:401
double m_maxTemp
Maximum temperature.
Definition PDSS.h:410
double m_minTemp
Minimum temperature.
Definition PDSS.h:407
double m_mw
Molecular Weight of the species.
Definition PDSS.h:413
double coeffThermExp() const
Returns the coefficient of thermal expansion.
double density(double temperature, double pressure, int phase=-1, double rhoguess=-1.0)
Calculates the density given the temperature and the pressure, and a guess at the density.
double pressure() const
Calculates the pressure (Pascals), given the current value of the temperature and density.
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 Pcrit() const
Returns the critical pressure of water (22.064E6 Pa)
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 Rhocrit() const
Return the critical density of water (kg m-3)
double Tcrit() const
Returns the critical temperature of water (Kelvin)
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.
void setState_TD(double temperature, double rho)
Set the internal state of the object wrt temperature and density.
int phaseState(bool checkState=false) const
Returns the Phase State flag for the current 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.
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
const double OneAtm
One atmosphere [Pa].
Definition ct_defs.h:96
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:120
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
double getElementWeight(const string &ename)
Get the atomic weight of an element.
Definition Elements.cpp:251
Contains declarations for string manipulation functions within Cantera.