Cantera  2.5.1
Heptane.cpp
Go to the documentation of this file.
1 /**
2  * @file Heptane.cpp representation of substance Heptane.
3  *
4  * Values and functions are from "Thermodynamic Properties in SI" by W.C.
5  * Reynolds. AUTHOR: jrh@stanford.edu: GCEP, Stanford University
6  */
7 
8 // This file is part of Cantera. See License.txt in the top-level directory or
9 // at https://cantera.org/license.txt for license and copyright information.
10 
11 #include "Heptane.h"
13 
14 using namespace Cantera;
15 
16 namespace tpx
17 {
18 
19 // Heptane constants
20 static const double Tmn = 182.56; // [K] minimum temperature for which calculations are valid
21 static const double Tmx = 1000.0; // [K] maximum temperature for which calculations are valid
22 static const double Tc=537.68; // [K] critical temperature
23 static const double Roc=197.60; // [kg/m^3] critical density
24 static const double To=300; // [K] reference Temperature
25 static const double R=82.99504; // [J/(kg*K)] gas constant (for this substance)
26 static const double Gamma=9.611604E-6; // [??]
27 static const double u0=3.4058439E5; // [] internal energy at To
28 static const double s0=1.1080254E3; // [] entropy at To
29 static const double Tp=400; // [K] ??
30 static const double Pc=2.6199E6; // [Pa] critical pressure
31 static const double M=100.20; // [kg/kmol] molar density
32 
33 // array Ahept is used by the function Pp
34 static const double Ahept[]= {
35  2.246032E-3,
36  2.082990E2,
37  5.085746E7,
38  3.566396E9,
39  1.622168E9,
40  1.065237E-5,
41  5.987922E-1,
42  7.736602,
43  1.929386E5,
44  5.291379E-9
45 };
46 
47 // array F is used by Psat
48 static const double F[]= {
49  -7.2298764,
50  3.8607475E-1,
51  -3.4216472,
52  4.6274432E-1,
53  -9.7926124,
54  -4.2058094E1,
55  7.5468678E1,
56  3.1758992E2
57 };
58 
59 // array D is used by the function ldens
60 static const double D[]= {
61  1.9760405E2,
62  8.9451237E2,
63  -1.1462908E3,
64  1.7996947E3,
65  -1.7250843E3,
66  9.7088329E2
67 };
68 
69 // array G is used by the function sp
70 static const double G[]= {
71  1.1925213E5,
72  -7.7231363E2,
73  7.4463527,
74  -3.0888167E-3,
75  0.0,
76  0.0
77 };
78 
79 double Heptane::C(int j,double Tinverse, double T2inverse, double T3inverse, double T4inverse)
80 {
81  switch (j) {
82  case 0:
83  return Ahept[0] * R * T -
84  Ahept[1] -
85  Ahept[2] * T2inverse +
86  Ahept[3] * T3inverse -
87  Ahept[4] * T4inverse;
88  case 1:
89  return Ahept[5] * R * T -
90  Ahept[6] -
91  Ahept[7] * Tinverse;
92  case 2:
93  return Ahept[9] * (Ahept[6] + Ahept[7] * Tinverse);
94  case 3:
95  return Ahept[8] * T2inverse;
96  default:
97  return 0.0;
98  }
99 }
100 
101 double Heptane::Cprime(int j, double T2inverse, double T3inverse, double T4inverse)
102 {
103  switch (j) {
104  case 0:
105  return Ahept[0] * R -
106  -2 * Ahept[2] * T3inverse +
107  -3 * Ahept[3] * T4inverse -
108  -4 * Ahept[4] * pow(T, -5.0);
109  case 1:
110  return Ahept[5] * R -
111  -1 * Ahept[7] * T2inverse;
112  case 2:
113  return Ahept[9] * (-1 * Ahept[7] * T2inverse);
114  case 3:
115  return -2 * Ahept[8] * T3inverse;
116  default:
117  return 0.0;
118  }
119 }
120 
121 double Heptane::I(int j, double ergho, double Gamma)
122 {
123  switch (j) {
124  case 0:
125  return Rho;
126  case 1:
127  return Rho * Rho / 2;
128  case 2:
129  return pow(Rho, 5.0)/ 5;
130  case 3:
131  return 1 / Gamma - (Gamma * Rho * Rho + 2) * ergho / (2 * Gamma);
132  default:
133  return 0.0;
134  }
135 }
136 
137 double Heptane::H(int i, double egrho)
138 {
139  if (i < 2) {
140  return pow(Rho,i+2);
141  } else if (i == 2) {
142  return pow(Rho,6.0);
143  } else if (i == 3) {
144  return pow(Rho,3) * (1 + Gamma * Rho * Rho) * egrho;
145  } else {
146  return 0;
147  }
148 }
149 
150 double Heptane::up()
151 {
152  double Tinverse = 1.0/T;
153  double T2inverse = pow(T, -2);
154  double T3inverse = pow(T, -3);
155  double T4inverse = pow(T, -4);
156  double egrho = exp(-Gamma*Rho*Rho);
157 
158  double sum = 0.0;
159  int i;
160  for (i=1; i<=5; i++) {
161  sum += G[i]*(pow(T,i) - pow(To,i))/double(i);
162  }
163  sum += G[0]*log(T/To);
164  for (i=0; i<=6; i++) {
165  sum += (C(i, Tinverse, T2inverse, T3inverse, T4inverse) - T*Cprime(i,T2inverse, T3inverse, T4inverse))*I(i,egrho, Gamma);
166  }
167  sum += u0;
168  return sum + m_energy_offset;
169 }
170 
171 double Heptane::sp()
172 {
173  double T2inverse = pow(T, -2);
174  double T3inverse = pow(T, -3);
175  double T4inverse = pow(T, -4);
176  double egrho = exp(-Gamma*Rho*Rho);
177 
178  double sum = 0.0;
179  for (int i=2; i<=5; i++) {
180  sum += G[i]*(pow(T,i-1) - pow(To,i-1))/double(i-1);
181  }
182  sum += G[1]*log(T/To);
183  sum -= G[0]*(1.0/T - 1.0/To);
184  for (int i=0; i<=6; i++) {
185  sum -= Cprime(i,T2inverse, T3inverse, T4inverse)*I(i,egrho, Gamma);
186  }
187  sum += s0 - R*log(Rho);
188  return sum + m_entropy_offset;
189 }
190 
191 double Heptane::Pp()
192 {
193  double Tinverse = pow(T,-1);
194  double T2inverse = pow(T, -2);
195  double T3inverse = pow(T, -3);
196  double T4inverse = pow(T, -4);
197  double egrho = exp(-Gamma*Rho*Rho);
198 
199  double P = Rho*R*T;
200  for (int i=0; i<=3; i++) {
201  P += C(i,Tinverse, T2inverse, T3inverse, T4inverse)*H(i,egrho);
202  }
203  return P;
204 }
205 
206 double Heptane::Psat()
207 {
208  double log, sum=0;
209  if ((T < Tmn) || (T > Tc)) {
210  throw CanteraError("Heptane::Psat",
211  "Temperature out of range. T = {}", T);
212  }
213  for (int i=1; i<=8; i++) {
214  sum += F[i-1] * pow((T/Tp -1),double(i-1));
215  }
216 
217  log = ((Tc/T)-1)*sum;
218  return exp(log)*Pc;
219 }
220 
221 double Heptane::ldens()
222 {
223  double xx=1-(T/Tc), sum=0;
224  if ((T < Tmn) || (T > Tc)) {
225  throw CanteraError("Heptane::ldens",
226  "Temperature out of range. T = {}", T);
227  }
228  for (int i=1; i<=6; i++) {
229  sum+=D[i-1]*pow(xx,double(i-1)/3.0);
230  }
231 
232  return sum;
233 }
234 
235 // The following functions allow users to get the properties of Heptane that
236 // are not dependent on the state
237 
238 double Heptane::Tcrit()
239 {
240  return Tc;
241 }
242 double Heptane::Pcrit()
243 {
244  return Pc;
245 }
246 double Heptane::Vcrit()
247 {
248  return 1.0/Roc;
249 }
250 double Heptane::Tmin()
251 {
252  return Tmn;
253 }
254 double Heptane::Tmax()
255 {
256  return Tmx;
257 }
258 double Heptane::MolWt()
259 {
260  return M;
261 }
262 }
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264
Contains declarations for string manipulation functions within Cantera.