11 using namespace Cantera;
19 static const double Tmn = 216.54;
20 static const double Tmx = 1500.0;
21 static const double Tc=304.21;
22 static const double Roc=464.00;
23 static const double To=216.54;
24 static const double R=188.918;
25 static const double Gamma=5.0E-6;
26 static const double u0=3.2174105E5;
27 static const double s0=2.1396056E3;
28 static const double Tp=250;
29 static const double Pc=7.38350E6;
30 static const double M=44.01;
33 static const double Acarbdi[]= {
56 static const double F[]= {
68 static const double D[]= {
78 static const double G[]= {
87 double CarbonDioxide::C(
int j,
double Tinverse,
double T2inverse,
double T3inverse,
double T4inverse)
93 Acarbdi[2] * Tinverse +
94 Acarbdi[3] * T2inverse +
95 Acarbdi[4] * T3inverse ;
97 return Acarbdi[5] *T +
99 Acarbdi[7] * Tinverse ;
101 return Acarbdi[8]*T + Acarbdi[9];
103 return Acarbdi[10]*T + Acarbdi[11];
107 return Acarbdi[13] *T2inverse +
108 Acarbdi[14] *T3inverse +
109 Acarbdi[15] *T4inverse;
111 return Acarbdi[16] *T2inverse +
112 Acarbdi[17] *T3inverse +
113 Acarbdi[18] *T4inverse;
119 inline double CarbonDioxide::Cprime(
int j,
double T2inverse,
double T3inverse,
double T4inverse)
124 - Acarbdi[2] * T2inverse +
125 -2 * Acarbdi[3] * T3inverse +
126 -3 * Acarbdi[4] * T4inverse ;
129 Acarbdi[7] * T2inverse;
138 -2 *Acarbdi[13] *T3inverse +
139 -3 *Acarbdi[14] *T4inverse +
140 -4 *Acarbdi[15]* pow(T,-5);
143 -2 *Acarbdi[16] *T3inverse +
144 -3 *Acarbdi[17] *T4inverse +
145 -4 *Acarbdi[18] *pow(T,-5);
151 inline double CarbonDioxide::I(
int j,
double ergho,
double Gamma)
158 return pow(Rho, 2)/2;
160 return pow(Rho, 3)/ 3;
162 return pow(Rho, 4)/ 4;
164 return pow(Rho, 5)/ 5;
166 return (1 - ergho) / double(2 * Gamma);
168 return (1 - ergho *
double(Gamma * pow(Rho,2) +
double(1)))/ double(2 * Gamma * Gamma);
174 double CarbonDioxide::H(
int i,
double egrho)
179 return pow(Rho,3)*egrho;
181 return pow(Rho,5)*egrho;
187 double CarbonDioxide::up()
189 double Tinverse = 1.0/T;
190 double T2inverse = pow(T, -2);
191 double T3inverse = pow(T, -3);
192 double T4inverse = pow(T, -4);
193 double egrho = exp(-Gamma*Rho*Rho);
198 sum += G[0]*log(T/To);
200 for (i=1; i<=5; i++) {
201 sum += G[i]*(pow(T,i) - pow(To,i))/
double(i);
204 for (i=0; i<=6; i++) {
205 sum += I(i,egrho, Gamma) *
206 (C(i, Tinverse, T2inverse, T3inverse, T4inverse) - T*Cprime(i,T2inverse, T3inverse, T4inverse));
210 return sum + m_energy_offset;
213 double CarbonDioxide::sp()
216 double T2inverse = pow(T, -2);
217 double T3inverse = pow(T, -3);
218 double T4inverse = pow(T, -4);
219 double egrho = exp(-Gamma*Rho*Rho);
223 for (
int i=2; i<=5; i++) {
224 sum += G[i]*(pow(T,i-1) - pow(To,i-1))/
double(i-1);
227 sum += G[1]*log(T/To);
228 sum -= G[0]*(1.0/T - 1.0/To);
231 for (
int i=0; i<=6; i++) {
232 sum -= Cprime(i,T2inverse, T3inverse, T4inverse)*I(i,egrho,Gamma);
235 sum += s0 - R*log(Rho);
237 return sum + m_entropy_offset;
240 double CarbonDioxide::Pp()
242 double Tinverse = pow(T,-1);
243 double T2inverse = pow(T, -2);
244 double T3inverse = pow(T, -3);
245 double T4inverse = pow(T, -4);
246 double egrho = exp(-Gamma*Rho*Rho);
251 for (
int i=0; i<=6; i++) {
252 P += C(i,Tinverse, T2inverse, T3inverse, T4inverse)*H(i,egrho);
257 double CarbonDioxide::Psat()
260 if ((T < Tmn) || (T > Tc)) {
261 throw TPX_Error(
"CarbonDixoide::Psat",
262 "Temperature out of range. T = " +
fp2str(T));
264 for (
int i=1; i<=8; i++) {
265 sum += F[i-1] * pow((T/Tp -1),
double(i-1));
268 log = ((Tc/T)-1)*sum;
276 double CarbonDioxide::ldens()
278 double xx=1-(T/Tc), sum=0;
279 if ((T < Tmn) || (T > Tc)) {
280 throw TPX_Error(
"CarbonDixoide::ldens",
281 "Temperature out of range. T = " +
fp2str(T));
283 for (
int i=1; i<=6; i++) {
284 sum+=D[i-1]*pow(xx,
double(i-1)/3.0);
293 double CarbonDioxide::Tcrit()
297 double CarbonDioxide::Pcrit()
301 double CarbonDioxide::Vcrit()
305 double CarbonDioxide::Tmin()
309 double CarbonDioxide::Tmax()
313 char* CarbonDioxide::name()
315 return (
char*) m_name.c_str() ;
317 char* CarbonDioxide::formula()
319 return (
char*) m_formula.c_str();
321 double CarbonDioxide::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.