Cantera  2.1.2
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 // Copyright 2001 California Institute of Technology
8 
10 
14 #include "cantera/thermo/VPSSMgr.h"
15 #include "VPSSMgrFactory.h"
16 
22 
25 
29 
32 
33 #undef USE_SSTP
34 #ifdef USE_SSTP
36 #else
38 #endif
39 
43 
46 
47 #include "cantera/thermo/HMWSoln.h"
53 
55 
56 using namespace std;
57 using namespace ctml;
58 
59 namespace Cantera
60 {
61 
62 ThermoFactory* ThermoFactory::s_factory = 0;
63 mutex_t ThermoFactory::thermo_mutex;
64 
65 //! Define the number of %ThermoPhase types for use in this factory routine
66 static int ntypes = 26;
67 
68 //! Define the string name of the %ThermoPhase types that are handled by this factory routine
69 static string _types[] = {"IdealGas", "Incompressible",
70  "Surface", "Edge", "Metal", "StoichSubstance",
71  "PureFluid", "LatticeSolid", "Lattice",
72  "HMW", "IdealSolidSolution", "DebyeHuckel",
73  "IdealMolalSolution", "IdealGasVPSS", "IdealSolnVPSS",
74  "MineralEQ3", "MetalSHEelectrons", "Margules", "PhaseCombo_Interaction",
75  "IonsFromNeutralMolecule", "FixedChemPot", "MolarityIonicVPSSTP",
76  "MixedSolventElectrolyte", "Redlich-Kister", "RedlichKwong",
77  "RedlichKwongMFTP"
78  };
79 
80 //! Define the integer id of the %ThermoPhase types that are handled by this factory routine
81 static int _itypes[] = {cIdealGas, cIncompressible,
82  cSurf, cEdge, cMetal, cStoichSubstance,
83  cPureFluid, cLatticeSolid, cLattice,
85  cIdealMolalSoln, cVPSS_IdealGas, cIdealSolnGasVPSS_iscv,
86  cMineralEQ3, cMetalSHEelectrons,
87  cMargulesVPSSTP, cPhaseCombo_Interaction, cIonsFromNeutral, cFixedChemPot,
88  cMolarityIonicVPSSTP, cMixedSolventElectrolyte, cRedlichKisterVPSSTP,
89  cRedlichKwongMFTP, cRedlichKwongMFTP
90  };
91 
92 ThermoPhase* ThermoFactory::newThermoPhase(const std::string& model)
93 {
94 
95  int ieos=-1;
96 
97  for (int n = 0; n < ntypes; n++) {
98  if (model == _types[n]) {
99  ieos = _itypes[n];
100  }
101  }
102 
103  ThermoPhase* th=0;
104  switch (ieos) {
105 
106  case cIdealGas:
107  th = new IdealGasPhase;
108  break;
109 
110  case cIncompressible:
111  th = new ConstDensityThermo;
112  break;
113 
114  case cSurf:
115  th = new SurfPhase;
116  break;
117 
118  case cEdge:
119  th = new EdgePhase;
120  break;
121 
123  th = new IdealSolidSolnPhase();
124  break;
125 
126  case cMargulesVPSSTP:
127  th = new MargulesVPSSTP();
128  break;
129 
130  case cRedlichKisterVPSSTP:
131  th = new RedlichKisterVPSSTP();
132  break;
133 
134  case cMolarityIonicVPSSTP:
135  th = new MolarityIonicVPSSTP();
136  break;
137 
138  case cPhaseCombo_Interaction:
139  th = new PhaseCombo_Interaction();
140  break;
141 
142  case cIonsFromNeutral:
143  th = new IonsFromNeutralVPSSTP();
144  break;
145 
146  case cMetal:
147  th = new MetalPhase;
148  break;
149 
150  case cStoichSubstance:
151 #ifdef USE_SSTP
152  th = new StoichSubstanceSSTP;
153 #else
154  th = new StoichSubstance;
155 #endif
156  break;
157 
158  case cFixedChemPot:
159  th = new FixedChemPotSSTP;
160  break;
161 
162  case cMineralEQ3:
163  th = new MineralEQ3();
164  break;
165 
166  case cMetalSHEelectrons:
167  th = new MetalSHEelectrons();
168  break;
169 
170  case cLatticeSolid:
171  th = new LatticeSolidPhase;
172  break;
173 
174  case cLattice:
175  th = new LatticePhase;
176  break;
177 
178  case cPureFluid:
179  th = new PureFluidPhase;
180  break;
181 
182  case cRedlichKwongMFTP:
183  th = new RedlichKwongMFTP;
184  break;
185 
186  case cHMW:
187  th = new HMWSoln;
188  break;
189 
190  case cDebyeHuckel:
191  th = new DebyeHuckel;
192  break;
193 
194  case cIdealMolalSoln:
195  th = new IdealMolalSoln;
196  break;
197 
198  case cVPSS_IdealGas:
199  th = new IdealSolnGasVPSS;
200  break;
201 
202  case cIdealSolnGasVPSS_iscv:
203  th = new IdealSolnGasVPSS;
204  break;
205 
206  default:
207  throw UnknownThermoPhaseModel("ThermoFactory::newThermoPhase",
208  model);
209  }
210  return th;
211 }
212 
213 std::string eosTypeString(int ieos, int length)
214 {
215  std::string ss = "UnknownPhaseType";
216  // bool found = false;
217  for (int n = 0; n < ntypes; n++) {
218  if (_itypes[n] == ieos) {
219  ss = _types[n];
220  //found = true;
221  }
222  }
223  return ss;
224 }
225 
227 {
228  const XML_Node& th = xmlphase.child("thermo");
229  string model = th["model"];
230  ThermoPhase* t = newThermoPhase(model);
231  if (model == "singing cows") {
232  throw CanteraError("ThermoPhase::newPhase", "Cows don't sing");
233  } else if (model == "HMW") {
234  HMWSoln* p = dynamic_cast<HMWSoln*>(t);
235  p->constructPhaseXML(xmlphase,"");
236  } else if (model == "IonsFromNeutralMolecule") {
237  IonsFromNeutralVPSSTP* p = dynamic_cast<IonsFromNeutralVPSSTP*>(t);
238  p->constructPhaseXML(xmlphase,"");
239  } else {
240  importPhase(xmlphase, t);
241  }
242  //return t;
243  //importPhase(xmlphase, t);
244  return t;
245 }
246 
247 ThermoPhase* newPhase(const std::string& infile, std::string id)
248 {
249  XML_Node* root = get_XML_File(infile);
250  if (id == "-") {
251  id = "";
252  }
253  XML_Node* xphase = get_XML_NameID("phase", std::string("#")+id, root);
254  if (!xphase) {
255  throw CanteraError("newPhase",
256  "Couldn't find phase named \"" + id + "\" in file, " + infile);
257  }
258  if (xphase) {
259  return newPhase(*xphase);
260  } else {
261  return (ThermoPhase*) 0;
262  }
263 }
264 
265 //====================================================================================================================
266 //! Gather a vector of pointers to XML_Nodes for a phase
267 /*!
268  * @param spDataNodeList Output vector of pointer to XML_Nodes which contain the species XML_Nodes for the
269  * species in the current phase.
270  * @param spNamesList Output Vector of strings, which contain the names of the species in the phase
271  * @param spRuleList Output Vector of ints, which contain the value of sprule for each species in the phase
272  * @param spArray_names Vector of pointers to the XML_Nodes which contains the names of the
273  * species in the phase
274  * @param spArray_dbases Input vector of pointers to species data bases.
275  * We search each data base for the required species names
276  * @param sprule Input vector of sprule values
277  */
278 static void formSpeciesXMLNodeList(std::vector<XML_Node*> &spDataNodeList,
279  std::vector<std::string> &spNamesList,
280  std::vector<int> &spRuleList,
281  const std::vector<XML_Node*> spArray_names,
282  const std::vector<XML_Node*> spArray_dbases,
283  const vector_int sprule)
284 {
285 
286  // used to check that each species is declared only once
287  std::map<std::string, bool> declared;
288 
289  size_t nSpecies = 0;
290  bool skip;
291 
292  for (size_t jsp = 0; jsp < spArray_dbases.size(); jsp++) {
293  const XML_Node& speciesArray = *spArray_names[jsp];
294 
295  // Get the top XML for the database
296  const XML_Node* db = spArray_dbases[jsp];
297 
298  // Get the array of species name strings and then count them
299  std::vector<std::string> spnames;
300  getStringArray(speciesArray, spnames);
301  size_t nsp = spnames.size();
302 
303  // if 'all' is specified as the one and only species in the
304  // spArray_names field, then add all species
305  // defined in the corresponding database to the phase
306  if (nsp == 1 && spnames[0] == "all") {
307  std::vector<XML_Node*> allsp;
308  db->getChildren("species", allsp);
309  nsp = allsp.size();
310  spnames.resize(nsp);
311  for (size_t nn = 0; nn < nsp; nn++) {
312  string stemp = (*allsp[nn])["name"];
313  bool skip = false;
314  if (declared[stemp]) {
315  if (sprule[jsp] >= 10) {
316  skip = true;
317  } else {
318  throw CanteraError("ThermoFactory::formSpeciesXMLNodeList()",
319  "duplicate species: \"" + stemp + "\"");
320  }
321  }
322  if (!skip) {
323  declared[stemp] = true;
324  nSpecies++;
325  spNamesList.resize(nSpecies);
326  spDataNodeList.resize(nSpecies, 0);
327  spRuleList.resize(nSpecies, 0);
328  spNamesList[nSpecies-1] = stemp;
329  spDataNodeList[nSpecies-1] = allsp[nn];
330  spRuleList[nSpecies-1] = sprule[jsp];
331  }
332  }
333  } else if (nsp == 1 && spnames[0] == "unique") {
334  std::vector<XML_Node*> allsp;
335  db->getChildren("species", allsp);
336  nsp = allsp.size();
337  spnames.resize(nsp);
338  for (size_t nn = 0; nn < nsp; nn++) {
339  string stemp = (*allsp[nn])["name"];
340  bool skip = false;
341  if (declared[stemp]) {
342  skip = true;
343  }
344  if (!skip) {
345  declared[stemp] = true;
346  nSpecies++;
347  spNamesList.resize(nSpecies);
348  spDataNodeList.resize(nSpecies, 0);
349  spRuleList.resize(nSpecies, 0);
350  spNamesList[nSpecies-1] = stemp;
351  spDataNodeList[nSpecies-1] = allsp[nn];
352  spRuleList[nSpecies-1] = sprule[jsp];
353  }
354  }
355  } else {
356  std::map<std::string, XML_Node*> speciesNodes;
357  for (size_t k = 0; k < db->nChildren(); k++) {
358  XML_Node& child = db->child(k);
359  speciesNodes[child["name"]] = &child;
360  }
361  for (size_t k = 0; k < nsp; k++) {
362  string stemp = spnames[k];
363  skip = false;
364  if (declared[stemp]) {
365  if (sprule[jsp] >= 10) {
366  skip = true;
367  } else {
368  throw CanteraError("ThermoFactory::formSpeciesXMLNodeList()",
369  "duplicate species: \"" + stemp + "\"");
370  }
371  }
372  if (!skip) {
373  declared[stemp] = true;
374  // Find the species in the database by name.
375  std::map<std::string, XML_Node*>::iterator iter = speciesNodes.find(stemp);
376  if (iter == speciesNodes.end()) {
377  throw CanteraError("importPhase","no data for species, \""
378  + stemp + "\"");
379  }
380  XML_Node* s = iter->second;
381  nSpecies++;
382  spNamesList.resize(nSpecies);
383  spDataNodeList.resize(nSpecies, 0);
384  spRuleList.resize(nSpecies, 0);
385  spNamesList[nSpecies-1] = stemp;
386  spDataNodeList[nSpecies-1] = s;
387  spRuleList[nSpecies-1] = sprule[jsp];
388  }
389  }
390  }
391  }
392 }
393 
395  SpeciesThermoFactory* spfactory)
396 {
397 
398  // Check the the supplied XML node in fact represents a
399  // phase.
400  if (phase.name() != "phase") {
401  throw CanteraError("importPhase",
402  "Current const XML_Node named, " + phase.name() +
403  ", is not a phase element.");
404  }
405 
406  /*
407  * In this section of code, we get the reference to the
408  * phase xml tree within the ThermoPhase object. Then,
409  * we clear it and fill it with the current information that
410  * we are about to use to construct the object. We will then
411  * be able to resurrect the information later by calling xml().
412  */
413  XML_Node& phaseNode_XML = th->xml();
414  phaseNode_XML.clear();
415  phase.copy(&phaseNode_XML);
416 
417  // set the id attribute of the phase to the 'id' attribute
418  // in the XML tree.
419  th->setID(phase.id());
420  th->setName(phase.id());
421 
422  // Number of spatial dimensions. Defaults to 3 (bulk phase)
423  if (phase.hasAttrib("dim")) {
424  int idim = intValue(phase["dim"]);
425  if (idim < 1 || idim > 3)
426  throw CanteraError("importPhase",
427  "phase, " + th->id() +
428  ", has unphysical number of dimensions: " + phase["dim"]);
429  th->setNDim(idim);
430  } else {
431  th->setNDim(3); // default
432  }
433 
434  // Set equation of state parameters. The parameters are
435  // specific to each subclass of ThermoPhase, so this is done
436  // by method setParametersFromXML in each subclass.
437  const XML_Node& eos = phase.child("thermo");
438  if (phase.hasChild("thermo")) {
439  th->setParametersFromXML(eos);
440  } else {
441  throw CanteraError("importPhase",
442  " phase, " + th->id() +
443  ", XML_Node does not have a \"thermo\" XML_Node");
444  }
445 
446  VPStandardStateTP* vpss_ptr = 0;
447  int ssConvention = th->standardStateConvention();
448  if (ssConvention == cSS_CONVENTION_VPSS) {
449  vpss_ptr = dynamic_cast <VPStandardStateTP*>(th);
450  if (vpss_ptr == 0) {
451  throw CanteraError("importPhase",
452  "phase, " + th->id() + ", was VPSS, but dynamic cast failed");
453  }
454  }
455 
456  // if no species thermo factory was supplied,
457  // use the default one.
458  if (!spfactory) {
459  spfactory = SpeciesThermoFactory::factory();
460  }
461 
462  /***************************************************************
463  * Add the elements.
464  ***************************************************************/
465  if (ssConvention != cSS_CONVENTION_SLAVE) {
466  th->addElementsFromXML(phase);
467  }
468 
469  /***************************************************************
470  * Add the species.
471  *
472  * Species definitions may be imported from multiple
473  * sources. For each one, a speciesArray element must be
474  * present.
475  ***************************************************************/
476  XML_Node* db = 0;
477  vector<XML_Node*> sparrays;
478  phase.getChildren("speciesArray", sparrays);
479  int jsp, nspa = static_cast<int>(sparrays.size());
480  if (ssConvention != cSS_CONVENTION_SLAVE) {
481  if (nspa == 0) {
482  throw CanteraError("importPhase",
483  "phase, " + th->id() + ", has zero \"speciesArray\" XML nodes.\n"
484  + " There must be at least one speciesArray nodes "
485  "with one or more species");
486  }
487  }
488  vector<XML_Node*> dbases;
489  vector_int sprule(nspa,0);
490 
491  // loop over the speciesArray elements
492  for (jsp = 0; jsp < nspa; jsp++) {
493 
494  const XML_Node& speciesArray = *sparrays[jsp];
495 
496  // If the speciesArray element has a child element
497  //
498  // <skip element="undeclared">
499  //
500  // then set sprule[jsp] to 1, so
501  // that any species with an undeclared element will be
502  // quietly skipped when importing species.
503  // Additionally, if the skip node has the following attribute:
504  //
505  // <skip species="duplicate">
506  //
507  // then duplicate species names will not cause Cantera to
508  // throw an exception. Instead, the duplicate entry will
509  // be discarded.
510  if (speciesArray.hasChild("skip")) {
511  const XML_Node& sk = speciesArray.child("skip");
512  string eskip = sk["element"];
513  if (eskip == "undeclared") {
514  sprule[jsp] = 1;
515  }
516  string dskip = sk["species"];
517  if (dskip == "duplicate") {
518  sprule[jsp] += 10;
519  }
520  }
521 
522  string fname, idstr;
523 
524  // Get a pointer to the node containing the species
525  // definitions for the species declared in this
526  // speciesArray element. This may be in the local file
527  // containing the phase element, or may be in another
528  // file.
529  db = get_XML_Node(speciesArray["datasrc"], &phase.root());
530  if (db == 0) {
531  throw CanteraError("importPhase()",
532  " Can not find XML node for species database: "
533  + speciesArray["datasrc"]);
534  }
535 
536  // add this node to the list of species database nodes.
537  dbases.push_back(db);
538  }
539 
540  // Now, collect all the species names and all the XML_Node * pointers
541  // for those species in a single vector. This is where we decide what
542  // species are to be included in the phase.
543  // The logic is complicated enough that we put it in a separate routine.
544  std::vector<XML_Node*> spDataNodeList;
545  std::vector<std::string> spNamesList;
546  std::vector<int> spRuleList;
547  formSpeciesXMLNodeList(spDataNodeList, spNamesList, spRuleList,
548  sparrays, dbases, sprule);
549 
550  // If the phase has a species thermo manager already installed,
551  // delete it since we are adding new species.
552  //delete &th->speciesThermo();
553 
554  // Decide whether the the phase has a variable pressure ss or not
555  SpeciesThermo* spth = 0;
556  VPSSMgr* vp_spth = 0;
557  if (ssConvention == cSS_CONVENTION_TEMPERATURE) {
558  // Create a new species thermo manager. Function
559  // 'newSpeciesThermoMgr' looks at the species in the database
560  // to see what thermodynamic property parameterizations are
561  // used, and selects a class that can handle the
562  // parameterizations found.
563  spth = newSpeciesThermoMgr(spDataNodeList);
564  if (eos["allow_discontinuities"] == "true") {
565  std::cout << "ALLOWING DISCONTINUOUS THERMO!" << std::endl;
566  spth->m_allow_discontinuities = true;
567  }
568 
569  // install it in the phase object
570  th->setSpeciesThermo(spth);
571  } else if (ssConvention == cSS_CONVENTION_SLAVE) {
572  /*
573  * No species thermo manager for this type
574  */
575  } else if (ssConvention == cSS_CONVENTION_VPSS) {
576  vp_spth = newVPSSMgr(vpss_ptr, &phase, spDataNodeList);
577  vpss_ptr->setVPSSMgr(vp_spth);
578  spth = vp_spth->SpeciesThermoMgr();
579  th->setSpeciesThermo(spth);
580  } else {
581  throw CanteraError("importPhase()", "unknown convention");
582  }
583 
584 
585  size_t k = 0;
586 
587  size_t nsp = spDataNodeList.size();
588  if (ssConvention == cSS_CONVENTION_SLAVE) {
589  if (nsp > 0) {
590  throw CanteraError("importPhase()", "For Slave standard states, number of species must be zero: "
591  + int2str(nsp));
592  }
593  }
594  for (size_t i = 0; i < nsp; i++) {
595  XML_Node* s = spDataNodeList[i];
596  AssertTrace(s != 0);
597  bool ok = installSpecies(k, *s, *th, spth, spRuleList[i],
598  &phase, vp_spth, spfactory);
599  if (ok) {
600  th->saveSpeciesData(k, s);
601  ++k;
602  }
603  }
604 
605  if (ssConvention == cSS_CONVENTION_SLAVE) {
606  th->installSlavePhases(&phase);
607  }
608 
609  // done adding species.
610  th->freezeSpecies();
611 
612  // Perform any required subclass-specific initialization.
613  th->initThermo();
614 
615  // Perform any required subclass-specific initialization
616  // that requires the XML phase object
617  std::string id = "";
618  th->initThermoXML(phase, id);
619 
620  return true;
621 }
622 
623 bool installSpecies(size_t k, const XML_Node& s, thermo_t& th,
624  SpeciesThermo* spthermo_ptr, int rule,
625  XML_Node* phaseNode_ptr,
626  VPSSMgr* vpss_ptr,
627  SpeciesThermoFactory* factory)
628 {
629  std::string xname = s.name();
630  if (xname != "species") {
631  throw CanteraError("installSpecies",
632  "Unexpected XML name of species XML_Node: " + xname);
633  }
634  // get the composition of the species
635  const XML_Node& a = s.child("atomArray");
636  map<string,string> comp;
637  getMap(a, comp);
638 
639  // check that all elements in the species
640  // exist in 'p'. If rule != 0, quietly skip
641  // this species if some elements are undeclared;
642  // otherwise, throw an exception
643  map<string,string>::const_iterator _b = comp.begin();
644  for (; _b != comp.end(); ++_b) {
645  if (th.elementIndex(_b->first) == npos) {
646  if (rule == 0) {
647  throw CanteraError("installSpecies",
648  "Species " + s["name"] +
649  " contains undeclared element " + _b->first);
650  } else {
651  return false;
652  }
653  }
654  }
655 
656  // construct a vector of atom numbers for each
657  // element in phase th. Elements not declared in the
658  // species (i.e., not in map comp) will have zero
659  // entries in the vector.
660  size_t nel = th.nElements();
661  vector_fp ecomp(nel, 0.0);
662  for (size_t m = 0; m < nel; m++) {
663  std::string& es = comp[th.elementName(m)];
664  if (!es.empty()) {
665  ecomp[m] = fpValueCheck(es);
666  }
667  }
668 
669 
670  // get the species charge, if any. Note that the charge need
671  // not be explicitly specified if special element 'E'
672  // (electron) is one of the elements.
673  doublereal chrg = 0.0;
674  if (s.hasChild("charge")) {
675  chrg = getFloat(s, "charge");
676  }
677 
678  // get the species size, if any. (This is used by surface
679  // phases to represent how many sites a species occupies.)
680  doublereal sz = 1.0;
681  if (s.hasChild("size")) {
682  sz = getFloat(s, "size");
683  }
684 
685  // add the species to phase th
686  th.addUniqueSpecies(s["name"], &ecomp[0], chrg, sz);
687 
688  if (vpss_ptr) {
689  VPStandardStateTP* vp_ptr = dynamic_cast<VPStandardStateTP*>(&th);
690  factory->installVPThermoForSpecies(k, s, vp_ptr, vpss_ptr, spthermo_ptr,
691  phaseNode_ptr);
692  } else {
693  // install the thermo parameterization for this species into
694  // the species thermo manager for phase th
695  factory->installThermoForSpecies(k, s, &th, *spthermo_ptr, phaseNode_ptr);
696  }
697 
698  return true;
699 }
700 
701 const XML_Node* speciesXML_Node(const std::string& kname,
702  const XML_Node* phaseSpeciesData)
703 {
704  if (!phaseSpeciesData) {
705  return 0;
706  }
707  string jname = phaseSpeciesData->name();
708  if (jname != "speciesData") {
709  throw CanteraError("speciesXML_Node()",
710  "Unexpected phaseSpeciesData name: " + jname);
711  }
712  vector<XML_Node*> xspecies;
713  phaseSpeciesData->getChildren("species", xspecies);
714  for (size_t j = 0; j < xspecies.size(); j++) {
715  const XML_Node& sp = *xspecies[j];
716  jname = sp["name"];
717  if (jname == kname) {
718  return &sp;
719  }
720  }
721  return 0;
722 }
723 
724 }
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:249
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:40
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:144
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...
size_t nElements() const
Number of elements.
Definition: Phase.cpp:139
void clear()
Clear the current node and everything under it.
Definition: xml.cpp:379
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:238
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.
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:173
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...
const int cSS_CONVENTION_TEMPERATURE
Standard state uses the molar convention.
Definition: ThermoPhase.h:34
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
doublereal getFloat(const Cantera::XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
Definition: ctml.cpp:267
A simple thermodynamic model for a bulk phase, assuming a lattice of solid atoms. ...
Definition: LatticePhase.h:246
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...
void installThermoForSpecies(size_t k, const XML_Node &speciesNode, ThermoPhase *th_ptr, SpeciesThermo &spthermo, const XML_Node *phaseNode_ptr=0) const
Install a species thermodynamic property parameterization for the reference state for one species int...
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:584
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:600
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
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:134
SpeciesThermo * newSpeciesThermoMgr(int type, SpeciesThermoFactory *f)
Create a new species thermo manager instance, by specifying the type and (optionally) a pointer to th...
std::vector< int > vector_int
Vector of ints.
Definition: ct_defs.h:167
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:31
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
Definition: SurfPhase.h:143
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...
void installVPThermoForSpecies(size_t k, const XML_Node &speciesNode, VPStandardStateTP *vp_ptr, VPSSMgr *vpss_ptr, SpeciesThermo *spthermo_ptr, const XML_Node *phaseNode_ptr) const
Install a species thermodynamic property parameterization for the standard state for one species into...
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 * newPhase(const std::string &infile, std::string id)
Create and Initialize a ThermoPhase object from an XML input file.
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:390
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:510
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:119
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:68
const int cVPSS_IdealGas
Variable Pressure Standard State ThermoPhase objects.
Definition: mix_defs.h:94
void addElementsFromXML(const XML_Node &phase)
Add all elements referenced in an XML_Node tree.
Definition: Phase.cpp:745
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:574
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
virtual void freezeSpecies()
Call when finished adding species.
Definition: Phase.cpp:913
const int cIdealMolalSoln
IdealMolalSoln - molality based solution with molality-based act coeffs of 1.
Definition: mix_defs.h:73
void copy(XML_Node *const node_dest) const
Copy all of the information in the current XML_Node tree into the destination XML_Node tree...
Definition: xml.cpp:875
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:519
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:216
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...
std::string id() const
Return the id attribute, if present.
Definition: xml.cpp:467
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:67
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.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:165
size_t elementIndex(const std::string &name) const
Return the index of element named 'name'.
Definition: Phase.cpp:164
Header file for the MineralEQ3 class, which represents a fixed-composition incompressible substance b...
void getStringArray(const Cantera::XML_Node &node, std::vector< std::string > &v)
This function interprets the value portion of an XML element as a string.
Definition: ctml.cpp:639
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:1489
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...
std::string elementName(size_t m) const
Name of the element with index m.
Definition: Phase.cpp:158
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:70
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:1226
XML_Node & xml()
Returns a reference to the XML_Node stored for the phase.
Definition: Phase.cpp:114
Header for factory to build instances of classes that manage the standard-state thermodynamic propert...
void setID(const std::string &id)
Set the string id for the phase.
Definition: Phase.cpp:124
void getMap(const Cantera::XML_Node &node, std::map< std::string, std::string > &m)
This routine is used to interpret the value portions of XML elements that contain colon separated pai...
Definition: ctml.cpp:508
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:1091
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:97
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
void addUniqueSpecies(const std::string &name, const doublereal *comp, doublereal charge=0.0, doublereal size=1.0)
Add a species to the phase, checking for uniqueness of the name This routine checks for uniqueness of...
Definition: Phase.cpp:884
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:271
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:594
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:916
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:579
const int cIdealSolidSolnPhase
Constant partial molar volume solution IdealSolidSolnPhase.h.
Definition: mix_defs.h:64