Cantera  2.3.0
RedlichKwong.cpp
Go to the documentation of this file.
1 //! @file RedlichKwong.cpp
2 
3 // This file is part of Cantera. See License.txt in the top-level directory or
4 // at http://www.cantera.org/license.txt for license and copyright information.
5 
6 #include "RedlichKwong.h"
7 
8 namespace tpx
9 {
11 {
12  return -Pp()/Rho + hresid() + m_energy_offset;
13 }
14 
15 double RedlichKwong::hresid()
16 {
17  double hh = m_b * (Rho/m_mw);
18  double hresid_mol_RT = z() - 1.0
19  - (1.5*m_a/(m_b*8314.3*T*sqrt(T)))*log(1.0 + hh);
20  return 8314.3*T*hresid_mol_RT/m_mw;
21 }
22 
23 double RedlichKwong::sresid()
24 {
25  double hh = m_b * (Rho/m_mw);
26  double sresid_mol_R = log(z()*(1.0 - hh))
27  - (0.5*m_a/(m_b*8314.3*T*sqrt(T)))*log(1.0 + hh);
28  return 8314.3*sresid_mol_R/m_mw;
29 }
30 
32 {
33  const double Pref = 101325.0;
34  double rgas = 8314.3/m_mw;
35  double sr = sresid();
36  double p = Pp();
37  return rgas*(log(Pref/p)) + sr + m_entropy_offset;
38 }
39 
40 double RedlichKwong::z()
41 {
42  return Pp()*m_mw/(Rho*8314.3*T);
43 }
44 
45 double RedlichKwong::Pp()
46 {
47  double R = 8314.3;
48  double V = m_mw/Rho;
49  return R*T/(V - m_b) - m_a/(sqrt(T)*V*(V+m_b));
50 }
51 
53 {
54  double tt = m_tcrit/T;
55  double lpr = -0.8734*tt*tt - 3.4522*tt + 4.2918;
56  return m_pcrit*exp(lpr);
57 }
58 
59 double RedlichKwong::ldens()
60 {
61  double c;
62  int i;
63  double sqt = sqrt(T);
64  double v = m_b, vnew;
65  double pp = Psat();
66  double Rhsave = Rho;
67  for (i = 0; i < 50; i++) {
68  c = m_b*m_b + m_b*GasConstant*T/pp - m_a/(pp*sqt);
69  vnew = (1.0/c)*(v*v*v - GasConstant*T*v*v/pp - m_a*m_b/(pp*sqt));
70  v = vnew;
71  }
72  Rho = Rhsave;
73  return m_mw/vnew;
74 }
75 
76 }
double up()
Internal energy of a single-phase state.
double v()
Specific volume [m^3/kg].
Definition: Sub.h:94
double Psat()
Saturation pressure, Pa.
double sp()
Entropy of a single-phase state.