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