Cantera  2.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  * 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 {
24 /**
25  * Basic list of constructors and duplicators
26  */
28  m_pdssType(cPDSS_UNDEF),
29  m_temp(-1.0),
30  m_pres(-1.0),
31  m_p0(-1.0),
32  m_minTemp(-1.0),
33  m_maxTemp(10000.0),
34  m_tp(0),
35  m_vpssmgr_ptr(0),
36  m_mw(0.0),
37  m_spindex(npos),
38  m_spthermo(0),
39  m_h0_RT_ptr(0),
40  m_cp0_R_ptr(0),
41  m_s0_R_ptr(0),
42  m_g0_RT_ptr(0),
43  m_V0_ptr(0),
44  m_hss_RT_ptr(0),
45  m_cpss_R_ptr(0),
46  m_sss_R_ptr(0),
47  m_gss_RT_ptr(0),
48  m_Vss_ptr(0)
49 {
50 }
51 
52 PDSS::PDSS(VPStandardStateTP* tp, size_t spindex) :
53  m_pdssType(cPDSS_UNDEF),
54  m_temp(-1.0),
55  m_pres(-1.0),
56  m_p0(-1.0),
57  m_minTemp(-1.0),
58  m_maxTemp(10000.0),
59  m_tp(tp),
60  m_vpssmgr_ptr(0),
61  m_mw(0.0),
62  m_spindex(spindex),
63  m_spthermo(0),
64  m_h0_RT_ptr(0),
65  m_cp0_R_ptr(0),
66  m_s0_R_ptr(0),
67  m_g0_RT_ptr(0),
68  m_V0_ptr(0),
69  m_hss_RT_ptr(0),
70  m_cpss_R_ptr(0),
71  m_sss_R_ptr(0),
72  m_gss_RT_ptr(0),
73  m_Vss_ptr(0)
74 {
75  if (tp) {
76  m_spthermo = &(tp->speciesThermo());
77  }
78  if (tp) {
80  }
81 }
82 
83 
84 
85 
86 PDSS::PDSS(const PDSS& b) :
87  m_pdssType(cPDSS_UNDEF),
88  m_temp(-1.0),
89  m_pres(-1.0),
90  m_p0(-1.0),
91  m_minTemp(-1.0),
92  m_maxTemp(10000.0),
93  m_tp(0),
94  m_vpssmgr_ptr(0),
95  m_mw(b.m_mw),
96  m_spindex(b.m_spindex),
97  m_spthermo(b.m_spthermo),
98  m_h0_RT_ptr(b.m_h0_RT_ptr),
99  m_cp0_R_ptr(b.m_cp0_R_ptr),
100  m_s0_R_ptr(b.m_s0_R_ptr),
101  m_g0_RT_ptr(b.m_g0_RT_ptr),
102  m_V0_ptr(b.m_V0_ptr),
103  m_hss_RT_ptr(b.m_hss_RT_ptr),
104  m_cpss_R_ptr(b.m_cpss_R_ptr),
105  m_sss_R_ptr(b.m_sss_R_ptr),
106  m_gss_RT_ptr(b.m_gss_RT_ptr),
107  m_Vss_ptr(b.m_Vss_ptr)
108 {
109  /*
110  * Use the assignment operator to do the brunt
111  * of the work for the copy constructor.
112  */
113  *this = b;
114 }
115 
116 /**
117  * Assignment operator
118  * ok -> we don't know what to do here, so we'll
119  * first implement a shallow copy.
120  */
122 {
123  if (&b == this) {
124  return *this;
125  }
126 
128  m_temp = b.m_temp;
129  m_pres = b.m_pres;
130  m_p0 = b.m_p0;
131  m_minTemp = b.m_minTemp;
132  m_maxTemp = b.m_maxTemp;
133 
134  // Pointers which are zero, are properly assigned in the
135  // function, initAllPtrs(). which must be called after the
136  // assignment operation.
137 
138  m_tp = 0;
139  m_vpssmgr_ptr = 0;
140  m_mw = b.m_mw;
141  m_spindex = b.m_spindex;
142  m_spthermo = 0;
143  m_cp0_R_ptr = 0;
144  m_h0_RT_ptr = 0;
145  m_s0_R_ptr = 0;
146  m_g0_RT_ptr = 0;
147  m_V0_ptr = 0;
148  m_cpss_R_ptr = 0;
149  m_hss_RT_ptr = 0;
150  m_sss_R_ptr = 0;
151  m_gss_RT_ptr = 0;
152  m_Vss_ptr = 0;
153 
154  // Here we just fill these in so that local copies within the VPSS object work.
155  m_tp = b.m_tp;
162  m_V0_ptr = b.m_V0_ptr;
167  m_Vss_ptr = b.m_Vss_ptr;
168 
169  return *this;
170 }
171 
173 {
174 }
175 
176 // Duplicator from the %PDSS parent class
177 /*
178  * Given a pointer to a %PDSS object, this function will
179  * duplicate the %PDSS object and all underlying structures.
180  * This is basically a wrapper around the copy constructor.
181  *
182  * @return returns a pointer to a %PDSS
183  */
185 {
186  PDSS* ip = new PDSS(*this);
187  return ip;
188 }
189 
190 // Returns the type of the standard state parameterization
191 /*
192  * @return Returns the integer # of the parameterization
193  */
195 {
196  return m_pdssType;
197 }
198 
199 void PDSS::initThermoXML(const XML_Node& phaseNode, std::string& id)
200 {
201  AssertThrow(m_tp != 0, "PDSS::initThermoXML()");
205 }
206 
208 {
209  AssertThrow(m_tp != 0, "PDSS::initThermo()");
212  initPtrs();
214 }
215 
217  SpeciesThermo* spthermo)
218 {
219  m_tp = tp;
220  m_vpssmgr_ptr = vpssmgr_ptr;
221  m_spthermo = spthermo;
222  initPtrs();
223 }
224 
226 {
227  AssertThrow(m_vpssmgr_ptr->mPDSS_h0_RT.size() != 0, "PDSS::initPtrs()");
233 
239 }
240 
241 
242 
243 // Return the molar enthalpy in units of J kmol-1
244 /*
245  * Returns the species standard state enthalpy in J kmol-1 at the
246  * current temperature and pressure.
247  * (NOTE: assumes that ThermoPhase Ref Polynomials are up-to-date)
248  */
249 doublereal PDSS::enthalpy_mole() const
250 {
251  err("enthalpy_mole()");
252  return (0.0);
253 }
254 
255 doublereal PDSS::enthalpy_RT() const
256 {
257  double RT = GasConstant * m_temp;
258  return (enthalpy_mole()/RT);
259 }
260 
261 // Return the molar internal Energy in units of J kmol-1
262 /*
263  * Returns the species standard state internal Energy in J kmol-1 at the
264  * current temperature and pressure.
265  *
266  * @return returns the species standard state internal Energy in J kmol-1
267  */
268 doublereal PDSS::intEnergy_mole() const
269 {
270  err("intEnergy_mole()");
271  return (0.0);
272 }
273 
274 // Return the molar entropy in units of J kmol-1 K-1
275 /*
276  * Returns the species standard state entropy in J kmol-1 K-1 at the
277  * current temperature and pressure.
278  *
279  * @return returns the species standard state entropy in J kmol-1 K-1
280  */
281 doublereal PDSS::entropy_mole() const
282 {
283  err("entropy_mole()");
284  return (0.0);
285 }
286 
287 doublereal PDSS::entropy_R() const
288 {
289  return(entropy_mole()/GasConstant);
290 }
291 
292 // Return the molar gibbs free energy in units of J kmol-1
293 /*
294  * Returns the species standard state gibbs free energy in J kmol-1 at the
295  * current temperature and pressure.
296  *
297  * @return returns the species standard state gibbs free energy in J kmol-1
298  */
299 doublereal PDSS::gibbs_mole() const
300 {
301  err("gibbs_mole()");
302  return (0.0);
303 }
304 
305 doublereal PDSS::gibbs_RT() const
306 {
307  double RT = GasConstant * m_temp;
308  return (gibbs_mole()/RT);
309 }
310 
311 // Return the molar const pressure heat capacity in units of J kmol-1 K-1
312 /*
313  * Returns the species standard state Cp in J kmol-1 K-1 at the
314  * current temperature and pressure.
315  *
316  * @return returns the species standard state Cp in J kmol-1 K-1
317  */
318 doublereal PDSS::cp_mole() const
319 {
320  err("cp_mole()");
321  return (0.0);
322 }
323 
324 doublereal PDSS::cp_R() const
325 {
326  return (cp_mole()/GasConstant);
327 }
328 
329 doublereal PDSS::molarVolume() const
330 {
331  err("molarVolume()");
332  return 0.0;
333 }
334 
335 doublereal PDSS::density() const
336 {
337  err("density()");
338  return 0.0;
339 }
340 
341 // Return the molar const volume heat capacity in units of J kmol-1 K-1
342 /*
343  * Returns the species standard state Cv in J kmol-1 K-1 at the
344  * current temperature and pressure.
345  *
346  * @return returns the species standard state Cv in J kmol-1 K-1
347  */
348 doublereal PDSS::cv_mole() const
349 {
350  err("cv_mole()");
351  return (0.0);
352 }
353 
354 doublereal PDSS::gibbs_RT_ref() const
355 {
356  err("gibbs_RT_ref()");
357  return 0.0;
358 }
359 
360 doublereal PDSS::enthalpy_RT_ref() const
361 {
362  err("enthalpy_RT_ref()");
363  return 0.0;
364 }
365 
366 doublereal PDSS::entropy_R_ref() const
367 {
368  err("entropy_RT_ref()");
369  return 0.0;
370 }
371 
372 doublereal PDSS::cp_R_ref() const
373 {
374  err("entropy_RT_ref()");
375  return 0.0;
376 }
377 
378 doublereal PDSS::molarVolume_ref() const
379 {
380  err("molarVolume_ref()");
381  return 0.0;
382 }
383 
384 /**
385  * Return the difference in enthalpy between current p
386  * and ref p0, in mks units of
387  * in units of J kmol-1
388  */
389 doublereal PDSS::
391 {
392  doublereal RT = m_temp * GasConstant;
393  doublereal tmp = enthalpy_RT_ref();
394  return(enthalpy_mole() - RT * tmp);
395 }
396 
397 
398 /**
399  * Return the difference in entropy between current p
400  * and ref p0, in mks units of
401  * J kmol-1 K-1
402  */
403 doublereal PDSS::entropyDelp_mole() const
404 {
405  doublereal tmp = entropy_R_ref();
406  return(entropy_mole() - GasConstant * tmp);
407 
408 }
409 
410 /**
411  * Calculate the difference in Gibbs free energy between current p and
412  * the ref p0, in mks units of
413  * J kmol-1 K-1.
414  */
415 doublereal PDSS::gibbsDelp_mole() const
416 {
417  doublereal RT = m_temp * GasConstant;
418  doublereal tmp = gibbs_RT_ref();
419  return(gibbs_mole() - RT * tmp);
420 }
421 
422 // Return the molar const volume heat capacity in units of J kmol-1 K-1
423 /*
424  * Returns the species standard state Cv in J kmol-1 K-1 at the
425  * current temperature and pressure.
426  *
427  * @return returns the species standard state Cv in J kmol-1 K-1
428  */
429 doublereal PDSS::cpDelp_mole() const
430 {
431  doublereal tmp = cp_R_ref();
432  return(cp_mole() - GasConstant * tmp);
433 }
434 
435 /**
436  * Calculate the pressure (Pascals), given the temperature and density
437  * Temperature: kelvin
438  * rho: density in kg m-3
439  */
440 doublereal PDSS::pressure() const
441 {
442  return (m_pres);
443 }
444 
445 // Return the volumetric thermal expansion coefficient. Units: 1/K.
446 /*
447  * The thermal expansion coefficient is defined as
448  * \f[
449  * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P
450  * \f]
451  */
452 doublereal PDSS::thermalExpansionCoeff() const
453 {
454  throw CanteraError("PDSS::thermalExpansionCoeff()", "unimplemented");
455  return (0.0);
456 }
457 
458 /// critical temperature
459 doublereal PDSS::critTemperature() const
460 {
461  err("critTemperature()");
462  return (0.0);
463 }
464 
465 /// critical pressure
466 doublereal PDSS::critPressure() const
467 {
468  err("critPressure()");
469  return (0.0);
470 }
471 
472 /// critical density
473 doublereal PDSS::critDensity() const
474 {
475  err("critDensity()");
476  return (0.0);
477 }
478 
479 void PDSS::setPressure(doublereal pres)
480 {
481  m_pres = pres;
482 }
483 
484 
485 /**
486  * Return the temperature
487  *
488  * Obtain the temperature from the owning ThermoPhase object
489  * if you can.
490  */
491 doublereal PDSS::temperature() const
492 {
493  return m_temp;
494 }
495 
496 void PDSS::setTemperature(doublereal temp)
497 {
498  m_temp = temp;
499 }
500 
501 doublereal PDSS::molecularWeight() const
502 {
503  return m_mw;
504 }
505 void PDSS::setMolecularWeight(doublereal mw)
506 {
507  m_mw = mw;
508 }
509 
510 void PDSS::setState_TP(doublereal temp, doublereal pres)
511 {
512  err("setState_TP()");
513 }
514 
515 void PDSS::setState_TR(doublereal temp, doublereal rho)
516 {
517  err("setState_TR()");
518 }
519 
520 /// saturation pressure
521 doublereal PDSS::satPressure(doublereal t)
522 {
523  err("satPressure()");
524  return (0.0);
525 }
526 
527 
528 void PDSS::err(std::string msg) const
529 {
530  throw CanteraError("PDSS::" + msg, "unimplemented");
531 }
532 
533 
534 void PDSS::reportParams(size_t& kindex, int& type,
535  doublereal* const c,
536  doublereal& minTemp,
537  doublereal& maxTemp,
538  doublereal& refPressure) const
539 {
540  kindex = m_spindex;
541  type = m_pdssType;
542  minTemp = m_minTemp;
543  maxTemp = m_maxTemp;
544  refPressure = m_p0;
545 }
546 }