Cantera  2.3.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 
13 #include "cantera/base/ctml.h"
16 
17 namespace Cantera
18 {
19 
20 // ---- Constructors -------
21 
23 {
24 }
25 
26 MetalSHEelectrons::MetalSHEelectrons(const std::string& infile, const std::string& id_)
27 {
28  initThermoFile(infile, id_);
29 }
30 
31 MetalSHEelectrons::MetalSHEelectrons(XML_Node& xmlphase, const std::string& id_)
32 {
33  importPhase(xmlphase, this);
34 }
35 
37 {
38  operator=(right);
39 }
40 
41 MetalSHEelectrons& MetalSHEelectrons::operator=(const MetalSHEelectrons& right)
42 {
43  if (&right != this) {
44  SingleSpeciesTP::operator=(right);
45  }
46 
47  return *this;
48 }
49 
51 {
52  return new MetalSHEelectrons(*this);
53 }
54 
55 // ---- Utilities -----
56 
58 {
59  warn_deprecated("MetalSHEelectrons::eosType",
60  "To be removed after Cantera 2.3.");
61  return cMetalSHEelectrons;
62 }
63 
64 // ----- Mechanical Equation of State ------
65 
66 doublereal MetalSHEelectrons::pressure() const
67 {
68  return m_press;
69 }
70 
72 {
73  m_press = p;
74 }
75 
77 {
78  return 1.0/pressure();
79 }
80 
82 {
83  return 1.0/temperature();
84 }
85 
86 // ---- Chemical Potentials and Activities ----
87 
89 {
90  c[0] = 1.0;
91 }
92 
93 doublereal MetalSHEelectrons::standardConcentration(size_t k) const
94 {
95  return 1.0;
96 }
97 
98 doublereal MetalSHEelectrons::logStandardConc(size_t k) const
99 {
100  return 0.0;
101 }
102 
103 // Properties of the Standard State of the Species in the Solution
104 
106 {
107  getGibbs_RT(mu0);
108  mu0[0] *= RT();
109 }
110 
111 void MetalSHEelectrons::getEnthalpy_RT(doublereal* hrt) const
112 {
113  getEnthalpy_RT_ref(hrt);
114 }
115 
116 void MetalSHEelectrons::getEntropy_R(doublereal* sr) const
117 {
118  getEntropy_R_ref(sr);
119  doublereal tmp = log(pressure() / m_p0);
120  sr[0] -= tmp;
121 }
122 
123 void MetalSHEelectrons::getGibbs_RT(doublereal* grt) const
124 {
125  getGibbs_RT_ref(grt);
126  doublereal tmp = log(pressure() / m_p0);
127  grt[0] += tmp;
128 }
129 
130 void MetalSHEelectrons::getCp_R(doublereal* cpr) const
131 {
132  _updateThermo();
133  cpr[0] = m_cp0_R;
134 }
135 void MetalSHEelectrons::getIntEnergy_RT(doublereal* urt) const
136 {
137  getEnthalpy_RT(urt);
138  urt[0] -= 1.0;
139 }
140 
141 void MetalSHEelectrons::getIntEnergy_RT_ref(doublereal* urt) const
142 {
143  _updateThermo();
144  urt[0] = m_h0_RT - m_p0 / molarDensity() / RT();
145 }
146 
147 // ---- Initialization and Internal functions
148 
149 void MetalSHEelectrons::initThermoXML(XML_Node& phaseNode, const std::string& id_)
150 {
151  // Find the Thermo XML node
152  if (!phaseNode.hasChild("thermo")) {
153  throw CanteraError("MetalSHEelectrons::initThermoXML",
154  "no thermo XML node");
155  }
156  XML_Node& tnode = phaseNode.child("thermo");
157  doublereal dens = 2.65E3;
158  if (tnode.hasChild("density")) {
159  dens = getFloat(tnode, "density", "toSI");
160  }
161  setDensity(dens);
162  SingleSpeciesTP::initThermoXML(phaseNode, id_);
163 }
164 
166 {
167  XML_Node* xtop = new XML_Node("ctml", 0);
168  XML_Node& xv = xtop->addChild("validate");
169  xv.addAttribute("reactions", "yes");
170  xv.addAttribute("species", "yes");
171 
172  XML_Node& xp = xtop->addChild("phase");
173  xp.addAttribute("dim", "3");
174  xp.addAttribute("id", "MetalSHEelectrons");
175  XML_Node& xe = xp.addChild("elementArray", "E");
176  xe.addAttribute("datasrc", "elements.xml");
177  XML_Node& xs = xp.addChild("speciesArray", "she_electron");
178  xs.addAttribute("datasrc", "#species_Metal_SHEelectrons");
179  XML_Node& xt = xp.addChild("thermo");
180  xt.addAttribute("model", "metalSHEelectrons");
181  XML_Node& xtr = xp.addChild("transport");
182  xtr.addAttribute("model", "none");
183  XML_Node& xk = xp.addChild("kinetics");
184  xk.addAttribute("model", "none");
185 
186  XML_Node& xsd = xtop->addChild("speciesData");
187  xsd.addAttribute("id", "species_Metal_SHEelectrons");
188 
189  XML_Node& xsp = xsd.addChild("species");
190  xsp.addAttribute("name", "she_electron");
191  xsp.addChild("atomArray", "E:1");
192  xsp.addChild("charge", "-1");
193  XML_Node& xspt = xsp.addChild("thermo");
194 
195  XML_Node& xN1 = xspt.addChild("NASA");
196  xN1.addAttribute("Tmax", "1000.");
197  xN1.addAttribute("Tmin", "200.");
198  xN1.addAttribute("P0", "100000.0");
199  XML_Node& xF1 = xsd.addChild("floatArray",
200  "1.172165560E+00, 3.990260375E-03, -9.739075500E-06, "
201  "1.007860470E-08, -3.688058805E-12, -4.589675865E+02, 3.415051190E-01");
202  xF1.addAttribute("name", "coeffs");
203  xF1.addAttribute("size", "7");
204 
205  XML_Node& xN2 = xspt.addChild("NASA");
206  xN2.addAttribute("Tmax", "6000.");
207  xN2.addAttribute("Tmin", "1000.");
208  xN2.addAttribute("P0", "100000.0");
209  XML_Node& xF2 = xsd.addChild("floatArray",
210  "1.466432895E+00, 4.133039835E-04, -7.320116750E-08, 7.705017950E-12,"
211  "-3.444022160E-16, -4.065327985E+02, -5.121644350E-01");
212  xF2.addAttribute("name", "coeffs");
213  xF2.addAttribute("size", "7");
214 
215  return xtop;
216 }
217 
218 void MetalSHEelectrons::setParameters(int n, doublereal* const c)
219 {
220  setDensity(c[0]);
221 }
222 
223 void MetalSHEelectrons::getParameters(int& n, doublereal* const c) const
224 {
225  n = 1;
226  c[0] = density();
227 }
228 
230 {
231  if ( eosdata["model"] != "MetalSHEelectrons") {
232  throw CanteraError("MetalSHEelectrons::setParametersFromXML",
233  "thermo model attribute must be MetalSHEelectrons");
234  }
235  doublereal rho = 2.65E3;
236  if (eosdata.hasChild("density")) {
237  rho = getFloat(eosdata, "density", "toSI");
238  }
239  setDensity(rho);
240 }
241 
242 }
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:809
double m_cp0_R
Dimensionless heat capacity at the (mtlast, m_p0)
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
virtual void setPressure(doublereal p)
Set the pressure at constant temperature. Units: Pa.
virtual int eosType() const
Equation of state flag.
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:666
Class MetalSHEelectrons represents electrons within a metal, adjacent to an aqueous electrolyte...
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:178
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: application.cpp:29
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...
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.