Cantera  2.3.0
PDSS_IdealGas.cpp
Go to the documentation of this file.
1 /**
2  * @file PDSS_IdealGas.cpp
3  * Implementation of a pressure dependent standard state
4  * virtual function.
5  */
6 
7 // This file is part of Cantera. See License.txt in the top-level directory or
8 // at http://www.cantera.org/license.txt for license and copyright information.
9 
10 #include "cantera/base/ctml.h"
13 
14 using namespace std;
15 
16 namespace Cantera
17 {
18 PDSS_IdealGas::PDSS_IdealGas(VPStandardStateTP* tp, int spindex) :
19  PDSS(tp, spindex)
20 {
21  m_pdssType = cPDSS_IDEALGAS;
22 }
23 
25  const std::string& inputFile, const std::string& id) :
26  PDSS(tp, spindex)
27 {
28  warn_deprecated("PDSS_IdealGas constructor from XML input file",
29  "To be removed after Cantera 2.3.");
30  m_pdssType = cPDSS_IDEALGAS;
31  constructPDSSFile(tp, spindex, inputFile, id);
32 }
33 
34 PDSS_IdealGas::PDSS_IdealGas(VPStandardStateTP* tp, size_t spindex, const XML_Node& speciesNode,
35  const XML_Node& phaseRoot, bool spInstalled) :
36  PDSS(tp, spindex)
37 {
38  if (!spInstalled) {
39  throw CanteraError("PDSS_IdealGas", "sp installing not done yet");
40  }
41  m_pdssType = cPDSS_IDEALGAS;
42  constructPDSSXML(tp, spindex, phaseRoot, "");
43 }
44 
46  PDSS(b)
47 {
48  // Use the assignment operator to do the brunt of the work for the copy
49  // constructor.
50  *this = b;
51 }
52 
53 PDSS_IdealGas& PDSS_IdealGas::operator=(const PDSS_IdealGas& b)
54 {
55  if (&b == this) {
56  return *this;
57  }
58  PDSS::operator=(b);
59  return *this;
60 }
61 
63 {
64  return new PDSS_IdealGas(*this);
65 }
66 
68  const XML_Node& phaseNode, const std::string& id)
69 {
70 }
71 
73  const std::string& inputFile,
74  const std::string& id)
75 {
76  warn_deprecated("PDSS_IdealGas::constructPDSSFile",
77  "To be removed after Cantera 2.3.");
78  if (inputFile.size() == 0) {
79  throw CanteraError("PDSS_IdealGas::constructPDSSFile",
80  "input file is null");
81  }
82 
83  // The phase object automatically constructs an XML object. Use this object
84  // to store information.
85  XML_Node fxml;
86  fxml.build(findInputFile(inputFile));
87  XML_Node* fxml_phase = findXMLPhase(&fxml, id);
88  if (!fxml_phase) {
89  throw CanteraError("PDSS_IdealGas::constructPDSSFile",
90  "ERROR: Can not find phase named " +
91  id + " in file named " + inputFile);
92  }
93  constructPDSSXML(tp, spindex, *fxml_phase, id);
94 }
95 
97 {
102 }
103 
104 doublereal PDSS_IdealGas::enthalpy_RT() const
105 {
106  return m_h0_RT_ptr[m_spindex];
107 }
108 
110 {
111  return (m_h0_RT_ptr[m_spindex] - 1.0) * GasConstant * m_temp;
112 }
113 
114 doublereal PDSS_IdealGas::entropy_R() const
115 {
116  return m_s0_R_ptr[m_spindex] - log(m_pres/m_p0);
117 }
118 
119 doublereal PDSS_IdealGas::gibbs_RT() const
120 {
121  return m_g0_RT_ptr[m_spindex] + log(m_pres/m_p0);
122 }
123 
124 doublereal PDSS_IdealGas::cp_R() const
125 {
126  return m_cp0_R_ptr[m_spindex];
127 }
128 
129 doublereal PDSS_IdealGas::molarVolume() const
130 {
131  return GasConstant * m_temp / m_pres;
132 }
133 
134 doublereal PDSS_IdealGas::density() const
135 {
136  return m_pres * m_mw / (GasConstant * m_temp);
137 }
138 
139 doublereal PDSS_IdealGas::cv_mole() const
140 {
141  return cp_mole() - GasConstant;
142 }
143 
144 doublereal PDSS_IdealGas::gibbs_RT_ref() const
145 {
146  return m_g0_RT_ptr[m_spindex];
147 }
148 
150 {
151  return m_h0_RT_ptr[m_spindex];
152 }
153 
155 {
156  return m_s0_R_ptr[m_spindex];
157 }
158 
159 doublereal PDSS_IdealGas::cp_R_ref() const
160 {
161  return cp_R();
162 }
163 
165 {
166  return GasConstant * m_temp / m_p0;
167 }
168 
169 doublereal PDSS_IdealGas::pressure() const
170 {
171  throw CanteraError("PDSS_IdealGas::pressure()", "unimplemented");
172 }
173 
174 void PDSS_IdealGas::setPressure(doublereal p)
175 {
179 }
180 
181 doublereal PDSS_IdealGas::temperature() const
182 {
184  return m_temp;
185 }
186 
187 void PDSS_IdealGas::setTemperature(doublereal temp)
188 {
189  m_temp = temp;
199 }
200 
201 void PDSS_IdealGas::setState_TP(doublereal temp, doublereal pres)
202 {
203  m_pres = pres;
204  setTemperature(temp);
205 }
206 
207 void PDSS_IdealGas::setState_TR(doublereal temp, doublereal rho)
208 {
209  m_pres = GasConstant * temp * rho / m_mw;
210  setTemperature(temp);
211 }
212 
213 }
virtual doublereal gibbs_RT_ref() const
Return the molar Gibbs free energy divided by RT at reference pressure.
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature.
virtual doublereal enthalpy_RT_ref() const
Return the molar enthalpy divided by RT at reference pressure.
virtual void initThermo()
Initialization routine for all of the shallow pointers.
doublereal temperature() const
Return the temperature stored in the object.
Definition: VPSSMgr.h:487
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget)
Search an XML_Node tree for a named phase XML_Node.
Definition: xml.cpp:1038
virtual void setTemperature(doublereal temp)
Set the internal temperature.
doublereal * m_cpss_R_ptr
Standard state heat capacity divided by R.
Definition: PDSS.h:627
std::string findInputFile(const std::string &name)
Find an input file.
Definition: global.cpp:155
doublereal * m_h0_RT_ptr
Reference state enthalpy divided by RT.
Definition: PDSS.h:586
virtual doublereal enthalpy_RT() const
Return the standard state molar enthalpy divided by RT.
virtual doublereal molarVolume_ref() const
Return the molar volume at reference pressure.
virtual void setState_TP(doublereal temp, doublereal pres)
Set the internal temperature and pressure.
virtual doublereal gibbs_RT() const
Return the molar Gibbs free energy divided by RT.
doublereal m_pres
State of the system - pressure.
Definition: PDSS.h:544
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
PDSS_IdealGas(VPStandardStateTP *tp, int spindex)
Constructor.
virtual doublereal cp_R_ref() const
Return the molar heat capacity divided by R at reference pressure.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
virtual PDSS * duplMyselfAsPDSS() const
Duplication routine for objects which inherit from PDSS.
STL namespace.
VPSSMgr * m_vpssmgr_ptr
Pointer to the VPSS manager for this object.
Definition: PDSS.h:564
virtual doublereal refPressure(size_t k=npos) const
The reference-state pressure for species k.
size_t m_spindex
Species index in the ThermoPhase corresponding to this species.
Definition: PDSS.h:570
doublereal * m_gss_RT_ptr
Standard state Gibbs free energy divided by RT.
Definition: PDSS.h:641
PDSS_enumType m_pdssType
Enumerated type describing the type of the PDSS object.
Definition: PDSS.h:538
virtual MultiSpeciesThermo & speciesThermo(int k=-1)
Return a changeable reference to the calculation manager for species reference-state thermodynamic pr...
virtual doublereal temperature() const
Return the current stored temperature.
doublereal * m_sss_R_ptr
Standard state entropy divided by R.
Definition: PDSS.h:634
virtual void setPressure(doublereal pres)
Sets the pressure in the object.
Declarations for the class PDSS_IdealGas (pressure dependent standard state) which handles calculatio...
virtual void initThermo()
Initialization routine for all of the shallow pointers.
Definition: PDSS.cpp:175
virtual doublereal entropy_R() const
Return the standard state entropy divided by RT.
virtual doublereal pressure() const
Returns the pressure (Pa)
virtual doublereal molarVolume() const
Return the molar volume at standard state.
virtual doublereal density() const
Return the standard state density at standard state.
virtual doublereal intEnergy_mole() const
Return the molar internal Energy in units of J kmol-1.
virtual doublereal cv_mole() const
Return the molar const volume heat capacity in units of J kmol-1 K-1.
virtual void setState_TR(doublereal temp, doublereal rho)
Set the internal temperature and density.
doublereal * m_s0_R_ptr
Reference state entropy divided by R.
Definition: PDSS.h:600
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
void constructPDSSXML(VPStandardStateTP *vptp_ptr, size_t spindex, const XML_Node &phaseNode, const std::string &id)
Initialization of a PDSS object using an XML tree.
void build(const std::string &filename)
Populate the XML tree from an input file.
Definition: xml.cpp:716
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
doublereal m_maxTemp
Maximum temperature.
Definition: PDSS.h:553
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature.
doublereal m_minTemp
Minimum temperature.
Definition: PDSS.h:550
doublereal * m_hss_RT_ptr
Standard state enthalpy divided by RT.
Definition: PDSS.h:620
void constructPDSSFile(VPStandardStateTP *vptp_ptr, size_t spindex, const std::string &inputFile, const std::string &id)
Initialization of a PDSS object using an input XML file.
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
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
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 void update_one(size_t k, doublereal T, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Like update(), but only updates the single species k.
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 doublereal entropy_R_ref() const
Return the molar entropy divided by R at reference pressure.
doublereal * m_Vss_ptr
Standard State molar volume (m3 kg-1)
Definition: PDSS.h:648
virtual doublereal cp_mole() const
Return the molar const pressure heat capacity in units of J kmol-1 K-1.
Definition: PDSS.cpp:432
doublereal * m_V0_ptr
Reference state molar volume (m3 kg-1)
Definition: PDSS.h:613
Derived class for pressure dependent standard states of an ideal gas species.
Definition: PDSS_IdealGas.h:24
Namespace for the Cantera kernel.
Definition: application.cpp:29
virtual doublereal cp_R() const
Return the molar const pressure heat capacity divided by RT.
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