52 ThermoFactory* ThermoFactory::s_factory = 0;
53 std::mutex ThermoFactory::thermo_mutex;
59 static string _types[] = {
"IdealGas",
"Incompressible",
60 "Surface",
"Edge",
"Metal",
"StoichSubstance",
61 "PureFluid",
"LatticeSolid",
"Lattice",
62 "HMW",
"IdealSolidSolution",
"DebyeHuckel",
63 "IdealMolalSolution",
"IdealGasVPSS",
"IdealSolnVPSS",
64 "MineralEQ3",
"MetalSHEelectrons",
"Margules",
"PhaseCombo_Interaction",
65 "IonsFromNeutralMolecule",
"FixedChemPot",
"MolarityIonicVPSSTP",
66 "MixedSolventElectrolyte",
"Redlich-Kister",
"RedlichKwong",
67 "RedlichKwongMFTP",
"MaskellSolidSolnPhase" 73 cPureFluid, cLatticeSolid, cLattice,
76 cMineralEQ3, cMetalSHEelectrons,
77 cMargulesVPSSTP, cPhaseCombo_Interaction, cIonsFromNeutral,
cFixedChemPot,
78 cMolarityIonicVPSSTP, cMixedSolventElectrolyte, cRedlichKisterVPSSTP,
79 cRedlichKwongMFTP, cRedlichKwongMFTP, cMaskellSolidSolnPhase
82 ThermoFactory::ThermoFactory()
86 reg(
"Surface", []() {
return new SurfPhase(); });
87 reg(
"Edge", []() {
return new EdgePhase(); });
88 reg(
"Metal", []() {
return new MetalPhase(); });
93 reg(
"HMW", []() {
return new HMWSoln(); });
95 reg(
"DebyeHuckel", []() {
return new DebyeHuckel(); });
99 reg(
"MineralEQ3", []() {
return new MineralEQ3(); });
114 return create(model);
120 for (
int n = 0; n <
ntypes; n++) {
125 return "UnknownPhaseType";
130 string model = xmlphase.
child(
"thermo")[
"model"];
145 "Couldn't find phase named \"" +
id +
"\" in file, " + infile);
166 std::vector<std::string> &spNamesList,
168 const std::vector<XML_Node*> spArray_names,
169 const std::vector<XML_Node*> spArray_dbases,
173 std::map<std::string, bool> declared;
175 for (
size_t jsp = 0; jsp < spArray_dbases.size(); jsp++) {
176 const XML_Node& speciesArray = *spArray_names[jsp];
179 const XML_Node* db = spArray_dbases[jsp];
182 std::vector<std::string> spnames;
184 size_t nsp = spnames.size();
189 if (nsp == 1 && spnames[0] ==
"all") {
190 std::vector<XML_Node*> allsp = db->
getChildren(
"species");
193 for (
size_t nn = 0; nn < nsp; nn++) {
194 string stemp = (*allsp[nn])[
"name"];
195 if (!declared[stemp] || sprule[jsp] < 10) {
196 declared[stemp] =
true;
197 spNamesList.push_back(stemp);
198 spDataNodeList.push_back(allsp[nn]);
199 spRuleList.push_back(sprule[jsp]);
202 }
else if (nsp == 1 && spnames[0] ==
"unique") {
203 std::vector<XML_Node*> allsp = db->
getChildren(
"species");
206 for (
size_t nn = 0; nn < nsp; nn++) {
207 string stemp = (*allsp[nn])[
"name"];
208 if (!declared[stemp]) {
209 declared[stemp] =
true;
210 spNamesList.push_back(stemp);
211 spDataNodeList.push_back(allsp[nn]);
212 spRuleList.push_back(sprule[jsp]);
216 std::map<std::string, XML_Node*> speciesNodes;
217 for (
size_t k = 0; k < db->
nChildren(); k++) {
219 speciesNodes[child[
"name"]] = &child;
221 for (
size_t k = 0; k < nsp; k++) {
222 string stemp = spnames[k];
223 if (!declared[stemp] || sprule[jsp] < 10) {
224 declared[stemp] =
true;
226 auto iter = speciesNodes.find(stemp);
227 if (iter == speciesNodes.end()) {
228 throw CanteraError(
"importPhase",
"no data for species, \"" 231 spNamesList.push_back(stemp);
232 spDataNodeList.push_back(iter->second);
233 spRuleList.push_back(sprule[jsp]);
243 if (phase.
name() !=
"phase") {
245 "Current const XML_Node named, " + phase.
name() +
246 ", is not a phase element.");
262 if (idim < 1 || idim > 3) {
264 "phase, " + th->
id() +
265 ", has unphysical number of dimensions: " + phase[
"dim"]);
280 " phase, " + th->
id() +
281 ", XML_Node does not have a \"thermo\" XML_Node");
290 "phase, " + th->
id() +
", was VPSS, but dynamic cast failed");
303 vector<XML_Node*> sparrays = phase.
getChildren(
"speciesArray");
306 "phase, " + th->
id() +
", has zero \"speciesArray\" XML nodes.\n" 307 +
" There must be at least one speciesArray nodes " 308 "with one or more species");
310 vector<XML_Node*> dbases;
314 for (
size_t jsp = 0; jsp < sparrays.size(); jsp++) {
315 const XML_Node& speciesArray = *sparrays[jsp];
329 if (speciesArray.
hasChild(
"skip")) {
331 string eskip = sk[
"element"];
332 if (eskip ==
"undeclared") {
335 string dskip = sk[
"species"];
336 if (dskip ==
"duplicate") {
347 " Can not find XML node for species database: " 348 + speciesArray[
"datasrc"]);
352 dbases.push_back(db);
359 std::vector<XML_Node*> spDataNodeList;
360 std::vector<std::string> spNamesList;
363 sparrays, dbases, sprule);
371 size_t nsp = spDataNodeList.size();
373 throw CanteraError(
"importPhase()",
"For Slave standard states, " 374 "number of species must be zero: {}", nsp);
376 for (
size_t k = 0; k < nsp; k++) {
384 vpss_ptr->createInstallPDSS(k, *s, &phase);
402 if (!phaseNode.
hasChild(
"elementArray")) {
404 "phase XML node doesn't have \"elementArray\" XML Node");
407 vector<string> enames;
411 string element_database =
"elements.xml";
413 element_database = elements[
"datasrc"];
422 local_db = &root.
child(
"elementData");
425 for (
size_t i = 0; i < enames.size(); i++) {
435 throw CanteraError(
"addElementsFromXML",
"no data for element " 440 doublereal weight = 0.0;
448 string symbol = e->
attrib(
"name");
456 th.
addElement(symbol, weight, anum, entropy298);
463 if (!phaseSpeciesData) {
466 string jname = phaseSpeciesData->
name();
467 if (jname !=
"speciesData") {
469 "Unexpected phaseSpeciesData name: " + jname);
471 vector<XML_Node*> xspecies = phaseSpeciesData->
getChildren(
"species");
472 for (
size_t j = 0; j < xspecies.size(); j++) {
475 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...
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...
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...
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.
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.
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...
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.
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.
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...
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.
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.
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 ...
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 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.
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...
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.
static string _types[]
Define the string name of the ThermoPhase types that are handled by this factory routine.
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.
const int cHMW
HMW - Strong electrolyte using the Pitzer formulation.
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.
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.
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.
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 MixedSolventElectrolyte ).
(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.
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...
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.
const int cIdealSolidSolnPhase
Constant partial molar volume solution IdealSolidSolnPhase.h.