Cantera  3.1.0a1
WaterPropsIAPWSphi.h
Go to the documentation of this file.
1 /**
2  * @file WaterPropsIAPWSphi.h
3  * Header for Lowest level of the classes which support a real water model
4  * (see class @link Cantera::WaterPropsIAPWS WaterPropsIAPWS@endlink and class
5  * @link Cantera::WaterPropsIAPWSphi WaterPropsIAPWSphi@endlink).
6  *
7  * This class calculates dimensionless quantities.
8  */
9 
10 // This file is part of Cantera. See License.txt in the top-level directory or
11 // at https://cantera.org/license.txt for license and copyright information.
12 
13 #ifndef WATERPROPSIAPWSPHI_H
14 #define WATERPROPSIAPWSPHI_H
15 
16 #include "cantera/base/config.h"
17 
18 namespace Cantera
19 {
20 
21 //! Low level class for the real description of water.
22 /*!
23  * This is a helper class for WaterSSTP and PDSS_Water and does not constitute
24  * a complete implementation of a thermo phase by itself (see @ref thermoprops
25  * and classes @link Cantera::WaterSSTP WaterSSTP@endlink and
26  * @link Cantera::PDSS_Water PDSS_Water@endlink).
27  *
28  * The reference is Wagner and Pruss @cite wagner2002.
29  *
30  * Units Note: This class works with reduced units exclusively.
31  */
33 {
34 public:
35  //! Base constructor
37 
38  //! Calculate the Phi function, which is the base function
39  /*!
40  * The phi function is basically the Helmholtz free energy Eqn. (6.4) All
41  * internal polynomials are recalculated.
42  *
43  * @param tau Dimensionless temperature = T_c/T
44  * @param delta Dimensionless density = delta = rho / Rho_c
45  */
46  double phi(double tau, double delta);
47 
48  //! Calculate derivative of phi wrt delta
49  /*!
50  * @param tau Dimensionless temperature = T_c/T
51  * @param delta Dimensionless density = delta = rho / Rho_c
52  */
53  double phi_d(double tau, double delta);
54 
55  //! 2nd derivative of phi wrt delta
56  /*!
57  * @param tau Dimensionless temperature = T_c/T
58  * @param delta Dimensionless density = delta = rho / Rho_c
59  */
60  double phi_dd(double tau, double delta);
61 
62  //! First derivative of phi wrt tau
63  /*!
64  * @param tau Dimensionless temperature = T_c/T
65  * @param delta Dimensionless density = delta = rho / Rho_c
66  */
67  double phi_t(double tau, double delta);
68 
69  //! Second derivative of phi wrt tau
70  /*!
71  * @param tau Dimensionless temperature = T_c/T
72  * @param delta Dimensionless density = delta = rho / Rho_c
73  */
74  double phi_tt(double tau, double delta);
75 
76  //! Calculate the dimensionless pressure at tau and delta;
77  /*!
78  * pM/(rhoRT) = delta * phi_d() = 1.0 + delta phiR_d()
79  *
80  * @param tau Dimensionless temperature = T_c/T
81  * @param delta Dimensionless density = delta = rho / Rho_c
82  *
83  * note: this is done so much, we have a separate routine.
84  */
85  double pressureM_rhoRT(double tau, double delta);
86 
87  //! Dimensionless derivative of p wrt rho at constant T
88  /*!
89  * dp/drho * 1/RT = (2. delta phi_d() + delta**2 phi_dd())
90  * (1.0 + 2. delta phiR_d() + delta**2 phiR_dd())
91  *
92  * @param tau Dimensionless temperature = T_c/T
93  * @param delta Dimensionless density = delta = rho / Rho_c
94  */
95  double dimdpdrho(double tau, double delta);
96 
97  //! Dimensionless derivative of p wrt T at constant rho
98  /*!
99  * dp/dT * M/(Rho R) = (1.0 + delta phiR_d()
100  * - tau delta (phiR_dt())
101  *
102  * @param tau Dimensionless temperature = T_c/T
103  * @param delta Dimensionless density = delta = rho / Rho_c
104  */
105  double dimdpdT(double tau, double delta);
106 
107  /**
108  * This function computes the reduced density, given the reduced pressure
109  * and the reduced temperature, tau. It takes an initial guess, deltaGuess.
110  * DeltaGuess is important as this is a multivalued function below the
111  * critical point.
112  *
113  * @param p_red Value of the dimensionless pressure
114  * @param tau Dimensionless temperature = T_c/T
115  * @param deltaGuess Initial guess for the dimensionless density
116  *
117  * @returns the dimensionless density.
118  */
119  double dfind(double p_red, double tau, double deltaGuess);
120 
121  //! Calculate the dimensionless Gibbs free energy
122  double gibbs_RT() const;
123 
124  //! Calculate the dimensionless enthalpy, h/RT
125  double enthalpy_RT() const;
126 
127  //! Calculate the dimensionless entropy, s/R
128  double entropy_R() const;
129 
130  //! Calculate the dimensionless internal energy, u/RT
131  double intEnergy_RT() const;
132 
133  //! Calculate the dimensionless constant volume heat capacity, Cv/R
134  double cv_R() const;
135 
136  //! Calculate the dimensionless constant pressure heat capacity, Cv/R
137  double cp_R() const;
138 
139  //! Calculates internal polynomials in tau and delta.
140  /*!
141  * This routine is used to store the internal state of tau and delta
142  * for later use by the other routines in the class.
143  *
144  * @param tau Dimensionless temperature = T_c/T
145  * @param delta Dimensionless density = delta = rho / Rho_c
146  */
147  void tdpolycalc(double tau, double delta);
148 
149  /**
150  * Calculate Equation 6.6 for phiR, the residual part of the
151  * dimensionless Helmholtz free energy.
152  */
153  double phiR() const;
154 
155 protected:
156  //! Calculate Equation 6.5 for phi0, the ideal gas part of the
157  //! dimensionless Helmholtz free energy.
158  double phi0() const;
159  //! Calculate d_phiR_d(delta), the first derivative of phiR wrt delta
160  double phiR_d() const;
161  //! Calculate d_phi0_d(delta), the first derivative of phi0 wrt delta
162  double phi0_d() const;
163  //! Calculate d2_phiR_dd(delta), the second derivative of phiR wrt delta
164  double phiR_dd() const;
165  //! Calculate d2_phi0_dd(delta), the second derivative of phi0 wrt delta
166  double phi0_dd() const;
167  //! Calculate d_phi0/d(tau)
168  double phi0_t() const;
169  //! Calculate Equation 6.6 for dphiRdtau, the derivative residual part of
170  //! the dimensionless Helmholtz free energy wrt temperature
171  double phiR_t() const;
172  //! Calculate Equation 6.6 for dphiRdtau, the second derivative residual
173  //! part of the dimensionless Helmholtz free energy wrt temperature
174  double phiR_tt() const;
175  //! Calculate d2_phi0/dtau2
176  double phi0_tt() const;
177  //! Calculate the mixed derivative d2_phiR/(dtau ddelta)
178  double phiR_dt() const;
179  //! Calculate the mixed derivative d2_phi0/(dtau ddelta)
180  double phi0_dt() const;
181 
182  //! Value of internally calculated polynomials of powers of TAU
183  double TAUp[52];
184 
185  //! Value of internally calculated polynomials of powers of delta
186  double DELTAp[16];
187 
188  //! Last tau that was used to calculate polynomials
189  double TAUsave = -1.0;
190 
191  //! sqrt of TAU
192  double TAUsqrt = -1.0;
193 
194  //! Last delta that was used to calculate polynomials
195  double DELTAsave = -1.0;
196 };
197 
198 } // namespace Cantera
199 #endif
Low level class for the real description of water.
double phiR_dt() const
Calculate the mixed derivative d2_phiR/(dtau ddelta)
double phi_tt(double tau, double delta)
Second derivative of phi wrt tau.
double phi_dd(double tau, double delta)
2nd derivative of phi wrt delta
double phi0_d() const
Calculate d_phi0_d(delta), the first derivative of phi0 wrt delta.
double phiR_dd() const
Calculate d2_phiR_dd(delta), the second derivative of phiR wrt delta.
double gibbs_RT() const
Calculate the dimensionless Gibbs free energy.
double phi0() const
Calculate Equation 6.5 for phi0, the ideal gas part of the dimensionless Helmholtz free energy.
double TAUp[52]
Value of internally calculated polynomials of powers of TAU.
double phi0_dt() const
Calculate the mixed derivative d2_phi0/(dtau ddelta)
double phi_d(double tau, double delta)
Calculate derivative of phi wrt delta.
double phi0_tt() const
Calculate d2_phi0/dtau2.
double phi0_t() const
Calculate d_phi0/d(tau)
WaterPropsIAPWSphi()
Base constructor.
double DELTAsave
Last delta that was used to calculate polynomials.
double cv_R() const
Calculate the dimensionless constant volume heat capacity, Cv/R.
double intEnergy_RT() const
Calculate the dimensionless internal energy, u/RT.
double TAUsave
Last tau that was used to calculate polynomials.
double phiR_t() const
Calculate Equation 6.6 for dphiRdtau, the derivative residual part of the dimensionless Helmholtz fre...
double enthalpy_RT() const
Calculate the dimensionless enthalpy, h/RT.
double phi(double tau, double delta)
Calculate the Phi function, which is the base function.
double entropy_R() const
Calculate the dimensionless entropy, s/R.
double phi0_dd() const
Calculate d2_phi0_dd(delta), the second derivative of phi0 wrt delta.
double phiR() const
Calculate Equation 6.6 for phiR, the residual part of the dimensionless Helmholtz free energy.
double pressureM_rhoRT(double tau, double delta)
Calculate the dimensionless pressure at tau and delta;.
double dimdpdrho(double tau, double delta)
Dimensionless derivative of p wrt rho at constant T.
double phiR_tt() const
Calculate Equation 6.6 for dphiRdtau, the second derivative residual part of the dimensionless Helmho...
double dfind(double p_red, double tau, double deltaGuess)
This function computes the reduced density, given the reduced pressure and the reduced temperature,...
double dimdpdT(double tau, double delta)
Dimensionless derivative of p wrt T at constant rho.
double cp_R() const
Calculate the dimensionless constant pressure heat capacity, Cv/R.
double DELTAp[16]
Value of internally calculated polynomials of powers of delta.
double phi_t(double tau, double delta)
First derivative of phi wrt tau.
void tdpolycalc(double tau, double delta)
Calculates internal polynomials in tau and delta.
double phiR_d() const
Calculate d_phiR_d(delta), the first derivative of phiR wrt delta.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:564