Cantera
2.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
include
cantera
thermo
WaterSSTP.h
Go to the documentation of this file.
1
/**
2
* @file WaterSSTP.h
3
* Declares a %ThermoPhase class consisting of pure water (see \ref thermoprops
4
* and class \link Cantera::WaterSSTP WaterSSTP\endlink).
5
*/
6
/*
7
* Copyright (2006) Sandia Corporation. Under the terms of
8
* Contract DE-AC04-94AL85000 with Sandia Corporation, the
9
* U.S. Government retains certain rights in this software.
10
*/
11
#ifndef CT_WATERSSTP_H
12
#define CT_WATERSSTP_H
13
14
#include "
SingleSpeciesTP.h
"
15
16
17
namespace
Cantera
18
{
19
20
class
WaterPropsIAPWS;
21
class
WaterProps;
22
//! Class for single-component water. This is designed to cover just the
23
//! liquid part of water.
24
/*!
25
* The reference is W. Wagner, A. Prub, "The IAPWS Formulation 1995 for the Thermodynamic
26
* Properties of Ordinary Water Substance for General and Scientific Use,"
27
* J. Phys. Chem. Ref. Dat, 31, 387, 2002.
28
*
29
* <HR>
30
* <H2> Specification of Species Standard %State Properties </H2>
31
* <HR>
32
*
33
* The offsets used in the steam tables are different than NIST's.
34
* They assume u_liq(TP) = 0.0, s_liq(TP) = 0.0, where TP is the
35
* triple point conditions:
36
*
37
* - u(273.16, rho) = 0.0
38
* - s(273.16, rho) = 0.0
39
* - psat(273.16) = 611.655 Pascal
40
* - rho(273.16, psat) = 999.793 kg m-3
41
*
42
* These "steam table" assumptions are used by the WaterPropsIAPWS class.
43
* Therefore, offsets must be calculated to make the thermodynamic
44
* properties calculated within this class to be consistent with
45
* thermo properties within Cantera.
46
*
47
* The thermodynamic base state for water is set to the NIST basis here
48
* by specifying constants, #EW_Offset and #SW_Offset, one for energy
49
* quantities and one for entropy quantities. The offsets are
50
* specified so that the following properties hold:
51
*
52
* - Delta_Hfo_idealgas(298.15) = -241.826 kJ/gmol
53
* - So_idealgas(298.15, 1bar) = 188.835 J/gmolK
54
*
55
* ref -> (http://webbook.nist.gov)
56
*
57
* The "o" here refers to a hypothetical ideal gas state. The way
58
* we achieve this in practice is to evaluate at a very low pressure
59
* and then use the theoretical ideal gas results to scale up to
60
* higher pressures:
61
*
62
* Ho(1bar) = H(P0)
63
*
64
* So(1bar) = S(P0) + RT ln(1bar/P0)
65
*
66
* <HR>
67
* <H2> %Application within %Kinetics Managers </H2>
68
* <HR>
69
*
70
* This is unimplemented.
71
*
72
* <HR>
73
* <H2> Instantiation of the Class </H2>
74
* <HR>
75
*
76
* The constructor for this phase is NOT located in the default ThermoFactory
77
* for %Cantera. However, a new %WaterSSTP object may be created by
78
* the following code snippets, combined with an XML file given in the
79
* XML example section.
80
*
81
* @code
82
* WaterSSTP *w = new WaterSSTP("waterSSTPphase.xml","");
83
* @endcode
84
*
85
* or
86
*
87
* @code
88
* char iFile[80], file_ID[80];
89
* strcpy(iFile, "waterSSTPphase.xml");
90
* sprintf(file_ID,"%s#water", iFile);
91
* XML_Node *xm = get_XML_NameID("phase", file_ID, 0);
92
* WaterSSTP *w = new WaterSSTP(*xm);
93
* @endcode
94
*
95
* or by the following call to importPhase():
96
*
97
* @code
98
* char iFile[80], file_ID[80];
99
* strcpy(iFile, "waterSSTPphase.xml");
100
* sprintf(file_ID,"%s#water", iFile);
101
* XML_Node *xm = get_XML_NameID("phase", file_ID, 0);
102
* WaterSSTP water;
103
* importPhase(*xm, &water);
104
* @endcode
105
*
106
* <HR>
107
* <H2> XML Example </H2>
108
* <HR>
109
*
110
* An example of an XML Element named phase setting up a WaterSSTP object with
111
* id "water" is given below.
112
*
113
* @verbatim
114
<!-- phase water -->
115
<phase dim="3" id="water">
116
<elementArray datasrc="elements.xml">O H </elementArray>
117
<speciesArray datasrc="#species_data">H2O</speciesArray>
118
<state>
119
<temperature units="K">300.0</temperature>
120
<pressure units="Pa">101325.0</pressure>
121
</state>
122
<thermo model="PureLiquidWater"/>
123
<kinetics model="none"/>
124
</phase>
125
@endverbatim
126
*
127
* Note the model "PureLiquidWater" indicates the usage of the WaterSSTP object.
128
*
129
* @ingroup thermoprops
130
*
131
*/
132
class
WaterSSTP
:
public
SingleSpeciesTP
133
{
134
135
public
:
136
137
//! Base constructor
138
WaterSSTP
();
139
140
//! Copy constructor
141
WaterSSTP
(
const
WaterSSTP
&);
142
143
//! Assignment operator
144
WaterSSTP
&
operator=
(
const
WaterSSTP
&);
145
146
//! Full constructor for a water phase
147
/*!
148
* @param inputFile String name of the input file
149
* @param id string id of the phase name
150
*/
151
WaterSSTP
(std::string inputFile, std::string
id
=
""
);
152
153
//! Full constructor for a water phase
154
/*!
155
* @param phaseRef XML node referencing the water phase.
156
* @param id string id of the phase name
157
*/
158
WaterSSTP
(
XML_Node
& phaseRef, std::string
id
=
""
);
159
160
//! Destructor
161
virtual
~WaterSSTP
();
162
163
//! Duplicator from a ThermoPhase object
164
ThermoPhase
*
duplMyselfAsThermoPhase
()
const
;
165
166
/**
167
*
168
* @name Utilities
169
* @{
170
*/
171
virtual
int
eosType
()
const
{
172
return
-1;
173
}
174
175
/**
176
* @}
177
* @name Molar Thermodynamic Properties of the Solution --------------
178
* @{
179
*/
180
181
virtual
doublereal
cv_mole
()
const
;
182
183
//@}
184
/// @name Mechanical Equation of State Properties ---------------------
185
//@{
186
187
virtual
doublereal
pressure
()
const
;
188
virtual
void
setPressure
(doublereal p);
189
190
//! Returns the isothermal compressibility. Units: 1/Pa.
191
/*!
192
* The isothermal compressibility is defined as
193
* \f[
194
* \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
195
* \f]
196
* or
197
* \f[
198
* \kappa_T = \frac{1}{\rho}\left(\frac{\partial \rho}{\partial P}\right)_T
199
* \f]
200
*/
201
virtual
doublereal
isothermalCompressibility
()
const
;
202
203
//! Return the volumetric thermal expansion coefficient. Units: 1/K.
204
/*!
205
* The thermal expansion coefficient is defined as
206
* \f[
207
* \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
208
* \f]
209
*/
210
virtual
doublereal
thermalExpansionCoeff
()
const
;
211
212
//! Return the derivative of the volumetric thermal expansion coefficient. Units: 1/K2.
213
/*!
214
* The thermal expansion coefficient is defined as
215
* \f[
216
* \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
217
* \f]
218
*/
219
virtual
doublereal
dthermalExpansionCoeffdT
()
const
;
220
221
/**
222
* @}
223
* @name Potential Energy
224
* @{
225
*/
226
227
/**
228
* @}
229
* @name Activities, Standard States, and Activity Concentrations
230
* @{
231
*/
232
233
//@}
234
/// @name Partial Molar Properties of the Solution -----------------
235
//@{
236
237
238
//@}
239
/// @name Properties of the Standard State of the Species
240
// in the Solution --
241
//@{
242
243
244
//! Get the gibbs function for the species
245
//! standard states at the current T and P of the solution.
246
/*!
247
* @param gss Vector of length m_kk, which on return
248
* will contain the
249
* standard state gibbs function for species <I>k</I>.
250
*/
251
virtual
void
getStandardChemPotentials
(doublereal* gss)
const
;
252
253
//!Get the nondimensional gibbs function for the species
254
//! standard states at the current T and P of the solution.
255
/*!
256
* @param grt Vector of length m_kk, which on return
257
* will contain the nondimensional
258
* standard state gibbs function for species <I>k</I>
259
*/
260
virtual
void
getGibbs_RT
(doublereal* grt)
const
;
261
262
//! Get the array of nondimensional Enthalpy functions for the standard state species
263
//! at the current <I>T</I> and <I>P</I> of the solution.
264
/*!
265
*
266
* @param hrt Vector of length m_kk, which on return
267
* will contain the nondimensional
268
* standard state enthalpy of species <I>k</I>
269
*/
270
void
getEnthalpy_RT
(doublereal* hrt)
const
;
271
272
273
//! Get the nondimensional Entropies for the species
274
//! standard states at the current T and P of the solution.
275
/*!
276
* @param sr Vector of length m_kk, which on return
277
* will contain the nondimensional
278
* standard state entropy for species<I>k</I>
279
*/
280
void
getEntropy_R
(doublereal* sr)
const
;
281
282
//! Get the nondimensional heat capacity at constant pressure
283
//! function for the species standard states at the current T and P of the solution.
284
/*!
285
*
286
* @param cpr Vector of length m_kk, which on return
287
* will contain the nondimensional
288
* constant pressure heat capacity for species <I>k</I>
289
*/
290
virtual
void
getCp_R
(doublereal* cpr)
const
;
291
292
//! Returns the vector of nondimensional
293
//! internal Energies of the standard state at the current
294
//! temperature and pressure of the solution for each species.
295
/*!
296
*
297
* @param urt Output vector of standard state nondimensional internal energies.
298
* Length: m_kk.
299
*/
300
virtual
void
getIntEnergy_RT
(doublereal* urt)
const
;
301
302
//@}
303
//! @name Thermodynamic Values for the Species Reference State
304
/*!
305
* All functions in this group need to be overrided, because
306
* the m_spthermo SpeciesThermo function is not adequate for
307
* the real equation of state.
308
*
309
*/
310
//@{
311
312
//! Returns the vector of nondimensional
313
//! enthalpies of the reference state at the current temperature
314
//! of the solution and the reference pressure for the species.
315
/*!
316
* @param hrt Output vector containing the nondimensional reference state enthalpies
317
* Length: m_kk.
318
*/
319
virtual
void
getEnthalpy_RT_ref
(doublereal* hrt)
const
;
320
321
/*!
322
* Returns the vector of nondimensional
323
* enthalpies of the reference state at the current temperature
324
* of the solution and the reference pressure for the species.
325
*
326
* @param grt Output vector containing the nondimensional reference state
327
* Gibbs Free energies. Length: m_kk.
328
*/
329
virtual
void
getGibbs_RT_ref
(doublereal* grt)
const
;
330
331
332
/*!
333
* Returns the vector of the
334
* gibbs function of the reference state at the current temperature
335
* of the solution and the reference pressure for the species.
336
* units = J/kmol
337
*
338
* @param g Output vector containing the reference state
339
* Gibbs Free energies. Length: m_kk. Units: J/kmol.
340
*/
341
virtual
void
getGibbs_ref
(doublereal* g)
const
;
342
343
/*!
344
* Returns the vector of nondimensional
345
* entropies of the reference state at the current temperature
346
* of the solution and the reference pressure for each species.
347
*
348
* @param er Output vector containing the nondimensional reference state
349
* entropies. Length: m_kk.
350
*/
351
virtual
void
getEntropy_R_ref
(doublereal* er)
const
;
352
353
/*!
354
* Returns the vector of nondimensional
355
* constant pressure heat capacities of the reference state
356
* at the current temperature of the solution
357
* and reference pressure for each species.
358
*
359
* @param cprt Output vector of nondimensional reference state
360
* heat capacities at constant pressure for the species.
361
* Length: m_kk
362
*/
363
virtual
void
getCp_R_ref
(doublereal* cprt)
const
;
364
365
//! Get the molar volumes of the species reference states at the current
366
//! <I>T</I> and <I>P_ref</I> of the solution.
367
/*!
368
* units = m^3 / kmol
369
*
370
* @param vol Output vector containing the standard state volumes.
371
* Length: m_kk.
372
*/
373
virtual
void
getStandardVolumes_ref
(doublereal* vol)
const
;
374
375
/// critical temperature
376
virtual
doublereal
critTemperature
()
const
;
377
378
/// critical pressure
379
virtual
doublereal
critPressure
()
const
;
380
381
/// critical density
382
virtual
doublereal
critDensity
()
const
;
383
384
/// saturation temperature
385
//virtual doublereal satTemperature(doublereal p) const;
386
387
388
389
/// saturation pressure
390
/*!
391
* @param t Temperature (kelvin)
392
*/
393
virtual
doublereal
satPressure
(doublereal t)
const
;
394
395
//! Return the fraction of vapor at the current conditions
396
/*!
397
* Below Tcrit, this routine will always return 0, by definition
398
* of the functionality of the routine. Above Tcrit, we query
399
* the density to toggle between 0 and 1.
400
*/
401
virtual
doublereal
vaporFraction
()
const
;
402
403
//! Set the temperature of the phase
404
/*!
405
* The density and composition of the phase is constant during this
406
* operator.
407
*
408
* @param temp Temperature (Kelvin)
409
*/
410
virtual
void
setTemperature
(
const
doublereal temp);
411
412
//! Set the density of the phase
413
/*!
414
* The temperature and composition of the phase is constant during this
415
* operator.
416
*
417
* @param dens value of the density in kg m-3
418
*/
419
virtual
void
setDensity
(
const
doublereal dens);
420
421
422
//! Initialization of a pure water phase using an
423
//! xml file.
424
/*!
425
* This routine is a precursor to constructPhaseXML(XML_Node*)
426
* routine, which does most of the work.
427
*
428
* @param inputFile String name of the file.
429
*
430
* @param id Optional parameter identifying the name of the
431
* phase. If none is given, the first XML
432
* phase element will be used.
433
*/
434
void
constructPhaseFile
(std::string inputFile, std::string
id
);
435
436
437
//! Initialization of a pure water phase using an xml file.
438
/*!
439
* This calls importPhase() to do the work.
440
*
441
* @param phaseNode XML file containing the description of the
442
* phase
443
*
444
* @param id Optional parameter identifying the name of the
445
* phase. If none is given, the first XML
446
* phase element will be used.
447
*/
448
void
constructPhaseXML
(
XML_Node
& phaseNode, std::string
id
);
449
450
//!Import and initialize a ThermoPhase object using an XML tree.
451
/*!
452
* @internal
453
*
454
* Here we read extra information about the XML description
455
* of a phase. Regular information about elements and species
456
* and their reference state thermodynamic information
457
* have already been read at this point.
458
* For example, we do not need to call this function for
459
* ideal gas equations of state. This function is called from importPhase()
460
* after the elements and the species are initialized with
461
* default ideal solution level data.
462
*
463
* The default implementation in ThermoPhase calls the
464
* virtual function initThermo() and then sets the "state" of the
465
* phase by looking for an XML element named "state", and then
466
* interpreting its contents by calling the virtual function
467
* setStateFromXML().
468
*
469
* @param phaseNode This object must be the phase node of a
470
* complete XML tree
471
* description of the phase, including all of the
472
* species data. In other words while "phase" must
473
* point to an XML phase object, it must have
474
* sibling nodes "speciesData" that describe
475
* the species in the phase.
476
* @param id ID of the phase. If nonnull, a check is done
477
* to see if phaseNode is pointing to the phase
478
* with the correct id.
479
*/
480
virtual
void
initThermoXML
(
XML_Node
& phaseNode, std::string
id
);
481
482
//! Initialize the ThermoPhase object after all species have been set up
483
/*!
484
* @internal Initialize.
485
*
486
* This method is provided to allow
487
* subclasses to perform any initialization required after all
488
* species have been added. For example, it might be used to
489
* resize internal work arrays that must have an entry for
490
* each species. The base class implementation does nothing,
491
* and subclasses that do not require initialization do not
492
* need to overload this method. When importing a CTML phase
493
* description, this method is called from ThermoPhase::initThermoXML(),
494
* which is called from importPhase(),
495
* just prior to returning from function importPhase().
496
*
497
* @see importCTML.cpp
498
*/
499
virtual
void
initThermo
();
500
501
//! Set equation of state parameter values from XML entries.
502
/*!
503
*
504
* This method is called by function importPhase() in
505
* file importCTML.cpp when processing a phase definition in
506
* an input file. It should be overloaded in subclasses to set
507
* any parameters that are specific to that particular phase
508
* model. Note, this method is called before the phase is
509
* initialized with elements and/or species.
510
*
511
* @param eosdata An XML_Node object corresponding to
512
* the "thermo" entry for this phase in the input file.
513
*/
514
virtual
void
setParametersFromXML
(
const
XML_Node
& eosdata);
515
516
//! Get a pointer to a changeable WaterPropsIAPWS object
517
WaterPropsIAPWS
*
getWater
() {
518
return
m_sub
;
519
}
520
521
//! Get a pointer to a changeable WaterPropsIAPWS object
522
WaterProps
*
getWaterProps
() {
523
return
m_waterProps
;
524
}
525
526
527
protected
:
528
529
/**
530
* @internal
531
* This internal routine must be overwritten because
532
* it is not applicable.
533
*/
534
void
_updateThermo
()
const
;
535
536
private
:
537
//! Pointer to the WaterPropsIAPWS that calculates the real properties
538
//! of water.
539
mutable
WaterPropsIAPWS
*
m_sub
;
540
541
//! Pointer to the WaterProps object
542
/*!
543
* This class is used to house several approximation
544
* routines for properties of water.
545
*
546
* This object owns m_waterProps, and the WaterPropsIAPWS object used by
547
* WaterProps is m_sub, which is defined above.
548
*/
549
WaterProps
*
m_waterProps
;
550
551
//! Molecular weight of Water -> Cantera assumption
552
doublereal
m_mw
;
553
554
//! Offset constants used to obtain consistency with the NIST database.
555
/*!
556
* This is added to all internal energy and enthalpy results.
557
* units = J kmol-1.
558
*/
559
doublereal
EW_Offset
;
560
561
//! Offset constant used to obtain consistency with NIST convention.
562
/*!
563
* This is added to all internal entropy results.
564
* units = J kmol-1 K-1.
565
*/
566
doublereal
SW_Offset
;
567
568
//! Boolean is true if object has been properly initialized for calculation
569
bool
m_ready
;
570
571
/**
572
* Since this phase represents a liquid phase, it's an error to
573
* return a gas-phase answer. However, if the below is true, then
574
* a gas-phase answer is allowed. This is used to check the thermodynamic
575
* consistency with ideal-gas thermo functions for example.
576
*/
577
bool
m_allowGasPhase
;
578
};
579
580
}
581
582
#endif
583
584
585
Generated by
1.8.2