5 using namespace Cantera;
9 static const double M = 28.01348,
16 R = 2.96790515164171e2,
17 Gamma = 7.13602531283233e-6,
23 static const double Ann[] = {
24 1.75889959256970e-1, 1.38197604384933e1, -3.14918412133921e2,
25 4.40300150239380e3, -5.45358971644916e5, 4.84413320182919e-4,
26 -5.18964416491365e-2, 6.57265859197103e-4 ,8.51299771713314e4 ,
27 1.33459405162578e-8, 3.83381319826746e-4, -8.35421151028455e-2,
29 -2.38296116270360e-7, -1.48321912935764e-4, 5.62605853190540e-10,
30 -2.98201050924595e-13, 9.85319087685241e-11, -1.92002176056468e-14,
31 -7.82250103373122e4, -5.51801778744598e5, -5.72781957607352e-1,
32 3.25760529488327e2, -1.34659309828737e-6, -1.92036423064911e-5,
33 -3.94564337674524e-12,-2.44388245328965e-9, -1.50970602460077e-18,
34 1.25854885346038e-16,-8.34271144923969e-24, -1.17299202018417e-22,
38 static const double Fnn[]= {
39 8.3944094440e3, -1.8785191705e3, -7.2822291650,
40 1.0228509660e-2, 5.5560638250e-4,
41 -5.9445446620e-6, 2.7154339320e-8,
42 -4.8795359040e-11, 5.0953608240e2
45 static const double Dnn[] = {
46 3.1402991e2, 4.4111015e2, 9.4622994e2 ,
47 -2.9067111e3, 4.4785979e3, -2.2746914e3
50 static const double Gnn[] = {
51 -2.18203473713518e5, 1.01573580096247e4, -1.65504721657240e2,
52 7.43175999190430e2, -5.14605623546025e-3,
53 5.18347156760489e-6, -1.05922170493616e-9, 2.98389393363817e2
56 double nitrogen::C(
int i,
double rt,
double rt2)
60 return Ann[0] * T + Ann[1] * sqrt(T)
61 + Ann[2] + (Ann[3] + Ann[4] * rt) * rt;
63 return Ann[5] * T + Ann[6] + rt * (Ann[7] + Ann[8] * rt);
65 return Ann[9] * T + Ann[10] + Ann[11] * rt;
69 return rt*(Ann[13] + Ann[14]*rt);
73 return rt*(Ann[16] + Ann[17]*rt);
77 return rt2*(Ann[19] + Ann[20]*rt);
79 return rt2*(Ann[21] + Ann[22]*rt2);
81 return rt2*(Ann[23] + Ann[24]*rt);
83 return rt2*(Ann[25] + Ann[26]*rt2);
85 return rt2*(Ann[27] + Ann[28]*rt);
87 return rt2*(Ann[29] + Ann[30]*rt + Ann[31]*rt2);
93 double nitrogen::Cprime(
int i,
double rt,
double rt2,
double rt3)
97 return Ann[0] + 0.5*Ann[1]/sqrt(T) - (Ann[3] + 2.0*Ann[4]*rt)*rt2;
99 return Ann[5] - rt2*(Ann[7] + 2.0*Ann[8]*rt);
101 return Ann[9] - Ann[11]*rt2;
105 return -rt2*(Ann[13] + 2.0*Ann[14]*rt);
109 return -rt2*(Ann[16] + 2.0*Ann[17]*rt);
111 return -2.0*Ann[18]*rt3;
113 return -rt3*(2.0*Ann[19] + 3.0*Ann[20]*rt);
115 return -rt3*(2.0*Ann[21] + 4.0*Ann[22]*rt2);
117 return -rt3*(2.0*Ann[23] + 3.0*Ann[24]*rt);
119 return -rt3*(2.0*Ann[25] + 4.0*Ann[26]*rt2);
121 return -rt3*(2.0*Ann[27] + 3.0*Ann[28]*rt);
123 return -rt3*(2.0*Ann[29] + 3.0*Ann[30]*rt + 4.0*Ann[31]*rt2);
129 double nitrogen::W(
int n,
double egrho)
131 return (n == 0 ? (1.0 - egrho)/(2.0*Gamma) :
132 (n*W(n-1, egrho) - 0.5*pow(Rho,2*n)*egrho)/Gamma);
135 double nitrogen::H(
int i,
double egrho)
137 return (i < 8 ? pow(Rho,i+2) : pow(Rho,2*i-13)*egrho);
140 double nitrogen::I(
int i,
double egrho)
142 return (i < 8 ? pow(Rho,i+1)/
double(i+1) : W(i-8, egrho));
145 double nitrogen::up()
150 double egrho = exp(-Gamma*Rho*Rho);
153 for (
int i=0; i<14; i++) {
154 sum += (C(i,rt,rt2) - T*Cprime(i,rt,rt2,rt3))*I(i,egrho);
157 sum += (((0.25*Gnn[6]*T + Gnn[5]/3.0)*T
158 + 0.5*Gnn[4])*T + Gnn[3])*T + Gnn[2]*log(T)
159 - (Gnn[1] + 0.5*Gnn[0]*rt)*rt
160 + Gnn[7]*beta/(exp(beta*rt) - 1.0) + u0
166 double nitrogen::sp()
171 double egrho = exp(-Gamma*Rho*Rho);
174 sum = s0 + m_entropy_offset - R*log(Rho);
175 for (
int i=0; i<14; i++) {
176 sum -= Cprime(i,rt,rt2,rt3)*I(i,egrho);
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));
186 double nitrogen::Pp()
190 double egrho = exp(-Gamma*Rho*Rho);
193 for (
int i=0; i<14; i++) {
194 P += C(i,rt,rt2)*H(i,egrho);
199 double nitrogen::Psat()
203 if ((T < Tmn) || (T > Tc)) {
204 throw TPX_Error(
"nitrogen::Psat",
205 "Temperature out of range. T = " +
fp2str(T));
207 for (i=0, lnp=0; i<=7; i++) {
209 lnp+=Fnn[i]*pow(Tc-T, alpha);
211 lnp+=Fnn[i]*pow(T,i-1);
218 double nitrogen::ldens()
220 double xx=1-T/Tc, sum=0;
221 if ((T < Tmn) || (T > Tc)) {
222 throw TPX_Error(
"nitrogen::ldens",
223 "Temperature out of range. T = " +
fp2str(T));
225 for (
int i=0; i<=5; i++) {
226 sum+=Dnn[i]*pow(xx,
double(i)/3.0);
231 double nitrogen::Tcrit()
235 double nitrogen::Pcrit()
239 double nitrogen::Vcrit()
243 double nitrogen::Tmin()
247 double nitrogen::Tmax()
251 char* nitrogen::name()
253 return (
char*) m_name.c_str();
255 char* nitrogen::formula()
257 return (
char*) m_formula.c_str();
259 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.