10 #include "CarbonDioxide.h"
20 static const double Tmn = 216.54;
21 static const double Tmx = 1500.0;
22 static const double Tc=304.21;
23 static const double Roc=464.00;
24 static const double To=216.54;
25 static const double R=188.918;
26 static const double Gamma=5.0E-6;
27 static const double u0=3.2174105E5;
28 static const double s0=2.1396056E3;
29 static const double Tp=250;
30 static const double Pc=7.38350E6;
31 static const double M=44.01;
36 static const double Acarbdi[]= {
62 static const double F[]= {
77 static const double D[]= {
90 static const double G[]= {
107 double CarbonDioxide::C(
int j,
double Tinverse,
double T2inverse,
double T3inverse,
double T4inverse)
111 return Acarbdi[0]*T +
113 Acarbdi[2] * Tinverse +
114 Acarbdi[3] * T2inverse +
115 Acarbdi[4] * T3inverse ;
117 return Acarbdi[5] *T +
119 Acarbdi[7] * Tinverse ;
121 return Acarbdi[8]*T + Acarbdi[9];
123 return Acarbdi[10]*T + Acarbdi[11];
127 return Acarbdi[13] *T2inverse +
128 Acarbdi[14] *T3inverse +
129 Acarbdi[15] *T4inverse;
131 return Acarbdi[16] *T2inverse +
132 Acarbdi[17] *T3inverse +
133 Acarbdi[18] *T4inverse;
142 inline double CarbonDioxide::Cprime(
int j,
double T2inverse,
double T3inverse,
double T4inverse)
148 - Acarbdi[2] * T2inverse +
149 -2 * Acarbdi[3] * T3inverse +
150 -3 * Acarbdi[4] * T4inverse ;
153 Acarbdi[7] * T2inverse;
162 -2 *Acarbdi[13] *T3inverse +
163 -3 *Acarbdi[14] *T4inverse +
164 -4 *Acarbdi[15]* pow(T,-5);
167 -2 *Acarbdi[16] *T3inverse +
168 -3 *Acarbdi[17] *T4inverse +
169 -4 *Acarbdi[18] *pow(T,-5);
179 inline double CarbonDioxide::I(
int j,
double ergho,
double Gamma)
186 return pow(Rho, 2)/2;
188 return pow(Rho, 3)/ 3;
190 return pow(Rho, 4)/ 4;
192 return pow(Rho, 5)/ 5;
194 return (1 - ergho) / double(2 * Gamma);
196 return (1 - ergho *
double(Gamma * pow(Rho,2) +
double(1)))/ double(2 * Gamma * Gamma);
210 double CarbonDioxide::H(
int i,
double egrho)
215 return pow(Rho,3)*egrho;
217 return pow(Rho,5)*egrho;
229 double CarbonDioxide::up()
232 double Tinverse = 1.0/T;
233 double T2inverse = pow(T, -2);
234 double T3inverse = pow(T, -3);
235 double T4inverse = pow(T, -4);
236 double egrho = exp(-Gamma*Rho*Rho);
241 sum += G[0]*log(T/To);
243 for (i=1; i<=5; i++) {
244 sum += G[i]*(pow(T,i) - pow(To,i))/
double(i);
248 for (i=0; i<=6; i++) {
249 sum += I(i,egrho, Gamma) *
250 (C(i, Tinverse, T2inverse, T3inverse, T4inverse) - T*Cprime(i,T2inverse, T3inverse, T4inverse));
254 return sum + m_energy_offset;
263 double CarbonDioxide::sp()
266 double T2inverse = pow(T, -2);
267 double T3inverse = pow(T, -3);
268 double T4inverse = pow(T, -4);
269 double egrho = exp(-Gamma*Rho*Rho);
273 for (
int i=2; i<=5; i++) {
274 sum += G[i]*(pow(T,i-1) - pow(To,i-1))/
double(i-1);
277 sum += G[1]*log(T/To);
278 sum -= G[0]*(1.0/T - 1.0/To);
281 for (
int i=0; i<=6; i++) {
282 sum -= Cprime(i,T2inverse, T3inverse, T4inverse)*I(i,egrho,Gamma);
285 sum += s0 - R*log(Rho);
287 return sum + m_entropy_offset;
296 double CarbonDioxide::Pp()
298 double Tinverse = pow(T,-1);
299 double T2inverse = pow(T, -2);
300 double T3inverse = pow(T, -3);
301 double T4inverse = pow(T, -4);
302 double egrho = exp(-Gamma*Rho*Rho);
307 for (
int i=0; i<=6; i++) {
308 P += C(i,Tinverse, T2inverse, T3inverse, T4inverse)*H(i,egrho);
318 double CarbonDioxide::Psat()
322 if ((T < Tmn) || (T > Tc)) {
323 std::cout <<
" error in Psat " << TempError << std::endl;
326 for (
int i=1; i<=8; i++) {
327 sum += F[i-1] * pow((T/Tp -1),
double(i-1));
330 log = ((Tc/T)-1)*sum;
342 double CarbonDioxide::ldens()
344 double xx=1-(T/Tc), sum=0;
345 if ((T < Tmn) || (T > Tc)) {
346 std::cout <<
" error in ldens " << TempError << std::endl;
349 for (
int i=1; i<=6; i++) {
350 sum+=D[i-1]*pow(xx,
double(i-1)/3.0);
361 double CarbonDioxide::Tcrit()
365 double CarbonDioxide::Pcrit()
369 double CarbonDioxide::Vcrit()
373 double CarbonDioxide::Tmin()
377 double CarbonDioxide::Tmax()
381 char* CarbonDioxide::name()
383 return (
char*) m_name.c_str() ;
385 char* CarbonDioxide::formula()
387 return (
char*) m_formula.c_str();
389 double CarbonDioxide::MolWt()