Cantera  2.4.0
MetalSHEelectrons.cpp
Go to the documentation of this file.
1 /**
2  * @file MetalSHEelectrons.cpp
3  * Definition file for the MetalSHEElectrons class, which represents the
4  * electrons in a metal that are consistent with the
5  * SHE electrode (see \ref thermoprops and
6  * class \link Cantera::MetalSHEelectrons MetalSHEelectrons\endlink)
7  */
8 
9 // This file is part of Cantera. See License.txt in the top-level directory or
10 // at http://www.cantera.org/license.txt for license and copyright information.
11 
12 #include "cantera/base/ctml.h"
15 
16 namespace Cantera
17 {
18 
19 // ---- Constructors -------
20 
22 {
23  warn_deprecated("Class MetalSHEelectrons", "To be removed after Cantera 2.4");
24 }
25 
26 MetalSHEelectrons::MetalSHEelectrons(const std::string& infile, const std::string& id_)
27 {
28  warn_deprecated("Class MetalSHEelectrons", "To be removed after Cantera 2.4");
29  initThermoFile(infile, id_);
30 }
31 
32 MetalSHEelectrons::MetalSHEelectrons(XML_Node& xmlphase, const std::string& id_)
33 {
34  warn_deprecated("Class MetalSHEelectrons", "To be removed after Cantera 2.4");
35  importPhase(xmlphase, this);
36 }
37 
38 // ----- Mechanical Equation of State ------
39 
40 doublereal MetalSHEelectrons::pressure() const
41 {
42  return m_press;
43 }
44 
46 {
47  m_press = p;
48 }
49 
51 {
52  return 1.0/pressure();
53 }
54 
56 {
57  return 1.0/temperature();
58 }
59 
60 // ---- Chemical Potentials and Activities ----
61 
63 {
64  c[0] = 1.0;
65 }
66 
67 doublereal MetalSHEelectrons::standardConcentration(size_t k) const
68 {
69  return 1.0;
70 }
71 
72 doublereal MetalSHEelectrons::logStandardConc(size_t k) const
73 {
74  return 0.0;
75 }
76 
77 // Properties of the Standard State of the Species in the Solution
78 
80 {
81  getGibbs_RT(mu0);
82  mu0[0] *= RT();
83 }
84 
85 void MetalSHEelectrons::getEnthalpy_RT(doublereal* hrt) const
86 {
87  getEnthalpy_RT_ref(hrt);
88 }
89 
90 void MetalSHEelectrons::getEntropy_R(doublereal* sr) const
91 {
92  getEntropy_R_ref(sr);
93  doublereal tmp = log(pressure() / m_p0);
94  sr[0] -= tmp;
95 }
96 
97 void MetalSHEelectrons::getGibbs_RT(doublereal* grt) const
98 {
99  getGibbs_RT_ref(grt);
100  doublereal tmp = log(pressure() / m_p0);
101  grt[0] += tmp;
102 }
103 
104 void MetalSHEelectrons::getCp_R(doublereal* cpr) const
105 {
106  _updateThermo();
107  cpr[0] = m_cp0_R;
108 }
109 void MetalSHEelectrons::getIntEnergy_RT(doublereal* urt) const
110 {
111  getEnthalpy_RT(urt);
112  urt[0] -= 1.0;
113 }
114 
115 void MetalSHEelectrons::getIntEnergy_RT_ref(doublereal* urt) const
116 {
117  _updateThermo();
118  urt[0] = m_h0_RT - m_p0 / molarDensity() / RT();
119 }
120 
121 // ---- Initialization and Internal functions
122 
123 void MetalSHEelectrons::initThermoXML(XML_Node& phaseNode, const std::string& id_)
124 {
125  // Find the Thermo XML node
126  if (!phaseNode.hasChild("thermo")) {
127  throw CanteraError("MetalSHEelectrons::initThermoXML",
128  "no thermo XML node");
129  }
130  XML_Node& tnode = phaseNode.child("thermo");
131  doublereal dens = 2.65E3;
132  if (tnode.hasChild("density")) {
133  dens = getFloat(tnode, "density", "toSI");
134  }
135  setDensity(dens);
136  SingleSpeciesTP::initThermoXML(phaseNode, id_);
137 }
138 
140 {
141  XML_Node* xtop = new XML_Node("ctml", 0);
142  XML_Node& xv = xtop->addChild("validate");
143  xv.addAttribute("reactions", "yes");
144  xv.addAttribute("species", "yes");
145 
146  XML_Node& xp = xtop->addChild("phase");
147  xp.addAttribute("dim", "3");
148  xp.addAttribute("id", "MetalSHEelectrons");
149  XML_Node& xe = xp.addChild("elementArray", "E");
150  xe.addAttribute("datasrc", "elements.xml");
151  XML_Node& xs = xp.addChild("speciesArray", "she_electron");
152  xs.addAttribute("datasrc", "#species_Metal_SHEelectrons");
153  XML_Node& xt = xp.addChild("thermo");
154  xt.addAttribute("model", "metalSHEelectrons");
155  XML_Node& xtr = xp.addChild("transport");
156  xtr.addAttribute("model", "none");
157  XML_Node& xk = xp.addChild("kinetics");
158  xk.addAttribute("model", "none");
159 
160  XML_Node& xsd = xtop->addChild("speciesData");
161  xsd.addAttribute("id", "species_Metal_SHEelectrons");
162 
163  XML_Node& xsp = xsd.addChild("species");
164  xsp.addAttribute("name", "she_electron");
165  xsp.addChild("atomArray", "E:1");
166  xsp.addChild("charge", "-1");
167  XML_Node& xspt = xsp.addChild("thermo");
168 
169  XML_Node& xN1 = xspt.addChild("NASA");
170  xN1.addAttribute("Tmax", "1000.");
171  xN1.addAttribute("Tmin", "200.");
172  xN1.addAttribute("P0", "100000.0");
173  XML_Node& xF1 = xsd.addChild("floatArray",
174  "1.172165560E+00, 3.990260375E-03, -9.739075500E-06, "
175  "1.007860470E-08, -3.688058805E-12, -4.589675865E+02, 3.415051190E-01");
176  xF1.addAttribute("name", "coeffs");
177  xF1.addAttribute("size", "7");
178 
179  XML_Node& xN2 = xspt.addChild("NASA");
180  xN2.addAttribute("Tmax", "6000.");
181  xN2.addAttribute("Tmin", "1000.");
182  xN2.addAttribute("P0", "100000.0");
183  XML_Node& xF2 = xsd.addChild("floatArray",
184  "1.466432895E+00, 4.133039835E-04, -7.320116750E-08, 7.705017950E-12,"
185  "-3.444022160E-16, -4.065327985E+02, -5.121644350E-01");
186  xF2.addAttribute("name", "coeffs");
187  xF2.addAttribute("size", "7");
188 
189  return xtop;
190 }
191 
192 void MetalSHEelectrons::setParameters(int n, doublereal* const c)
193 {
194  setDensity(c[0]);
195 }
196 
197 void MetalSHEelectrons::getParameters(int& n, doublereal* const c) const
198 {
199  n = 1;
200  c[0] = density();
201 }
202 
204 {
205  if ( eosdata["model"] != "MetalSHEelectrons") {
206  throw CanteraError("MetalSHEelectrons::setParametersFromXML",
207  "thermo model attribute must be MetalSHEelectrons");
208  }
209  doublereal rho = 2.65E3;
210  if (eosdata.hasChild("density")) {
211  rho = getFloat(eosdata, "density", "toSI");
212  }
213  setDensity(rho);
214 }
215 
216 }
virtual void getIntEnergy_RT_ref(doublereal *urt) const
Returns the vector of nondimensional internal Energies of the reference state at the current temperat...
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
double m_h0_RT
Dimensionless enthalpy at the (mtlast, m_p0)
virtual void getIntEnergy_RT(doublereal *urt) const
Returns the vector of nondimensional Internal Energies of the standard state species at the current T...
virtual void setParameters(int n, doublereal *const c)
Set the equation of state parameters.
MetalSHEelectrons()
Default constructor for the MetalSHEelectrons class.
doublereal temperature() const
Temperature (K).
Definition: Phase.h:601
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
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 density() const
Density (kg/m^3).
Definition: Phase.h:607
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
virtual void getStandardChemPotentials(doublereal *mu0) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
doublereal RT() const
Return the Gas Constant multiplied by the current temperature.
Definition: ThermoPhase.h:748
double m_cp0_R
Dimensionless heat capacity at the (mtlast, m_p0)
virtual void setPressure(doublereal p)
Set the pressure at constant temperature. Units: Pa.
Header file for the MetalSHEElectrons class, which represents the electrons in a metal that are consi...
virtual doublereal isothermalCompressibility() const
Returns the isothermal compressibility. Units: 1/Pa.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
doublereal molarDensity() const
Molar density (kmol/m^3).
Definition: Phase.cpp:590
virtual doublereal pressure() const
Report the Pressure. Units: Pa.
virtual doublereal thermalExpansionCoeff() const
Return the volumetric thermal expansion coefficient. Units: 1/K.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
void addAttribute(const std::string &attrib, const std::string &value)
Add or modify an attribute of the current node.
Definition: xml.cpp:474
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:536
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:546
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
static XML_Node * makeDefaultXMLTree()
Make the default XML tree.
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
Definition: ctml.cpp:164
doublereal m_press
The current pressure of the solution (Pa). It gets initialized to 1 atm.
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
virtual void initThermoFile(const std::string &inputFile, const std::string &id)
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
virtual void getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
virtual void setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase.
Definition: Phase.h:622
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...