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