34 SpeciesThermoFactory* SpeciesThermoFactory::s_factory = 0;
35 mutex_t SpeciesThermoFactory::species_thermo_mutex;
53 int& has_nasa,
int& has_shomate,
int& has_simple,
56 for (
size_t n = 0; n < spDataNodeList.size(); n++) {
57 XML_Node* spNode = spDataNodeList[n];
58 if (spNode->
hasChild(
"standardState")) {
59 string mname = spNode->
child(
"standardState")[
"model"];
60 if (mname ==
"water" || mname ==
"waterIAPWS") {
73 }
else if (th.
hasChild(
"const_cp")) {
76 if (th.
child(
"poly")[
"order"] ==
"1") {
79 "poly with order > 1 not yet supported");
84 }
else if (th.
hasChild(
"NASA9MULTITEMP")) {
86 }
else if (th.
hasChild(
"adsorbate")) {
93 spNode->
attrib(
"name") +
" is missing the thermo XML node");
101 "To be removed after Cantera 2.2.");
102 ScopedLock lock(species_thermo_mutex);
109 void SpeciesThermoFactory::deleteFactory()
111 ScopedLock lock(species_thermo_mutex);
116 SpeciesThermo* SpeciesThermoFactory::newSpeciesThermo(std::vector<XML_Node*> & spDataNodeList)
const
119 "To be removed after Cantera 2.2. Use class GeneralSpeciesThermo directly.");
120 int inasa = 0, ishomate = 0, isimple = 0, iother = 0;
130 return newSpeciesThermo(
NASA*inasa
137 "To be removed after Cantera 2.2. Use class GeneralSpeciesThermo directly.");
158 SpeciesThermo* SpeciesThermoFactory::newSpeciesThermoManager(
const std::string& stype)
const
161 "To be removed after Cantera 2.2. Use class GeneralSpeciesThermo directly.");
163 if (ltype ==
"nasa") {
165 }
else if (ltype ==
"shomate") {
167 }
else if (ltype ==
"simple" || ltype ==
"constant_cp") {
169 }
else if (ltype ==
"nasa_shomate_duo") {
171 }
else if (ltype ==
"nasa_simple_duo") {
173 }
else if (ltype ==
"shomate_simple_duo") {
175 }
else if (ltype ==
"general") {
177 }
else if (ltype ==
"") {
187 double thigh,
double pref,
const double* coeffs)
191 return new NasaPoly1(tlow, thigh, pref, coeffs);
198 return new Mu0Poly(tlow, thigh, pref, coeffs);
202 return new NasaPoly2(tlow, thigh, pref, coeffs);
204 return new Adsorbate(tlow, thigh, pref, coeffs);
207 "Unknown species thermo type: " +
int2str(type) +
".");
212 double tlow,
double thigh,
double pref,
const double* coeffs)
216 if (type ==
"nasa2" || type ==
"nasa") {
218 }
else if (type ==
"const_cp" || type ==
"simple") {
220 }
else if (type ==
"shomate" || type ==
"shomate1") {
222 }
else if (type ==
"shomate2") {
224 }
else if (type ==
"nasa1") {
226 }
else if (type ==
"nasa9") {
228 }
else if (type ==
"nasa9multi") {
230 }
else if (type ==
"mu0") {
232 }
else if (type ==
"adsorbate") {
236 "Unknown species thermo type: '" + stype +
"'.");
252 bool dualRange = (nodes.size() > 1);
254 double tmin0 =
fpValue(f0[
"Tmin"]);
255 double tmax0 =
fpValue(f0[
"Tmax"]);
266 double tmin1 = tmax0;
267 double tmax1 = tmin1 + 0.0001;
269 tmin1 =
fpValue(nodes[1]->attrib(
"Tmin"));
270 tmax1 =
fpValue(nodes[1]->attrib(
"Tmax"));
274 doublereal tmin, tmid, tmax;
275 if (fabs(tmax0 - tmin1) < 0.01) {
286 copy(c0.begin(), c0.end(), c1.begin());
288 }
else if (fabs(tmax1 - tmin0) < 0.01) {
297 "non-continuous temperature ranges.");
302 copy(c1.begin(), c1.begin()+7, c.begin() + 1);
303 copy(c0.begin(), c0.begin()+7, c.begin() + 8);
314 doublereal tmin0 =
strSItoDbl(MinEQ3node[
"Tmin"]);
315 doublereal tmax0 =
strSItoDbl(MinEQ3node[
"Tmax"]);
316 doublereal p0 =
strSItoDbl(MinEQ3node[
"Pref"]);
318 doublereal deltaG_formation_pr_tr =
320 doublereal deltaH_formation_pr_tr =
326 doublereal dg = deltaG_formation_pr_tr * 4.184 * 1.0E3;
327 doublereal DHjmol = deltaH_formation_pr_tr * 1.0E3 * 4.184;
328 doublereal fac = DHjmol - dg - 298.15 * Entrop_pr_tr * 1.0E3 * 4.184;
329 doublereal Mu0_tr_pr = fac + dg;
330 doublereal e = Entrop_pr_tr * 1.0E3 * 4.184;
331 doublereal Hcalc = Mu0_tr_pr + 298.15 * e;
343 double As = a * 4.184;
344 double Bs = b * 4.184 * 1000.;
347 double Es = c * 4.184 / (1.0E6);
349 double t = 298.15 / 1000.;
350 double H298smFs = As * t + Bs * t * t / 2.0 - Es / t;
352 double HcalcS = Hcalc / 1.0E6;
353 double Fs = HcalcS - H298smFs;
355 double S298smGs = As * log(t) + Bs * t - Es/(2.0*t*t);
356 double ScalcS = e / 1.0E3;
357 double Gs = ScalcS - S298smGs;
359 double c0[7] = {As, Bs, Cs, Ds, Es, Fs, Gs};
373 vector<XML_Node*>& nodes)
375 bool dualRange =
false;
376 if (nodes.size() == 2) {
379 double tmin0 =
fpValue(nodes[0]->attrib(
"Tmin"));
380 double tmax0 =
fpValue(nodes[0]->attrib(
"Tmax"));
383 if (nodes[0]->hasAttrib(
"P0")) {
384 p0 =
fpValue(nodes[0]->attrib(
"P0"));
386 if (nodes[0]->hasAttrib(
"Pref")) {
387 p0 =
fpValue(nodes[0]->attrib(
"Pref"));
391 double tmin1 = tmax0;
392 double tmax1 = tmin1 + 0.0001;
394 tmin1 =
fpValue(nodes[1]->attrib(
"Tmin"));
395 tmax1 =
fpValue(nodes[1]->attrib(
"Tmax"));
399 doublereal tmin, tmid, tmax;
400 if (fabs(tmax0 - tmin1) < 0.01) {
411 "Shomate thermo requires 7 coefficients in float array.");
414 copy(c0.begin(), c0.begin()+7, c1.begin());
416 }
else if (fabs(tmax1 - tmin0) < 0.01) {
424 "non-continuous temperature ranges.");
426 if(c0.size() != 7 || c1.size() != 7)
429 "Shomate thermo requires 7 coefficients in float array.");
433 copy(c0.begin(), c0.begin()+7, c.begin() + 1);
434 copy(c1.begin(), c1.begin()+7, c.begin() + 8);
447 double tmin =
fpValue(f[
"Tmin"]);
448 double tmax =
fpValue(f[
"Tmax"]);
471 const std::vector<XML_Node*>& tp)
475 std::vector<Nasa9Poly1*> regionPtrs;
478 for (
size_t i = 0; i < tp.size(); i++) {
480 if (fptr.
name() ==
"NASA9" && fptr.
hasChild(
"floatArray")) {
481 double tmin =
fpValue(fptr[
"Tmin"]);
482 double tmax =
fpValue(fptr[
"Tmax"]);
491 if (cPoly.size() != 9) {
493 "Expected 9 coeff polynomial");
495 regionPtrs.push_back(
new Nasa9Poly1(tmin, tmax, pref, &cPoly[0]));
500 throw CanteraError(
"newNasa9ThermoFromXML",
"zero regions found");
501 }
else if (nRegions == 1) {
502 return regionPtrs[0];
514 doublereal tmin =
fpValue(f[
"Tmin"]);
515 doublereal tmax =
fpValue(f[
"Tmax"]);
528 return new StatMech(0, tmin, tmax, pref, &coeffs[0],
"");
542 double tmin =
fpValue(f[
"Tmin"]);
543 double tmax =
fpValue(f[
"Tmax"]);
557 for (
size_t n = 0; n < freqs.size(); n++) {
561 coeffs[0] =
static_cast<double>(freqs.size());
562 coeffs[1] =
getFloat(f,
"binding_energy",
"toSI");
563 copy(freqs.begin(), freqs.end(), coeffs.begin() + 2);
564 return new Adsorbate(0, tmin, tmax, pref, &coeffs[0]);
567 void SpeciesThermoFactory::installThermoForSpecies
571 shared_ptr<SpeciesThermoInterpType> stit(
573 stit->validate(speciesNode[
"name"]);
577 void SpeciesThermoFactory::installVPThermoForSpecies(
size_t k,
582 const XML_Node* phaseNode_ptr)
const
585 "Call VPStandardStateTP::createInstallPDSS directly.");
594 vp_ptr->createInstallPDSS(k, speciesNode, phaseNode_ptr);
602 const std::vector<XML_Node*>& tpWC = thermo.
children();
603 std::vector<XML_Node*> tp;
604 for (
size_t i = 0; i < tpWC.size(); i++) {
605 if (!(tpWC[i])->isComment()) {
606 tp.push_back(tpWC[i]);
610 std::string thermoType =
lowercase(tp[0]->name());
612 for (
size_t i = 1; i < tp.size(); i++) {
613 if (
lowercase(tp[i]->name()) != thermoType) {
615 "Encountered unsupported mixed species thermo parameterizations");
618 if ((tp.size() > 2 && thermoType !=
"nasa9") ||
619 (tp.size() > 1 && (thermoType ==
"const_cp" ||
620 thermoType ==
"mu0" ||
621 thermoType ==
"adsorbate"))) {
623 "Too many regions in thermo parameterization.");
626 std::string model =
lowercase(thermo[
"model"]);
627 if (model ==
"mineraleq3") {
628 if (thermoType !=
"mineq3") {
629 throw CanteraError(
"SpeciesThermoFactory::installThermoForSpecies",
630 "confused: expected MinEQ3");
633 }
else if (thermoType ==
"shomate") {
635 }
else if (thermoType ==
"const_cp") {
637 }
else if (thermoType ==
"nasa") {
639 }
else if (thermoType ==
"mu0") {
641 }
else if (thermoType ==
"nasa9") {
643 }
else if (thermoType ==
"adsorbate") {
645 }
else if (thermoType ==
"statmech") {
647 }
else if (model ==
"hkft" || model ==
"ionfromneutral") {
654 "Unknown species thermo model '" + thermoType +
"'.");
660 warn_deprecated(
"newSpeciesThermoMgr",
"To be removed after Cantera 2.2. "
661 "Use class GeneralSpeciesThermo directly.");
663 f = SpeciesThermoFactory::factory();
671 warn_deprecated(
"newSpeciesThermoMgr",
"To be removed after Cantera 2.2. "
672 "Use class GeneralSpeciesThermo directly.");
674 f = SpeciesThermoFactory::factory();
682 warn_deprecated(
"newSpeciesThermoMgr",
"To be removed after Cantera 2.2. "
683 "Use class GeneralSpeciesThermo directly.");
685 f = SpeciesThermoFactory::factory();
Factory to build instances of classes that manage the standard-state thermodynamic properties of a se...
doublereal fpValue(const std::string &val)
Translate a string into one doublereal value.
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
Header for a single-species standard state object derived from SpeciesThermoInterpType based on a pie...
Pure Virtual Base class for the thermodynamic manager for an individual species' reference state...
#define NASA
Two regions of 7 coefficient NASA Polynomials This is implemented in the class NasaPoly2 in NasaPoly2...
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
void popError()
Discard the last error message.
#define SHOMATE
Two regions of Shomate Polynomials.
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
#define CONSTANT_CP
Constant Cp.
The NASA polynomial parameterization for two temperature ranges.
const doublereal OneAtm
One atmosphere [Pa].
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
const std::vector< XML_Node * > & children() const
Return an unchangeable reference to the vector of children of the current node.
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...
static SpeciesThermoInterpType * newAdsorbateThermoFromXML(const XML_Node &f)
Create an Adsorbate polynomial thermodynamic property parameterization for a species.
Header for the SimpleThermo (constant heat capacity) species reference-state model for multiple speci...
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
virtual void install_STIT(size_t index, shared_ptr< SpeciesThermoInterpType > stit)=0
Install a new species thermodynamic property parameterization for one species.
Class XML_Node is a tree-based representation of the contents of an XML file.
#define NASA2
Two regions of 7 coefficient NASA Polynomials This is implemented in the class NasaPoly2 in NasaPoly2...
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Virtual base class for the calculation of multiple-species thermodynamic reference-state property man...
The Mu0Poly class implements an interpolation of the Gibbs free energy based on a piecewise constant ...
SpeciesThermoInterpType * newShomateForMineralEQ3(const XML_Node &MinEQ3node)
Create a Shomate polynomial from an XML node giving the 'EQ3' coefficients.
SpeciesThermoInterpType * newSpeciesThermoInterpType(const XML_Node &thermo)
Create a new SpeciesThermoInterpType object from XML_Node.
A species thermodynamic property manager for the NASA polynomial parameterization with two temperatur...
std::string lowercase(const std::string &s)
Cast a copy of a string to lower case.
A constant-heat capacity species thermodynamic property manager class.
Pure Virtual base class for the species thermo manager classes.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
#define MU0_INTERP
piecewise interpolation of mu0.
Base class for a phase with thermodynamic properties.
#define NASA1
7 coefficient NASA Polynomials This is implemented in the class NasaPoly1 in NasaPoly1.h
Contains const definitions for types of species reference-state thermodynamics managers (see Species ...
static void getSpeciesThermoTypes(std::vector< XML_Node * > &spDataNodeList, int &has_nasa, int &has_shomate, int &has_simple, int &has_other)
Examine the types of species thermo parameterizations, and return a flag indicating the type of refer...
#define NASA9MULTITEMP
9 coefficient NASA Polynomials in multiple temperature regions This is implemented in the class Nasa9...
SpeciesThermo * newSpeciesThermoMgr(std::vector< XML_Node * > spData_nodes, SpeciesThermoFactory *f)
Function to return SpeciesThermo manager.
#define NASA9
9 coefficient NASA Polynomials This is implemented in the class Nasa9Poly1 in Nasa9Poly1.h
A species thermodynamic property manager for a phase.
The Shomate polynomial parameterization for one temperature range for one species.
SpeciesThermo * newSpeciesThermoManager(const std::string &stype) const
Create a new species thermo property manager given a string.
The Shomate polynomial parameterization for two temperature ranges for one species.
std::string name() const
Returns the name of the XML node.
Header for the 2 regime 7 coefficient NASA thermodynamic polynomials for multiple species in a phase...
Base class for exceptions thrown by Cantera classes.
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
#define SIMPLE
Constant Cp thermo.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
static SpeciesThermoInterpType * newNasaThermoFromXML(vector< XML_Node * > nodes)
Create a NASA polynomial thermodynamic property parameterization for a species from a set ! of XML no...
SpeciesThermo * newSpeciesThermo(int type) const
Create a new species property manager for the reference state.
Header for a single-species standard state object derived from.
static SpeciesThermoInterpType * newConstCpThermoFromXML(XML_Node &f)
Create a "simple" constant heat capacity thermodynamic property parameterization for a ! species...
#define SHOMATE2
Two regions of Shomate Polynomials.
This species thermo manager requires that all species have one of two parameterizations.
static StatMech * newStatMechThermoFromXML(XML_Node &f)
Create a stat mech based property solver for a species.
This file contains descriptions of templated subclasses of the virtual base class, SpeciesThermo, which includes SpeciesThermoDuo (see Managers for Calculating Reference-State Thermodynamics and class SpeciesThermoDuo)
Throw a named error for an unknown or missing species thermo model.
An adsorbed surface species.
Header for factory to build instances of classes that manage the standard-state thermodynamic propert...
Headers for a completely general species thermodynamic property manager for a phase (see Managers for...
Header for the 2 regions Shomate polynomial for multiple species in a phase, derived from the Species...
A species thermodynamic property manager for the Shomate polynomial parameterization.
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Unknown species thermo manager string error.
size_t getFloatArray(const XML_Node &node, std::vector< doublereal > &v, const bool convert, const std::string &unitsString, const std::string &nodeName)
This function reads the current node or a child node of the current node with the default name...
Headers for the SpeciesThermoInterpType object that employs a constant heat capacity assumption (see ...
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type)
Get a floating-point value from a child element.
The NASA 9 polynomial parameterization for one temperature range.
doublereal getFloatDefaultUnits(const XML_Node &parent, const std::string &name, const std::string &defaultUnits, const std::string &type)
Get a floating-point value from a child element with a defined units field.
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the e...
The NASA polynomial parameterization for one temperature range.
static SpeciesThermoInterpType * newNasa9ThermoFromXML(const std::vector< XML_Node * > &tp)
Create a NASA9 polynomial thermodynamic property parameterization for a species.
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
The NASA 9 polynomial parameterization for a single species encompassing multiple temperature regions...
doublereal strSItoDbl(const std::string &strSI)
Interpret one or two token string as a single double.
Mu0Poly * newMu0ThermoFromXML(const XML_Node &Mu0Node)
Install a Mu0 polynomial thermodynamic reference state.
#define SHOMATE1
one region of Shomate Polynomials used in NIST database This is implemented in the NIST database...
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
static SpeciesThermoInterpType * newShomateThermoFromXML(vector< XML_Node * > &nodes)
Create a Shomate polynomial thermodynamic property parameterization for a species.
#define ADSORBATE
Surface Adsorbate Model for a species on a surface.