Cantera  2.0
RedlichKwong.cpp
1 // Lee-Kesler equation of state
2 
3 #include "RedlichKwong.h"
4 #include <math.h>
5 
6 namespace tpx
7 {
8 
9 
10 //--------------------------- member functions ------------------
11 
12 double RedlichKwong::up()
13 {
14  double u = -Pp()/Rho + hresid() + m_energy_offset;
15  return u;
16 }
17 
18 double RedlichKwong::hresid()
19 {
20  double hh = m_b * (Rho/m_mw);
21  double hresid_mol_RT = z() - 1.0
22  - (1.5*m_a/(m_b*8314.3*T*sqrt(T)))*log(1.0 + hh);
23  return 8314.3*T*hresid_mol_RT/m_mw;
24 }
25 
26 double RedlichKwong::sresid()
27 {
28  double hh = m_b * (Rho/m_mw);
29  double sresid_mol_R = log(z()*(1.0 - hh))
30  - (0.5*m_a/(m_b*8314.3*T*sqrt(T)))*log(1.0 + hh);
31  double sp = 8314.3*sresid_mol_R/m_mw;
32  return sp;
33 }
34 
35 double RedlichKwong::sp()
36 {
37  const double Pref = 101325.0;
38  double rgas = 8314.3/m_mw;
39  //double ss = rgas*(log(Pref/(Rho*rgas*T)));
40  double sr = sresid();
41  double p = Pp();
42  double s = rgas*(log(Pref/p)) + sr + m_entropy_offset;
43  return s;
44 }
45 
46 double RedlichKwong::z()
47 {
48  return Pp()*m_mw/(Rho*8314.3*T);
49 }
50 
51 
52 double RedlichKwong::Pp()
53 {
54  double R = 8314.3;
55  double V = m_mw/Rho;
56  double pp = R*T/(V - m_b) - m_a/(sqrt(T)*V*(V+m_b));
57  return pp;
58 }
59 
60 double RedlichKwong::Psat()
61 {
62  double tt = m_tcrit/T;
63  double lpr = -0.8734*tt*tt - 3.4522*tt + 4.2918;
64  return m_pcrit*exp(lpr);
65 }
66 
67 double RedlichKwong::ldens()
68 {
69  double c;
70  int i;
71  double sqt = sqrt(T);
72  double v = m_b, vnew;
73  double pp = Psat();
74  double Rhsave = Rho;
75  for (i = 0; i < 50; i++) {
76  c = m_b*m_b + m_b*GasConstant*T/pp - m_a/(pp*sqt);
77  vnew = (1.0/c)*(v*v*v - GasConstant*T*v*v/pp - m_a*m_b/(pp*sqt));
78  v = vnew;
79  }
80  Rho = Rhsave;
81  return m_mw/vnew;
82 }
83 
84 
85 }