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