Cantera  3.1.0a1
Nitrogen.cpp
Go to the documentation of this file.
1 //! @file Nitrogen.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 "Nitrogen.h"
8 
9 using namespace Cantera;
10 
11 namespace tpx
12 {
13 static const double M = 28.01348,
14  Tmn = 63.15,
15  Tmx = 2000.0,
16  Tc = 126.200,
17  Pc = 3.4e6,
18  Roc = 314.03,
19  R = 2.96790515164171e2,
20  Gamma = 7.13602531283233e-6,
21  alpha = 1.95,
22  beta = 3353.40610,
23  u0 = 150877.551,
24  s0 = 214.9352518;
25 
26 static const double Ann[] = {
27  1.75889959256970e-1, 1.38197604384933e1, -3.14918412133921e2,
28  4.40300150239380e3, -5.45358971644916e5, 4.84413320182919e-4,
29  -5.18964416491365e-2, 6.57265859197103e-4 ,8.51299771713314e4 ,
30  1.33459405162578e-8, 3.83381319826746e-4, -8.35421151028455e-2,
31  2.84874912286101e-7,
32  -2.38296116270360e-7, -1.48321912935764e-4, 5.62605853190540e-10,
33  -2.98201050924595e-13, 9.85319087685241e-11, -1.92002176056468e-14,
34  -7.82250103373122e4, -5.51801778744598e5, -5.72781957607352e-1,
35  3.25760529488327e2, -1.34659309828737e-6, -1.92036423064911e-5,
36  -3.94564337674524e-12,-2.44388245328965e-9, -1.50970602460077e-18,
37  1.25854885346038e-16,-8.34271144923969e-24, -1.17299202018417e-22,
38  9.06544823455730e-22
39 };
40 
41 static const double Fnn[]= {
42  8.3944094440e3, -1.8785191705e3, -7.2822291650,
43  1.0228509660e-2, 5.5560638250e-4,
44  -5.9445446620e-6, 2.7154339320e-8,
45  -4.8795359040e-11, 5.0953608240e2
46 };
47 
48 static const double Dnn[] = {
49  3.1402991e2, 4.4111015e2, 9.4622994e2 ,
50  -2.9067111e3, 4.4785979e3, -2.2746914e3
51 };
52 
53 static const double Gnn[] = {
54  -2.18203473713518e5, 1.01573580096247e4, -1.65504721657240e2,
55  7.43175999190430e2, -5.14605623546025e-3,
56  5.18347156760489e-6, -1.05922170493616e-9, 2.98389393363817e2
57 };
58 
59 double nitrogen::C(int i, double rt, double rt2)
60 {
61  switch (i) {
62  case 0:
63  return Ann[0] * T + Ann[1] * sqrt(T)
64  + Ann[2] + (Ann[3] + Ann[4] * rt) * rt;
65  case 1:
66  return Ann[5] * T + Ann[6] + rt * (Ann[7] + Ann[8] * rt);
67  case 2:
68  return Ann[9] * T + Ann[10] + Ann[11] * rt;
69  case 3:
70  return Ann[12];
71  case 4:
72  return rt*(Ann[13] + Ann[14]*rt);
73  case 5:
74  return Ann[15]*rt;
75  case 6:
76  return rt*(Ann[16] + Ann[17]*rt);
77  case 7:
78  return Ann[18]*rt2;
79  case 8:
80  return rt2*(Ann[19] + Ann[20]*rt);
81  case 9:
82  return rt2*(Ann[21] + Ann[22]*rt2);
83  case 10:
84  return rt2*(Ann[23] + Ann[24]*rt);
85  case 11:
86  return rt2*(Ann[25] + Ann[26]*rt2);
87  case 12:
88  return rt2*(Ann[27] + Ann[28]*rt);
89  case 13:
90  return rt2*(Ann[29] + Ann[30]*rt + Ann[31]*rt2);
91  default:
92  return 0.0;
93  }
94 }
95 
96 double nitrogen::Cprime(int i, double rt, double rt2, double rt3)
97 {
98  switch (i) {
99  case 0:
100  return Ann[0] + 0.5*Ann[1]/sqrt(T) - (Ann[3] + 2.0*Ann[4]*rt)*rt2;
101  case 1:
102  return Ann[5] - rt2*(Ann[7] + 2.0*Ann[8]*rt);
103  case 2:
104  return Ann[9] - Ann[11]*rt2;
105  case 3:
106  return 0.0;
107  case 4:
108  return -rt2*(Ann[13] + 2.0*Ann[14]*rt);
109  case 5:
110  return -Ann[15]*rt2;
111  case 6:
112  return -rt2*(Ann[16] + 2.0*Ann[17]*rt);
113  case 7:
114  return -2.0*Ann[18]*rt3;
115  case 8:
116  return -rt3*(2.0*Ann[19] + 3.0*Ann[20]*rt);
117  case 9:
118  return -rt3*(2.0*Ann[21] + 4.0*Ann[22]*rt2);
119  case 10:
120  return -rt3*(2.0*Ann[23] + 3.0*Ann[24]*rt);
121  case 11:
122  return -rt3*(2.0*Ann[25] + 4.0*Ann[26]*rt2);
123  case 12:
124  return -rt3*(2.0*Ann[27] + 3.0*Ann[28]*rt);
125  case 13:
126  return -rt3*(2.0*Ann[29] + 3.0*Ann[30]*rt + 4.0*Ann[31]*rt2);
127  default:
128  return 0.0;
129  }
130 }
131 
132 double nitrogen::W(int n, double egrho)
133 {
134  return (n == 0 ? (1.0 - egrho)/(2.0*Gamma) :
135  (n*W(n-1, egrho) - 0.5*pow(Rho,2*n)*egrho)/Gamma);
136 }
137 
138 double nitrogen::H(int i, double egrho)
139 {
140  return (i < 8 ? pow(Rho,i+2) : pow(Rho,2*i-13)*egrho);
141 }
142 
143 double nitrogen::I(int i, double egrho)
144 {
145  return (i < 8 ? pow(Rho,i+1)/double(i+1) : W(i-8, egrho));
146 }
147 
148 double nitrogen::up()
149 {
150  double rt = 1.0/T;
151  double rt2 = rt*rt;
152  double rt3 = rt*rt2;
153  double egrho = exp(-Gamma*Rho*Rho);
154 
155  double sum = 0.0;
156  for (int i=0; i<14; i++) {
157  sum += (C(i,rt,rt2) - T*Cprime(i,rt,rt2,rt3))*I(i,egrho);
158  }
159  sum += (((0.25*Gnn[6]*T + Gnn[5]/3.0)*T
160  + 0.5*Gnn[4])*T + Gnn[3])*T + Gnn[2]*log(T)
161  - (Gnn[1] + 0.5*Gnn[0]*rt)*rt
162  + Gnn[7]*beta/(exp(beta*rt) - 1.0) + u0
163  + m_energy_offset;
164  return sum;
165 }
166 
167 double nitrogen::sp()
168 {
169  double rt = 1.0/T;
170  double rt2 = rt*rt;
171  double rt3 = rt*rt2;
172  double egrho = exp(-Gamma*Rho*Rho);
173 
174  double sum = 0.0;
175  sum = s0 + m_entropy_offset - R*log(Rho);
176  for (int i=0; i<14; i++) {
177  sum -= Cprime(i,rt,rt2,rt3)*I(i,egrho);
178  }
179  sum += (((Gnn[6]/3.0)*T + 0.5*Gnn[5])*T + Gnn[4])*T + Gnn[3]*log(T)
180  -((Gnn[0]*rt/3.0 + 0.5*Gnn[1])*rt + Gnn[2])*rt
181  + Gnn[7]*(beta*rt + beta*rt/(exp(beta*rt) - 1.0)
182  - log(exp(beta*rt) - 1.0));
183  return sum;
184 }
185 
186 double nitrogen::Pp()
187 {
188  double rt = 1.0/T;
189  double rt2 = rt*rt;
190  double egrho = exp(-Gamma*Rho*Rho);
191 
192  double P = Rho*R*T;
193  for (int i=0; i<14; i++) {
194  P += C(i,rt,rt2)*H(i,egrho);
195  }
196  return P;
197 }
198 
199 double nitrogen::Psat()
200 {
201  double lnp;
202  int i;
203  if ((T < Tmn) || (T > Tc)) {
204  throw CanteraError("nitrogen::Psat",
205  "Temperature out of range. T = {}", T);
206  }
207  for (i=0, lnp=0; i<=7; i++) {
208  if (i==3) {
209  lnp+=Fnn[i]*pow(Tc-T, alpha);
210  } else {
211  lnp+=Fnn[i]*pow(T,i-1);
212  }
213  }
214  lnp+=Fnn[8]*log(T);
215  return exp(lnp);
216 }
217 
218 double nitrogen::ldens()
219 {
220  double xx=1-T/Tc, sum=0;
221  if ((T < Tmn) || (T > Tc)) {
222  throw CanteraError("nitrogen::ldens",
223  "Temperature out of range. T = {}", T);
224  }
225  for (int i=0; i<=5; i++) {
226  sum+=Dnn[i]*pow(xx,double(i)/3.0);
227  }
228  return sum;
229 }
230 
231 double nitrogen::Tcrit()
232 {
233  return Tc;
234 }
235 double nitrogen::Pcrit()
236 {
237  return Pc;
238 }
239 double nitrogen::Vcrit()
240 {
241  return 1.0/Roc;
242 }
243 double nitrogen::Tmin()
244 {
245  return Tmn;
246 }
247 double nitrogen::Tmax()
248 {
249  return Tmx;
250 }
251 double nitrogen::MolWt()
252 {
253  return M;
254 }
255 }
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.