Cantera 2.6.0

Water.cpp
Go to the documentation of this file.
1//! @file Water.cpp
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#include "Water.h"
7#include "cantera/base/stringUtils.h"
8
9 using namespace Cantera;
10
11 namespace tpx
12{
13 static const double Tmn=273.16;
14 static const double Tmx=1600.0;
15 static const double M=18.016;
16 static const double Tc=647.286;
17 static const double Pc=22.089e6;
18 static const double Roc=317.0;
19 static const double To=273.16;
20 static const double R=461.51;
21 static const double E=4.8E-3;
22 static const double Ta=1000.0;
23 static const double tauc=1.544912;
24 static const double Tp=338.15;
25 static const double aww=0.01;
26 static const double Roa1=634.0;
27 static const double Roaj=1000.0;
28 static const double u0=2375470.875;
29 static const double s0=6697.356635;
30
31 static const double A[10][7]= {{
32 2.9492937E-2,-5.1985860E-3,
33 6.8335354E-3,-1.5641040E-4,
34 -6.3972405E-3, -3.9661401E-3, -6.9048554E-4
35 },
36 {
37 -1.3213917E-4,7.7779182E-6, -2.6149751E-5,-7.2546108E-7,
38 2.6409282E-5, 1.5453061E-5,2.7407416E-6
39 },
40 {
41 2.7464632E-7,-3.3301902E-8,6.5326396E-8,-9.2734289E-9,
42 -4.7740374E-8,-2.9142470E-8,-5.1028070E-9
43 },
44 {
45 -3.6093828E-10, -1.6254622E-11, -2.6181978E-11, 4.3125840E-12,
46 5.6323130E-11, 2.9568796E-11,3.9636085E-12
47 },
48 {3.4218431E-13, -1.7731074E-13,0,0,0,0,0},
49 {-2.4450042E-16, 1.2748742E-16,0,0,0,0,0},
50 {1.5518535E-19, 1.3746153E-19,0,0,0,0,0},
51 {5.9728487E-24,1.5597836E-22, 0,0,0,0,0},
52 {
53 -4.1030848E-1, 3.3731180E-1, -1.3746678E-1, 6.7874983E-3,
54 1.3687317E-1, 7.984797E-2, 1.3041253E-2
55 },
56 {
57 -4.1605860E-4, -2.0988866E-4,-7.3396848E-4,1.0401717E-5,
58 6.4581880E-4, 3.9917570E-4, 7.1531353E-5
59 }
60};
61
62 static const double F[]= {-7.4192420, 2.9721E-1,-1.155286E-1,8.685635E-3,
63 1.0940980E-3, -4.39993E-3, 2.5206580E-3, -5.2186840E-4
64 };
65
66 static const double D[]= {3.6711257,-2.8512396E1,2.2265240E2,-8.8243852E2,
67 2.0002765E3,-2.6122557E3,1.8297674E3,-5.3350520E2
68 };
69
70 static const double G[]= {4.6E4,1.011249E3,8.3893E-1,-2.19989E-4,2.466619E-7,
71 -9.704700E-11
72 };
73
74 static const double taua[] = {1.544912, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5};
75
76 double water::C(int i)
77{
78 double tau = Ta/T;
79 return (i == 0 ? R*T : R*T*(tau - tauc)*pow(tau - taua[i],i-1));
80}
81
82 double water::Cprime(int i)
83{
84 double tau = Ta/T;
85 return (i == 0 ? R : (i == 1 ? -R*tauc :
86 -R*pow(tau - taua[i],i-2)*(tauc*(tau - taua[i])
87 + (i-1)*tau*(tau - tauc))));
88}
89
90 double water::I(int j)
91{
92 double factor, sum, rho_aj;
93 rho_aj = (j == 0 ? Roa1 : Roaj);
94 sum = 0.0;
95 factor = Rho - rho_aj;
96 for (int i=7; i>0; i--) {
97 sum += A[i][j];
98 sum *= factor;
99 }
100 sum += A[0][j];
101 sum += (exp(-E*Rho)*(A[8][j] + A[9][j]*Rho));
102 return Rho*sum;
103}
104
105 double water::H(int j)
106{
107 double factor, sum, rho_aj;
108 rho_aj = (j == 0 ? Roa1 : Roaj);
109 sum = 0.0;
110 factor = Rho - rho_aj;
111 for (int i=6; i>0; i--) {
112 sum += (A[i][j] + Rho*(i+1)*A[i+1][j]);
113 sum *= factor;
114 }
115 sum += (A[0][j] + Rho*A[1][j]);
116 sum += (exp(-E*Rho)*((1.0 - Rho*E)*A[8][j]
117 + Rho*(2.0 - Rho*E)*A[9][j]));
118 sum += A[7][j]*pow(factor,7);
119 return Rho*Rho*sum;
120}
121
122 double water::up()
123{
124 double sum = 0.0;
125 int i;
126 for (i=0; i<7; i++) {
127 sum += (C(i) - T*Cprime(i))*I(i);
128 }
129 for (i=1; i<6; i++) {
130 sum += G[i]*(pow(T,i) - pow(To,i))/double(i);
131 }
132 sum += G[0]*log(T/To) + u0;
133 return sum + m_energy_offset;
134}
135
136 double water::sp()
137{
138 double sum = 0.0;
139 int i;
140 for (i=2; i<6; i++) {
141 sum += G[i]*(pow(T,i-1) - pow(To,i-1))/double(i-1);
142 }
143 sum += G[1]*log(T/To);
144 sum -= G[0]*(1.0/T - 1.0/To);
145 sum += s0 - R*log(Rho);
146 for (i=0; i<7; i++) {
147 sum -= Cprime(i)*I(i);
148 }
149 return sum + m_entropy_offset;
150}
151
152 double water::Pp()
153{
154 double P = Rho*R*T;
155 for (int i=0; i<7; i++) {
156 P += C(i)*H(i);
157 }
158 return P;
159}
160
161 double water::Psat()
162{
163 double log, sum=0;
164 if ((T < Tmn) || (T > Tc)) {
165 throw CanteraError("water::Psat",
166 "Temperature out of range. T = {}", T);
167 }
168 for (int i=1; i<=8; i++) {
169 sum += F[i-1]*pow(aww*(T-Tp),double(i-1)); // DGG mod
170 }
171 log = (Tc/T-1)*sum;
172 return exp(log)*Pc;
173}
174
175 double water::ldens()
176{
177 double sum=0;
178 int i;
179 if ((T < Tmn) || (T > Tc)) {
180 throw CanteraError("water::ldens",
181 "Temperature out of range. T = {}", T);
182 }
183 for (i=0; i<8; i++) {
184 sum+=D[i]*pow(1.0 - T/Tc, double(i+1)/3.0);
185 }
186 return Roc*(1+sum);
187}
188
189 double water::Tcrit()
190{
191 return Tc;
192}
193 double water::Pcrit()
194{
195 return Pc;
196}
197 double water::Vcrit()
198{
199 return 1.0/Roc;
200}
201 double water::Tmin()
202{
203 return Tmn;
204}
205 double water::Tmax()
206{
207 return Tmx;
208}
209 double water::MolWt()
210{
211 return M;
212}
213
214}
Water.h
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
tpx::Substance::P
double P()
Pressure [Pa].
Definition: Sub.cpp:48
tpx::water::Vcrit
double Vcrit()
Critical specific volume [m^3/kg].
Definition: Water.cpp:197
tpx::water::Tmax
double Tmax()
Maximum temperature for which the equation of state is valid.
Definition: Water.cpp:205
tpx::water::Tmin
double Tmin()
Minimum temperature for which the equation of state is valid.
Definition: Water.cpp:201
tpx::water::MolWt
double MolWt()
Molecular weight [kg/kmol].
Definition: Water.cpp:209
tpx::water::sp
double sp()
Entropy of a single-phase state.
Definition: Water.cpp:136
tpx::water::Tcrit
double Tcrit()
Critical temperature [K].
Definition: Water.cpp:189
tpx::water::Pcrit
double Pcrit()
Critical pressure [Pa].
Definition: Water.cpp:193
tpx::water::Psat
double Psat()
Saturation pressure, Pa.
Definition: Water.cpp:161
tpx::water::up
double up()
Internal energy of a single-phase state.
Definition: Water.cpp:122
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
stringUtils.h
Contains declarations for string manipulation functions within Cantera.