6 using namespace Cantera;
20 Gamma=3.72992471469e-5,
28 static const double Ameth[] = {
29 -7.25929210183, 4.13766054566e2, -6.32167316855e3,
30 3.34015577724e5, -1.68253379982e7, 1.87884851902e-2, -1.18673201223e1,
31 2.09062618015e3, -4.07532656958e5, -5.73917603241e-5,4.37711441593e-2,
32 -4.38766500673, 1.13524630779e-5, -5.07028240949e-5, 2.28002199522e-2,
33 9.25611329590e-9, 1.33865662546e-10, -1.65439044196e-7, 1.81030980110e-10,
34 5.45753645958e5, -3.63192281933e7, 4.81463473761, 1.56633022620e5,
35 7.89977010972e-5, 1.39993881210e-2, -1.70656092212e-11, -4.55256623445e-5,
36 -2.29314170748e-14,8.31548197665e-12, 6.84673626259e-20,
37 -4.70845544152e-17, 5.21465091383e-16
40 static const double Dmeth[]=
41 { -1.78860165e-1, 4.83847500e-2, -1.84898700e-2 };
43 static const double Fmeth[]=
44 { 4.77748580, 1.76065363, -5.67888940e-1, 1.32786231 };
46 static const double Gmeth[]=
47 { 1.34740610e3, 1.35512060e2, -2.93910458e1, 2.12774600, 2.44656600e3 };
49 double methane::C(
int i,
double rt,
double rt2)
53 return Ameth[0] * T + Ameth[1] * sqrt(T) + Ameth[2] + (Ameth[3] + Ameth[4] * rt) * rt;
55 return Ameth[5] * T + Ameth[6] + rt * (Ameth[7] + Ameth[8] * rt);
57 return Ameth[9] * T + Ameth[10] + Ameth[11] * rt;
61 return rt*(Ameth[13] + Ameth[14]*rt);
65 return rt*(Ameth[16] + Ameth[17]*rt);
69 return rt2*(Ameth[19] + Ameth[20]*rt);
71 return rt2*(Ameth[21] + Ameth[22]*rt2);
73 return rt2*(Ameth[23] + Ameth[24]*rt);
75 return rt2*(Ameth[25] + Ameth[26]*rt2);
77 return rt2*(Ameth[27] + Ameth[28]*rt);
79 return rt2*(Ameth[29] + Ameth[30]*rt + Ameth[31]*rt2);
85 double methane::Cprime(
int i,
double rt,
double rt2,
double rt3)
89 return Ameth[0] + 0.5*Ameth[1]/sqrt(T) - (Ameth[3] + 2.0*Ameth[4]*rt)*rt2;
91 return Ameth[5] - rt2*(Ameth[7] + 2.0*Ameth[8]*rt);
93 return Ameth[9] - Ameth[11]*rt2;
97 return -rt2*(Ameth[13] + 2.0*Ameth[14]*rt);
99 return -Ameth[15]*rt2;
101 return -rt2*(Ameth[16] + 2.0*Ameth[17]*rt);
103 return -2.0*Ameth[18]*rt3;
105 return -rt3*(2.0*Ameth[19] + 3.0*Ameth[20]*rt);
107 return -rt3*(2.0*Ameth[21] + 4.0*Ameth[22]*rt2);
109 return -rt3*(2.0*Ameth[23] + 3.0*Ameth[24]*rt);
111 return -rt3*(2.0*Ameth[25] + 4.0*Ameth[26]*rt2);
113 return -rt3*(2.0*Ameth[27] + 3.0*Ameth[28]*rt);
115 return -rt3*(2.0*Ameth[29] + 3.0*Ameth[30]*rt + 4.0*Ameth[31]*rt2);
121 double methane::W(
int n,
double egrho)
123 return (n == 0 ? (1.0 - egrho)/(2.0*Gamma) :
124 (n*W(n-1, egrho) - 0.5*pow(Rho,2*n)*egrho)/Gamma);
127 double methane::H(
int i,
double egrho)
129 return (i < 8 ? pow(Rho,i+2) : pow(Rho,2*i-13)*egrho);
132 double methane::I(
int i,
double egrho)
134 return (i < 8 ? pow(Rho,i+1)/
double(i+1) : W(i-8, egrho));
142 double egrho = exp(-Gamma*Rho*Rho);
143 double t3 = pow(T,1.0/3.0);
146 for (
int i=0; i<14; i++) {
147 sum += (C(i, rt, rt2) - T*Cprime(i, rt, rt2, rt3))*I(i, egrho);
150 sum += T*(Gmeth[0] + 0.75*Gmeth[1]*t3 + 0.6*Gmeth[2]*t3*t3 + 0.5*Gmeth[3]*T)
151 + Gmeth[4]*beta/(exp(beta*rt) - 1.0) + u0;
152 return sum + m_energy_offset;
160 double egrho = exp(-Gamma*Rho*Rho);
161 double t3 = pow(T,1.0/3.0);
163 sum = s0 - R*log(Rho);
164 for (
int i=0; i<14; i++) {
165 sum -= Cprime(i, rt, rt2, rt3)*I(i, egrho);
167 sum += Gmeth[0]*log(T) + 3.0*Gmeth[1]*t3 + 1.5*Gmeth[2]*t3*t3 + Gmeth[3]*T
168 + Gmeth[4]*(beta*rt + beta*rt/(exp(beta*rt) - 1.0)
169 - log(exp(beta*rt) - 1.0));
170 return sum + m_entropy_offset;
177 double egrho = exp(-Gamma*Rho*Rho);
180 for (
int i=0; i<14; i++) {
181 P += C(i, rt, rt2)*H(i, egrho);
186 double methane::Psat()
188 double x = (1.0 - Tt/T)/(1.0 - Tt/Tc);
190 if ((T < Tmn) || (T > Tc)) {
191 throw TPX_Error(
"methane::Psat",
192 "Temperature out of range. T = " +
fp2str(T));
194 result = Fmeth[0]*x + Fmeth[1]*x*x + Fmeth[2]*x*x*x +
195 Fmeth[3]*x*pow(1-x, alpha);
196 return exp(result)*Pt;
199 double methane::ldens()
204 if ((T < Tmn) || (T > Tc)) {
205 throw TPX_Error(
"methane::ldens",
206 "Temperature out of range. T = " +
fp2str(T));
208 w = (Tc - T)/(Tc - Tt);
209 sum = Dmeth[0]*(1.0 - pow(w, 2.0/3.0)) + Dmeth[1]*(1.0 - pow(w, 4.0/3.0))
210 + Dmeth[2]*(1.0 - pow(w, 2));
211 result = pow(w,alpha1)*exp(sum);
217 double methane::Tcrit()
221 double methane::Pcrit()
225 double methane::Vcrit()
229 double methane::Tmin()
233 double methane::Tmax()
237 double methane::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.