32 double thigh,
double pref,
const double* coeffs)
36 return new NasaPoly1(tlow, thigh, pref, coeffs);
43 return new Mu0Poly(tlow, thigh, pref, coeffs);
47 return new NasaPoly2(tlow, thigh, pref, coeffs);
49 return new Adsorbate(tlow, thigh, pref, coeffs);
52 "Unknown species thermo type: {}.", type);
57 double tlow,
double thigh,
double pref,
const double* coeffs)
60 std::string type = ba::to_lower_copy(stype);
61 if (type ==
"nasa2" || type ==
"nasa") {
63 }
else if (type ==
"const_cp" || type ==
"simple") {
65 }
else if (type ==
"shomate" || type ==
"shomate1") {
67 }
else if (type ==
"shomate2") {
69 }
else if (type ==
"nasa1") {
71 }
else if (type ==
"nasa9") {
73 }
else if (type ==
"nasa9multi") {
75 }
else if (type ==
"mu0") {
77 }
else if (type ==
"adsorbate") {
81 "Unknown species thermo type: '" + stype +
"'.");
97 bool dualRange = (nodes.size() > 1);
98 double tmin0 =
fpValue(f0[
"Tmin"]);
99 double tmax0 =
fpValue(f0[
"Tmax"]);
110 double tmin1 = tmax0;
111 double tmax1 = tmin1 + 0.0001;
113 tmin1 =
fpValue(nodes[1]->attrib(
"Tmin"));
114 tmax1 =
fpValue(nodes[1]->attrib(
"Tmax"));
118 doublereal tmin, tmid, tmax;
119 if (fabs(tmax0 - tmin1) < 0.01) {
131 }
else if (fabs(tmax1 - tmin0) < 0.01) {
140 "non-continuous temperature ranges.");
145 copy(c1.begin(), c1.begin()+7, c.begin() + 1);
146 copy(c0.begin(), c0.begin()+7, c.begin() + 8);
157 doublereal tmin0 =
strSItoDbl(MinEQ3node[
"Tmin"]);
158 doublereal tmax0 =
strSItoDbl(MinEQ3node[
"Tmax"]);
159 doublereal p0 =
strSItoDbl(MinEQ3node[
"Pref"]);
161 doublereal deltaG_formation_pr_tr =
163 doublereal deltaH_formation_pr_tr =
165 doublereal Entrop_pr_tr =
getFloat(MinEQ3node,
"S0_Pr_Tr",
"toSI") /
toSI(
"cal/gmol/K");
166 doublereal a =
getFloat(MinEQ3node,
"a",
"toSI") /
toSI(
"cal/gmol/K");
167 doublereal b =
getFloat(MinEQ3node,
"b",
"toSI") /
toSI(
"cal/gmol/K2");
168 doublereal c =
getFloat(MinEQ3node,
"c",
"toSI") /
toSI(
"cal-K/gmol");
169 doublereal dg = deltaG_formation_pr_tr *
toSI(
"cal/gmol");
170 doublereal DHjmol = deltaH_formation_pr_tr *
toSI(
"cal/gmol");
171 doublereal fac = DHjmol - dg - 298.15 * Entrop_pr_tr *
toSI(
"cal/gmol");
172 doublereal Mu0_tr_pr = fac + dg;
173 doublereal e = Entrop_pr_tr *
toSI(
"cal/gmol");
174 doublereal Hcalc = Mu0_tr_pr + 298.15 * e;
184 double As = a *
toSI(
"cal");
185 double Bs = b *
toSI(
"cal") * 1000.;
188 double Es = c *
toSI(
"cal") / (1.0E6);
190 double t = 298.15 / 1000.;
191 double H298smFs = As * t + Bs * t * t / 2.0 - Es / t;
192 double HcalcS = Hcalc / 1.0E6;
193 double Fs = HcalcS - H298smFs;
194 double S298smGs = As * log(t) + Bs * t - Es/(2.0*t*t);
195 double ScalcS = e / 1.0E3;
196 double Gs = ScalcS - S298smGs;
198 double c0[7] = {As, Bs, Cs, Ds, Es, Fs, Gs};
211 vector<XML_Node*>& nodes)
213 bool dualRange =
false;
214 if (nodes.size() == 2) {
217 double tmin0 =
fpValue(nodes[0]->attrib(
"Tmin"));
218 double tmax0 =
fpValue(nodes[0]->attrib(
"Tmax"));
221 if (nodes[0]->hasAttrib(
"P0")) {
222 p0 =
fpValue(nodes[0]->attrib(
"P0"));
224 if (nodes[0]->hasAttrib(
"Pref")) {
225 p0 =
fpValue(nodes[0]->attrib(
"Pref"));
229 double tmin1 = tmax0;
230 double tmax1 = tmin1 + 0.0001;
232 tmin1 =
fpValue(nodes[1]->attrib(
"Tmin"));
233 tmax1 =
fpValue(nodes[1]->attrib(
"Tmax"));
237 doublereal tmin, tmid, tmax;
238 if (fabs(tmax0 - tmin1) < 0.01) {
249 "Shomate thermo requires 7 coefficients in float array.");
252 copy(c0.begin(), c0.begin()+7, c1.begin());
254 }
else if (fabs(tmax1 - tmin0) < 0.01) {
262 "non-continuous temperature ranges.");
264 if(c0.size() != 7 || c1.size() != 7)
267 "Shomate thermo requires 7 coefficients in float array.");
271 copy(c0.begin(), c0.begin()+7, c.begin() + 1);
272 copy(c1.begin(), c1.begin()+7, c.begin() + 8);
285 double tmin =
fpValue(f[
"Tmin"]);
286 double tmax =
fpValue(f[
"Tmax"]);
308 const std::vector<XML_Node*>& tp)
312 std::vector<Nasa9Poly1*> regionPtrs;
315 for (
size_t i = 0; i < tp.size(); i++) {
317 if (fptr.
name() ==
"NASA9" && fptr.
hasChild(
"floatArray")) {
318 double tmin =
fpValue(fptr[
"Tmin"]);
319 double tmax =
fpValue(fptr[
"Tmax"]);
328 if (cPoly.size() != 9) {
330 "Expected 9 coeff polynomial");
332 regionPtrs.push_back(
new Nasa9Poly1(tmin, tmax, pref, &cPoly[0]));
337 throw CanteraError(
"newNasa9ThermoFromXML",
"zero regions found");
338 }
else if (nRegions == 1) {
339 return regionPtrs[0];
356 double tmin =
fpValue(f[
"Tmin"]);
357 double tmax =
fpValue(f[
"Tmax"]);
371 for (
size_t n = 0; n < freqs.size(); n++) {
375 coeffs[0] =
static_cast<double>(freqs.size());
376 coeffs[1] =
getFloat(f,
"binding_energy",
"toSI");
377 copy(freqs.begin(), freqs.end(), coeffs.begin() + 2);
378 return new Adsorbate(tmin, tmax, pref, &coeffs[0]);
387 const std::vector<XML_Node*>& tpWC = thermo.
children();
388 std::vector<XML_Node*> tp;
389 for (
size_t i = 0; i < tpWC.size(); i++) {
390 if (!tpWC[i]->isComment()) {
391 tp.push_back(tpWC[i]);
395 std::string thermoType = ba::to_lower_copy(tp[0]->name());
397 for (
size_t i = 1; i < tp.size(); i++) {
398 if (!ba::iequals(tp[i]->name(), thermoType)) {
400 "Encountered unsupported mixed species thermo parameterizations");
403 if ((tp.size() > 2 && thermoType !=
"nasa9") ||
404 (tp.size() > 1 && (thermoType ==
"const_cp" ||
405 thermoType ==
"mu0" ||
406 thermoType ==
"adsorbate"))) {
408 "Too many regions in thermo parameterization.");
411 std::string model = ba::to_lower_copy(thermo[
"model"]);
412 if (model ==
"mineraleq3") {
413 if (thermoType !=
"mineq3") {
415 "confused: expected MinEQ3");
418 }
else if (thermoType ==
"shomate") {
420 }
else if (thermoType ==
"const_cp") {
422 }
else if (thermoType ==
"nasa") {
424 }
else if (thermoType ==
"mu0") {
426 }
else if (thermoType ==
"nasa9") {
428 }
else if (thermoType ==
"adsorbate") {
430 }
else if (model ==
"hkft" || model ==
"ionfromneutral") {
437 "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.
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...
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].
doublereal actEnergyToSI(const std::string &unit)
Return the conversion factor to convert activation energy unit std::string 'unit' to Kelvin...
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.
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.
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.
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.