Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  * Copyright (2006) Sandia Corporation. Under the terms of
11  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
12  * U.S. Government retains certain rights in this software.
13  */
14 #ifndef WATERPROPSIAPWSPHI_H
15 #define WATERPROPSIAPWSPHI_H
16 
17 #include "cantera/base/config.h"
18 
19 namespace Cantera
20 {
21 
22 //! Low level class for the real description of water.
23 /*!
24  * The reference is W. Wagner, A. Prub, "The IAPWS Formulation 1995 for the
25  * Thermodynamic Properties of Ordinary Water Substance for General and
26  * Scientific Use," J. Phys. Chem. Ref. Dat, 31, 387, 2002.
27  *
28  * Units Note: This class works with reduced units exclusively.
29  */
31 {
32 public:
33  //! Base constructor
35 
36  //! Calculate the Phi function, which is the base function
37  /*!
38  * The phi function is basically the helmholtz free energy Eqn. (6.4) All
39  * internal polynomials are recalculated.
40  *
41  * @param tau Dimensionless temperature = T_c/T
42  * @param delta Dimensionless density = delta = rho / Rho_c
43  */
44  doublereal phi(doublereal tau, doublereal delta);
45 
46  //! Calculate derivative of phi wrt delta
47  /*!
48  * @param tau Dimensionless temperature = T_c/T
49  * @param delta Dimensionless density = delta = rho / Rho_c
50  */
51  doublereal phi_d(doublereal tau, doublereal delta);
52 
53  //! 2nd derivative of phi wrt delta
54  /*!
55  * @param tau Dimensionless temperature = T_c/T
56  * @param delta Dimensionless density = delta = rho / Rho_c
57  */
58  doublereal phi_dd(doublereal tau, doublereal delta);
59 
60  //! First derivative of phi wrt tau
61  /*!
62  * @param tau Dimensionless temperature = T_c/T
63  * @param delta Dimensionless density = delta = rho / Rho_c
64  */
65  doublereal phi_t(doublereal tau, doublereal delta);
66 
67  //! Second derivative of phi wrt tau
68  /*!
69  * @param tau Dimensionless temperature = T_c/T
70  * @param delta Dimensionless density = delta = rho / Rho_c
71  */
72  doublereal phi_tt(doublereal tau, doublereal delta);
73 
74  //! Internal check # 1
75  void check1();
76 
77  //! Internal check # 2
78  void check2();
79 
80  //! Calculate the dimensionless pressure at tau and delta;
81  /*!
82  * pM/(rhoRT) = delta * phi_d() = 1.0 + delta phiR_d()
83  *
84  * @param tau Dimensionless temperature = T_c/T
85  * @param delta Dimensionless density = delta = rho / Rho_c
86  *
87  * note: this is done so much, we have a separate routine.
88  */
89  doublereal pressureM_rhoRT(doublereal tau, doublereal delta);
90 
91  //! Dimensionless derivative of p wrt rho at constant T
92  /*!
93  * dp/drho * 1/RT = (2. delta phi_d() + delta**2 phi_dd())
94  * (1.0 + 2. delta phiR_d() + delta**2 phiR_dd())
95  *
96  * @param tau Dimensionless temperature = T_c/T
97  * @param delta Dimensionless density = delta = rho / Rho_c
98  */
99  doublereal dimdpdrho(doublereal tau, doublereal delta);
100 
101  //! Dimensionless derivative of p wrt T at constant rho
102  /*!
103  * dp/dT * M/(Rho R) = (1.0 + delta phiR_d()
104  * - tau delta (phiR_dt())
105  *
106  * @param tau Dimensionless temperature = T_c/T
107  * @param delta Dimensionless density = delta = rho / Rho_c
108  */
109  doublereal dimdpdT(doublereal tau, doublereal delta);
110 
111  /**
112  * This function computes the reduced density, given the reduced pressure
113  * and the reduced temperature, tau. It takes an initial guess,
114  * deltaGuess. DeltaGuess is important as this is a multivalued function
115  * below the critical point.
116  *
117  * @param p_red Value of the dimensionless pressure
118  * @param tau Dimensionless temperature = T_c/T
119  * @param deltaGuess Initial guess for the dimensionless density
120  *
121  * @return
122  * Returns the dimensionless density.
123  */
124  doublereal dfind(doublereal p_red, doublereal tau, doublereal deltaGuess);
125 
126  //! Calculate the dimensionless Gibbs free energy
127  doublereal gibbs_RT() const;
128 
129  //! Calculate the dimensionless enthalpy, h/RT
130  doublereal enthalpy_RT() const;
131 
132  //! Calculate the dimensionless entropy, s/R
133  doublereal entropy_R() const;
134 
135  //! Calculate the dimensionless internal energy, u/RT
136  doublereal intEnergy_RT() const;
137 
138  //! Calculate the dimensionless constant volume heat capacity, Cv/R
139  doublereal cv_R() const;
140 
141  //! Calculate the dimensionless constant pressure heat capacity, Cv/R
142  doublereal cp_R() const;
143 
144  //! Calculates internal polynomials in tau and delta.
145  /*!
146  * This routine is used to store the internal state of tau and delta
147  * for later use by the other routines in the class.
148  *
149  * @param tau Dimensionless temperature = T_c/T
150  * @param delta Dimensionless density = delta = rho / Rho_c
151  */
152  void tdpolycalc(doublereal tau, doublereal delta);
153 
154  /*!
155  * Calculate Equation 6.6 for phiR, the residual part of the
156  * dimensionless Helmholtz free energy.
157  */
158  doublereal phiR() const;
159 
160 private:
161  //! Calculate Equation 6.5 for phi0, the ideal gas part of the
162  //! dimensionless Helmholtz free energy.
163  doublereal phi0() const;
164  //! Calculate d_phiR_d(delta), the first derivative of phiR wrt delta
165  doublereal phiR_d() const;
166  //! Calculate d_phi0_d(delta), the first derivative of phi0 wrt delta
167  doublereal phi0_d() const;
168  //! Calculate d2_phiR_dd(delta), the second derivative of phiR wrt delta
169  doublereal phiR_dd() const;
170  //! Calculate d2_phi0_dd(delta), the second derivative of phi0 wrt delta
171  doublereal phi0_dd() const;
172  //! Calculate d_phi0/d(tau)
173  doublereal phi0_t() const;
174  //! Calculate Equation 6.6 for dphiRdtau, the derivative residual part of
175  //! the dimensionless Helmholtz free energy wrt temperature
176  doublereal phiR_t() const;
177  //! Calculate Equation 6.6 for dphiRdtau, the second derivative residual
178  //! part of the dimensionless Helmholtz free energy wrt temperature
179  doublereal phiR_tt() const;
180  //! Calculate d2_phi0/dtau2
181  doublereal phi0_tt() const;
182  //! Calculate the mixed derivative d2_phiR/(dtau ddelta)
183  doublereal phiR_dt() const;
184  //! Calculate the mixed derivative d2_phi0/(dtau ddelta)
185  doublereal phi0_dt() const;
186 
187  /**
188  * Calculates all of the functions at a one point and prints out the
189  * result. It's used for conducting the internal check.
190  *
191  * @param tau Dimensionless temperature = T_c/T
192  * @param delta Dimensionless density = delta = rho / Rho_c
193  */
194  void intCheck(doublereal tau, doublereal delta);
195 
196  //! Value of internally calculated polynomials of powers of TAU
197  doublereal TAUp[52];
198 
199  //! Value of internally calculated polynomials of powers of delta
200  doublereal DELTAp[16];
201 
202  //! Last tau that was used to calculate polynomials
203  doublereal TAUsave;
204 
205  //! sqrt of TAU
206  doublereal TAUsqrt;
207 
208  //! Last delta that was used to calculate polynomials
209  doublereal DELTAsave;
210 };
211 
212 } // namespace Cantera
213 #endif
doublereal phi0_dd() const
Calculate d2_phi0_dd(delta), the second derivative of phi0 wrt delta.
doublereal phiR_dt() const
Calculate the mixed derivative d2_phiR/(dtau ddelta)
doublereal phi0_d() const
Calculate d_phi0_d(delta), the first derivative of phi0 wrt delta.
doublereal phi_dd(doublereal tau, doublereal delta)
2nd derivative of phi wrt delta
doublereal gibbs_RT() const
Calculate the dimensionless Gibbs free energy.
doublereal phi0_dt() const
Calculate the mixed derivative d2_phi0/(dtau ddelta)
doublereal entropy_R() const
Calculate the dimensionless entropy, s/R.
void check1()
Internal check # 1.
void intCheck(doublereal tau, doublereal delta)
Calculates all of the functions at a one point and prints out the result.
doublereal dfind(doublereal p_red, doublereal tau, doublereal deltaGuess)
This function computes the reduced density, given the reduced pressure and the reduced temperature...
doublereal TAUsave
Last tau that was used to calculate polynomials.
doublereal DELTAp[16]
Value of internally calculated polynomials of powers of delta.
doublereal phiR_dd() const
Calculate d2_phiR_dd(delta), the second derivative of phiR wrt delta.
doublereal DELTAsave
Last delta that was used to calculate polynomials.
doublereal pressureM_rhoRT(doublereal tau, doublereal delta)
Calculate the dimensionless pressure at tau and delta;.
doublereal phiR_tt() const
Calculate Equation 6.6 for dphiRdtau, the second derivative residual part of the dimensionless Helmho...
doublereal phi0_t() const
Calculate d_phi0/d(tau)
doublereal dimdpdrho(doublereal tau, doublereal delta)
Dimensionless derivative of p wrt rho at constant T.
doublereal phiR_t() const
Calculate Equation 6.6 for dphiRdtau, the derivative residual part of the dimensionless Helmholtz fre...
doublereal phi_tt(doublereal tau, doublereal delta)
Second derivative of phi wrt tau.
doublereal phiR_d() const
Calculate d_phiR_d(delta), the first derivative of phiR wrt delta.
doublereal dimdpdT(doublereal tau, doublereal delta)
Dimensionless derivative of p wrt T at constant rho.
void check2()
Internal check # 2.
WaterPropsIAPWSphi()
Base constructor.
void tdpolycalc(doublereal tau, doublereal delta)
Calculates internal polynomials in tau and delta.
doublereal phi0() const
Calculate Equation 6.5 for phi0, the ideal gas part of the dimensionless Helmholtz free energy...
doublereal phi_t(doublereal tau, doublereal delta)
First derivative of phi wrt tau.
doublereal enthalpy_RT() const
Calculate the dimensionless enthalpy, h/RT.
Low level class for the real description of water.
doublereal TAUsqrt
sqrt of TAU
doublereal cp_R() const
Calculate the dimensionless constant pressure heat capacity, Cv/R.
doublereal cv_R() const
Calculate the dimensionless constant volume heat capacity, Cv/R.
doublereal phi_d(doublereal tau, doublereal delta)
Calculate derivative of phi wrt delta.
doublereal phi0_tt() const
Calculate d2_phi0/dtau2.
doublereal intEnergy_RT() const
Calculate the dimensionless internal energy, u/RT.
doublereal phi(doublereal tau, doublereal delta)
Calculate the Phi function, which is the base function.
doublereal TAUp[52]
Value of internally calculated polynomials of powers of TAU.