11 using namespace Cantera;
19 static const double Tmn = 216.54;
20 static const double Tmx = 1500.0;
21 static const double Tc=304.21;
22 static const double Roc=464.00;
23 static const double To=216.54;
24 static const double R=188.918;
25 static const double Gamma=5.0E-6;
26 static const double u0=3.2174105E5;
27 static const double s0=2.1396056E3;
28 static const double Tp=250;
29 static const double Pc=7.38350E6;
30 static const double M=44.01;
33 static const double Acarbdi[]= {
56 static const double F[]= {
68 static const double D[]= {
78 static const double G[]= {
87 double CarbonDioxide::C(
int j,
double Tinverse,
double T2inverse,
double T3inverse,
double T4inverse)
93 Acarbdi[2] * Tinverse +
94 Acarbdi[3] * T2inverse +
95 Acarbdi[4] * T3inverse ;
97 return Acarbdi[5] *T +
99 Acarbdi[7] * Tinverse ;
101 return Acarbdi[8]*T + Acarbdi[9];
103 return Acarbdi[10]*T + Acarbdi[11];
107 return Acarbdi[13] *T2inverse +
108 Acarbdi[14] *T3inverse +
109 Acarbdi[15] *T4inverse;
111 return Acarbdi[16] *T2inverse +
112 Acarbdi[17] *T3inverse +
113 Acarbdi[18] *T4inverse;
119 inline double CarbonDioxide::Cprime(
int j,
double T2inverse,
double T3inverse,
double T4inverse)
124 - Acarbdi[2] * T2inverse +
125 -2 * Acarbdi[3] * T3inverse +
126 -3 * Acarbdi[4] * T4inverse ;
129 Acarbdi[7] * T2inverse;
138 -2 *Acarbdi[13] *T3inverse +
139 -3 *Acarbdi[14] *T4inverse +
140 -4 *Acarbdi[15]* pow(T,-5);
143 -2 *Acarbdi[16] *T3inverse +
144 -3 *Acarbdi[17] *T4inverse +
145 -4 *Acarbdi[18] *pow(T,-5);
151 inline double CarbonDioxide::I(
int j,
double ergho,
double Gamma)
158 return pow(Rho, 2)/2;
160 return pow(Rho, 3)/ 3;
162 return pow(Rho, 4)/ 4;
164 return pow(Rho, 5)/ 5;
166 return (1 - ergho) / double(2 * Gamma);
168 return (1 - ergho *
double(Gamma * pow(Rho,2) +
double(1)))/ double(2 * Gamma * Gamma);
174 double CarbonDioxide::H(
int i,
double egrho)
179 return pow(Rho,3)*egrho;
181 return pow(Rho,5)*egrho;
187 double CarbonDioxide::up()
189 double Tinverse = 1.0/T;
190 double T2inverse = pow(T, -2);
191 double T3inverse = pow(T, -3);
192 double T4inverse = pow(T, -4);
193 double egrho = exp(-Gamma*Rho*Rho);
198 sum += G[0]*log(T/To);
200 for (i=1; i<=5; i++) {
201 sum += G[i]*(pow(T,i) - pow(To,i))/
double(i);
204 for (i=0; i<=6; i++) {
205 sum += I(i,egrho, Gamma) *
206 (C(i, Tinverse, T2inverse, T3inverse, T4inverse) - T*Cprime(i,T2inverse, T3inverse, T4inverse));
210 return sum + m_energy_offset;
213 double CarbonDioxide::sp()
215 double T2inverse = pow(T, -2);
216 double T3inverse = pow(T, -3);
217 double T4inverse = pow(T, -4);
218 double egrho = exp(-Gamma*Rho*Rho);
222 for (
int i=2; i<=5; i++) {
223 sum += G[i]*(pow(T,i-1) - pow(To,i-1))/
double(i-1);
226 sum += G[1]*log(T/To);
227 sum -= G[0]*(1.0/T - 1.0/To);
230 for (
int i=0; i<=6; i++) {
231 sum -= Cprime(i,T2inverse, T3inverse, T4inverse)*I(i,egrho,Gamma);
234 sum += s0 - R*log(Rho);
236 return sum + m_entropy_offset;
239 double CarbonDioxide::Pp()
241 double Tinverse = pow(T,-1);
242 double T2inverse = pow(T, -2);
243 double T3inverse = pow(T, -3);
244 double T4inverse = pow(T, -4);
245 double egrho = exp(-Gamma*Rho*Rho);
250 for (
int i=0; i<=6; i++) {
251 P += C(i,Tinverse, T2inverse, T3inverse, T4inverse)*H(i,egrho);
256 double CarbonDioxide::Psat()
259 if ((T < Tmn) || (T > Tc)) {
260 throw TPX_Error(
"CarbonDixoide::Psat",
261 "Temperature out of range. T = " +
fp2str(T));
263 for (
int i=1; i<=8; i++) {
264 sum += F[i-1] * pow((T/Tp -1),
double(i-1));
267 log = ((Tc/T)-1)*sum;
273 double CarbonDioxide::ldens()
275 double xx=1-(T/Tc), sum=0;
276 if ((T < Tmn) || (T > Tc)) {
277 throw TPX_Error(
"CarbonDixoide::ldens",
278 "Temperature out of range. T = " +
fp2str(T));
280 for (
int i=1; i<=6; i++) {
281 sum+=D[i-1]*pow(xx,
double(i-1)/3.0);
290 double CarbonDioxide::Tcrit()
294 double CarbonDioxide::Pcrit()
298 double CarbonDioxide::Vcrit()
302 double CarbonDioxide::Tmin()
306 double CarbonDioxide::Tmax()
310 double CarbonDioxide::MolWt()
std::string fp2str(const double x, const std::string &fmt)
Convert a double into a c++ string.
Contains declarations for string manipulation functions within Cantera.