5 using namespace Cantera;
9 static const double M = 28.01348,
15 R = 2.96790515164171e2,
16 Gamma = 7.13602531283233e-6,
22 static const double Ann[] = {
23 1.75889959256970e-1, 1.38197604384933e1, -3.14918412133921e2,
24 4.40300150239380e3, -5.45358971644916e5, 4.84413320182919e-4,
25 -5.18964416491365e-2, 6.57265859197103e-4 ,8.51299771713314e4 ,
26 1.33459405162578e-8, 3.83381319826746e-4, -8.35421151028455e-2,
28 -2.38296116270360e-7, -1.48321912935764e-4, 5.62605853190540e-10,
29 -2.98201050924595e-13, 9.85319087685241e-11, -1.92002176056468e-14,
30 -7.82250103373122e4, -5.51801778744598e5, -5.72781957607352e-1,
31 3.25760529488327e2, -1.34659309828737e-6, -1.92036423064911e-5,
32 -3.94564337674524e-12,-2.44388245328965e-9, -1.50970602460077e-18,
33 1.25854885346038e-16,-8.34271144923969e-24, -1.17299202018417e-22,
37 static const double Fnn[]= {
38 8.3944094440e3, -1.8785191705e3, -7.2822291650,
39 1.0228509660e-2, 5.5560638250e-4,
40 -5.9445446620e-6, 2.7154339320e-8,
41 -4.8795359040e-11, 5.0953608240e2
44 static const double Dnn[] = {
45 3.1402991e2, 4.4111015e2, 9.4622994e2 ,
46 -2.9067111e3, 4.4785979e3, -2.2746914e3
49 static const double Gnn[] = {
50 -2.18203473713518e5, 1.01573580096247e4, -1.65504721657240e2,
51 7.43175999190430e2, -5.14605623546025e-3,
52 5.18347156760489e-6, -1.05922170493616e-9, 2.98389393363817e2
55 double nitrogen::C(
int i,
double rt,
double rt2)
59 return Ann[0] * T + Ann[1] * sqrt(T)
60 + Ann[2] + (Ann[3] + Ann[4] * rt) * rt;
62 return Ann[5] * T + Ann[6] + rt * (Ann[7] + Ann[8] * rt);
64 return Ann[9] * T + Ann[10] + Ann[11] * rt;
68 return rt*(Ann[13] + Ann[14]*rt);
72 return rt*(Ann[16] + Ann[17]*rt);
76 return rt2*(Ann[19] + Ann[20]*rt);
78 return rt2*(Ann[21] + Ann[22]*rt2);
80 return rt2*(Ann[23] + Ann[24]*rt);
82 return rt2*(Ann[25] + Ann[26]*rt2);
84 return rt2*(Ann[27] + Ann[28]*rt);
86 return rt2*(Ann[29] + Ann[30]*rt + Ann[31]*rt2);
92 double nitrogen::Cprime(
int i,
double rt,
double rt2,
double rt3)
96 return Ann[0] + 0.5*Ann[1]/sqrt(T) - (Ann[3] + 2.0*Ann[4]*rt)*rt2;
98 return Ann[5] - rt2*(Ann[7] + 2.0*Ann[8]*rt);
100 return Ann[9] - Ann[11]*rt2;
104 return -rt2*(Ann[13] + 2.0*Ann[14]*rt);
108 return -rt2*(Ann[16] + 2.0*Ann[17]*rt);
110 return -2.0*Ann[18]*rt3;
112 return -rt3*(2.0*Ann[19] + 3.0*Ann[20]*rt);
114 return -rt3*(2.0*Ann[21] + 4.0*Ann[22]*rt2);
116 return -rt3*(2.0*Ann[23] + 3.0*Ann[24]*rt);
118 return -rt3*(2.0*Ann[25] + 4.0*Ann[26]*rt2);
120 return -rt3*(2.0*Ann[27] + 3.0*Ann[28]*rt);
122 return -rt3*(2.0*Ann[29] + 3.0*Ann[30]*rt + 4.0*Ann[31]*rt2);
128 double nitrogen::W(
int n,
double egrho)
130 return (n == 0 ? (1.0 - egrho)/(2.0*Gamma) :
131 (n*W(n-1, egrho) - 0.5*pow(Rho,2*n)*egrho)/Gamma);
134 double nitrogen::H(
int i,
double egrho)
136 return (i < 8 ? pow(Rho,i+2) : pow(Rho,2*i-13)*egrho);
139 double nitrogen::I(
int i,
double egrho)
141 return (i < 8 ? pow(Rho,i+1)/
double(i+1) : W(i-8, egrho));
144 double nitrogen::up()
149 double egrho = exp(-Gamma*Rho*Rho);
152 for (
int i=0; i<14; i++) {
153 sum += (C(i,rt,rt2) - T*Cprime(i,rt,rt2,rt3))*I(i,egrho);
156 sum += (((0.25*Gnn[6]*T + Gnn[5]/3.0)*T
157 + 0.5*Gnn[4])*T + Gnn[3])*T + Gnn[2]*log(T)
158 - (Gnn[1] + 0.5*Gnn[0]*rt)*rt
159 + Gnn[7]*beta/(exp(beta*rt) - 1.0) + u0
165 double nitrogen::sp()
170 double egrho = exp(-Gamma*Rho*Rho);
173 sum = s0 + m_entropy_offset - R*log(Rho);
174 for (
int i=0; i<14; i++) {
175 sum -= Cprime(i,rt,rt2,rt3)*I(i,egrho);
178 sum += (((Gnn[6]/3.0)*T + 0.5*Gnn[5])*T + Gnn[4])*T + Gnn[3]*log(T)
179 -((Gnn[0]*rt/3.0 + 0.5*Gnn[1])*rt + Gnn[2])*rt
180 + Gnn[7]*(beta*rt + beta*rt/(exp(beta*rt) - 1.0)
181 - log(exp(beta*rt) - 1.0));
185 double nitrogen::Pp()
189 double egrho = exp(-Gamma*Rho*Rho);
192 for (
int i=0; i<14; i++) {
193 P += C(i,rt,rt2)*H(i,egrho);
198 double nitrogen::Psat()
202 if ((T < Tmn) || (T > Tc)) {
203 throw TPX_Error(
"nitrogen::Psat",
204 "Temperature out of range. T = " +
fp2str(T));
206 for (i=0, lnp=0; i<=7; i++) {
208 lnp+=Fnn[i]*pow(Tc-T, alpha);
210 lnp+=Fnn[i]*pow(T,i-1);
217 double nitrogen::ldens()
219 double xx=1-T/Tc, sum=0;
220 if ((T < Tmn) || (T > Tc)) {
221 throw TPX_Error(
"nitrogen::ldens",
222 "Temperature out of range. T = " +
fp2str(T));
224 for (
int i=0; i<=5; i++) {
225 sum+=Dnn[i]*pow(xx,
double(i)/3.0);
230 double nitrogen::Tcrit()
234 double nitrogen::Pcrit()
238 double nitrogen::Vcrit()
242 double nitrogen::Tmin()
246 double nitrogen::Tmax()
250 double nitrogen::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.