62 ThermoFactory* ThermoFactory::s_factory = 0;
63 mutex_t ThermoFactory::thermo_mutex;
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",
83 cPureFluid, cLatticeSolid, cLattice,
86 cMineralEQ3, cMetalSHEelectrons,
87 cMargulesVPSSTP, cPhaseCombo_Interaction, cIonsFromNeutral,
cFixedChemPot,
88 cMolarityIonicVPSSTP, cMixedSolventElectrolyte, cRedlichKisterVPSSTP,
89 cRedlichKwongMFTP, cRedlichKwongMFTP
97 for (
int n = 0; n <
ntypes; n++) {
110 case cIncompressible:
126 case cMargulesVPSSTP:
130 case cRedlichKisterVPSSTP:
134 case cMolarityIonicVPSSTP:
138 case cPhaseCombo_Interaction:
142 case cIonsFromNeutral:
150 case cStoichSubstance:
166 case cMetalSHEelectrons:
182 case cRedlichKwongMFTP:
202 case cIdealSolnGasVPSS_iscv:
215 std::string ss =
"UnknownPhaseType";
217 for (
int n = 0; n <
ntypes; n++) {
229 string model = th[
"model"];
231 if (model ==
"singing cows") {
232 throw CanteraError(
"ThermoPhase::newPhase",
"Cows don't sing");
233 }
else if (model ==
"HMW") {
236 }
else if (model ==
"IonsFromNeutralMolecule") {
256 "Couldn't find phase named \"" +
id +
"\" in file, " + infile);
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,
287 std::map<std::string, bool> declared;
292 for (
size_t jsp = 0; jsp < spArray_dbases.size(); jsp++) {
293 const XML_Node& speciesArray = *spArray_names[jsp];
296 const XML_Node* db = spArray_dbases[jsp];
299 std::vector<std::string> spnames;
301 size_t nsp = spnames.size();
306 if (nsp == 1 && spnames[0] ==
"all") {
307 std::vector<XML_Node*> allsp;
311 for (
size_t nn = 0; nn < nsp; nn++) {
312 string stemp = (*allsp[nn])[
"name"];
314 if (declared[stemp]) {
315 if (sprule[jsp] >= 10) {
318 throw CanteraError(
"ThermoFactory::formSpeciesXMLNodeList()",
319 "duplicate species: \"" + stemp +
"\"");
323 declared[stemp] =
true;
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];
333 }
else if (nsp == 1 && spnames[0] ==
"unique") {
334 std::vector<XML_Node*> allsp;
338 for (
size_t nn = 0; nn < nsp; nn++) {
339 string stemp = (*allsp[nn])[
"name"];
341 if (declared[stemp]) {
345 declared[stemp] =
true;
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];
356 std::map<std::string, XML_Node*> speciesNodes;
357 for (
size_t k = 0; k < db->
nChildren(); k++) {
359 speciesNodes[child[
"name"]] = &child;
361 for (
size_t k = 0; k < nsp; k++) {
362 string stemp = spnames[k];
364 if (declared[stemp]) {
365 if (sprule[jsp] >= 10) {
368 throw CanteraError(
"ThermoFactory::formSpeciesXMLNodeList()",
369 "duplicate species: \"" + stemp +
"\"");
373 declared[stemp] =
true;
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, \""
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];
400 if (phase.
name() !=
"phase") {
402 "Current const XML_Node named, " + phase.
name() +
403 ", is not a phase element.");
414 phaseNode_XML.
clear();
415 phase.
copy(&phaseNode_XML);
425 if (idim < 1 || idim > 3)
427 "phase, " + th->
id() +
428 ", has unphysical number of dimensions: " + phase[
"dim"]);
442 " phase, " + th->
id() +
443 ", XML_Node does not have a \"thermo\" XML_Node");
452 "phase, " + th->
id() +
", was VPSS, but dynamic cast failed");
459 spfactory = SpeciesThermoFactory::factory();
477 vector<XML_Node*> sparrays;
479 int jsp, nspa =
static_cast<int>(sparrays.size());
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");
488 vector<XML_Node*> dbases;
492 for (jsp = 0; jsp < nspa; jsp++) {
494 const XML_Node& speciesArray = *sparrays[jsp];
510 if (speciesArray.
hasChild(
"skip")) {
512 string eskip = sk[
"element"];
513 if (eskip ==
"undeclared") {
516 string dskip = sk[
"species"];
517 if (dskip ==
"duplicate") {
532 " Can not find XML node for species database: "
533 + speciesArray[
"datasrc"]);
537 dbases.push_back(db);
544 std::vector<XML_Node*> spDataNodeList;
545 std::vector<std::string> spNamesList;
546 std::vector<int> spRuleList;
548 sparrays, dbases, sprule);
564 if (eos[
"allow_discontinuities"] ==
"true") {
565 std::cout <<
"ALLOWING DISCONTINUOUS THERMO!" << std::endl;
566 spth->m_allow_discontinuities =
true;
576 vp_spth =
newVPSSMgr(vpss_ptr, &phase, spDataNodeList);
581 throw CanteraError(
"importPhase()",
"unknown convention");
587 size_t nsp = spDataNodeList.size();
590 throw CanteraError(
"importPhase()",
"For Slave standard states, number of species must be zero: "
594 for (
size_t i = 0; i < nsp; i++) {
598 &phase, vp_spth, spfactory);
629 std::string xname = s.
name();
630 if (xname !=
"species") {
632 "Unexpected XML name of species XML_Node: " + xname);
636 map<string,string> comp;
643 map<string,string>::const_iterator _b = comp.begin();
644 for (; _b != comp.end(); ++_b) {
648 "Species " + s[
"name"] +
649 " contains undeclared element " + _b->first);
662 for (
size_t m = 0; m < nel; m++) {
673 doublereal chrg = 0.0;
704 if (!phaseSpeciesData) {
707 string jname = phaseSpeciesData->
name();
708 if (jname !=
"speciesData") {
710 "Unexpected phaseSpeciesData name: " + jname);
712 vector<XML_Node*> xspecies;
713 phaseSpeciesData->
getChildren(
"species", xspecies);
714 for (
size_t j = 0; j < xspecies.size(); j++) {
717 if (jname == kname) {
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.
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 ...
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.
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.
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.
void clear()
Clear the current node and everything under it.
Virtual base class for the classes that manage the calculation of standard state properties for all t...
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"
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...
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.
Class XML_Node is a tree-based representation of the contents of an XML file.
doublereal getFloat(const Cantera::XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
A simple thermodynamic model for a bulk phase, assuming a lattice of solid atoms. ...
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.
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...
Base class for a phase with thermodynamic properties.
Class StoichSubstanceSSTP represents a stoichiometric (fixed composition) incompressible substance...
const int cSurf
A surface phase. Used by class SurfPhase.
void setName(const std::string &nm)
Sets the string name for the phase.
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.
Contains const definitions for types of species reference-state thermodynamics managers (see Species ...
A thermodynamic phase representing a one dimensional edge between two surfaces.
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
const int cFixedChemPot
Stoichiometric compound with a constant chemical potential.
bool importPhase(XML_Node &phase, ThermoPhase *th, SpeciesThermoFactory *spfactory)
Import a phase information into an empty thermophase object.
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...
std::string name() const
Returns the name of the XML node.
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. ...
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.
std::string id() const
Return the string id for the phase.
Overloads the virtual methods of class ThermoPhase to implement the incompressible equation of state...
Base class for exceptions thrown by Cantera classes.
const int cVPSS_IdealGas
Variable Pressure Standard State ThermoPhase objects.
void addElementsFromXML(const XML_Node &phase)
Add all elements referenced in an XML_Node tree.
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.
ThermoPhase * newThermoPhase(const std::string &model, ThermoFactory *f=0)
Create a new thermo manager instance.
const int cEdge
An edge between two 2D surfaces.
virtual void freezeSpecies()
Call when finished adding species.
const int cIdealMolalSoln
IdealMolalSoln - molality based solution with molality-based act coeffs of 1.
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...
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).
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.
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.
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.
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.
size_t elementIndex(const std::string &name) const
Return the index of element named 'name'.
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.
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.
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.
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.
This file contains the class declarations for the StoichSubstance ThermoPhase class.
const int cDebyeHuckel
DebyeHuckel - Weak electrolyte using various Debye-Huckel formulations.
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...
XML_Node & xml()
Returns a reference to the XML_Node stored for the phase.
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.
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...
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.
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...
doublereal fpValueCheck(const std::string &val)
Translate a string into one doublereal value, with error checking.
const int cIdealGas
Equation of state types:
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...
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 ...
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.
const int cSS_CONVENTION_SLAVE
Standard state thermodynamics is obtained from slave ThermoPhase objects.
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...
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.
const int cIdealSolidSolnPhase
Constant partial molar volume solution IdealSolidSolnPhase.h.