Cantera  2.3.0
ThermoFactory.cpp
Go to the documentation of this file.
1 /**
2  * @file ThermoFactory.cpp
3  * Definitions for the factory class that can create known ThermoPhase objects
4  * (see \ref thermoprops and class \link Cantera::ThermoFactory ThermoFactory\endlink).
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 
11 
12 #include "cantera/thermo/Species.h"
17 #include "cantera/thermo/VPSSMgr.h"
18 #include "VPSSMgrFactory.h"
19 
39 #include "cantera/thermo/HMWSoln.h"
46 
47 using namespace std;
48 
49 namespace Cantera
50 {
51 
52 ThermoFactory* ThermoFactory::s_factory = 0;
53 std::mutex ThermoFactory::thermo_mutex;
54 
55 //! Define the number of ThermoPhase types for use in this factory routine
56 static int ntypes = 27;
57 
58 //! Define the string name of the ThermoPhase types that are handled by this factory routine
59 static string _types[] = {"IdealGas", "Incompressible",
60  "Surface", "Edge", "Metal", "StoichSubstance",
61  "PureFluid", "LatticeSolid", "Lattice",
62  "HMW", "IdealSolidSolution", "DebyeHuckel",
63  "IdealMolalSolution", "IdealGasVPSS", "IdealSolnVPSS",
64  "MineralEQ3", "MetalSHEelectrons", "Margules", "PhaseCombo_Interaction",
65  "IonsFromNeutralMolecule", "FixedChemPot", "MolarityIonicVPSSTP",
66  "MixedSolventElectrolyte", "Redlich-Kister", "RedlichKwong",
67  "RedlichKwongMFTP", "MaskellSolidSolnPhase"
68  };
69 
70 //! Define the integer id of the ThermoPhase types that are handled by this factory routine
71 static int _itypes[] = {cIdealGas, cIncompressible,
72  cSurf, cEdge, cMetal, cStoichSubstance,
73  cPureFluid, cLatticeSolid, cLattice,
75  cIdealMolalSoln, cVPSS_IdealGas, cIdealSolnGasVPSS_iscv,
76  cMineralEQ3, cMetalSHEelectrons,
77  cMargulesVPSSTP, cPhaseCombo_Interaction, cIonsFromNeutral, cFixedChemPot,
78  cMolarityIonicVPSSTP, cMixedSolventElectrolyte, cRedlichKisterVPSSTP,
79  cRedlichKwongMFTP, cRedlichKwongMFTP, cMaskellSolidSolnPhase
80  };
81 
82 ThermoFactory::ThermoFactory()
83 {
84  reg("IdealGas", []() { return new IdealGasPhase(); });
85  reg("Incompressible", []() { return new ConstDensityThermo(); });
86  reg("Surface", []() { return new SurfPhase(); });
87  reg("Edge", []() { return new EdgePhase(); });
88  reg("Metal", []() { return new MetalPhase(); });
89  reg("StoichSubstance", []() { return new StoichSubstance(); });
90  reg("PureFluid", []() { return new PureFluidPhase(); });
91  reg("LatticeSolid", []() { return new LatticeSolidPhase(); });
92  reg("Lattice", []() { return new LatticePhase(); });
93  reg("HMW", []() { return new HMWSoln(); });
94  reg("IdealSolidSolution", []() { return new IdealSolidSolnPhase(); });
95  reg("DebyeHuckel", []() { return new DebyeHuckel(); });
96  reg("IdealMolalSolution", []() { return new IdealMolalSoln(); });
97  reg("IdealGasVPSS", []() { return new IdealSolnGasVPSS(); });
98  reg("IdealSolnVPSS", []() { return new IdealSolnGasVPSS(); });
99  reg("MineralEQ3", []() { return new MineralEQ3(); });
100  reg("MetalSHEelectrons", []() { return new MetalSHEelectrons(); });
101  reg("Margules", []() { return new MargulesVPSSTP(); });
102  reg("PhaseCombo_Interaction", []() { return new PhaseCombo_Interaction(); });
103  reg("IonsFromNeutralMolecule", []() { return new IonsFromNeutralVPSSTP(); });
104  reg("FixedChemPot", []() { return new FixedChemPotSSTP(); });
105  reg("MolarityIonicVPSSTP", []() { return new MolarityIonicVPSSTP(); });
106  reg("Redlich-Kister", []() { return new RedlichKisterVPSSTP(); });
107  reg("RedlichKwong", []() { return new RedlichKwongMFTP(); });
108  reg("RedlichKwongMFTP", []() { return new RedlichKwongMFTP(); });
109  reg("MaskellSolidSolnPhase", []() { return new MaskellSolidSolnPhase(); });
110 }
111 
112 ThermoPhase* ThermoFactory::newThermoPhase(const std::string& model)
113 {
114  return create(model);
115 }
116 
117 std::string eosTypeString(int ieos, int length)
118 {
119  warn_deprecated("eosTypeString", "To be removed after Cantera 2.3.");
120  for (int n = 0; n < ntypes; n++) {
121  if (_itypes[n] == ieos) {
122  return _types[n];
123  }
124  }
125  return "UnknownPhaseType";
126 }
127 
129 {
130  string model = xmlphase.child("thermo")["model"];
131  unique_ptr<ThermoPhase> t(newThermoPhase(model));
132  importPhase(xmlphase, t.get());
133  return t.release();
134 }
135 
136 ThermoPhase* newPhase(const std::string& infile, std::string id)
137 {
138  XML_Node* root = get_XML_File(infile);
139  if (id == "-") {
140  id = "";
141  }
142  XML_Node* xphase = get_XML_NameID("phase", "#"+id, root);
143  if (!xphase) {
144  throw CanteraError("newPhase",
145  "Couldn't find phase named \"" + id + "\" in file, " + infile);
146  }
147  return newPhase(*xphase);
148 }
149 
150 //! Gather a vector of pointers to XML_Nodes for a phase
151 /*!
152  * @param spDataNodeList Output vector of pointer to XML_Nodes which contain
153  * the species XML_Nodes for the species in the current phase.
154  * @param spNamesList Output Vector of strings, which contain the names
155  * of the species in the phase
156  * @param spRuleList Output Vector of ints, which contain the value of
157  * sprule for each species in the phase
158  * @param spArray_names Vector of pointers to the XML_Nodes which contains
159  * the names of the species in the phase
160  * @param spArray_dbases Input vector of pointers to species data bases. We
161  * search each data base for the required species
162  * names
163  * @param sprule Input vector of sprule values
164  */
165 static void formSpeciesXMLNodeList(std::vector<XML_Node*> &spDataNodeList,
166  std::vector<std::string> &spNamesList,
167  vector_int &spRuleList,
168  const std::vector<XML_Node*> spArray_names,
169  const std::vector<XML_Node*> spArray_dbases,
170  const vector_int sprule)
171 {
172  // used to check that each species is declared only once
173  std::map<std::string, bool> declared;
174 
175  for (size_t jsp = 0; jsp < spArray_dbases.size(); jsp++) {
176  const XML_Node& speciesArray = *spArray_names[jsp];
177 
178  // Get the top XML for the database
179  const XML_Node* db = spArray_dbases[jsp];
180 
181  // Get the array of species name strings and then count them
182  std::vector<std::string> spnames;
183  getStringArray(speciesArray, spnames);
184  size_t nsp = spnames.size();
185 
186  // if 'all' is specified as the one and only species in the
187  // spArray_names field, then add all species defined in the
188  // corresponding database to the phase
189  if (nsp == 1 && spnames[0] == "all") {
190  std::vector<XML_Node*> allsp = db->getChildren("species");
191  nsp = allsp.size();
192  spnames.resize(nsp);
193  for (size_t nn = 0; nn < nsp; nn++) {
194  string stemp = (*allsp[nn])["name"];
195  if (!declared[stemp] || sprule[jsp] < 10) {
196  declared[stemp] = true;
197  spNamesList.push_back(stemp);
198  spDataNodeList.push_back(allsp[nn]);
199  spRuleList.push_back(sprule[jsp]);
200  }
201  }
202  } else if (nsp == 1 && spnames[0] == "unique") {
203  std::vector<XML_Node*> allsp = db->getChildren("species");
204  nsp = allsp.size();
205  spnames.resize(nsp);
206  for (size_t nn = 0; nn < nsp; nn++) {
207  string stemp = (*allsp[nn])["name"];
208  if (!declared[stemp]) {
209  declared[stemp] = true;
210  spNamesList.push_back(stemp);
211  spDataNodeList.push_back(allsp[nn]);
212  spRuleList.push_back(sprule[jsp]);
213  }
214  }
215  } else {
216  std::map<std::string, XML_Node*> speciesNodes;
217  for (size_t k = 0; k < db->nChildren(); k++) {
218  XML_Node& child = db->child(k);
219  speciesNodes[child["name"]] = &child;
220  }
221  for (size_t k = 0; k < nsp; k++) {
222  string stemp = spnames[k];
223  if (!declared[stemp] || sprule[jsp] < 10) {
224  declared[stemp] = true;
225  // Find the species in the database by name.
226  auto iter = speciesNodes.find(stemp);
227  if (iter == speciesNodes.end()) {
228  throw CanteraError("importPhase","no data for species, \""
229  + stemp + "\"");
230  }
231  spNamesList.push_back(stemp);
232  spDataNodeList.push_back(iter->second);
233  spRuleList.push_back(sprule[jsp]);
234  }
235  }
236  }
237  }
238 }
239 
241 {
242  // Check the the supplied XML node in fact represents a phase.
243  if (phase.name() != "phase") {
244  throw CanteraError("importPhase",
245  "Current const XML_Node named, " + phase.name() +
246  ", is not a phase element.");
247  }
248 
249  // In this section of code, we get the reference to the phase XML tree
250  // within the ThermoPhase object. Then, we clear it and fill it with the
251  // current information that we are about to use to construct the object. We
252  // will then be able to resurrect the information later by calling xml().
253  th->setXMLdata(phase);
254 
255  // set the id attribute of the phase to the 'id' attribute in the XML tree.
256  th->setID(phase.id());
257  th->setName(phase.id());
258 
259  // Number of spatial dimensions. Defaults to 3 (bulk phase)
260  if (phase.hasAttrib("dim")) {
261  int idim = intValue(phase["dim"]);
262  if (idim < 1 || idim > 3) {
263  throw CanteraError("importPhase",
264  "phase, " + th->id() +
265  ", has unphysical number of dimensions: " + phase["dim"]);
266  }
267  th->setNDim(idim);
268  } else {
269  th->setNDim(3); // default
270  }
271 
272  // Set equation of state parameters. The parameters are specific to each
273  // subclass of ThermoPhase, so this is done by method setParametersFromXML
274  // in each subclass.
275  const XML_Node& eos = phase.child("thermo");
276  if (phase.hasChild("thermo")) {
277  th->setParametersFromXML(eos);
278  } else {
279  throw CanteraError("importPhase",
280  " phase, " + th->id() +
281  ", XML_Node does not have a \"thermo\" XML_Node");
282  }
283 
284  VPStandardStateTP* vpss_ptr = 0;
285  int ssConvention = th->standardStateConvention();
286  if (ssConvention == cSS_CONVENTION_VPSS) {
287  vpss_ptr = dynamic_cast <VPStandardStateTP*>(th);
288  if (vpss_ptr == 0) {
289  throw CanteraError("importPhase",
290  "phase, " + th->id() + ", was VPSS, but dynamic cast failed");
291  }
292  }
293 
294  // Add the elements.
295  if (ssConvention != cSS_CONVENTION_SLAVE) {
296  installElements(*th, phase);
297  }
298 
299  // Add the species.
300  //
301  // Species definitions may be imported from multiple sources. For each one,
302  // a speciesArray element must be present.
303  vector<XML_Node*> sparrays = phase.getChildren("speciesArray");
304  if (ssConvention != cSS_CONVENTION_SLAVE && sparrays.empty()) {
305  throw CanteraError("importPhase",
306  "phase, " + th->id() + ", has zero \"speciesArray\" XML nodes.\n"
307  + " There must be at least one speciesArray nodes "
308  "with one or more species");
309  }
310  vector<XML_Node*> dbases;
311  vector_int sprule(sparrays.size(),0);
312 
313  // loop over the speciesArray elements
314  for (size_t jsp = 0; jsp < sparrays.size(); jsp++) {
315  const XML_Node& speciesArray = *sparrays[jsp];
316 
317  // If the speciesArray element has a child element
318  //
319  // <skip element="undeclared">
320  //
321  // then set sprule[jsp] to 1, so that any species with an undeclared
322  // element will be quietly skipped when importing species. Additionally,
323  // if the skip node has the following attribute:
324  //
325  // <skip species="duplicate">
326  //
327  // then duplicate species names will not cause Cantera to throw an
328  // exception. Instead, the duplicate entry will be discarded.
329  if (speciesArray.hasChild("skip")) {
330  const XML_Node& sk = speciesArray.child("skip");
331  string eskip = sk["element"];
332  if (eskip == "undeclared") {
333  sprule[jsp] = 1;
334  }
335  string dskip = sk["species"];
336  if (dskip == "duplicate") {
337  sprule[jsp] += 10;
338  }
339  }
340 
341  // Get a pointer to the node containing the species definitions for the
342  // species declared in this speciesArray element. This may be in the
343  // local file containing the phase element, or may be in another file.
344  XML_Node* db = get_XML_Node(speciesArray["datasrc"], &phase.root());
345  if (db == 0) {
346  throw CanteraError("importPhase()",
347  " Can not find XML node for species database: "
348  + speciesArray["datasrc"]);
349  }
350 
351  // add this node to the list of species database nodes.
352  dbases.push_back(db);
353  }
354 
355  // Now, collect all the species names and all the XML_Node * pointers for
356  // those species in a single vector. This is where we decide what species
357  // are to be included in the phase. The logic is complicated enough that we
358  // put it in a separate routine.
359  std::vector<XML_Node*> spDataNodeList;
360  std::vector<std::string> spNamesList;
361  vector_int spRuleList;
362  formSpeciesXMLNodeList(spDataNodeList, spNamesList, spRuleList,
363  sparrays, dbases, sprule);
364 
365  // Decide whether the the phase has a variable pressure ss or not
366  if (ssConvention == cSS_CONVENTION_VPSS) {
367  VPSSMgr* vp_spth = newVPSSMgr(vpss_ptr, &phase, spDataNodeList);
368  vpss_ptr->setVPSSMgr(vp_spth);
369  }
370 
371  size_t nsp = spDataNodeList.size();
372  if (ssConvention == cSS_CONVENTION_SLAVE && nsp > 0) {
373  throw CanteraError("importPhase()", "For Slave standard states, "
374  "number of species must be zero: {}", nsp);
375  }
376  for (size_t k = 0; k < nsp; k++) {
377  XML_Node* s = spDataNodeList[k];
378  AssertTrace(s != 0);
379  if (spRuleList[k]) {
381  }
382  th->addSpecies(newSpecies(*s));
383  if (vpss_ptr) {
384  vpss_ptr->createInstallPDSS(k, *s, &phase);
385  }
386  th->saveSpeciesData(k, s);
387  }
388 
389  // Done adding species. Perform any required subclass-specific
390  // initialization.
391  th->initThermo();
392 
393  // Perform any required subclass-specific initialization that requires the
394  // XML phase object
395  std::string id = "";
396  th->initThermoXML(phase, id);
397 }
398 
399 void installElements(Phase& th, const XML_Node& phaseNode)
400 {
401  // get the declared element names
402  if (!phaseNode.hasChild("elementArray")) {
403  throw CanteraError("installElements",
404  "phase XML node doesn't have \"elementArray\" XML Node");
405  }
406  XML_Node& elements = phaseNode.child("elementArray");
407  vector<string> enames;
408  getStringArray(elements, enames);
409 
410  // // element database defaults to elements.xml
411  string element_database = "elements.xml";
412  if (elements.hasAttrib("datasrc")) {
413  element_database = elements["datasrc"];
414  }
415 
416  XML_Node* doc = get_XML_File(element_database);
417  XML_Node* dbe = &doc->child("elementData");
418 
419  XML_Node& root = phaseNode.root();
420  XML_Node* local_db = 0;
421  if (root.hasChild("elementData")) {
422  local_db = &root.child("elementData");
423  }
424 
425  for (size_t i = 0; i < enames.size(); i++) {
426  // Find the element data
427  XML_Node* e = 0;
428  if (local_db) {
429  e = local_db->findByAttr("name",enames[i]);
430  }
431  if (!e) {
432  e = dbe->findByAttr("name",enames[i]);
433  }
434  if (!e) {
435  throw CanteraError("addElementsFromXML","no data for element "
436  +enames[i]);
437  }
438 
439  // Add the element
440  doublereal weight = 0.0;
441  if (e->hasAttrib("atomicWt")) {
442  weight = fpValue(e->attrib("atomicWt"));
443  }
444  int anum = 0;
445  if (e->hasAttrib("atomicNumber")) {
446  anum = intValue(e->attrib("atomicNumber"));
447  }
448  string symbol = e->attrib("name");
449  doublereal entropy298 = ENTROPY298_UNKNOWN;
450  if (e->hasChild("entropy298")) {
451  XML_Node& e298Node = e->child("entropy298");
452  if (e298Node.hasAttrib("value")) {
453  entropy298 = fpValueCheck(e298Node["value"]);
454  }
455  }
456  th.addElement(symbol, weight, anum, entropy298);
457  }
458 }
459 
460 const XML_Node* speciesXML_Node(const std::string& kname,
461  const XML_Node* phaseSpeciesData)
462 {
463  if (!phaseSpeciesData) {
464  return 0;
465  }
466  string jname = phaseSpeciesData->name();
467  if (jname != "speciesData") {
468  throw CanteraError("speciesXML_Node()",
469  "Unexpected phaseSpeciesData name: " + jname);
470  }
471  vector<XML_Node*> xspecies = phaseSpeciesData->getChildren("species");
472  for (size_t j = 0; j < xspecies.size(); j++) {
473  const XML_Node& sp = *xspecies[j];
474  jname = sp["name"];
475  if (jname == kname) {
476  return &sp;
477  }
478  }
479  return 0;
480 }
481 
482 }
Header for a general species thermodynamic property manager for a phase (see MultiSpeciesThermo).
XML_Node * get_XML_Node(const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
Definition: global.cpp:214
doublereal fpValue(const std::string &val)
Translate a string into one doublereal value.
std::vector< XML_Node * > getChildren(const std::string &name) const
Get a vector of pointers to XML_Node containing all of the children of the current node which match t...
Definition: xml.cpp:864
std::string eosTypeString(int ieos, int length)
Translate the eosType id into a string.
ThermoPhase object for the ideal molal equation of state (see Thermodynamic Properties and class Idea...
virtual bool addSpecies(shared_ptr< Species > spec)
Implementation of a multi-species Redlich-Kwong equation of state.
XML_Node * get_XML_File(const std::string &file, int debug)
Return a pointer to the XML tree for a Cantera input file.
Definition: global.cpp:96
std::string name() const
Returns the name of the XML node.
Definition: xml.h:370
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase, assuming an ideal solution model (see Thermodynamic Properties and class SurfPhase).
(see Thermodynamic Properties and class MargulesVPSSTP).
This phase object consists of a single component that can be a gas, a liquid, a mixed gas-liquid flui...
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:228
Declaration file for a virtual base class that manages the calculation of standard state properties f...
Header for intermediate ThermoPhase object for phases which employ the Margules Gibbs free energy for...
RedlichKisterVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Redlich-Kister approxima...
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state...
Header for intermediate ThermoPhase object for phases which consist of ions whose thermodynamics is c...
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
Definition file for a derived class of ThermoPhase that assumes either an ideal gas or ideal solution...
Class MetalPhase represents electrons in a metal.
Definition: MetalPhase.h:23
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
STL namespace.
Class Phase is the base class for phases of matter, managing the species and elements in a phase...
Definition: Phase.h:96
A simple thermodynamic model for a bulk phase, assuming a lattice of solid atoms. ...
Definition: LatticePhase.h:232
const XML_Node * speciesXML_Node(const std::string &kname, const XML_Node *phaseSpeciesData)
Search an XML tree for species data.
Class FixedChemPotSSTP represents a stoichiometric (fixed composition) incompressible substance...
Header for a Thermo manager for incompressible ThermoPhases (see Thermodynamic Properties and ConstDe...
ThermoPhase * newPhase(const std::string &infile, std::string id)
Create and Initialize a ThermoPhase object from an XML input file.
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
Definition: xml.cpp:541
void saveSpeciesData(const size_t k, const XML_Node *const data)
Store a reference pointer to the XML tree containing the species data for this phase.
(see Thermodynamic Properties and class MolarityIonicVPSSTP).
Headers for the DebyeHuckel ThermoPhase object, which models dilute electrolyte solutions (see Thermo...
Class StoichSubstance represents a stoichiometric (fixed composition) incompressible substance...
static int ntypes
Define the number of ThermoPhase types for use in this factory routine.
Class DebyeHuckel represents a dilute liquid electrolyte phase which obeys the Debye Huckel formulati...
Definition: DebyeHuckel.h:563
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
Header file for a solid solution model following Maskell, Shaw, and Tye.
const int cSurf
A surface phase. Used by class SurfPhase.
Definition: mix_defs.h:41
void setName(const std::string &nm)
Sets the string name for the phase.
Definition: Phase.cpp:156
std::vector< int > vector_int
Vector of ints.
Definition: ct_defs.h:159
Contains const definitions for types of species reference-state thermodynamics managers (see Species ...
A thermodynamic phase representing a one dimensional edge between two surfaces.
Definition: EdgePhase.h:30
shared_ptr< Species > newSpecies(const XML_Node &species_node)
Create a new Species object from a &#39;species&#39; XML_Node.
Definition: Species.cpp:67
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:143
void ignoreUndefinedElements()
Set behavior when adding a species containing undefined elements to just skip the species...
Definition: Phase.cpp:878
const int cFixedChemPot
Stoichiometric compound with a constant chemical potential.
Definition: mix_defs.h:61
Header file for the MetalSHEElectrons class, which represents the electrons in a metal that are consi...
void setVPSSMgr(VPSSMgr *vp_ptr)
set the VPSS Mgr
Headers for the HMWSoln ThermoPhase object, which models concentrated electrolyte solutions (see Ther...
Header for a simple thermodynamics model of a bulk solid phase derived from ThermoPhase, assuming an ideal solution model based on a lattice of solid atoms (see Thermodynamic Properties and class LatticeSolidPhase).
ThermoPhase object for the ideal gas equation of state - workhorse for Cantera (see Thermodynamic Pro...
static int _itypes[]
Define the integer id of the ThermoPhase types that are handled by this factory routine.
Header for a ThermoPhase class for a pure fluid phase consisting of gas, liquid, mixed-gas-liquid and...
Class MetalSHEelectrons represents electrons within a metal, adjacent to an aqueous electrolyte...
VPSSMgr * newVPSSMgr(VPSSMgr_enumType type, VPStandardStateTP *vp_ptr, Cantera::VPSSMgrFactory *f)
Create a new species thermo manager instance, by specifying the type and (optionally) a pointer to th...
Header file for an ideal solid solution model with incompressible thermodynamics (see Thermodynamic P...
const int cMetal
A metal phase.
Definition: mix_defs.h:44
Overloads the virtual methods of class ThermoPhase to implement the incompressible equation of state...
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
const int cVPSS_IdealGas
Variable Pressure Standard State ThermoPhase objects.
Definition: mix_defs.h:96
virtual int standardStateConvention() const
This method returns the convention used in specification of the standard state, of which there are cu...
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
ThermoPhase * newThermoPhase(const std::string &model, ThermoFactory *f=0)
Create a new thermo manager instance.
const int cEdge
An edge between two 2D surfaces.
Definition: mix_defs.h:58
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
void installElements(Phase &th, const XML_Node &phaseNode)
Add the elements given in an XML_Node tree to the specified phase.
const int cIdealMolalSoln
IdealMolalSoln - molality based solution with molality-based act coeffs of 1.
Definition: mix_defs.h:75
#define ENTROPY298_UNKNOWN
Number indicating we don&#39;t know the entropy of the element in its most stable state at 298...
Definition: Elements.h:87
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&#39;th child of the current node.
Definition: xml.cpp:546
int intValue(const std::string &val)
Translate a string into one integer value.
void setNDim(size_t ndim)
Set the number of spatial dimensions (1, 2, or 3).
Definition: Phase.h:592
XML_Node & root() const
Return the root of the current XML_Node tree.
Definition: xml.cpp:1025
#define AssertTrace(expr)
Assertion must be true or an error is thrown.
Definition: ctexceptions.h:239
static string _types[]
Define the string name of the ThermoPhase types that are handled by this factory routine.
Header for factory functions to build instances of classes that manage the standard-state thermodynam...
std::string id() const
Return the string id for the phase.
Definition: Phase.cpp:141
size_t addElement(const std::string &symbol, doublereal weight=-12345.0, int atomicNumber=0, doublereal entropy298=ENTROPY298_UNKNOWN, int elem_type=CT_ELEM_TYPE_ABSPOS)
Add an element.
Definition: Phase.cpp:705
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
const int cHMW
HMW - Strong electrolyte using the Pitzer formulation.
Definition: mix_defs.h:69
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:500
Class IdealSolidSolnPhase represents a condensed phase ideal solution compound.
Header file for the MineralEQ3 class, which represents a fixed-composition incompressible substance b...
void getStringArray(const XML_Node &node, std::vector< std::string > &v)
This function interprets the value portion of an XML element as a string.
Definition: ctml.cpp:470
PhaseCombo_Interaction is a derived class of GibbsExcessVPSSTP that employs the Margules approximatio...
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
Definition: ThermoPhase.h:1554
A phase that is comprised of a fixed additive combination of other lattice phases.
std::string id() const
Return the id attribute, if present.
Definition: xml.cpp:428
const int cSS_CONVENTION_VPSS
Standard state uses the molality convention.
Definition: ThermoPhase.h:38
Contains declarations for string manipulation functions within Cantera.
Header file for the FixedChemPotSSTP class, which represents a fixed-composition incompressible subst...
Header file for the StoichSubstance class, which represents a fixed-composition incompressible substa...
static void formSpeciesXMLNodeList(std::vector< XML_Node *> &spDataNodeList, std::vector< std::string > &spNamesList, vector_int &spRuleList, const std::vector< XML_Node *> spArray_names, const std::vector< XML_Node *> spArray_dbases, const vector_int sprule)
Gather a vector of pointers to XML_Nodes for a phase.
const int cDebyeHuckel
DebyeHuckel - Weak electrolyte using various Debye-Huckel formulations.
Definition: mix_defs.h:72
MargulesVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Margules approximation for th...
Class HMWSoln represents a dilute or concentrated liquid electrolyte phase which obeys the Pitzer for...
Definition: HMWSoln.h:1145
Header for factory to build instances of classes that manage the standard-state thermodynamic propert...
void setXMLdata(XML_Node &xmlPhase)
Stores the XML tree information for the current phase.
Definition: Phase.cpp:122
Class MaskellSolidSolnPhase represents a condensed phase non-ideal solution with 2 species following ...
void setID(const std::string &id)
Set the string id for the phase.
Definition: Phase.cpp:146
XML_Node * findByAttr(const std::string &attr, const std::string &val, int depth=100000) const
This routine carries out a recursive search for an XML node based on an attribute of each XML node...
Definition: xml.cpp:661
Declaration for class Cantera::Species.
This phase is based upon the mixing-rule assumption that all molality-based activity coefficients are...
Namespace for the Cantera kernel.
Definition: application.cpp:29
(see Thermodynamic Properties and class MixedSolventElectrolyte ).
(see Thermodynamic Properties and class RedlichKisterVPSSTP).
Class MineralEQ3 represents a stoichiometric (fixed composition) incompressible substance based on EQ...
Definition: MineralEQ3.h:95
doublereal fpValueCheck(const std::string &val)
Translate a string into one doublereal value, with error checking.
size_t nChildren(bool discardComments=false) const
Return the number of children.
Definition: xml.cpp:556
const int cIdealGas
Equation of state types:
Definition: mix_defs.h:38
XML_Node * get_XML_NameID(const std::string &nameTarget, const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
Definition: global.cpp:252
Header for a simple thermodynamics model of a bulk phase derived from ThermoPhase, assuming a lattice of solid atoms (see Thermodynamic Properties and class LatticePhase).
Declarations for the EdgePhase ThermoPhase object, which models the interface between two surfaces (s...
const int cSS_CONVENTION_SLAVE
Standard state thermodynamics is obtained from slave ThermoPhase objects.
Definition: ThermoPhase.h:40
An ideal solution or an ideal gas approximation of a phase.
const int cIdealSolidSolnPhase
Constant partial molar volume solution IdealSolidSolnPhase.h.
Definition: mix_defs.h:64