63 ThermoFactory* ThermoFactory::s_factory = 0;
64 mutex_t ThermoFactory::thermo_mutex;
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"
84 cPureFluid, cLatticeSolid, cLattice,
87 cMineralEQ3, cMetalSHEelectrons,
88 cMargulesVPSSTP, cPhaseCombo_Interaction, cIonsFromNeutral,
cFixedChemPot,
89 cMolarityIonicVPSSTP, cMixedSolventElectrolyte, cRedlichKisterVPSSTP,
90 cRedlichKwongMFTP, cRedlichKwongMFTP, cMaskellSolidSolnPhase
97 for (
int n = 0; n <
ntypes; n++) {
108 case cIncompressible:
116 case cMargulesVPSSTP:
118 case cRedlichKisterVPSSTP:
120 case cMolarityIonicVPSSTP:
122 case cPhaseCombo_Interaction:
124 case cIonsFromNeutral:
128 case cStoichSubstance:
138 case cMetalSHEelectrons:
146 case cRedlichKwongMFTP:
156 case cIdealSolnGasVPSS_iscv:
158 case cMaskellSolidSolnPhase:
167 for (
int n = 0; n <
ntypes; n++) {
172 return "UnknownPhaseType";
177 string model = xmlphase.
child(
"thermo")[
"model"];
179 if (model ==
"singing cows") {
180 throw CanteraError(
"ThermoPhase::newPhase",
"Cows don't sing");
181 }
else if (model ==
"HMW") {
184 }
else if (model ==
"IonsFromNeutralMolecule") {
202 "Couldn't find phase named \"" +
id +
"\" in file, " + infile);
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,
227 std::map<std::string, bool> declared;
229 for (
size_t jsp = 0; jsp < spArray_dbases.size(); jsp++) {
230 const XML_Node& speciesArray = *spArray_names[jsp];
233 const XML_Node* db = spArray_dbases[jsp];
236 std::vector<std::string> spnames;
238 size_t nsp = spnames.size();
243 if (nsp == 1 && spnames[0] ==
"all") {
244 std::vector<XML_Node*> allsp = db->
getChildren(
"species");
247 for (
size_t nn = 0; nn < nsp; nn++) {
248 string stemp = (*allsp[nn])[
"name"];
250 if (declared[stemp]) {
251 if (sprule[jsp] >= 10) {
254 throw CanteraError(
"ThermoFactory::formSpeciesXMLNodeList()",
255 "duplicate species: \"" + stemp +
"\"");
259 declared[stemp] =
true;
260 spNamesList.push_back(stemp);
261 spDataNodeList.push_back(allsp[nn]);
262 spRuleList.push_back(sprule[jsp]);
265 }
else if (nsp == 1 && spnames[0] ==
"unique") {
266 std::vector<XML_Node*> allsp = db->
getChildren(
"species");
269 for (
size_t nn = 0; nn < nsp; nn++) {
270 string stemp = (*allsp[nn])[
"name"];
272 if (declared[stemp]) {
276 declared[stemp] =
true;
277 spNamesList.push_back(stemp);
278 spDataNodeList.push_back(allsp[nn]);
279 spRuleList.push_back(sprule[jsp]);
283 std::map<std::string, XML_Node*> speciesNodes;
284 for (
size_t k = 0; k < db->
nChildren(); k++) {
286 speciesNodes[child[
"name"]] = &child;
288 for (
size_t k = 0; k < nsp; k++) {
289 string stemp = spnames[k];
291 if (declared[stemp]) {
292 if (sprule[jsp] >= 10) {
295 throw CanteraError(
"ThermoFactory::formSpeciesXMLNodeList()",
296 "duplicate species: \"" + stemp +
"\"");
300 declared[stemp] =
true;
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, \""
307 spNamesList.push_back(stemp);
308 spDataNodeList.push_back(iter->second);
309 spRuleList.push_back(sprule[jsp]);
320 if (phase.
name() !=
"phase") {
322 "Current const XML_Node named, " + phase.
name() +
323 ", is not a phase element.");
342 if (idim < 1 || idim > 3)
344 "phase, " + th->
id() +
345 ", has unphysical number of dimensions: " + phase[
"dim"]);
359 " phase, " + th->
id() +
360 ", XML_Node does not have a \"thermo\" XML_Node");
369 "phase, " + th->
id() +
", was VPSS, but dynamic cast failed");
387 vector<XML_Node*> sparrays = phase.
getChildren(
"speciesArray");
389 if (sparrays.empty()) {
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");
396 vector<XML_Node*> dbases;
400 for (
size_t jsp = 0; jsp < sparrays.size(); jsp++) {
402 const XML_Node& speciesArray = *sparrays[jsp];
416 if (speciesArray.
hasChild(
"skip")) {
418 string eskip = sk[
"element"];
419 if (eskip ==
"undeclared") {
422 string dskip = sk[
"species"];
423 if (dskip ==
"duplicate") {
436 " Can not find XML node for species database: "
437 + speciesArray[
"datasrc"]);
441 dbases.push_back(db);
448 std::vector<XML_Node*> spDataNodeList;
449 std::vector<std::string> spNamesList;
450 std::vector<int> spRuleList;
452 sparrays, dbases, sprule);
461 size_t nsp = spDataNodeList.size();
464 throw CanteraError(
"importPhase()",
"For Slave standard states, number of species must be zero: "
468 for (
size_t k = 0; k < nsp; k++) {
476 vpss_ptr->createInstallPDSS(k, *s, &phase);
500 if (!phaseNode.
hasChild(
"elementArray")) {
502 "phase XML node doesn't have \"elementArray\" XML Node");
505 vector<string> enames;
509 string element_database =
"elements.xml";
511 element_database = elements[
"datasrc"];
520 local_db = &root.
child(
"elementData");
523 for (
size_t i = 0; i < enames.size(); i++) {
533 throw CanteraError(
"addElementsFromXML",
"no data for element "
538 doublereal weight = 0.0;
546 string symbol = e->
attrib(
"name");
555 th.
addElement(symbol, weight, anum, entropy298);
569 " VPStandardStateTP phases, call createInstallPDSS as well."
570 " To be removed after Cantera 2.2.");
574 vp_ptr->createInstallPDSS(k, s, phaseNode_ptr);
582 if (!phaseSpeciesData) {
585 string jname = phaseSpeciesData->
name();
586 if (jname !=
"speciesData") {
588 "Unexpected phaseSpeciesData name: " + jname);
590 vector<XML_Node*> xspecies = phaseSpeciesData->
getChildren(
"species");
591 for (
size_t j = 0; j < xspecies.size(); j++) {
594 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 ...
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...
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.
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.
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.
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.
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...
Class XML_Node is a tree-based representation of the contents of an XML file.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Class Phase is the base class for phases of matter, managing the species and elements in a phase...
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...
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.
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.
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.
void setName(const std::string &nm)
Sets the string name for the phase.
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.
shared_ptr< Species > newSpecies(const XML_Node &species_node)
Create a new Species object from a 'species' XML_Node.
A simple thermodynamic model for a surface phase, assuming an ideal solution model.
void ignoreUndefinedElements()
Set behavior when adding a species containing undefined elements to just skip the species...
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...
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...
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.
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.
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.
#define ENTROPY298_UNKNOWN
Number indicating we don't know the entropy of the element in its most stable state at 298...
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...
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.
std::string id() const
Return the id attribute, if present.
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.
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.
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...
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...
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.
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.
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.
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:
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.