Cantera  3.1.0a1
Methane.cpp
Go to the documentation of this file.
1 //! @file Methane.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 "Methane.h"
8 
9 using namespace Cantera;
10 
11 namespace tpx
12 {
13 static const double
14 M = 16.04996,
15 Tmn = 90.68,
16 Tmx = 1700.0,
17 Tc = 190.555,
18 Pc = 4.5988e6,
19 Roc= 160.43,
20 Tt = 90.68,
21 Pt=11743.5675,
22 R = 5.18253475866e2,
23 Gamma=3.72992471469e-5,
24 alpha = 1.5, //Used with Psat
25 alpha1 = .36, //used with ldens;
26 Rot=451.562,
27 beta=2009.152,
28 u0 = 357696.0858,
29 s0 = -1918.035071;
30 
31 static const double Ameth[] = {
32  -7.25929210183, 4.13766054566e2, -6.32167316855e3,
33  3.34015577724e5, -1.68253379982e7, 1.87884851902e-2, -1.18673201223e1,
34  2.09062618015e3, -4.07532656958e5, -5.73917603241e-5,4.37711441593e-2,
35  -4.38766500673, 1.13524630779e-5, -5.07028240949e-5, 2.28002199522e-2,
36  9.25611329590e-9, 1.33865662546e-10, -1.65439044196e-7, 1.81030980110e-10,
37  5.45753645958e5, -3.63192281933e7, 4.81463473761, 1.56633022620e5,
38  7.89977010972e-5, 1.39993881210e-2, -1.70656092212e-11, -4.55256623445e-5,
39  -2.29314170748e-14,8.31548197665e-12, 6.84673626259e-20,
40  -4.70845544152e-17, 5.21465091383e-16
41 };
42 
43 static const double Dmeth[]=
44 { -1.78860165e-1, 4.83847500e-2, -1.84898700e-2 };
45 
46 static const double Fmeth[]=
47 { 4.77748580, 1.76065363, -5.67888940e-1, 1.32786231 };
48 
49 static const double Gmeth[]=
50 { 1.34740610e3, 1.35512060e2, -2.93910458e1, 2.12774600, 2.44656600e3 };
51 
52 double methane::C(int i, double rt, double rt2)
53 {
54  switch (i) {
55  case 0:
56  return Ameth[0] * T + Ameth[1] * sqrt(T) + Ameth[2] + (Ameth[3] + Ameth[4] * rt) * rt;
57  case 1:
58  return Ameth[5] * T + Ameth[6] + rt * (Ameth[7] + Ameth[8] * rt);
59  case 2:
60  return Ameth[9] * T + Ameth[10] + Ameth[11] * rt;
61  case 3:
62  return Ameth[12];
63  case 4:
64  return rt*(Ameth[13] + Ameth[14]*rt);
65  case 5:
66  return Ameth[15]*rt;
67  case 6:
68  return rt*(Ameth[16] + Ameth[17]*rt);
69  case 7:
70  return Ameth[18]*rt2;
71  case 8:
72  return rt2*(Ameth[19] + Ameth[20]*rt);
73  case 9:
74  return rt2*(Ameth[21] + Ameth[22]*rt2);
75  case 10:
76  return rt2*(Ameth[23] + Ameth[24]*rt);
77  case 11:
78  return rt2*(Ameth[25] + Ameth[26]*rt2);
79  case 12:
80  return rt2*(Ameth[27] + Ameth[28]*rt);
81  case 13:
82  return rt2*(Ameth[29] + Ameth[30]*rt + Ameth[31]*rt2);
83  default:
84  return 0.0;
85  }
86 }
87 
88 double methane::Cprime(int i, double rt, double rt2, double rt3)
89 {
90  switch (i) {
91  case 0:
92  return Ameth[0] + 0.5*Ameth[1]/sqrt(T) - (Ameth[3] + 2.0*Ameth[4]*rt)*rt2;
93  case 1:
94  return Ameth[5] - rt2*(Ameth[7] + 2.0*Ameth[8]*rt);
95  case 2:
96  return Ameth[9] - Ameth[11]*rt2;
97  case 3:
98  return 0.0;
99  case 4:
100  return -rt2*(Ameth[13] + 2.0*Ameth[14]*rt);
101  case 5:
102  return -Ameth[15]*rt2;
103  case 6:
104  return -rt2*(Ameth[16] + 2.0*Ameth[17]*rt);
105  case 7:
106  return -2.0*Ameth[18]*rt3;
107  case 8:
108  return -rt3*(2.0*Ameth[19] + 3.0*Ameth[20]*rt);
109  case 9:
110  return -rt3*(2.0*Ameth[21] + 4.0*Ameth[22]*rt2);
111  case 10:
112  return -rt3*(2.0*Ameth[23] + 3.0*Ameth[24]*rt);
113  case 11:
114  return -rt3*(2.0*Ameth[25] + 4.0*Ameth[26]*rt2);
115  case 12:
116  return -rt3*(2.0*Ameth[27] + 3.0*Ameth[28]*rt);
117  case 13:
118  return -rt3*(2.0*Ameth[29] + 3.0*Ameth[30]*rt + 4.0*Ameth[31]*rt2);
119  default:
120  return 0.0;
121  }
122 }
123 
124 double methane::W(int n, double egrho)
125 {
126  return (n == 0 ? (1.0 - egrho)/(2.0*Gamma) :
127  (n*W(n-1, egrho) - 0.5*pow(Rho,2*n)*egrho)/Gamma);
128 }
129 
130 double methane::H(int i, double egrho)
131 {
132  return (i < 8 ? pow(Rho,i+2) : pow(Rho,2*i-13)*egrho);
133 }
134 
135 double methane::I(int i, double egrho)
136 {
137  return (i < 8 ? pow(Rho,i+1)/double(i+1) : W(i-8, egrho));
138 }
139 
140 double methane::up()
141 {
142  double rt = 1.0/T;
143  double rt2 = rt*rt;
144  double rt3 = rt*rt2;
145  double egrho = exp(-Gamma*Rho*Rho);
146  double t3 = pow(T,1.0/3.0);
147 
148  double sum = 0.0;
149  for (int i=0; i<14; i++) {
150  sum += (C(i, rt, rt2) - T*Cprime(i, rt, rt2, rt3))*I(i, egrho);
151  }
152  sum += T*(Gmeth[0] + 0.75*Gmeth[1]*t3 + 0.6*Gmeth[2]*t3*t3 + 0.5*Gmeth[3]*T)
153  + Gmeth[4]*beta/(exp(beta*rt) - 1.0) + u0;
154  return sum + m_energy_offset;
155 }
156 
157 double methane::sp()
158 {
159  double rt = 1.0/T;
160  double rt2 = rt*rt;
161  double rt3 = rt*rt2;
162  double egrho = exp(-Gamma*Rho*Rho);
163  double t3 = pow(T,1.0/3.0);
164  double sum = 0.0;
165  sum = s0 - R*log(Rho);
166  for (int i=0; i<14; i++) {
167  sum -= Cprime(i, rt, rt2, rt3)*I(i, egrho);
168  }
169  sum += Gmeth[0]*log(T) + 3.0*Gmeth[1]*t3 + 1.5*Gmeth[2]*t3*t3 + Gmeth[3]*T
170  + Gmeth[4]*(beta*rt + beta*rt/(exp(beta*rt) - 1.0)
171  - log(exp(beta*rt) - 1.0));
172  return sum + m_entropy_offset;
173 }
174 
175 double methane::Pp()
176 {
177  double rt = 1.0/T;
178  double rt2 = rt*rt;
179  double egrho = exp(-Gamma*Rho*Rho);
180 
181  double P = Rho*R*T;
182  for (int i=0; i<14; i++) {
183  P += C(i, rt, rt2)*H(i, egrho);
184  }
185  return P;
186 }
187 
188 double methane::Psat()
189 {
190  double x = (1.0 - Tt/T)/(1.0 - Tt/Tc);
191  double result;
192  if ((T < Tmn) || (T > Tc)) {
193  throw CanteraError("methane::Psat",
194  "Temperature out of range. T = {}", T);
195  }
196  result = Fmeth[0]*x + Fmeth[1]*x*x + Fmeth[2]*x*x*x +
197  Fmeth[3]*x*pow(1-x, alpha);
198  return exp(result)*Pt;
199 }
200 
201 double methane::ldens()
202 {
203  double result;
204  double sum;
205  double w;
206  if ((T < Tmn) || (T > Tc)) {
207  throw CanteraError("methane::ldens",
208  "Temperature out of range. T = {}", T);
209  }
210  w = (Tc - T)/(Tc - Tt);
211  sum = Dmeth[0]*(1.0 - pow(w, 2.0/3.0)) + Dmeth[1]*(1.0 - pow(w, 4.0/3.0))
212  + Dmeth[2]*(1.0 - pow(w, 2));
213  result = pow(w,alpha1)*exp(sum);
214  result *= (Rot-Roc);
215  result += Roc;
216  return result;
217 }
218 
219 double methane::Tcrit()
220 {
221  return Tc;
222 }
223 double methane::Pcrit()
224 {
225  return Pc;
226 }
227 double methane::Vcrit()
228 {
229  return 1.0/Roc;
230 }
231 double methane::Tmin()
232 {
233  return Tmn;
234 }
235 double methane::Tmax()
236 {
237  return Tmx;
238 }
239 double methane::MolWt()
240 {
241  return M;
242 }
243 
244 }
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:66
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:564
Contains declarations for string manipulation functions within Cantera.