49 ThermoFactory* ThermoFactory::s_factory = 0;
50 std::mutex ThermoFactory::thermo_mutex;
52 ThermoFactory::ThermoFactory()
56 reg(
"Surface", []() {
return new SurfPhase(); });
57 reg(
"Edge", []() {
return new EdgePhase(); });
58 reg(
"Metal", []() {
return new MetalPhase(); });
63 reg(
"HMW", []() {
return new HMWSoln(); });
65 reg(
"DebyeHuckel", []() {
return new DebyeHuckel(); });
68 m_synonyms[
"IdealGasVPSS"] =
"IdealSolnVPSS";
69 reg(
"MineralEQ3", []() {
return new MineralEQ3(); });
78 m_synonyms[
"RedlichKwongMFTP"] =
"RedlichKwong";
89 string model = xmlphase.
child(
"thermo")[
"model"];
104 "Couldn't find phase named \"" +
id +
"\" in file, " + infile);
125 std::vector<std::string> &spNamesList,
127 const std::vector<XML_Node*> spArray_names,
128 const std::vector<XML_Node*> spArray_dbases,
132 std::map<std::string, bool> declared;
134 for (
size_t jsp = 0; jsp < spArray_dbases.size(); jsp++) {
135 const XML_Node& speciesArray = *spArray_names[jsp];
138 const XML_Node* db = spArray_dbases[jsp];
141 std::vector<std::string> spnames;
143 size_t nsp = spnames.size();
148 if (nsp == 1 && spnames[0] ==
"all") {
149 std::vector<XML_Node*> allsp = db->
getChildren(
"species");
152 for (
size_t nn = 0; nn < nsp; nn++) {
153 string stemp = (*allsp[nn])[
"name"];
154 if (!declared[stemp] || sprule[jsp] < 10) {
155 declared[stemp] =
true;
156 spNamesList.push_back(stemp);
157 spDataNodeList.push_back(allsp[nn]);
158 spRuleList.push_back(sprule[jsp]);
161 }
else if (nsp == 1 && spnames[0] ==
"unique") {
162 std::vector<XML_Node*> allsp = db->
getChildren(
"species");
165 for (
size_t nn = 0; nn < nsp; nn++) {
166 string stemp = (*allsp[nn])[
"name"];
167 if (!declared[stemp]) {
168 declared[stemp] =
true;
169 spNamesList.push_back(stemp);
170 spDataNodeList.push_back(allsp[nn]);
171 spRuleList.push_back(sprule[jsp]);
175 std::map<std::string, XML_Node*> speciesNodes;
176 for (
size_t k = 0; k < db->
nChildren(); k++) {
178 speciesNodes[child[
"name"]] = &child;
180 for (
size_t k = 0; k < nsp; k++) {
181 string stemp = spnames[k];
182 if (!declared[stemp] || sprule[jsp] < 10) {
183 declared[stemp] =
true;
185 auto iter = speciesNodes.find(stemp);
186 if (iter == speciesNodes.end()) {
187 throw CanteraError(
"importPhase",
"no data for species, \"" 190 spNamesList.push_back(stemp);
191 spDataNodeList.push_back(iter->second);
192 spRuleList.push_back(sprule[jsp]);
202 if (phase.
name() !=
"phase") {
204 "Current const XML_Node named, " + phase.
name() +
205 ", is not a phase element.");
221 if (idim < 1 || idim > 3) {
223 "phase, " + th->
id() +
224 ", has unphysical number of dimensions: " + phase[
"dim"]);
239 " phase, " + th->
id() +
240 ", XML_Node does not have a \"thermo\" XML_Node");
249 "phase, " + th->
id() +
", was VPSS, but dynamic cast failed");
262 vector<XML_Node*> sparrays = phase.
getChildren(
"speciesArray");
265 "phase, " + th->
id() +
", has zero \"speciesArray\" XML nodes.\n" 266 +
" There must be at least one speciesArray nodes " 267 "with one or more species");
269 vector<XML_Node*> dbases;
277 for (
size_t jsp = 0; jsp < sparrays.size(); jsp++) {
278 const XML_Node& speciesArray = *sparrays[jsp];
292 if (speciesArray.
hasChild(
"skip")) {
294 string eskip = sk[
"element"];
295 if (eskip ==
"undeclared") {
298 string dskip = sk[
"species"];
299 if (dskip ==
"duplicate") {
310 " Can not find XML node for species database: " 311 + speciesArray[
"datasrc"]);
315 dbases.push_back(db);
322 std::vector<XML_Node*> spDataNodeList;
323 std::vector<std::string> spNamesList;
326 sparrays, dbases, sprule);
328 size_t nsp = spDataNodeList.size();
330 throw CanteraError(
"importPhase()",
"For Slave standard states, " 331 "number of species must be zero: {}", nsp);
333 for (
size_t k = 0; k < nsp; k++) {
342 std::string ss_model = (ss) ? ss->
attrib(
"model") :
"ideal-gas";
343 unique_ptr<PDSS> kPDSS(newPDSS(ss_model));
344 kPDSS->setParametersFromXML(*s);
363 if (!phaseNode.
hasChild(
"elementArray")) {
365 "phase XML node doesn't have \"elementArray\" XML Node");
368 vector<string> enames;
372 string element_database =
"elements.xml";
374 element_database = elements[
"datasrc"];
383 local_db = &root.
child(
"elementData");
386 for (
size_t i = 0; i < enames.size(); i++) {
396 throw CanteraError(
"addElementsFromXML",
"no data for element " 401 doublereal weight = 0.0;
409 string symbol = e->
attrib(
"name");
417 th.
addElement(symbol, weight, anum, entropy298);
424 if (!phaseSpeciesData) {
427 string jname = phaseSpeciesData->
name();
428 if (jname !=
"speciesData") {
430 "Unexpected phaseSpeciesData name: " + jname);
432 vector<XML_Node*> xspecies = phaseSpeciesData->
getChildren(
"species");
433 for (
size_t j = 0; j < xspecies.size(); j++) {
436 if (jname == kname) {
Header for a general species thermodynamic property manager for a phase (see MultiSpeciesThermo).
XML_Node * get_XML_Node(const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
doublereal fpValue(const std::string &val)
Translate a string into one doublereal value.
std::vector< XML_Node * > getChildren(const std::string &name) const
Get a vector of pointers to XML_Node containing all of the children of the current node which match t...
ThermoPhase object for the ideal molal equation of state (see Thermodynamic Properties and class Idea...
virtual bool addSpecies(shared_ptr< Species > spec)
Implementation of a multi-species Redlich-Kwong equation of state.
XML_Node * get_XML_File(const std::string &file, int debug)
Return a pointer to the XML tree for a Cantera input file.
std::string name() const
Returns the name of the XML node.
Header for a simple thermodynamics model of a surface phase derived from ThermoPhase, assuming an ideal solution model (see Thermodynamic Properties and class SurfPhase).
(see Thermodynamic Properties and class MargulesVPSSTP).
This phase object consists of a single component that can be a gas, a liquid, a mixed gas-liquid flui...
const XML_Node * findByName(const std::string &nm, int depth=100000) const
This routine carries out a recursive search for an XML node based on the name of the node...
Header for intermediate ThermoPhase object for phases which employ the Margules Gibbs free energy for...
RedlichKisterVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Redlich-Kister approxima...
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state...
Header for intermediate ThermoPhase object for phases which consist of ions whose thermodynamics is c...
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
Definition file for a derived class of ThermoPhase that assumes either an ideal gas or ideal solution...
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.
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.
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
void saveSpeciesData(const size_t k, const XML_Node *const data)
Store a reference pointer to the XML tree containing the species data for this phase.
(see Thermodynamic Properties and class MolarityIonicVPSSTP).
Headers for the DebyeHuckel ThermoPhase object, which models dilute electrolyte solutions (see Thermo...
Class StoichSubstance represents a stoichiometric (fixed composition) incompressible substance...
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.
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 ...
void throwUndefinedElements()
Set the behavior when adding a species containing undefined elements to throw an exception.
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...
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...
Header for a ThermoPhase class for a pure fluid phase consisting of gas, liquid, mixed-gas-liquid and...
Header file for an ideal solid solution model with incompressible thermodynamics (see Thermodynamic P...
Overloads the virtual methods of class ThermoPhase to implement the incompressible equation of state...
Base class for exceptions thrown by Cantera classes.
void installPDSS(size_t k, std::unique_ptr< PDSS > &&pdss)
Install a PDSS object for species k
virtual int standardStateConvention() const
This method returns the convention used in specification of the standard state, of which there are cu...
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
void installElements(Phase &th, const XML_Node &phaseNode)
Add the elements given in an XML_Node tree to the specified phase.
#define ENTROPY298_UNKNOWN
Number indicating we don't know the entropy of the element in its most stable state at 298...
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
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).
XML_Node & root() const
Return the root of the current XML_Node tree.
#define AssertTrace(expr)
Assertion must be true or an error is thrown.
Header for factory functions to build instances of classes that manage the standard-state thermodynam...
std::string id() const
Return the string id for the phase.
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.
virtual void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
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.
std::string id() const
Return the id attribute, if present.
const int cSS_CONVENTION_VPSS
Standard state uses the molality convention.
Contains declarations for string manipulation functions within Cantera.
Header file for the FixedChemPotSSTP class, which represents a fixed-composition incompressible subst...
Header file for the StoichSubstance class, which represents a fixed-composition incompressible substa...
static void formSpeciesXMLNodeList(std::vector< XML_Node *> &spDataNodeList, std::vector< std::string > &spNamesList, vector_int &spRuleList, const std::vector< XML_Node *> spArray_names, const std::vector< XML_Node *> spArray_dbases, const vector_int sprule)
Gather a vector of pointers to XML_Nodes for a phase.
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...
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.
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...
Declaration for class Cantera::Species.
ThermoPhase * newThermoPhase(const std::string &model)
Create a new thermo manager instance.
This phase is based upon the mixing-rule assumption that all molality-based activity coefficients are...
Namespace for the Cantera kernel.
(see Thermodynamic Properties and class RedlichKisterVPSSTP).
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.
size_t nChildren(bool discardComments=false) const
Return the number of children.
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...
const int cSS_CONVENTION_SLAVE
Standard state thermodynamics is obtained from slave ThermoPhase objects.
An ideal solution or an ideal gas approximation of a phase.