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);
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") {
78 "Unknown species thermo type: '" + stype +
"'.");
94 bool dualRange = (nodes.size() > 1);
95 double tmin0 =
fpValue(f0[
"Tmin"]);
96 double tmax0 =
fpValue(f0[
"Tmax"]);
107 double tmin1 = tmax0;
108 double tmax1 = tmin1 + 0.0001;
110 tmin1 =
fpValue(nodes[1]->attrib(
"Tmin"));
111 tmax1 =
fpValue(nodes[1]->attrib(
"Tmax"));
115 doublereal tmin, tmid, tmax;
116 if (fabs(tmax0 - tmin1) < 0.01) {
128 }
else if (fabs(tmax1 - tmin0) < 0.01) {
137 "non-continuous temperature ranges.");
142 copy(c1.begin(), c1.begin()+7, c.begin() + 1);
143 copy(c0.begin(), c0.begin()+7, c.begin() + 8);
147void setupSpeciesThermo(SpeciesThermoInterpType& thermo,
150 double Pref = node.convert(
"reference-pressure",
"Pa",
OneAtm);
151 thermo.setRefPressure(Pref);
152 thermo.input() = node;
155void setupNasaPoly(NasaPoly2& thermo,
const AnyMap& node)
157 setupSpeciesThermo(thermo, node);
158 vector_fp Tranges = node.convertVector(
"temperature-ranges",
"K", 2, 3);
159 const auto& data = node[
"data"].asVector<
vector_fp>(Tranges.size()-1);
160 for (
const auto& poly : data) {
161 if (poly.size() != 7) {
162 throw CanteraError(
"setupNasaPoly",
"Wrong number of coefficients "
163 "for NASA polynomial. Expected 7, but got {}", poly.size());
166 thermo.setMinTemp(Tranges.front());
167 thermo.setMaxTemp(Tranges.back());
168 if (Tranges.size() == 3) {
169 thermo.setParameters(Tranges[1], data[0], data[1]);
171 thermo.setParameters(Tranges[1], data[0], data[0]);
185 vector<XML_Node*>& nodes)
187 bool dualRange =
false;
188 if (nodes.size() == 2) {
191 double tmin0 =
fpValue(nodes[0]->attrib(
"Tmin"));
192 double tmax0 =
fpValue(nodes[0]->attrib(
"Tmax"));
195 if (nodes[0]->hasAttrib(
"P0")) {
196 p0 =
fpValue(nodes[0]->attrib(
"P0"));
198 if (nodes[0]->hasAttrib(
"Pref")) {
199 p0 =
fpValue(nodes[0]->attrib(
"Pref"));
203 double tmin1 = tmax0;
204 double tmax1 = tmin1 + 0.0001;
206 tmin1 =
fpValue(nodes[1]->attrib(
"Tmin"));
207 tmax1 =
fpValue(nodes[1]->attrib(
"Tmax"));
211 doublereal tmin, tmid, tmax;
212 if (fabs(tmax0 - tmin1) < 0.01) {
223 "Shomate thermo requires 7 coefficients in float array.");
226 copy(c0.begin(), c0.begin()+7, c1.begin());
228 }
else if (fabs(tmax1 - tmin0) < 0.01) {
236 "non-continuous temperature ranges.");
238 if(c0.size() != 7 || c1.size() != 7)
241 "Shomate thermo requires 7 coefficients in float array.");
245 copy(c0.begin(), c0.begin()+7, c.begin() + 1);
246 copy(c1.begin(), c1.begin()+7, c.begin() + 8);
251void setupShomatePoly(ShomatePoly2& thermo,
const AnyMap& node)
253 setupSpeciesThermo(thermo, node);
254 vector_fp Tranges = node.convertVector(
"temperature-ranges",
"K", 2, 3);
255 const auto& data = node[
"data"].asVector<
vector_fp>(Tranges.size()-1);
256 for (
const auto& poly : data) {
257 if (poly.size() != 7) {
258 throw CanteraError(
"setupShomatePoly",
"Wrong number of coefficients "
259 "for Shomate polynomial. Expected 7, but got {}", poly.size());
262 thermo.setMinTemp(Tranges.front());
263 thermo.setMaxTemp(Tranges.back());
264 if (Tranges.size() == 3) {
265 thermo.setParameters(Tranges[1], data[0], data[1]);
267 thermo.setParameters(Tranges[1], data[0], data[0]);
281 double tmin =
fpValue(f[
"Tmin"]);
282 double tmax =
fpValue(f[
"Tmax"]);
296void setupConstCp(ConstCpPoly& thermo,
const AnyMap& node)
298 setupSpeciesThermo(thermo, node);
299 if (node.hasKey(
"T-min")) {
300 thermo.setMinTemp(node.convert(
"T-min",
"K"));
302 if (node.hasKey(
"T-max")) {
303 thermo.setMaxTemp(node.convert(
"T-max",
"K"));
305 double T0 = node.convert(
"T0",
"K", 298.15);
306 double h0 = node.convert(
"h0",
"J/kmol", 0.0);
307 double s0 = node.convert(
"s0",
"J/kmol/K", 0.0);
308 double cp0 = node.convert(
"cp0",
"J/kmol/K", 0.0);
309 thermo.setParameters(T0, h0, s0, cp0);
320 const std::vector<XML_Node*>& tp)
324 std::vector<Nasa9Poly1*> regionPtrs;
327 for (
size_t i = 0; i < tp.size(); i++) {
329 if (fptr.
name() ==
"NASA9" && fptr.
hasChild(
"floatArray")) {
330 double tmin =
fpValue(fptr[
"Tmin"]);
331 double tmax =
fpValue(fptr[
"Tmax"]);
340 if (cPoly.size() != 9) {
342 "Expected 9 coeff polynomial");
344 regionPtrs.push_back(
new Nasa9Poly1(tmin, tmax, pref, &cPoly[0]));
349 throw CanteraError(
"newNasa9ThermoFromXML",
"zero regions found");
350 }
else if (nRegions == 1) {
351 return regionPtrs[0];
358void setupNasa9Poly(Nasa9PolyMultiTempRegion& thermo,
const AnyMap& node)
360 setupSpeciesThermo(thermo, node);
361 vector_fp Tranges = node.convertVector(
"temperature-ranges",
"K", 2, 999);
362 const auto& data = node[
"data"].asVector<
vector_fp>(Tranges.size()-1);
363 map<double, vector_fp> regions;
364 for (
size_t i = 0; i < data.size(); i++) {
365 if (data[i].size() != 9) {
366 throw CanteraError(
"setupNasa9Poly",
"Wrong number of coefficients "
367 "for NASA9 polynomial. Expected 9, but got {}", data[i].size());
369 regions[Tranges[i]] = data[i];
371 thermo.setMinTemp(Tranges.front());
372 thermo.setMaxTemp(Tranges.back());
373 thermo.setParameters(regions);
377void setupMu0(Mu0Poly& thermo,
const AnyMap& node)
379 setupSpeciesThermo(thermo, node);
380 if (node.hasKey(
"T-min")) {
381 thermo.setMinTemp(node.convert(
"T-min",
"K"));
383 if (node.hasKey(
"T-max")) {
384 thermo.setMaxTemp(node.convert(
"T-max",
"K"));
386 bool dimensionless = node.getBool(
"dimensionless",
false);
387 double h0 = node.convert(
"h0",
"J/kmol", 0.0);
388 map<double, double> T_mu;
389 for (
const auto& item : node[
"data"]) {
390 double T = node.units().convertTo(
fpValueCheck(item.first),
"K");
392 T_mu[T] = item.second.asDouble() *
GasConstant * T;
394 T_mu[T] = node.units().convert(item.second,
"J/kmol");
397 thermo.setParameters(h0, T_mu);
403 if (model ==
"hkft" || model ==
"ionfromneutral") {
414 const std::vector<XML_Node*>& tpWC = thermo.
children();
415 std::vector<XML_Node*> tp;
416 for (
size_t i = 0; i < tpWC.size(); i++) {
417 if (!tpWC[i]->isComment()) {
418 tp.push_back(tpWC[i]);
422 std::string thermoType =
toLowerCopy(tp[0]->name());
424 for (
size_t i = 1; i < tp.size(); i++) {
427 "Encountered unsupported mixed species thermo "
428 "parameterizations, '{}' and '{}'", tp[i]->name(), thermoType);
431 if ((tp.size() > 2 && thermoType !=
"nasa9") ||
432 (tp.size() > 1 && (thermoType ==
"const_cp" ||
433 thermoType ==
"mu0"))) {
435 "Too many regions in thermo parameterization.");
438 if (thermoType ==
"shomate") {
440 }
else if (thermoType ==
"const_cp") {
442 }
else if (thermoType ==
"nasa") {
444 }
else if (thermoType ==
"mu0") {
446 }
else if (thermoType ==
"nasa9") {
450 "Unknown species thermo model '" + thermoType +
"'.");
457 std::string model = node[
"model"].asString();
458 if (model ==
"NASA7") {
459 unique_ptr<NasaPoly2> thermo(
new NasaPoly2());
460 setupNasaPoly(*thermo, node);
461 return unique_ptr<SpeciesThermoInterpType>(move(thermo));
462 }
else if (model ==
"Shomate") {
464 setupShomatePoly(*thermo, node);
465 return unique_ptr<SpeciesThermoInterpType>(move(thermo));
466 }
else if (model ==
"NASA9") {
468 setupNasa9Poly(*thermo, node);
469 return unique_ptr<SpeciesThermoInterpType>(move(thermo));
470 }
else if (model ==
"constant-cp") {
472 setupConstCp(*thermo, node);
473 return unique_ptr<SpeciesThermoInterpType>(move(thermo));
474 }
else if (model ==
"piecewise-Gibbs") {
475 unique_ptr<Mu0Poly> thermo(
new Mu0Poly());
476 setupMu0(*thermo, node);
477 return unique_ptr<SpeciesThermoInterpType>(move(thermo));
480 "Unknown thermo model '{}'", model);
Headers for the SpeciesThermoInterpType object that employs a constant heat capacity assumption (see ...
Header for a single-species standard state object derived from SpeciesThermoInterpType based on a pie...
Header for a general species thermodynamic property manager for a phase (see MultiSpeciesThermo).
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the N...
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the S...
Header for factory functions to build instances of classes that manage the standard-state thermodynam...
Header for unit conversion utilities, which are used to translate user input from input files (See In...
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
A map of string keys to values whose type can vary at runtime.
Base class for exceptions thrown by Cantera classes.
A constant-heat capacity species thermodynamic property manager class.
The Mu0Poly class implements an interpolation of the Gibbs free energy based on a piecewise constant ...
The NASA 9 polynomial parameterization for one temperature range.
The NASA 9 polynomial parameterization for a single species encompassing multiple temperature regions...
The NASA polynomial parameterization for one temperature range.
The NASA polynomial parameterization for two temperature ranges.
The Shomate polynomial parameterization for two temperature ranges for one species.
The Shomate polynomial parameterization for one temperature range for one species.
Abstract Base class for the thermodynamic manager for an individual species' reference state.
Class XML_Node is a tree-based representation of the contents of an XML file.
std::string name() const
Returns the name of the XML node.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
const std::vector< XML_Node * > & children() const
Return an unchangeable reference to the vector of children of the current node.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
Mu0Poly * newMu0ThermoFromXML(const XML_Node &Mu0Node)
Install a Mu0 polynomial thermodynamic reference state.
Namespace for the Cantera kernel.
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 !...
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type="")
Get a floating-point value from a child element.
doublereal fpValue(const std::string &val)
Translate a string into one doublereal value.
const double OneAtm
One atmosphere [Pa].
bool caseInsensitiveEquals(const std::string &input, const std::string &test)
Case insensitive equality predicate.
unique_ptr< SpeciesThermoInterpType > newSpeciesThermo(const AnyMap &thermo_node)
Create a new SpeciesThermoInterpType object using the specified parameters.
std::string toLowerCopy(const std::string &input)
Convert to lower case.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
const double GasConstant
Universal Gas Constant [J/kmol/K].
size_t getFloatArray(const XML_Node &node, vector_fp &v, const bool convert=true, const std::string &unitsString="", const std::string &nodeName="floatArray")
This function reads the current node or a child node of the current node with the default name,...
static SpeciesThermoInterpType * newConstCpThermoFromXML(XML_Node &f)
Create a "simple" constant heat capacity thermodynamic property parameterization for a !...
doublereal fpValueCheck(const std::string &val)
Translate a string into one doublereal value, with error checking.
static SpeciesThermoInterpType * newShomateThermoFromXML(vector< XML_Node * > &nodes)
Create a Shomate polynomial thermodynamic property parameterization for a species.
SpeciesThermoInterpType * newSpeciesThermoInterpType(int type, double tlow, double thigh, double pref, const double *coeffs)
Create a new SpeciesThermoInterpType object given a corresponding constant.
Contains const definitions for types of species reference-state thermodynamics managers (see Species ...
#define NASA1
7 coefficient NASA Polynomials This is implemented in the class NasaPoly1 in NasaPoly1....
#define CONSTANT_CP
Constant Cp.
#define MU0_INTERP
piecewise interpolation of mu0.
#define SHOMATE1
one region of Shomate Polynomials used in NIST database This is implemented in the NIST database.
#define NASA9MULTITEMP
9 coefficient NASA Polynomials in multiple temperature regions This is implemented in the class Nasa9...
#define SHOMATE
Two regions of Shomate Polynomials.
#define NASA9
9 coefficient NASA Polynomials This is implemented in the class Nasa9Poly1 in Nasa9Poly1....
#define SHOMATE2
Two regions of Shomate Polynomials.
#define NASA
Two regions of 7 coefficient NASA Polynomials This is implemented in the class NasaPoly2 in NasaPoly2...
#define SIMPLE
Constant Cp thermo.
#define NASA2
Two regions of 7 coefficient NASA Polynomials This is implemented in the class NasaPoly2 in NasaPoly2...
Contains declarations for string manipulation functions within Cantera.