Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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/ctml.h"
13 #include "cantera/thermo/PDSS.h"
15 
16 namespace Cantera
17 {
19  m_pdssType(cPDSS_UNDEF),
20  m_temp(-1.0),
21  m_pres(-1.0),
22  m_p0(-1.0),
23  m_minTemp(-1.0),
24  m_maxTemp(10000.0),
25  m_tp(0),
26  m_vpssmgr_ptr(0),
27  m_mw(0.0),
28  m_spindex(npos),
29  m_spthermo(0),
30  m_h0_RT_ptr(0),
31  m_cp0_R_ptr(0),
32  m_s0_R_ptr(0),
33  m_g0_RT_ptr(0),
34  m_V0_ptr(0),
35  m_hss_RT_ptr(0),
36  m_cpss_R_ptr(0),
37  m_sss_R_ptr(0),
38  m_gss_RT_ptr(0),
39  m_Vss_ptr(0)
40 {
41 }
42 
43 PDSS::PDSS(VPStandardStateTP* tp, size_t spindex) :
44  m_pdssType(cPDSS_UNDEF),
45  m_temp(-1.0),
46  m_pres(-1.0),
47  m_p0(-1.0),
48  m_minTemp(-1.0),
49  m_maxTemp(10000.0),
50  m_tp(tp),
51  m_vpssmgr_ptr(0),
52  m_mw(0.0),
53  m_spindex(spindex),
54  m_spthermo(0),
55  m_h0_RT_ptr(0),
56  m_cp0_R_ptr(0),
57  m_s0_R_ptr(0),
58  m_g0_RT_ptr(0),
59  m_V0_ptr(0),
60  m_hss_RT_ptr(0),
61  m_cpss_R_ptr(0),
62  m_sss_R_ptr(0),
63  m_gss_RT_ptr(0),
64  m_Vss_ptr(0)
65 {
66  if (tp) {
67  m_spthermo = &(tp->speciesThermo());
68  }
69  if (tp) {
71  }
72 }
73 
74 PDSS::PDSS(const PDSS& b) :
75  m_pdssType(cPDSS_UNDEF),
76  m_temp(-1.0),
77  m_pres(-1.0),
78  m_p0(-1.0),
79  m_minTemp(-1.0),
80  m_maxTemp(10000.0),
81  m_tp(0),
82  m_vpssmgr_ptr(0),
83  m_mw(b.m_mw),
84  m_spindex(b.m_spindex),
85  m_spthermo(b.m_spthermo),
86  m_h0_RT_ptr(b.m_h0_RT_ptr),
87  m_cp0_R_ptr(b.m_cp0_R_ptr),
88  m_s0_R_ptr(b.m_s0_R_ptr),
89  m_g0_RT_ptr(b.m_g0_RT_ptr),
90  m_V0_ptr(b.m_V0_ptr),
91  m_hss_RT_ptr(b.m_hss_RT_ptr),
92  m_cpss_R_ptr(b.m_cpss_R_ptr),
93  m_sss_R_ptr(b.m_sss_R_ptr),
94  m_gss_RT_ptr(b.m_gss_RT_ptr),
95  m_Vss_ptr(b.m_Vss_ptr)
96 {
97  /*
98  * Use the assignment operator to do the brunt
99  * of the work for the copy constructor.
100  */
101  *this = b;
102 }
103 
105 {
106  if (&b == this) {
107  return *this;
108  }
109 
111  m_temp = b.m_temp;
112  m_pres = b.m_pres;
113  m_p0 = b.m_p0;
114  m_minTemp = b.m_minTemp;
115  m_maxTemp = b.m_maxTemp;
116 
117  // Pointers which are zero, are properly assigned in the
118  // function, initAllPtrs(). which must be called after the
119  // assignment operation.
120 
121  m_tp = 0;
122  m_vpssmgr_ptr = 0;
123  m_mw = b.m_mw;
124  m_spindex = b.m_spindex;
125  m_spthermo = 0;
126  m_cp0_R_ptr = 0;
127  m_h0_RT_ptr = 0;
128  m_s0_R_ptr = 0;
129  m_g0_RT_ptr = 0;
130  m_V0_ptr = 0;
131  m_cpss_R_ptr = 0;
132  m_hss_RT_ptr = 0;
133  m_sss_R_ptr = 0;
134  m_gss_RT_ptr = 0;
135  m_Vss_ptr = 0;
136 
137  // Here we just fill these in so that local copies within the VPSS object work.
138  m_tp = b.m_tp;
145  m_V0_ptr = b.m_V0_ptr;
150  m_Vss_ptr = b.m_Vss_ptr;
151 
152  return *this;
153 }
154 
156 {
157  return new PDSS(*this);
158 }
159 
161 {
162  return m_pdssType;
163 }
164 
165 void PDSS::initThermoXML(const XML_Node& phaseNode, const std::string& id)
166 {
167  AssertThrow(m_tp != 0, "PDSS::initThermoXML()");
171 }
172 
174 {
175  AssertThrow(m_tp != 0, "PDSS::initThermo()");
178  initPtrs();
180 }
181 
183  SpeciesThermo* spthermo)
184 {
185  m_tp = tp;
186  m_vpssmgr_ptr = vpssmgr_ptr;
187  m_spthermo = spthermo;
188  initPtrs();
189 }
190 
192 {
193  AssertThrow(m_vpssmgr_ptr->mPDSS_h0_RT.size() != 0, "PDSS::initPtrs()");
199 
205 }
206 
207 doublereal PDSS::enthalpy_mole() const
208 {
209  throw NotImplementedError("PDSS::enthalpy_mole()");
210 }
211 
212 doublereal PDSS::enthalpy_RT() const
213 {
214  throw NotImplementedError("PDSS::enthalpy_RT()");
215 }
216 
217 doublereal PDSS::intEnergy_mole() const
218 {
219  throw NotImplementedError("PDSS::intEnergy_mole()");
220 }
221 
222 doublereal PDSS::entropy_mole() const
223 {
224  throw NotImplementedError("PDSS::entropy_mole()");
225 }
226 
227 doublereal PDSS::entropy_R() const
228 {
229  throw NotImplementedError("PDSS::entropy_R()");
230 }
231 
232 doublereal PDSS::gibbs_mole() const
233 {
234  throw NotImplementedError("PDSS::gibbs_mole()");
235 }
236 
237 doublereal PDSS::gibbs_RT() const
238 {
239  throw NotImplementedError("PDSS::gibbs_RT()");
240 }
241 
242 doublereal PDSS::cp_mole() const
243 {
244  throw NotImplementedError("PDSS::cp_mole()");
245 }
246 
247 doublereal PDSS::cp_R() const
248 {
249  throw NotImplementedError("PDSS::cp_R()");
250 }
251 
252 doublereal PDSS::molarVolume() const
253 {
254  throw NotImplementedError("PDSS::molarVolume()");
255 }
256 
257 doublereal PDSS::density() const
258 {
259  throw NotImplementedError("PDSS::density()");
260 }
261 
262 doublereal PDSS::cv_mole() const
263 {
264  throw NotImplementedError("PDSS::cv_mole()");
265 }
266 
267 doublereal PDSS::gibbs_RT_ref() const
268 {
269  throw NotImplementedError("PDSS::gibbs_RT_ref()");
270 }
271 
272 doublereal PDSS::enthalpy_RT_ref() const
273 {
274  throw NotImplementedError("PDSS::enthalpy_RT_ref()");
275 }
276 
277 doublereal PDSS::entropy_R_ref() const
278 {
279  throw NotImplementedError("PDSS::entropy_RT_ref()");
280 }
281 
282 doublereal PDSS::cp_R_ref() const
283 {
284  throw NotImplementedError("PDSS::entropy_RT_ref()");
285 }
286 
287 doublereal PDSS::molarVolume_ref() const
288 {
289  throw NotImplementedError("PDSS::molarVolume_ref()");
290 }
291 
292 doublereal PDSS::enthalpyDelp_mole() const
293 {
295 }
296 
297 doublereal PDSS::entropyDelp_mole() const
298 {
299  return entropy_mole() - GasConstant * entropy_R_ref();
300 
301 }
302 
303 doublereal PDSS::gibbsDelp_mole() const
304 {
305  return gibbs_mole() - m_temp * GasConstant * gibbs_RT_ref();
306 }
307 
308 doublereal PDSS::cpDelp_mole() const
309 {
310  return cp_mole() - GasConstant * cp_R_ref();
311 }
312 
313 doublereal PDSS::pressure() const
314 {
315  return m_pres;
316 }
317 
318 doublereal PDSS::thermalExpansionCoeff() const
319 {
320  throw NotImplementedError("PDSS::thermalExpansionCoeff()");
321 }
322 
323 doublereal PDSS::critTemperature() const
324 {
325  throw NotImplementedError("PDSS::critTemperature()");
326 }
327 
328 doublereal PDSS::critPressure() const
329 {
330  throw NotImplementedError("PDSS::critPressure()");
331 }
332 
333 doublereal PDSS::critDensity() const
334 {
335  throw NotImplementedError("PDSS::critDensity()");
336 }
337 
338 void PDSS::setPressure(doublereal pres)
339 {
340  m_pres = pres;
341 }
342 
343 doublereal PDSS::temperature() const
344 {
345  return m_temp;
346 }
347 
348 void PDSS::setTemperature(doublereal temp)
349 {
350  m_temp = temp;
351 }
352 
353 doublereal PDSS::molecularWeight() const
354 {
355  return m_mw;
356 }
357 void PDSS::setMolecularWeight(doublereal mw)
358 {
359  m_mw = mw;
360 }
361 
362 void PDSS::setState_TP(doublereal temp, doublereal pres)
363 {
364  throw NotImplementedError("PDSS::setState_TP()");
365 }
366 
367 void PDSS::setState_TR(doublereal temp, doublereal rho)
368 {
369  throw NotImplementedError("PDSS::setState_TR()");
370 }
371 
372 doublereal PDSS::satPressure(doublereal t)
373 {
374  throw NotImplementedError("PDSS::satPressure()");
375 }
376 
377 void PDSS::reportParams(size_t& kindex, int& type,
378  doublereal* const c,
379  doublereal& minTemp_,
380  doublereal& maxTemp_,
381  doublereal& refPressure_) const
382 {
383  kindex = m_spindex;
384  type = m_pdssType;
385  minTemp_ = m_minTemp;
386  maxTemp_ = m_maxTemp;
387  refPressure_ = m_p0;
388 }
389 
390 // PDSS_Molar methods
391 
392 doublereal PDSS_Molar::enthalpy_RT() const
393 {
394  return enthalpy_mole() / (GasConstant * temperature());
395 }
396 
397 doublereal PDSS_Molar::entropy_R() const
398 {
399  return entropy_mole() / GasConstant;
400 }
401 
402 doublereal PDSS_Molar::gibbs_RT() const
403 {
404  return gibbs_mole() / (GasConstant * temperature());
405 }
406 
407 doublereal PDSS_Molar::cp_R() const
408 {
409  return cp_mole() / GasConstant;
410 }
411 
412 // PDSS_Nondimensional methods
413 
415 {
416  return enthalpy_RT() * GasConstant * temperature();
417 }
418 
420 {
421  return entropy_R() * GasConstant;
422 }
423 
425 {
426  return gibbs_RT() * GasConstant * temperature();
427 }
428 
430 {
431  return cp_R() * GasConstant;
432 }
433 
434 }
virtual doublereal cpDelp_mole() const
Get the difference in standard state heat capacity between the current pressure and the reference pre...
Definition: PDSS.cpp:308
virtual doublereal gibbs_RT() const
Return the molar Gibbs free energy divided by RT.
Definition: PDSS.cpp:237
virtual doublereal cv_mole() const
Return the molar const volume heat capacity in units of J kmol-1 K-1.
Definition: PDSS.cpp:262
vector_fp mPDSS_s0_R
species reference entropies - used by individual PDSS objects
Definition: VPSSMgr.h:837
doublereal molecularWeight(size_t k) const
Molecular weight of species k.
Definition: Phase.cpp:494
virtual doublereal entropy_mole() const
Return the molar entropy in units of J kmol-1 K-1.
Definition: PDSS.cpp:419
void initPtrs()
Initialize all of the internal shallow pointers that can be initialized.
Definition: PDSS.cpp:191
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
virtual doublereal critPressure() const
critical pressure
Definition: PDSS.cpp:328
virtual doublereal cp_R_ref() const
Return the molar heat capacity divided by R at reference pressure.
Definition: PDSS.cpp:282
SpeciesThermo * m_spthermo
Pointer to the species thermodynamic property manager.
Definition: PDSS.h:604
vector_fp mPDSS_V0
species reference state molar Volumes - used by individual PDSS objects
Definition: VPSSMgr.h:844
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:213
doublereal * m_cpss_R_ptr
Standard state heat capacity divided by R.
Definition: PDSS.h:652
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:235
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
Definition: PDSS.cpp:217
virtual void initThermoXML(const XML_Node &phaseNode, const std::string &id)
Initialization routine for the PDSS object based on the phaseNode.
Definition: PDSS.cpp:165
virtual void setPressure(doublereal pres)
Sets the pressure in the object.
Definition: PDSS.cpp:338
doublereal * m_h0_RT_ptr
Reference state enthalpy divided by RT.
Definition: PDSS.h:611
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature.
Definition: VPSSMgr.cpp:420
virtual doublereal satPressure(doublereal T)
saturation pressure
Definition: PDSS.cpp:372
virtual doublereal enthalpy_RT() const
Return the standard state molar enthalpy divided by RT.
Definition: PDSS.cpp:212
doublereal m_pres
State of the system - pressure.
Definition: PDSS.h:565
vector_fp mPDSS_cpss_R
species standard state heat capacities - used by individual PDSS objects
Definition: VPSSMgr.h:858
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition: PDSS.cpp:318
VPSSMgr * m_vpssmgr_ptr
Pointer to the VPSS manager for this object.
Definition: PDSS.h:585
virtual void initAllPtrs(VPStandardStateTP *vptp_ptr, VPSSMgr *vpssmgr_ptr, SpeciesThermo *spthermo_ptr)
Initialize or Reinitialize all shallow pointers in the object.
Definition: PDSS.cpp:182
virtual doublereal gibbs_RT_ref() const
Return the molar Gibbs free energy divided by RT at reference pressure.
Definition: PDSS.cpp:267
size_t m_spindex
Species index in the ThermoPhase corresponding to this species.
Definition: PDSS.h:595
virtual void initThermo()
Definition: VPSSMgr.cpp:350
virtual doublereal temperature() const
Return the current stored temperature.
Definition: PDSS.cpp:343
void setMolecularWeight(doublereal mw)
Set the molecular weight of the species.
Definition: PDSS.cpp:357
doublereal * m_gss_RT_ptr
Standard state Gibbs free energy divided by RT.
Definition: PDSS.h:666
PDSS_enumType m_pdssType
Enumerated type describing the type of the PDSS object.
Definition: PDSS.h:559
virtual doublereal enthalpyDelp_mole() const
Get the difference in the standard state enthalpy between the current pressure and the reference pres...
Definition: PDSS.cpp:292
Pure Virtual base class for the species thermo manager classes.
doublereal * m_sss_R_ptr
Standard state entropy divided by R.
Definition: PDSS.h:659
virtual doublereal gibbs_mole() const
Return the molar Gibbs free energy in units of J kmol-1.
Definition: PDSS.cpp:232
virtual PDSS * duplMyselfAsPDSS() const
Duplication routine for objects which inherit from PDSS.
Definition: PDSS.cpp:155
vector_fp mPDSS_cp0_R
species reference heat capacities - used by individual PDSS objects
Definition: VPSSMgr.h:823
virtual doublereal entropy_R() const
Return the standard state entropy divided by RT.
Definition: PDSS.cpp:227
virtual void initThermo()
Initialization routine for all of the shallow pointers.
Definition: PDSS.cpp:173
virtual doublereal critTemperature() const
critical temperature
Definition: PDSS.cpp:323
virtual doublereal entropy_mole() const
Return the molar entropy in units of J kmol-1 K-1.
Definition: PDSS.cpp:222
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:348
PDSS_enumType
Types of PDSS's.
Definition: mix_defs.h:121
vector_fp mPDSS_g0_RT
species reference Gibbs free energies - used by individual PDSS objects
Definition: VPSSMgr.h:830
virtual doublereal refPressure(size_t k=npos) const
The reference-state pressure for the standard state.
Definition: VPSSMgr.cpp:428
virtual doublereal pressure() const
Returns the pressure (Pa)
Definition: PDSS.cpp:313
virtual doublereal enthalpy_mole() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS.cpp:207
#define AssertThrow(expr, procedure)
Assertion must be true or an error is thrown.
Definition: ctexceptions.h:283
virtual doublereal enthalpy_mole() const
Return the molar enthalpy in units of J kmol-1.
Definition: PDSS.cpp:414
doublereal * m_s0_R_ptr
Reference state entropy divided by R.
Definition: PDSS.h:625
virtual doublereal entropyDelp_mole() const
Get the difference in the standard state entropy between the current pressure and the reference press...
Definition: PDSS.cpp:297
virtual doublereal cp_R() const
Return the molar const pressure heat capacity divided by RT.
Definition: PDSS.cpp:407
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:872
vector_fp mPDSS_Vss
species standard state molar Volumes - used by individual PDSS objects
Definition: VPSSMgr.h:879
virtual doublereal density() const
Return the standard state density at standard state.
Definition: PDSS.cpp:257
doublereal m_maxTemp
Maximum temperature.
Definition: PDSS.h:574
virtual doublereal enthalpy_RT() const
Return the standard state molar enthalpy divided by RT.
Definition: PDSS.cpp:392
doublereal m_minTemp
Minimum temperature.
Definition: PDSS.h:571
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature.
Definition: VPSSMgr.cpp:412
doublereal * m_hss_RT_ptr
Standard state enthalpy divided by RT.
Definition: PDSS.h:645
vector_fp mPDSS_gss_RT
species standard state Gibbs free energies - used by individual PDSS objects
Definition: VPSSMgr.h:865
virtual void setState_TR(doublereal temp, doublereal rho)
Set the internal temperature and density.
Definition: PDSS.cpp:367
virtual doublereal critDensity() const
critical density
Definition: PDSS.cpp:333
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS.cpp:242
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS.cpp:429
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:377
virtual doublereal cp_R() const
Return the molar const pressure heat capacity divided by RT.
Definition: PDSS.cpp:247
virtual doublereal molarVolume() const
Return the molar volume at standard state.
Definition: PDSS.cpp:252
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:193
PDSS()
Empty Constructor.
Definition: PDSS.cpp:18
vector_fp mPDSS_hss_RT
species standard state enthalpies - used by individual PDSS objects
Definition: VPSSMgr.h:851
doublereal molecularWeight() const
Return the molecular weight of the species in units of kg kmol-1.
Definition: PDSS.cpp:353
VPStandardStateTP * m_tp
ThermoPhase which this species belongs to.
Definition: PDSS.h:582
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
doublereal m_temp
Current temperature used by the PDSS object.
Definition: PDSS.h:562
virtual doublereal entropy_R_ref() const
Return the molar entropy divided by R at reference pressure.
Definition: PDSS.cpp:277
PDSS & operator=(const PDSS &b)
Assignment operator.
Definition: PDSS.cpp:104
doublereal * m_g0_RT_ptr
Reference state Gibbs free energy divided by RT.
Definition: PDSS.h:631
virtual doublereal gibbs_mole() const
Return the molar Gibbs free energy in units of J kmol-1.
Definition: PDSS.cpp:424
doublereal * m_cp0_R_ptr
Reference state heat capacity divided by R.
Definition: PDSS.h:618
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:303
doublereal * m_Vss_ptr
Standard State molar volume (m3 kg-1)
Definition: PDSS.h:673
doublereal * m_V0_ptr
Reference state molar volume (m3 kg-1)
Definition: PDSS.h:638
vector_fp mPDSS_h0_RT
species reference enthalpies - used by individual PDSS objects
Definition: VPSSMgr.h:816
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:362
PDSS_enumType reportPDSSType() const
Returns the type of the standard state parameterization.
Definition: PDSS.cpp:160
doublereal m_p0
Reference state pressure of the species.
Definition: PDSS.h:568
virtual doublereal molarVolume_ref() const
Return the molar volume at reference pressure.
Definition: PDSS.cpp:287
virtual doublereal gibbs_RT() const
Return the molar Gibbs free energy divided by RT.
Definition: PDSS.cpp:402
doublereal m_mw
Molecular Weight of the species.
Definition: PDSS.h:590
virtual doublereal enthalpy_RT_ref() const
Return the molar enthalpy divided by RT at reference pressure.
Definition: PDSS.cpp:272
virtual doublereal entropy_R() const
Return the standard state entropy divided by RT.
Definition: PDSS.cpp:397