Cantera  2.1.2
PDSS.cpp
Go to the documentation of this file.
1 /**
2  * @file PDSS.cpp
3  * Implementation of a pressure dependent standard state
4  * virtual function
5  * (see class \link Cantera::PDSS PDSS\endlink).
6  */
7 /*
8  * Copyright (2006) Sandia Corporation. Under the terms of
9  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
10  * U.S. Government retains certain rights in this software.
11  */
12 #include "cantera/base/ct_defs.h"
13 #include "cantera/base/xml.h"
14 #include "cantera/base/ctml.h"
15 #include "cantera/thermo/PDSS.h"
16 
19 
21 
22 namespace Cantera
23 {
25  m_pdssType(cPDSS_UNDEF),
26  m_temp(-1.0),
27  m_pres(-1.0),
28  m_p0(-1.0),
29  m_minTemp(-1.0),
30  m_maxTemp(10000.0),
31  m_tp(0),
32  m_vpssmgr_ptr(0),
33  m_mw(0.0),
34  m_spindex(npos),
35  m_spthermo(0),
36  m_h0_RT_ptr(0),
37  m_cp0_R_ptr(0),
38  m_s0_R_ptr(0),
39  m_g0_RT_ptr(0),
40  m_V0_ptr(0),
41  m_hss_RT_ptr(0),
42  m_cpss_R_ptr(0),
43  m_sss_R_ptr(0),
44  m_gss_RT_ptr(0),
45  m_Vss_ptr(0)
46 {
47 }
48 
49 PDSS::PDSS(VPStandardStateTP* tp, size_t spindex) :
50  m_pdssType(cPDSS_UNDEF),
51  m_temp(-1.0),
52  m_pres(-1.0),
53  m_p0(-1.0),
54  m_minTemp(-1.0),
55  m_maxTemp(10000.0),
56  m_tp(tp),
57  m_vpssmgr_ptr(0),
58  m_mw(0.0),
59  m_spindex(spindex),
60  m_spthermo(0),
61  m_h0_RT_ptr(0),
62  m_cp0_R_ptr(0),
63  m_s0_R_ptr(0),
64  m_g0_RT_ptr(0),
65  m_V0_ptr(0),
66  m_hss_RT_ptr(0),
67  m_cpss_R_ptr(0),
68  m_sss_R_ptr(0),
69  m_gss_RT_ptr(0),
70  m_Vss_ptr(0)
71 {
72  if (tp) {
73  m_spthermo = &(tp->speciesThermo());
74  }
75  if (tp) {
77  }
78 }
79 
80 PDSS::PDSS(const PDSS& b) :
81  m_pdssType(cPDSS_UNDEF),
82  m_temp(-1.0),
83  m_pres(-1.0),
84  m_p0(-1.0),
85  m_minTemp(-1.0),
86  m_maxTemp(10000.0),
87  m_tp(0),
88  m_vpssmgr_ptr(0),
89  m_mw(b.m_mw),
90  m_spindex(b.m_spindex),
91  m_spthermo(b.m_spthermo),
92  m_h0_RT_ptr(b.m_h0_RT_ptr),
93  m_cp0_R_ptr(b.m_cp0_R_ptr),
94  m_s0_R_ptr(b.m_s0_R_ptr),
95  m_g0_RT_ptr(b.m_g0_RT_ptr),
96  m_V0_ptr(b.m_V0_ptr),
97  m_hss_RT_ptr(b.m_hss_RT_ptr),
98  m_cpss_R_ptr(b.m_cpss_R_ptr),
99  m_sss_R_ptr(b.m_sss_R_ptr),
100  m_gss_RT_ptr(b.m_gss_RT_ptr),
101  m_Vss_ptr(b.m_Vss_ptr)
102 {
103  /*
104  * Use the assignment operator to do the brunt
105  * of the work for the copy constructor.
106  */
107  *this = b;
108 }
109 
111 {
112  if (&b == this) {
113  return *this;
114  }
115 
117  m_temp = b.m_temp;
118  m_pres = b.m_pres;
119  m_p0 = b.m_p0;
120  m_minTemp = b.m_minTemp;
121  m_maxTemp = b.m_maxTemp;
122 
123  // Pointers which are zero, are properly assigned in the
124  // function, initAllPtrs(). which must be called after the
125  // assignment operation.
126 
127  m_tp = 0;
128  m_vpssmgr_ptr = 0;
129  m_mw = b.m_mw;
130  m_spindex = b.m_spindex;
131  m_spthermo = 0;
132  m_cp0_R_ptr = 0;
133  m_h0_RT_ptr = 0;
134  m_s0_R_ptr = 0;
135  m_g0_RT_ptr = 0;
136  m_V0_ptr = 0;
137  m_cpss_R_ptr = 0;
138  m_hss_RT_ptr = 0;
139  m_sss_R_ptr = 0;
140  m_gss_RT_ptr = 0;
141  m_Vss_ptr = 0;
142 
143  // Here we just fill these in so that local copies within the VPSS object work.
144  m_tp = b.m_tp;
151  m_V0_ptr = b.m_V0_ptr;
156  m_Vss_ptr = b.m_Vss_ptr;
157 
158  return *this;
159 }
160 
162 {
163 }
164 
166 {
167  return new PDSS(*this);
168 }
169 
171 {
172  return m_pdssType;
173 }
174 
175 void PDSS::initThermoXML(const XML_Node& phaseNode, const std::string& id)
176 {
177  AssertThrow(m_tp != 0, "PDSS::initThermoXML()");
181 }
182 
184 {
185  AssertThrow(m_tp != 0, "PDSS::initThermo()");
188  initPtrs();
190 }
191 
193  SpeciesThermo* spthermo)
194 {
195  m_tp = tp;
196  m_vpssmgr_ptr = vpssmgr_ptr;
197  m_spthermo = spthermo;
198  initPtrs();
199 }
200 
202 {
203  AssertThrow(m_vpssmgr_ptr->mPDSS_h0_RT.size() != 0, "PDSS::initPtrs()");
209 
215 }
216 
217 doublereal PDSS::enthalpy_mole() const
218 {
219  err("enthalpy_mole()");
220  return 0.0;
221 }
222 
223 doublereal PDSS::enthalpy_RT() const
224 {
225  double RT = GasConstant * m_temp;
226  return enthalpy_mole()/RT;
227 }
228 
229 doublereal PDSS::intEnergy_mole() const
230 {
231  err("intEnergy_mole()");
232  return 0.0;
233 }
234 
235 doublereal PDSS::entropy_mole() const
236 {
237  err("entropy_mole()");
238  return 0.0;
239 }
240 
241 doublereal PDSS::entropy_R() const
242 {
243  return entropy_mole()/GasConstant;
244 }
245 
246 doublereal PDSS::gibbs_mole() const
247 {
248  err("gibbs_mole()");
249  return 0.0;
250 }
251 
252 doublereal PDSS::gibbs_RT() const
253 {
254  double RT = GasConstant * m_temp;
255  return gibbs_mole()/RT;
256 }
257 
258 doublereal PDSS::cp_mole() const
259 {
260  err("cp_mole()");
261  return 0.0;
262 }
263 
264 doublereal PDSS::cp_R() const
265 {
266  return cp_mole()/GasConstant;
267 }
268 
269 doublereal PDSS::molarVolume() const
270 {
271  err("molarVolume()");
272  return 0.0;
273 }
274 
275 doublereal PDSS::density() const
276 {
277  err("density()");
278  return 0.0;
279 }
280 
281 doublereal PDSS::cv_mole() const
282 {
283  err("cv_mole()");
284  return 0.0;
285 }
286 
287 doublereal PDSS::gibbs_RT_ref() const
288 {
289  err("gibbs_RT_ref()");
290  return 0.0;
291 }
292 
293 doublereal PDSS::enthalpy_RT_ref() const
294 {
295  err("enthalpy_RT_ref()");
296  return 0.0;
297 }
298 
299 doublereal PDSS::entropy_R_ref() const
300 {
301  err("entropy_RT_ref()");
302  return 0.0;
303 }
304 
305 doublereal PDSS::cp_R_ref() const
306 {
307  err("entropy_RT_ref()");
308  return 0.0;
309 }
310 
311 doublereal PDSS::molarVolume_ref() const
312 {
313  err("molarVolume_ref()");
314  return 0.0;
315 }
316 
317 doublereal PDSS::
319 {
320  doublereal RT = m_temp * GasConstant;
321  doublereal tmp = enthalpy_RT_ref();
322  return enthalpy_mole() - RT * tmp;
323 }
324 
325 doublereal PDSS::entropyDelp_mole() const
326 {
327  doublereal tmp = entropy_R_ref();
328  return entropy_mole() - GasConstant * tmp;
329 
330 }
331 
332 doublereal PDSS::gibbsDelp_mole() const
333 {
334  doublereal RT = m_temp * GasConstant;
335  doublereal tmp = gibbs_RT_ref();
336  return gibbs_mole() - RT * tmp;
337 }
338 
339 doublereal PDSS::cpDelp_mole() const
340 {
341  doublereal tmp = cp_R_ref();
342  return cp_mole() - GasConstant * tmp;
343 }
344 
345 doublereal PDSS::pressure() const
346 {
347  return m_pres;
348 }
349 
350 doublereal PDSS::thermalExpansionCoeff() const
351 {
352  throw CanteraError("PDSS::thermalExpansionCoeff()", "unimplemented");
353  return 0.0;
354 }
355 
356 doublereal PDSS::critTemperature() const
357 {
358  err("critTemperature()");
359  return 0.0;
360 }
361 
362 doublereal PDSS::critPressure() const
363 {
364  err("critPressure()");
365  return 0.0;
366 }
367 
368 doublereal PDSS::critDensity() const
369 {
370  err("critDensity()");
371  return 0.0;
372 }
373 
374 void PDSS::setPressure(doublereal pres)
375 {
376  m_pres = pres;
377 }
378 
379 doublereal PDSS::temperature() const
380 {
381  return m_temp;
382 }
383 
384 void PDSS::setTemperature(doublereal temp)
385 {
386  m_temp = temp;
387 }
388 
389 doublereal PDSS::molecularWeight() const
390 {
391  return m_mw;
392 }
393 void PDSS::setMolecularWeight(doublereal mw)
394 {
395  m_mw = mw;
396 }
397 
398 void PDSS::setState_TP(doublereal temp, doublereal pres)
399 {
400  err("setState_TP()");
401 }
402 
403 void PDSS::setState_TR(doublereal temp, doublereal rho)
404 {
405  err("setState_TR()");
406 }
407 
408 doublereal PDSS::satPressure(doublereal t)
409 {
410  err("satPressure()");
411  return 0.0;
412 }
413 
414 void PDSS::err(const std::string& msg) const
415 {
416  throw CanteraError("PDSS::" + msg, "unimplemented");
417 }
418 
419 void PDSS::reportParams(size_t& kindex, int& type,
420  doublereal* const c,
421  doublereal& minTemp_,
422  doublereal& maxTemp_,
423  doublereal& refPressure_) const
424 {
425  kindex = m_spindex;
426  type = m_pdssType;
427  minTemp_ = m_minTemp;
428  maxTemp_ = m_maxTemp;
429  refPressure_ = m_p0;
430 }
431 }
virtual doublereal cpDelp_mole() const
Get the difference in standard state heat capacity between the current pressure and the reference pre...
Definition: PDSS.cpp:339
virtual doublereal gibbs_RT() const
Return the molar Gibbs free energy divided by RT.
Definition: PDSS.cpp:252
virtual doublereal cv_mole() const
Return the molar const volume heat capacity in units of J kmol-1 K-1.
Definition: PDSS.cpp:281
vector_fp mPDSS_s0_R
species reference entropies - used by individual PDSS objects
Definition: VPSSMgr.h:842
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
Definition: Phase.cpp:484
void initPtrs()
Initialize all of the internal shallow pointers that can be initialized.
Definition: PDSS.cpp:201
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
virtual doublereal critPressure() const
critical pressure
Definition: PDSS.cpp:362
virtual doublereal cp_R_ref() const
Return the molar heat capacity divided by R at reference pressure.
Definition: PDSS.cpp:305
SpeciesThermo * m_spthermo
Pointer to the species thermodynamic property manager.
Definition: PDSS.h:615
vector_fp mPDSS_V0
species reference state molar Volumes - used by individual PDSS objects
Definition: VPSSMgr.h:849
doublereal * m_cpss_R_ptr
Standard state heat capacity divided by R.
Definition: PDSS.h:663
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:238
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
Definition: PDSS.cpp:229
virtual void initThermoXML(const XML_Node &phaseNode, const std::string &id)
Initialization routine for the PDSS object based on the phaseNode.
Definition: PDSS.cpp:175
virtual void setPressure(doublereal pres)
Sets the pressure in the object.
Definition: PDSS.cpp:374
doublereal * m_h0_RT_ptr
Reference state enthalpy divided by RT.
Definition: PDSS.h:622
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:173
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature.
Definition: VPSSMgr.cpp:468
void err(const std::string &msg) const
Set an error within this object for an unhandled capability.
Definition: PDSS.cpp:414
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
virtual doublereal satPressure(doublereal T)
saturation pressure
Definition: PDSS.cpp:408
virtual doublereal enthalpy_RT() const
Return the standard state molar enthalpy divided by RT.
Definition: PDSS.cpp:223
doublereal m_pres
State of the system - pressure.
Definition: PDSS.h:576
vector_fp mPDSS_cpss_R
species standard state heat capacities - used by individual PDSS objects
Definition: VPSSMgr.h:863
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
Virtual base class for the calculation of multiple-species thermodynamic reference-state property man...
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: PDSS.cpp:350
VPSSMgr * m_vpssmgr_ptr
Pointer to the VPSS manager for this object.
Definition: PDSS.h:596
virtual void initAllPtrs(VPStandardStateTP *vptp_ptr, VPSSMgr *vpssmgr_ptr, SpeciesThermo *spthermo_ptr)
Initialize or Reinitialize all shallow pointers in the object.
Definition: PDSS.cpp:192
virtual doublereal gibbs_RT_ref() const
Return the molar gibbs free energy divided by RT at reference pressure.
Definition: PDSS.cpp:287
size_t m_spindex
Species index in the ThermoPhase corresponding to this species.
Definition: PDSS.h:606
virtual void initThermo()
Definition: VPSSMgr.cpp:360
doublereal temperature() const
Return the current stored temperature.
Definition: PDSS.cpp:379
void setMolecularWeight(doublereal mw)
Set the molecular weight of the species.
Definition: PDSS.cpp:393
doublereal * m_gss_RT_ptr
Standard state Gibbs free energy divided by RT.
Definition: PDSS.h:677
PDSS_enumType m_pdssType
Enumerated type describing the type of the PDSS object.
Definition: PDSS.h:570
virtual doublereal enthalpyDelp_mole() const
Get the difference in the standard state enthalpy between the current pressure and the reference pres...
Definition: PDSS.cpp:318
Pure Virtual base class for the species thermo manager classes.
doublereal * m_sss_R_ptr
Standard state entropy divided by R.
Definition: PDSS.h:670
virtual doublereal gibbs_mole() const
Return the molar Gibbs free energy in units of J kmol-1.
Definition: PDSS.cpp:246
virtual PDSS * duplMyselfAsPDSS() const
Duplication routine for objects which inherit from PDSS.
Definition: PDSS.cpp:165
vector_fp mPDSS_cp0_R
species reference heat capacities - used by individual PDSS objects
Definition: VPSSMgr.h:828
virtual doublereal entropy_R() const
Return the standard state entropy divided by RT.
Definition: PDSS.cpp:241
virtual void initThermo()
Initialization routine for all of the shallow pointers.
Definition: PDSS.cpp:183
virtual doublereal critTemperature() const
critical temperature
Definition: PDSS.cpp:356
virtual doublereal entropy_mole() const
Return the molar entropy in units of J kmol-1 K-1.
Definition: PDSS.cpp:235
Declarations for the virtual base class PDSS (pressure dependent standard state) which handles calcul...
virtual void setTemperature(doublereal temp)
Set the internal temperature.
Definition: PDSS.cpp:384
PDSS_enumType
Types of PDSS's.
Definition: mix_defs.h:119
vector_fp mPDSS_g0_RT
species reference gibbs free energies - used by individual PDSS objects
Definition: VPSSMgr.h:835
Classes providing support for XML data files.
virtual doublereal refPressure(size_t k=npos) const
The reference-state pressure for the standard state.
Definition: VPSSMgr.cpp:477
virtual doublereal pressure() const
Returns the pressure (Pa)
Definition: PDSS.cpp:345
virtual doublereal enthalpy_mole() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS.cpp:217
#define AssertThrow(expr, procedure)
Assertion must be true or an error is thrown.
Definition: ctexceptions.h:229
doublereal * m_s0_R_ptr
Reference state entropy divided by R.
Definition: PDSS.h:636
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:68
virtual doublereal entropyDelp_mole() const
Get the difference in the standard state entropy between the current pressure and the reference press...
Definition: PDSS.cpp:325
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
vector_fp mPDSS_sss_R
species standard state entropies - used by individual PDSS objects
Definition: VPSSMgr.h:877
vector_fp mPDSS_Vss
species standard state molar Volumes - used by individual PDSS objects
Definition: VPSSMgr.h:884
virtual doublereal density() const
Return the standard state density at standard state.
Definition: PDSS.cpp:275
doublereal m_maxTemp
Maximum temperature.
Definition: PDSS.h:585
doublereal m_minTemp
Minimum temperature.
Definition: PDSS.h:582
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature.
Definition: VPSSMgr.cpp:459
doublereal * m_hss_RT_ptr
Standard state enthalpy divided by RT.
Definition: PDSS.h:656
vector_fp mPDSS_gss_RT
species standard state gibbs free energies - used by individual PDSS objects
Definition: VPSSMgr.h:870
virtual void setState_TR(doublereal temp, doublereal rho)
Set the internal temperature and density.
Definition: PDSS.cpp:403
virtual doublereal critDensity() const
critical density
Definition: PDSS.cpp:368
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS.cpp:258
virtual void reportParams(size_t &kindex, int &type, doublereal *const c, doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
Definition: PDSS.cpp:419
virtual doublereal cp_R() const
Return the molar const pressure heat capacity divided by RT.
Definition: PDSS.cpp:264
virtual doublereal molarVolume() const
Return the molar volume at standard state.
Definition: PDSS.cpp:269
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
Virtual base class for a species with a pressure dependent standard state.
Definition: PDSS.h:195
PDSS()
Empty Constructor.
Definition: PDSS.cpp:24
vector_fp mPDSS_hss_RT
species standard state enthalpies - used by individual PDSS objects
Definition: VPSSMgr.h:856
virtual ~PDSS()
Destructor for the phase.
Definition: PDSS.cpp:161
doublereal molecularWeight() const
Return the molecular weight of the species in units of kg kmol-1.
Definition: PDSS.cpp:389
VPStandardStateTP * m_tp
ThermoPhase which this species belongs to.
Definition: PDSS.h:593
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:66
doublereal m_temp
Current temperature used by the PDSS object.
Definition: PDSS.h:573
virtual doublereal entropy_R_ref() const
Return the molar entropy divided by R at reference pressure.
Definition: PDSS.cpp:299
PDSS & operator=(const PDSS &b)
Assignment operator.
Definition: PDSS.cpp:110
doublereal * m_g0_RT_ptr
Reference state Gibbs free energy divided by RT.
Definition: PDSS.h:642
doublereal * m_cp0_R_ptr
Reference state heat capacity divided by R.
Definition: PDSS.h:629
virtual SpeciesThermo & speciesThermo(int k=-1)
Return a changeable reference to the calculation manager for species reference-state thermodynamic pr...
virtual doublereal gibbsDelp_mole() const
Get the difference in the standard state gibbs free energy between the current pressure and the refer...
Definition: PDSS.cpp:332
doublereal * m_Vss_ptr
Standard State molar volume (m3 kg-1)
Definition: PDSS.h:684
doublereal * m_V0_ptr
Reference state molar volume (m3 kg-1)
Definition: PDSS.h:649
vector_fp mPDSS_h0_RT
species reference enthalpies - used by individual PDSS objects
Definition: VPSSMgr.h:821
VPSSMgr * provideVPSSMgr()
Return a pointer to the VPSSMgr for this phase.
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
Definition: PDSS.cpp:398
PDSS_enumType reportPDSSType() const
Returns the type of the standard state parameterization.
Definition: PDSS.cpp:170
doublereal m_p0
Reference state pressure of the species.
Definition: PDSS.h:579
virtual doublereal molarVolume_ref() const
Return the molar volume at reference pressure.
Definition: PDSS.cpp:311
doublereal m_mw
Molecular Weight of the species.
Definition: PDSS.h:601
virtual doublereal enthalpy_RT_ref() const
Return the molar enthalpy divided by RT at reference pressure.
Definition: PDSS.cpp:293