31 double thigh,
double pref,
const double* coeffs)
35 return new NasaPoly1(tlow, thigh, pref, coeffs);
42 return new Mu0Poly(tlow, thigh, pref, coeffs);
46 return new NasaPoly2(tlow, thigh, pref, coeffs);
48 return new Adsorbate(tlow, thigh, pref, coeffs);
51 "Unknown species thermo type: {}.", type);
56 double tlow,
double thigh,
double pref,
const double* coeffs)
60 if (type ==
"nasa2" || type ==
"nasa") {
62 }
else if (type ==
"const_cp" || type ==
"simple") {
64 }
else if (type ==
"shomate" || type ==
"shomate1") {
66 }
else if (type ==
"shomate2") {
68 }
else if (type ==
"nasa1") {
70 }
else if (type ==
"nasa9") {
72 }
else if (type ==
"nasa9multi") {
74 }
else if (type ==
"mu0") {
76 }
else if (type ==
"adsorbate") {
80 "Unknown species thermo type: '" + stype +
"'.");
96 bool dualRange = (nodes.size() > 1);
97 double tmin0 =
fpValue(f0[
"Tmin"]);
98 double tmax0 =
fpValue(f0[
"Tmax"]);
109 double tmin1 = tmax0;
110 double tmax1 = tmin1 + 0.0001;
112 tmin1 =
fpValue(nodes[1]->attrib(
"Tmin"));
113 tmax1 =
fpValue(nodes[1]->attrib(
"Tmax"));
117 doublereal tmin, tmid, tmax;
118 if (fabs(tmax0 - tmin1) < 0.01) {
130 }
else if (fabs(tmax1 - tmin0) < 0.01) {
139 "non-continuous temperature ranges.");
144 copy(c1.begin(), c1.begin()+7, c.begin() + 1);
145 copy(c0.begin(), c0.begin()+7, c.begin() + 8);
156 doublereal tmin0 =
strSItoDbl(MinEQ3node[
"Tmin"]);
157 doublereal tmax0 =
strSItoDbl(MinEQ3node[
"Tmax"]);
158 doublereal p0 =
strSItoDbl(MinEQ3node[
"Pref"]);
160 doublereal deltaG_formation_pr_tr =
162 doublereal deltaH_formation_pr_tr =
164 doublereal Entrop_pr_tr =
getFloat(MinEQ3node,
"S0_Pr_Tr",
"toSI") /
toSI(
"cal/gmol/K");
165 doublereal a =
getFloat(MinEQ3node,
"a",
"toSI") /
toSI(
"cal/gmol/K");
166 doublereal b =
getFloat(MinEQ3node,
"b",
"toSI") /
toSI(
"cal/gmol/K2");
167 doublereal c =
getFloat(MinEQ3node,
"c",
"toSI") /
toSI(
"cal-K/gmol");
168 doublereal dg = deltaG_formation_pr_tr *
toSI(
"cal/gmol");
169 doublereal DHjmol = deltaH_formation_pr_tr *
toSI(
"cal/gmol");
170 doublereal fac = DHjmol - dg - 298.15 * Entrop_pr_tr *
toSI(
"cal/gmol");
171 doublereal Mu0_tr_pr = fac + dg;
172 doublereal e = Entrop_pr_tr *
toSI(
"cal/gmol");
173 doublereal Hcalc = Mu0_tr_pr + 298.15 * e;
183 double As = a *
toSI(
"cal");
184 double Bs = b *
toSI(
"cal") * 1000.;
187 double Es = c *
toSI(
"cal") / (1.0E6);
189 double t = 298.15 / 1000.;
190 double H298smFs = As * t + Bs * t * t / 2.0 - Es / t;
191 double HcalcS = Hcalc / 1.0E6;
192 double Fs = HcalcS - H298smFs;
193 double S298smGs = As * log(t) + Bs * t - Es/(2.0*t*t);
194 double ScalcS = e / 1.0E3;
195 double Gs = ScalcS - S298smGs;
197 double c0[7] = {As, Bs, Cs, Ds, Es, Fs, Gs};
210 vector<XML_Node*>& nodes)
212 bool dualRange =
false;
213 if (nodes.size() == 2) {
216 double tmin0 =
fpValue(nodes[0]->attrib(
"Tmin"));
217 double tmax0 =
fpValue(nodes[0]->attrib(
"Tmax"));
220 if (nodes[0]->hasAttrib(
"P0")) {
221 p0 =
fpValue(nodes[0]->attrib(
"P0"));
223 if (nodes[0]->hasAttrib(
"Pref")) {
224 p0 =
fpValue(nodes[0]->attrib(
"Pref"));
228 double tmin1 = tmax0;
229 double tmax1 = tmin1 + 0.0001;
231 tmin1 =
fpValue(nodes[1]->attrib(
"Tmin"));
232 tmax1 =
fpValue(nodes[1]->attrib(
"Tmax"));
236 doublereal tmin, tmid, tmax;
237 if (fabs(tmax0 - tmin1) < 0.01) {
248 "Shomate thermo requires 7 coefficients in float array.");
251 copy(c0.begin(), c0.begin()+7, c1.begin());
253 }
else if (fabs(tmax1 - tmin0) < 0.01) {
261 "non-continuous temperature ranges.");
263 if(c0.size() != 7 || c1.size() != 7)
266 "Shomate thermo requires 7 coefficients in float array.");
270 copy(c0.begin(), c0.begin()+7, c.begin() + 1);
271 copy(c1.begin(), c1.begin()+7, c.begin() + 8);
284 double tmin =
fpValue(f[
"Tmin"]);
285 double tmax =
fpValue(f[
"Tmax"]);
307 const std::vector<XML_Node*>& tp)
311 std::vector<Nasa9Poly1*> regionPtrs;
314 for (
size_t i = 0; i < tp.size(); i++) {
316 if (fptr.
name() ==
"NASA9" && fptr.
hasChild(
"floatArray")) {
317 double tmin =
fpValue(fptr[
"Tmin"]);
318 double tmax =
fpValue(fptr[
"Tmax"]);
327 if (cPoly.size() != 9) {
329 "Expected 9 coeff polynomial");
331 regionPtrs.push_back(
new Nasa9Poly1(tmin, tmax, pref, &cPoly[0]));
336 throw CanteraError(
"newNasa9ThermoFromXML",
"zero regions found");
337 }
else if (nRegions == 1) {
338 return regionPtrs[0];
355 double tmin =
fpValue(f[
"Tmin"]);
356 double tmax =
fpValue(f[
"Tmax"]);
370 for (
size_t n = 0; n < freqs.size(); n++) {
374 coeffs[0] =
static_cast<double>(freqs.size());
375 coeffs[1] =
getFloat(f,
"binding_energy",
"toSI");
376 copy(freqs.begin(), freqs.end(), coeffs.begin() + 2);
377 return new Adsorbate(tmin, tmax, pref, &coeffs[0]);
383 if (model ==
"hkft" || model ==
"ionfromneutral") {
394 const std::vector<XML_Node*>& tpWC = thermo.
children();
395 std::vector<XML_Node*> tp;
396 for (
size_t i = 0; i < tpWC.size(); i++) {
397 if (!tpWC[i]->isComment()) {
398 tp.push_back(tpWC[i]);
402 std::string thermoType =
toLowerCopy(tp[0]->name());
404 for (
size_t i = 1; i < tp.size(); i++) {
407 "Encountered unsupported mixed species thermo " 408 "parameterizations, '{}' and '{}'", tp[i]->name(), thermoType);
411 if ((tp.size() > 2 && thermoType !=
"nasa9") ||
412 (tp.size() > 1 && (thermoType ==
"const_cp" ||
413 thermoType ==
"mu0" ||
414 thermoType ==
"adsorbate"))) {
416 "Too many regions in thermo parameterization.");
419 if (model ==
"mineraleq3") {
420 if (thermoType !=
"mineq3") {
422 "confused: expected MinEQ3");
425 }
else if (thermoType ==
"shomate") {
427 }
else if (thermoType ==
"const_cp") {
429 }
else if (thermoType ==
"nasa") {
431 }
else if (thermoType ==
"mu0") {
433 }
else if (thermoType ==
"nasa9") {
435 }
else if (thermoType ==
"adsorbate") {
439 "Unknown species thermo model '" + thermoType +
"'.");
Header for a general species thermodynamic property manager for a phase (see MultiSpeciesThermo).
doublereal fpValue(const std::string &val)
Translate a string into one doublereal value.
Header for a single-species standard state object derived from SpeciesThermoInterpType based on a pie...
Abstract 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...
std::string name() const
Returns the name of the XML node.
#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].
size_t getFloatArray(const XML_Node &node, vector_fp &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...
doublereal actEnergyToSI(const std::string &unit)
Return the conversion factor to convert activation energy unit std::string 'unit' to Kelvin...
static SpeciesThermoInterpType * newAdsorbateThermoFromXML(const XML_Node &f)
Create an Adsorbate polynomial thermodynamic property parameterization for a species.
doublereal toSI(const std::string &unit)
Return the conversion factor to convert unit std::string 'unit' to SI units.
static SpeciesThermoInterpType * newNasa9ThermoFromXML(const std::vector< XML_Node *> &tp)
Create a NASA9 polynomial thermodynamic property parameterization for a species.
static SpeciesThermoInterpType * newNasaThermoFromXML(vector< XML_Node *> nodes)
Create a NASA polynomial thermodynamic property parameterization for a species from a set ! of XML no...
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
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...
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.
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
A constant-heat capacity species thermodynamic property manager class.
#define MU0_INTERP
piecewise interpolation of mu0.
#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 ...
#define NASA9MULTITEMP
9 coefficient NASA Polynomials in multiple temperature regions This is implemented in the class Nasa9...
#define NASA9
9 coefficient NASA Polynomials This is implemented in the class Nasa9Poly1 in Nasa9Poly1.h
const std::vector< XML_Node * > & children() const
Return an unchangeable reference to the vector of children of the current node.
The Shomate polynomial parameterization for one temperature range for one species.
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the S...
The Shomate polynomial parameterization for two temperature ranges for one species.
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
Base class for exceptions thrown by Cantera classes.
#define SIMPLE
Constant Cp thermo.
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.
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.
An adsorbed surface species.
Header for factory functions to build instances of classes that manage the standard-state thermodynam...
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.
Headers for the SpeciesThermoInterpType object that employs a constant heat capacity assumption (see ...
Contains declarations for string manipulation functions within Cantera.
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.
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the e...
static SpeciesThermoInterpType * newShomateThermoFromXML(vector< XML_Node *> &nodes)
Create a Shomate polynomial thermodynamic property parameterization for a species.
The NASA polynomial parameterization for one temperature range.
std::string toLowerCopy(const std::string &input)
Convert to lower case.
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
Namespace for the Cantera kernel.
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...
#define ADSORBATE
Surface Adsorbate Model for a species on a surface.