Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RedlichKwong.cpp
Go to the documentation of this file.
1 //! @file RedlichKwong.cpp
2 #include "RedlichKwong.h"
3 
4 namespace tpx
5 {
6 double RedlichKwong::up()
7 {
8  return -Pp()/Rho + hresid() + m_energy_offset;
9 }
10 
11 double RedlichKwong::hresid()
12 {
13  double hh = m_b * (Rho/m_mw);
14  double hresid_mol_RT = z() - 1.0
15  - (1.5*m_a/(m_b*8314.3*T*sqrt(T)))*log(1.0 + hh);
16  return 8314.3*T*hresid_mol_RT/m_mw;
17 }
18 
19 double RedlichKwong::sresid()
20 {
21  double hh = m_b * (Rho/m_mw);
22  double sresid_mol_R = log(z()*(1.0 - hh))
23  - (0.5*m_a/(m_b*8314.3*T*sqrt(T)))*log(1.0 + hh);
24  return 8314.3*sresid_mol_R/m_mw;
25 }
26 
27 double RedlichKwong::sp()
28 {
29  const double Pref = 101325.0;
30  double rgas = 8314.3/m_mw;
31  double sr = sresid();
32  double p = Pp();
33  return rgas*(log(Pref/p)) + sr + m_entropy_offset;
34 }
35 
36 double RedlichKwong::z()
37 {
38  return Pp()*m_mw/(Rho*8314.3*T);
39 }
40 
41 double RedlichKwong::Pp()
42 {
43  double R = 8314.3;
44  double V = m_mw/Rho;
45  return R*T/(V - m_b) - m_a/(sqrt(T)*V*(V+m_b));
46 }
47 
48 double RedlichKwong::Psat()
49 {
50  double tt = m_tcrit/T;
51  double lpr = -0.8734*tt*tt - 3.4522*tt + 4.2918;
52  return m_pcrit*exp(lpr);
53 }
54 
55 double RedlichKwong::ldens()
56 {
57  double c;
58  int i;
59  double sqt = sqrt(T);
60  double v = m_b, vnew;
61  double pp = Psat();
62  double Rhsave = Rho;
63  for (i = 0; i < 50; i++) {
64  c = m_b*m_b + m_b*GasConstant*T/pp - m_a/(pp*sqt);
65  vnew = (1.0/c)*(v*v*v - GasConstant*T*v*v/pp - m_a*m_b/(pp*sqt));
66  v = vnew;
67  }
68  Rho = Rhsave;
69  return m_mw/vnew;
70 }
71 
72 }