Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // Copyright 2001 California Institute of Technology
7 
9 
10 #include "cantera/thermo/Species.h"
15 #include "cantera/thermo/VPSSMgr.h"
16 #include "VPSSMgrFactory.h"
17 
24 
27 
31 
34 
35 #undef USE_SSTP
36 #ifdef USE_SSTP
38 #else
40 #endif
41 
45 
48 
49 #include "cantera/thermo/HMWSoln.h"
55 
57 
58 using namespace std;
59 
60 namespace Cantera
61 {
62 
63 ThermoFactory* ThermoFactory::s_factory = 0;
64 mutex_t ThermoFactory::thermo_mutex;
65 
66 //! Define the number of ThermoPhase types for use in this factory routine
67 static int ntypes = 27;
68 
69 //! Define the string name of the ThermoPhase types that are handled by this factory routine
70 static string _types[] = {"IdealGas", "Incompressible",
71  "Surface", "Edge", "Metal", "StoichSubstance",
72  "PureFluid", "LatticeSolid", "Lattice",
73  "HMW", "IdealSolidSolution", "DebyeHuckel",
74  "IdealMolalSolution", "IdealGasVPSS", "IdealSolnVPSS",
75  "MineralEQ3", "MetalSHEelectrons", "Margules", "PhaseCombo_Interaction",
76  "IonsFromNeutralMolecule", "FixedChemPot", "MolarityIonicVPSSTP",
77  "MixedSolventElectrolyte", "Redlich-Kister", "RedlichKwong",
78  "RedlichKwongMFTP", "MaskellSolidSolnPhase"
79  };
80 
81 //! Define the integer id of the ThermoPhase types that are handled by this factory routine
82 static int _itypes[] = {cIdealGas, cIncompressible,
83  cSurf, cEdge, cMetal, cStoichSubstance,
84  cPureFluid, cLatticeSolid, cLattice,
86  cIdealMolalSoln, cVPSS_IdealGas, cIdealSolnGasVPSS_iscv,
87  cMineralEQ3, cMetalSHEelectrons,
88  cMargulesVPSSTP, cPhaseCombo_Interaction, cIonsFromNeutral, cFixedChemPot,
89  cMolarityIonicVPSSTP, cMixedSolventElectrolyte, cRedlichKisterVPSSTP,
90  cRedlichKwongMFTP, cRedlichKwongMFTP, cMaskellSolidSolnPhase
91  };
92 
93 ThermoPhase* ThermoFactory::newThermoPhase(const std::string& model)
94 {
95  int ieos=-1;
96 
97  for (int n = 0; n < ntypes; n++) {
98  if (model == _types[n]) {
99  ieos = _itypes[n];
100  break;
101  }
102  }
103 
104  switch (ieos) {
105 
106  case cIdealGas:
107  return new IdealGasPhase;
108  case cIncompressible:
109  return new ConstDensityThermo;
110  case cSurf:
111  return new SurfPhase;
112  case cEdge:
113  return new EdgePhase;
115  return new IdealSolidSolnPhase();
116  case cMargulesVPSSTP:
117  return new MargulesVPSSTP();
118  case cRedlichKisterVPSSTP:
119  return new RedlichKisterVPSSTP();
120  case cMolarityIonicVPSSTP:
121  return new MolarityIonicVPSSTP();
122  case cPhaseCombo_Interaction:
123  return new PhaseCombo_Interaction();
124  case cIonsFromNeutral:
125  return new IonsFromNeutralVPSSTP();
126  case cMetal:
127  return new MetalPhase;
128  case cStoichSubstance:
129 #ifdef USE_SSTP
130  return new StoichSubstanceSSTP;
131 #else
132  return new StoichSubstance;
133 #endif
134  case cFixedChemPot:
135  return new FixedChemPotSSTP;
136  case cMineralEQ3:
137  return new MineralEQ3();
138  case cMetalSHEelectrons:
139  return new MetalSHEelectrons();
140  case cLatticeSolid:
141  return new LatticeSolidPhase;
142  case cLattice:
143  return new LatticePhase;
144  case cPureFluid:
145  return new PureFluidPhase;
146  case cRedlichKwongMFTP:
147  return new RedlichKwongMFTP;
148  case cHMW:
149  return new HMWSoln;
150  case cDebyeHuckel:
151  return new DebyeHuckel;
152  case cIdealMolalSoln:
153  return new IdealMolalSoln;
154  case cVPSS_IdealGas:
155  return new IdealSolnGasVPSS;
156  case cIdealSolnGasVPSS_iscv:
157  return new IdealSolnGasVPSS;
158  case cMaskellSolidSolnPhase:
159  return new MaskellSolidSolnPhase;
160  default:
161  throw UnknownThermoPhaseModel("ThermoFactory::newThermoPhase", model);
162  }
163 }
164 
165 std::string eosTypeString(int ieos, int length)
166 {
167  for (int n = 0; n < ntypes; n++) {
168  if (_itypes[n] == ieos) {
169  return _types[n];
170  }
171  }
172  return "UnknownPhaseType";
173 }
174 
176 {
177  string model = xmlphase.child("thermo")["model"];
178  ThermoPhase* t = newThermoPhase(model);
179  if (model == "singing cows") {
180  throw CanteraError("ThermoPhase::newPhase", "Cows don't sing");
181  } else if (model == "HMW") {
182  HMWSoln* p = dynamic_cast<HMWSoln*>(t);
183  p->constructPhaseXML(xmlphase,"");
184  } else if (model == "IonsFromNeutralMolecule") {
185  IonsFromNeutralVPSSTP* p = dynamic_cast<IonsFromNeutralVPSSTP*>(t);
186  p->constructPhaseXML(xmlphase,"");
187  } else {
188  importPhase(xmlphase, t);
189  }
190  return t;
191 }
192 
193 ThermoPhase* newPhase(const std::string& infile, std::string id)
194 {
195  XML_Node* root = get_XML_File(infile);
196  if (id == "-") {
197  id = "";
198  }
199  XML_Node* xphase = get_XML_NameID("phase", "#"+id, root);
200  if (!xphase) {
201  throw CanteraError("newPhase",
202  "Couldn't find phase named \"" + id + "\" in file, " + infile);
203  }
204  return newPhase(*xphase);
205 }
206 
207 //! Gather a vector of pointers to XML_Nodes for a phase
208 /*!
209  * @param spDataNodeList Output vector of pointer to XML_Nodes which contain the species XML_Nodes for the
210  * species in the current phase.
211  * @param spNamesList Output Vector of strings, which contain the names of the species in the phase
212  * @param spRuleList Output Vector of ints, which contain the value of sprule for each species in the phase
213  * @param spArray_names Vector of pointers to the XML_Nodes which contains the names of the
214  * species in the phase
215  * @param spArray_dbases Input vector of pointers to species data bases.
216  * We search each data base for the required species names
217  * @param sprule Input vector of sprule values
218  */
219 static void formSpeciesXMLNodeList(std::vector<XML_Node*> &spDataNodeList,
220  std::vector<std::string> &spNamesList,
221  std::vector<int> &spRuleList,
222  const std::vector<XML_Node*> spArray_names,
223  const std::vector<XML_Node*> spArray_dbases,
224  const vector_int sprule)
225 {
226  // used to check that each species is declared only once
227  std::map<std::string, bool> declared;
228 
229  for (size_t jsp = 0; jsp < spArray_dbases.size(); jsp++) {
230  const XML_Node& speciesArray = *spArray_names[jsp];
231 
232  // Get the top XML for the database
233  const XML_Node* db = spArray_dbases[jsp];
234 
235  // Get the array of species name strings and then count them
236  std::vector<std::string> spnames;
237  getStringArray(speciesArray, spnames);
238  size_t nsp = spnames.size();
239 
240  // if 'all' is specified as the one and only species in the
241  // spArray_names field, then add all species
242  // defined in the corresponding database to the phase
243  if (nsp == 1 && spnames[0] == "all") {
244  std::vector<XML_Node*> allsp = db->getChildren("species");
245  nsp = allsp.size();
246  spnames.resize(nsp);
247  for (size_t nn = 0; nn < nsp; nn++) {
248  string stemp = (*allsp[nn])["name"];
249  bool skip = false;
250  if (declared[stemp]) {
251  if (sprule[jsp] >= 10) {
252  skip = true;
253  } else {
254  throw CanteraError("ThermoFactory::formSpeciesXMLNodeList()",
255  "duplicate species: \"" + stemp + "\"");
256  }
257  }
258  if (!skip) {
259  declared[stemp] = true;
260  spNamesList.push_back(stemp);
261  spDataNodeList.push_back(allsp[nn]);
262  spRuleList.push_back(sprule[jsp]);
263  }
264  }
265  } else if (nsp == 1 && spnames[0] == "unique") {
266  std::vector<XML_Node*> allsp = db->getChildren("species");
267  nsp = allsp.size();
268  spnames.resize(nsp);
269  for (size_t nn = 0; nn < nsp; nn++) {
270  string stemp = (*allsp[nn])["name"];
271  bool skip = false;
272  if (declared[stemp]) {
273  skip = true;
274  }
275  if (!skip) {
276  declared[stemp] = true;
277  spNamesList.push_back(stemp);
278  spDataNodeList.push_back(allsp[nn]);
279  spRuleList.push_back(sprule[jsp]);
280  }
281  }
282  } else {
283  std::map<std::string, XML_Node*> speciesNodes;
284  for (size_t k = 0; k < db->nChildren(); k++) {
285  XML_Node& child = db->child(k);
286  speciesNodes[child["name"]] = &child;
287  }
288  for (size_t k = 0; k < nsp; k++) {
289  string stemp = spnames[k];
290  bool skip = false;
291  if (declared[stemp]) {
292  if (sprule[jsp] >= 10) {
293  skip = true;
294  } else {
295  throw CanteraError("ThermoFactory::formSpeciesXMLNodeList()",
296  "duplicate species: \"" + stemp + "\"");
297  }
298  }
299  if (!skip) {
300  declared[stemp] = true;
301  // Find the species in the database by name.
302  std::map<std::string, XML_Node*>::iterator iter = speciesNodes.find(stemp);
303  if (iter == speciesNodes.end()) {
304  throw CanteraError("importPhase","no data for species, \""
305  + stemp + "\"");
306  }
307  spNamesList.push_back(stemp);
308  spDataNodeList.push_back(iter->second);
309  spRuleList.push_back(sprule[jsp]);
310  }
311  }
312  }
313  }
314 }
315 
317  SpeciesThermoFactory* spfactory)
318 {
319  // Check the the supplied XML node in fact represents a phase.
320  if (phase.name() != "phase") {
321  throw CanteraError("importPhase",
322  "Current const XML_Node named, " + phase.name() +
323  ", is not a phase element.");
324  }
325 
326  /*
327  * In this section of code, we get the reference to the
328  * phase XML tree within the ThermoPhase object. Then,
329  * we clear it and fill it with the current information that
330  * we are about to use to construct the object. We will then
331  * be able to resurrect the information later by calling xml().
332  */
333  th->setXMLdata(phase);
334 
335  // set the id attribute of the phase to the 'id' attribute in the XML tree.
336  th->setID(phase.id());
337  th->setName(phase.id());
338 
339  // Number of spatial dimensions. Defaults to 3 (bulk phase)
340  if (phase.hasAttrib("dim")) {
341  int idim = intValue(phase["dim"]);
342  if (idim < 1 || idim > 3)
343  throw CanteraError("importPhase",
344  "phase, " + th->id() +
345  ", has unphysical number of dimensions: " + phase["dim"]);
346  th->setNDim(idim);
347  } else {
348  th->setNDim(3); // default
349  }
350 
351  // Set equation of state parameters. The parameters are
352  // specific to each subclass of ThermoPhase, so this is done
353  // by method setParametersFromXML in each subclass.
354  const XML_Node& eos = phase.child("thermo");
355  if (phase.hasChild("thermo")) {
356  th->setParametersFromXML(eos);
357  } else {
358  throw CanteraError("importPhase",
359  " phase, " + th->id() +
360  ", XML_Node does not have a \"thermo\" XML_Node");
361  }
362 
363  VPStandardStateTP* vpss_ptr = 0;
364  int ssConvention = th->standardStateConvention();
365  if (ssConvention == cSS_CONVENTION_VPSS) {
366  vpss_ptr = dynamic_cast <VPStandardStateTP*>(th);
367  if (vpss_ptr == 0) {
368  throw CanteraError("importPhase",
369  "phase, " + th->id() + ", was VPSS, but dynamic cast failed");
370  }
371  }
372 
373  /***************************************************************
374  * Add the elements.
375  ***************************************************************/
376  if (ssConvention != cSS_CONVENTION_SLAVE) {
377  installElements(*th, phase);
378  }
379 
380  /***************************************************************
381  * Add the species.
382  *
383  * Species definitions may be imported from multiple
384  * sources. For each one, a speciesArray element must be
385  * present.
386  ***************************************************************/
387  vector<XML_Node*> sparrays = phase.getChildren("speciesArray");
388  if (ssConvention != cSS_CONVENTION_SLAVE) {
389  if (sparrays.empty()) {
390  throw CanteraError("importPhase",
391  "phase, " + th->id() + ", has zero \"speciesArray\" XML nodes.\n"
392  + " There must be at least one speciesArray nodes "
393  "with one or more species");
394  }
395  }
396  vector<XML_Node*> dbases;
397  vector_int sprule(sparrays.size(),0);
398 
399  // loop over the speciesArray elements
400  for (size_t jsp = 0; jsp < sparrays.size(); jsp++) {
401 
402  const XML_Node& speciesArray = *sparrays[jsp];
403 
404  // If the speciesArray element has a child element
405  //
406  // <skip element="undeclared">
407  //
408  // then set sprule[jsp] to 1, so that any species with an undeclared
409  // element will be quietly skipped when importing species. Additionally,
410  // if the skip node has the following attribute:
411  //
412  // <skip species="duplicate">
413  //
414  // then duplicate species names will not cause Cantera to throw an
415  // exception. Instead, the duplicate entry will be discarded.
416  if (speciesArray.hasChild("skip")) {
417  const XML_Node& sk = speciesArray.child("skip");
418  string eskip = sk["element"];
419  if (eskip == "undeclared") {
420  sprule[jsp] = 1;
421  }
422  string dskip = sk["species"];
423  if (dskip == "duplicate") {
424  sprule[jsp] += 10;
425  }
426  }
427 
428  // Get a pointer to the node containing the species
429  // definitions for the species declared in this
430  // speciesArray element. This may be in the local file
431  // containing the phase element, or may be in another
432  // file.
433  XML_Node* db = get_XML_Node(speciesArray["datasrc"], &phase.root());
434  if (db == 0) {
435  throw CanteraError("importPhase()",
436  " Can not find XML node for species database: "
437  + speciesArray["datasrc"]);
438  }
439 
440  // add this node to the list of species database nodes.
441  dbases.push_back(db);
442  }
443 
444  // Now, collect all the species names and all the XML_Node * pointers
445  // for those species in a single vector. This is where we decide what
446  // species are to be included in the phase.
447  // The logic is complicated enough that we put it in a separate routine.
448  std::vector<XML_Node*> spDataNodeList;
449  std::vector<std::string> spNamesList;
450  std::vector<int> spRuleList;
451  formSpeciesXMLNodeList(spDataNodeList, spNamesList, spRuleList,
452  sparrays, dbases, sprule);
453 
454  // Decide whether the the phase has a variable pressure ss or not
455  if (ssConvention == cSS_CONVENTION_VPSS) {
456  VPSSMgr* vp_spth = newVPSSMgr(vpss_ptr, &phase, spDataNodeList);
457  vpss_ptr->setVPSSMgr(vp_spth);
458  th->setSpeciesThermo(vp_spth->SpeciesThermoMgr());
459  }
460 
461  size_t nsp = spDataNodeList.size();
462  if (ssConvention == cSS_CONVENTION_SLAVE) {
463  if (nsp > 0) {
464  throw CanteraError("importPhase()", "For Slave standard states, number of species must be zero: "
465  + int2str(nsp));
466  }
467  }
468  for (size_t k = 0; k < nsp; k++) {
469  XML_Node* s = spDataNodeList[k];
470  AssertTrace(s != 0);
471  if (spRuleList[k]) {
473  }
474  th->addSpecies(newSpecies(*s));
475  if (vpss_ptr) {
476  vpss_ptr->createInstallPDSS(k, *s, &phase);
477  }
478  th->saveSpeciesData(k, s);
479  }
480 
481  if (ssConvention == cSS_CONVENTION_SLAVE) {
482  th->installSlavePhases(&phase);
483  }
484 
485  // Done adding species. Perform any required subclass-specific
486  // initialization.
487  th->initThermo();
488 
489  // Perform any required subclass-specific initialization
490  // that requires the XML phase object
491  std::string id = "";
492  th->initThermoXML(phase, id);
493 
494  return true;
495 }
496 
497 void installElements(Phase& th, const XML_Node& phaseNode)
498 {
499  // get the declared element names
500  if (!phaseNode.hasChild("elementArray")) {
501  throw CanteraError("installElements",
502  "phase XML node doesn't have \"elementArray\" XML Node");
503  }
504  XML_Node& elements = phaseNode.child("elementArray");
505  vector<string> enames;
506  getStringArray(elements, enames);
507 
508  // // element database defaults to elements.xml
509  string element_database = "elements.xml";
510  if (elements.hasAttrib("datasrc")) {
511  element_database = elements["datasrc"];
512  }
513 
514  XML_Node* doc = get_XML_File(element_database);
515  XML_Node* dbe = &doc->child("elementData");
516 
517  XML_Node& root = phaseNode.root();
518  XML_Node* local_db = 0;
519  if (root.hasChild("elementData")) {
520  local_db = &root.child("elementData");
521  }
522 
523  for (size_t i = 0; i < enames.size(); i++) {
524  // Find the element data
525  XML_Node* e = 0;
526  if (local_db) {
527  e = local_db->findByAttr("name",enames[i]);
528  }
529  if (!e) {
530  e = dbe->findByAttr("name",enames[i]);
531  }
532  if (!e) {
533  throw CanteraError("addElementsFromXML","no data for element "
534  +enames[i]);
535  }
536 
537  // Add the element
538  doublereal weight = 0.0;
539  if (e->hasAttrib("atomicWt")) {
540  weight = fpValue(e->attrib("atomicWt"));
541  }
542  int anum = 0;
543  if (e->hasAttrib("atomicNumber")) {
544  anum = intValue(e->attrib("atomicNumber"));
545  }
546  string symbol = e->attrib("name");
547  doublereal entropy298 = ENTROPY298_UNKNOWN;
548  if (e->hasChild("entropy298")) {
549  XML_Node& e298Node = e->child("entropy298");
550  if (e298Node.hasAttrib("value")) {
551  entropy298 = fpValueCheck(e298Node["value"]);
552  }
553  }
554  if (weight != 0.0) {
555  th.addElement(symbol, weight, anum, entropy298);
556  } else {
557  th.addElement(symbol);
558  }
559  }
560 }
561 
562 bool installSpecies(size_t k, const XML_Node& s, thermo_t& th,
563  SpeciesThermo* spthermo_ptr, int rule,
564  XML_Node* phaseNode_ptr,
565  VPSSMgr* vpss_ptr,
566  SpeciesThermoFactory* factory)
567 {
568  warn_deprecated("installSpecies", "Use newSpecies and addSpecies. For"
569  " VPStandardStateTP phases, call createInstallPDSS as well."
570  " To be removed after Cantera 2.2.");
571  th.addSpecies(newSpecies(s));
572  VPStandardStateTP* vp_ptr = dynamic_cast<VPStandardStateTP*>(&th);
573  if (vp_ptr) {
574  vp_ptr->createInstallPDSS(k, s, phaseNode_ptr);
575  }
576  return true;
577 }
578 
579 const XML_Node* speciesXML_Node(const std::string& kname,
580  const XML_Node* phaseSpeciesData)
581 {
582  if (!phaseSpeciesData) {
583  return 0;
584  }
585  string jname = phaseSpeciesData->name();
586  if (jname != "speciesData") {
587  throw CanteraError("speciesXML_Node()",
588  "Unexpected phaseSpeciesData name: " + jname);
589  }
590  vector<XML_Node*> xspecies = phaseSpeciesData->getChildren("species");
591  for (size_t j = 0; j < xspecies.size(); j++) {
592  const XML_Node& sp = *xspecies[j];
593  jname = sp["name"];
594  if (jname == kname) {
595  return &sp;
596  }
597  }
598  return 0;
599 }
600 
601 }
Factory to build instances of classes that manage the standard-state thermodynamic properties of a se...
Specific error to be thrown if the type of Thermo manager is unrecognized.
Definition: ThermoFactory.h:37
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.
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:704
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...
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
Definition: stringUtils.cpp:39
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
This class can handle either an ideal solution or an ideal gas approximation of a phase...
static void formSpeciesXMLNodeList(std::vector< XML_Node * > &spDataNodeList, std::vector< std::string > &spNamesList, std::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.
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:105
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase, assuming an ideal solution model (see Thermodynamic Properties and class SurfPhase).
Header for intermediate ThermoPhase object for phases which employ Gibbs excess free energy based for...
This phase object consists of a single component that can be a gas, a liquid, a mixed gas-liquid flui...
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:527
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:235
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.
bool installSpecies(size_t k, const XML_Node &s, thermo_t &th, SpeciesThermo *spthermo_ptr, int rule, XML_Node *phaseNode_ptr, VPSSMgr *vpss_ptr, SpeciesThermoFactory *factory)
Install a species into a ThermoPhase object, which defines the phase thermodynamics and speciation...
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:100
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:78
Class Phase is the base class for phases of matter, managing the species and elements in a phase...
Definition: Phase.h:92
A simple thermodynamic model for a bulk phase, assuming a lattice of solid atoms. ...
Definition: LatticePhase.h:241
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.
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.
Pure Virtual base class for the species thermo manager classes.
Header for intermediate ThermoPhase object for phases which employ Gibbs excess free energy based for...
Headers for the DebyeHuckel ThermoPhase object, which models dilute electrolyte solutions (see Thermo...
void constructPhaseXML(XML_Node &phaseNode, std::string id)
Import and initialize an IonsFromNeutralVPSSTP phase specification in an XML tree into the current ob...
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definition: xml.cpp:573
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:599
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
Header file for a solid solution model following Maskell, Shaw, and Tye.
Class StoichSubstanceSSTP represents a stoichiometric (fixed composition) incompressible substance...
const int cSurf
A surface phase. Used by class SurfPhase.
Definition: mix_defs.h:40
void setName(const std::string &nm)
Sets the string name for the phase.
Definition: Phase.cpp:162
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:29
shared_ptr< Species > newSpecies(const XML_Node &species_node)
Create a new Species object from a 'species' XML_Node.
Definition: Species.cpp:61
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:988
const int cFixedChemPot
Stoichiometric compound with a constant chemical potential.
Definition: mix_defs.h:61
bool importPhase(XML_Node &phase, ThermoPhase *th, SpeciesThermoFactory *spfactory)
Import a phase information into an empty ThermoPhase object.
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...
std::string name() const
Returns the name of the XML node.
Definition: xml.h:394
Definition file for a derived class of ThermoPhase that assumes either an ideal gas or ideal solution...
SpeciesThermo * SpeciesThermoMgr()
Return the pointer to the reference-state Thermo calculator SpeciesThermo object. ...
Definition: VPSSMgr.h:505
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:43
std::string id() const
Return the string id for the phase.
Definition: Phase.cpp:147
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:99
const int cVPSS_IdealGas
Variable Pressure Standard State ThermoPhase objects.
Definition: mix_defs.h:96
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
void constructPhaseXML(XML_Node &phaseNode, std::string id)
Import and initialize a HMWSoln phase specification in an XML tree into the current object...
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
Definition: xml.cpp:563
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 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't know the entropy of the element in its most stable state at 298...
Definition: Elements.h:84
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:593
virtual void installSlavePhases(Cantera::XML_Node *phaseNode)
Add in species from Slave phases.
#define AssertTrace(expr)
Assertion must be true or an error is thrown.
Definition: ctexceptions.h:270
static string _types[]
Define the string name of the ThermoPhase types that are handled by this factory routine.
Header for factory to build instances of classes that manage the standard-state thermodynamic propert...
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:714
std::string id() const
Return the id attribute, if present.
Definition: xml.cpp:448
Headers for a completely general species thermodynamic property manager for a phase (see Managers for...
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
virtual int standardStateConvention() const
This method returns the convention used in specification of the standard state, of which there are cu...
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:503
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:1470
A phase that is comprised of a fixed additive combination of other lattice phases.
const int cSS_CONVENTION_VPSS
Standard state uses the molality convention.
Definition: ThermoPhase.h:36
Header file for the StoichSubstanceSSTP class, which represents a fixed-composition incompressible su...
Contains declarations for string manipulation functions within Cantera.
Header file for the FixedChemPotSSTP class, which represents a fixed-composition incompressible subst...
This file contains the class declarations for the StoichSubstance ThermoPhase class.
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:1225
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:128
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:152
Declaration for class Cantera::Species.
void setSpeciesThermo(SpeciesThermo *spthermo)
Install a species thermodynamic property manager.
This phase is based upon the mixing-rule assumption that all molality-based activity coefficients are...
XML_Node & root() const
Return the root of the current XML_Node tree.
Definition: xml.cpp:1095
Header for intermediate ThermoPhase object for phases which employ Gibbs excess free energy based for...
Header for intermediate ThermoPhase object for phases which employ Gibbs excess free energy based for...
Class MineralEQ3 represents a stoichiometric (fixed composition) incompressible substance based on EQ...
Definition: MineralEQ3.h:94
doublereal fpValueCheck(const std::string &val)
Translate a string into one doublereal value, with error checking.
const int cIdealGas
Equation of state types:
Definition: mix_defs.h:37
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...
size_t nChildren(bool discardComments=false) const
Return the number of children.
Definition: xml.cpp:583
const int cSS_CONVENTION_SLAVE
Standard state thermodynamics is obtained from slave ThermoPhase objects.
Definition: ThermoPhase.h:38
void getChildren(const std::string &name, std::vector< XML_Node * > &children) const
Get a vector of pointers to XML_Node containing all of the children of the current node which matches...
Definition: xml.cpp:915
An ideal solution or an ideal gas approximation of a phase.
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
Definition: xml.cpp:568
const int cIdealSolidSolnPhase
Constant partial molar volume solution IdealSolidSolnPhase.h.
Definition: mix_defs.h:64