Cantera  4.0.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
87double PDSS_Water::dVdT() const
88{
90}
91
92double PDSS_Water::dVdP() const
93{
95}
96
98{
100 double h = m_sub.enthalpy_mass() * m_mw;
102 return (h + EW_Offset - SW_Offset * m_temp) / (m_temp * GasConstant);
103}
104
106{
108 double h = m_sub.enthalpy_mass() * m_mw;
110 return (h + EW_Offset) / (m_temp * GasConstant);
111}
112
114{
116 double s = m_sub.entropy_mass() * m_mw;
118 return (s + SW_Offset) / GasConstant;
119}
120
122{
124 double cp = m_sub.cp_mass() * m_mw;
126 return cp / GasConstant;
127}
128
130{
132 double mv = m_mw / m_sub.density();
134 return mv;
135}
136
138{
140 return m_pres;
141}
142
144{
145 // In this routine we must be sure to only find the water branch of the
146 // curve and not the gas branch
147 double T = m_temp;
148 double dens = m_dens;
149 int waterState = WATER_LIQUID;
150 if (T > m_sub.Tcrit()) {
151 waterState = WATER_SUPERCRIT;
152 }
153
154 double dd = m_sub.density(T, p, waterState, dens);
155 if (dd <= 0.0) {
156 throw CanteraError("PDSS_Water:setPressure",
157 "Failed to set water SS state: T = {} K and p = {} Pa", T, p);
158 }
159 m_dens = dd;
160 m_pres = p;
161
162 // We are only putting the phase check here because of speed considerations.
163 m_iState = m_sub.phaseState(true);
164 if (!m_allowGasPhase && m_iState != WATER_SUPERCRIT && m_iState != WATER_LIQUID && m_iState != WATER_UNSTABLELIQUID) {
165 throw CanteraError("PDSS_Water::setPressure",
166 "Water State isn't liquid or crit");
167 }
168}
169
171{
172 return m_sub.coeffThermExp();
173}
174
176{
177 double pres = pressure();
178 double dens_save = m_dens;
179 double tt = m_temp - 0.04;
180 double dd = m_sub.density(tt, pres, m_iState, m_dens);
181 if (dd < 0.0) {
182 throw CanteraError("PDSS_Water::dthermalExpansionCoeffdT",
183 "unable to solve for the density at T = {}, P = {}", tt, pres);
184 }
185 double vald = m_sub.coeffThermExp();
186 m_sub.setState_TD(m_temp, dens_save);
187 double val2 = m_sub.coeffThermExp();
188 return (val2 - vald) / 0.04;
189}
190
192{
194}
195
197{
198 return m_sub.Tcrit();
199}
200
202{
203 return m_sub.Pcrit();
204}
205
207{
208 return m_sub.Rhocrit();
209}
210
211void PDSS_Water::setDensity(double dens)
212{
213 m_dens = dens;
215}
216
218{
219 return m_dens;
220}
221
223{
224 m_temp = temp;
225 m_sub.setState_TD(temp, m_dens);
226}
227
228void PDSS_Water::setState_TP(double temp, double pres)
229{
230 m_temp = temp;
231 setPressure(pres);
232}
233
234double PDSS_Water::pref_safe(double temp) const
235{
236 if (temp < m_sub.Tcrit()) {
237 double pp = m_sub.psat_est(temp);
238 if (pp > OneAtm) {
239 return pp;
240 }
241 } else {
242 return m_sub.Pcrit();
243 }
244 return OneAtm;
245}
246
248{
249 double pp = m_sub.psat(t, WATER_LIQUID);
250 m_dens = m_sub.density();
251 m_temp = t;
252 return pp;
253}
254
256{
257 eosNode["model"] = "liquid-water-IAPWS95";
258}
259
260}
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:431
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:162
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:205
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 dVdP() const override
Return the pressure derivative of the standard state molar volume at constant temperature [m³/kmol/Pa...
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:198
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:191
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:179
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:214
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 dVdT() const override
Return the temperature derivative of the standard state molar volume at constant pressure [m³/kmol/K]...
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:418
double m_temp
Current temperature used by the PDSS object.
Definition PDSS.h:412
double m_pres
State of the system - pressure.
Definition PDSS.h:415
double m_maxTemp
Maximum temperature.
Definition PDSS.h:424
double m_minTemp
Minimum temperature.
Definition PDSS.h:421
double m_mw
Molecular Weight of the species.
Definition PDSS.h:427
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:99
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:123
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
double getElementWeight(const string &ename)
Get the atomic weight of an element.
Definition Elements.cpp:251
Contains declarations for string manipulation functions within Cantera.