Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpeciesThermoFactory.cpp
Go to the documentation of this file.
1 /**
2  * @file SpeciesThermoFactory.cpp
3  * Definitions for factory to build instances of classes that manage the
4  * standard-state thermodynamic properties of a set of species
5  * (see \ref spthermo and class \link Cantera::SpeciesThermoFactory SpeciesThermoFactory\endlink);
6  */
7 // Copyright 2001 California Institute of Technology
8 
10 
12 #include "NasaThermo.h"
13 #include "ShomateThermo.h"
16 #include "cantera/thermo/Mu0Poly.h"
25 #include "cantera/thermo/VPSSMgr.h"
27 
28 #include "cantera/base/ctml.h"
29 
30 using namespace std;
31 
32 namespace Cantera
33 {
34 SpeciesThermoFactory* SpeciesThermoFactory::s_factory = 0;
35 mutex_t SpeciesThermoFactory::species_thermo_mutex;
36 
37 //! Examine the types of species thermo parameterizations,
38 //! and return a flag indicating the type of reference state thermo manager
39 //! that will be needed in order to evaluate them all.
40 /*!
41  *
42  * @param spDataNodeList This vector contains a list
43  * of species XML nodes that will be in the phase
44  * @param has_nasa Return int that indicates whether the phase has a NASA polynomial form for one of its species
45  * @param has_shomate Return int that indicates whether the phase has a SHOMATE polynomial form for one of its species
46  * @param has_simple Return int that indicates whether the phase has a SIMPLE polynomial form for one of its species
47  * @param has_other Return int that indicates whether the phase has a form for one of its species that is not one of the ones listed above.
48  *
49  * @todo Make sure that spDadta_node is species Data XML node by checking its name is speciesData
50  * @deprecated
51  */
52 static void getSpeciesThermoTypes(std::vector<XML_Node*> & spDataNodeList,
53  int& has_nasa, int& has_shomate, int& has_simple,
54  int& has_other)
55 {
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") {
61  has_other = 1;
62  continue;
63  }
64  }
65  if (spNode->hasChild("thermo")) {
66  const XML_Node& th = spNode->child("thermo");
67  if (th.hasChild("NASA")) {
68  has_nasa = 1;
69  } else if (th.hasChild("Shomate")) {
70  has_shomate = 1;
71  } else if (th.hasChild("MinEQ3")) {
72  has_shomate = 1;
73  } else if (th.hasChild("const_cp")) {
74  has_simple = 1;
75  } else if (th.hasChild("poly")) {
76  if (th.child("poly")["order"] == "1") {
77  has_simple = 1;
78  } else throw CanteraError("newSpeciesThermo",
79  "poly with order > 1 not yet supported");
80  } else if (th.hasChild("Mu0")) {
81  has_other = 1;
82  } else if (th.hasChild("NASA9")) {
83  has_other = 1;
84  } else if (th.hasChild("NASA9MULTITEMP")) {
85  has_other = 1;
86  } else if (th.hasChild("adsorbate")) {
87  has_other = 1;
88  } else {
89  has_other = 1;
90  }
91  } else {
92  throw CanteraError("getSpeciesThermoTypes:",
93  spNode->attrib("name") + " is missing the thermo XML node");
94  }
95  }
96 }
97 
98 SpeciesThermoFactory* SpeciesThermoFactory::factory()
99 {
100  warn_deprecated("class SpeciesThermoFactory",
101  "To be removed after Cantera 2.2.");
102  ScopedLock lock(species_thermo_mutex);
103  if (!s_factory) {
104  s_factory = new SpeciesThermoFactory;
105  }
106  return s_factory;
107 }
108 
109 void SpeciesThermoFactory::deleteFactory()
110 {
111  ScopedLock lock(species_thermo_mutex);
112  delete s_factory;
113  s_factory = 0;
114 }
115 
116 SpeciesThermo* SpeciesThermoFactory::newSpeciesThermo(std::vector<XML_Node*> & spDataNodeList) const
117 {
118  warn_deprecated("SpeciesThermoFactory::newSpeciesThermo",
119  "To be removed after Cantera 2.2. Use class GeneralSpeciesThermo directly.");
120  int inasa = 0, ishomate = 0, isimple = 0, iother = 0;
121  try {
122  getSpeciesThermoTypes(spDataNodeList, inasa, ishomate, isimple, iother);
123  } catch (UnknownSpeciesThermoModel) {
124  iother = 1;
125  popError();
126  }
127  if (iother) {
128  return new GeneralSpeciesThermo();
129  }
130  return newSpeciesThermo(NASA*inasa
131  + SHOMATE*ishomate + SIMPLE*isimple);
132 }
133 
134 SpeciesThermo* SpeciesThermoFactory::newSpeciesThermo(int type) const
135 {
136  warn_deprecated("SpeciesThermoFactory::newSpeciesThermo",
137  "To be removed after Cantera 2.2. Use class GeneralSpeciesThermo directly.");
138  switch (type) {
139  case NASA:
140  return new NasaThermo;
141  case SHOMATE:
142  return new ShomateThermo;
143  case SIMPLE:
144  return new SimpleThermo;
145  case NASA + SHOMATE:
147  case NASA + SIMPLE:
149  case SHOMATE + SIMPLE:
151  default:
152  throw UnknownSpeciesThermo("SpeciesThermoFactory::newSpeciesThermo",
153  type);
154  return 0;
155  }
156 }
157 
158 SpeciesThermo* SpeciesThermoFactory::newSpeciesThermoManager(const std::string& stype) const
159 {
160  warn_deprecated("SpeciesThermoFactory::newSpeciesThermo",
161  "To be removed after Cantera 2.2. Use class GeneralSpeciesThermo directly.");
162  std::string ltype = lowercase(stype);
163  if (ltype == "nasa") {
164  return new NasaThermo;
165  } else if (ltype == "shomate") {
166  return new ShomateThermo;
167  } else if (ltype == "simple" || ltype == "constant_cp") {
168  return new SimpleThermo;
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") {
176  return new GeneralSpeciesThermo();
177  } else if (ltype == "") {
178  return (SpeciesThermo*) 0;
179  } else {
180  throw UnknownSpeciesThermo("SpeciesThermoFactory::newSpeciesThermoManager",
181  stype);
182  }
183  return (SpeciesThermo*) 0;
184 }
185 
187  double thigh, double pref, const double* coeffs)
188 {
189  switch (type) {
190  case NASA1:
191  return new NasaPoly1(tlow, thigh, pref, coeffs);
192  case SHOMATE1:
193  return new ShomatePoly(tlow, thigh, pref, coeffs);
194  case CONSTANT_CP:
195  case SIMPLE:
196  return new ConstCpPoly(tlow, thigh, pref, coeffs);
197  case MU0_INTERP:
198  return new Mu0Poly(tlow, thigh, pref, coeffs);
199  case SHOMATE2:
200  return new ShomatePoly2(tlow, thigh, pref, coeffs);
201  case NASA2:
202  return new NasaPoly2(tlow, thigh, pref, coeffs);
203  case ADSORBATE:
204  return new Adsorbate(tlow, thigh, pref, coeffs);
205  default:
206  throw CanteraError("newSpeciesThermoInterpType",
207  "Unknown species thermo type: " + int2str(type) + ".");
208  }
209 }
210 
212  double tlow, double thigh, double pref, const double* coeffs)
213 {
214  int itype = -1;
215  std::string type = lowercase(stype);
216  if (type == "nasa2" || type == "nasa") {
217  itype = NASA2; // two-region 7-coefficient NASA polynomials
218  } else if (type == "const_cp" || type == "simple") {
219  itype = CONSTANT_CP;
220  } else if (type == "shomate" || type == "shomate1") {
221  itype = SHOMATE1; // single-region Shomate polynomial
222  } else if (type == "shomate2") {
223  itype = SHOMATE2; // two-region Shomate polynomials
224  } else if (type == "nasa1") {
225  itype = NASA1; // single-region, 7-coefficient NASA polynomial
226  } else if (type == "nasa9") {
227  itype = NASA9; // single-region, 9-coefficient NASA polynomial
228  } else if (type == "nasa9multi") {
229  itype = NASA9MULTITEMP; // multi-region, 9-coefficient NASA polynomials
230  } else if (type == "mu0") {
231  itype = MU0_INTERP;
232  } else if (type == "adsorbate") {
233  itype = ADSORBATE;
234  } else {
235  throw CanteraError("newSpeciesThermoInterpType",
236  "Unknown species thermo type: '" + stype + "'.");
237  }
238  return newSpeciesThermoInterpType(itype, tlow, thigh, pref, coeffs);
239 }
240 
241 //! Create a NASA polynomial thermodynamic property parameterization for a
242 //! species from a set ! of XML nodes
243 /*!
244  * This is called if a 'NASA' node is found in the XML input.
245  *
246  * @param nodes vector of 1 or 2 'NASA' XML_Nodes, each defining the
247  * coefficients for a temperature range
248  */
249 static SpeciesThermoInterpType* newNasaThermoFromXML(vector<XML_Node*> nodes)
250 {
251  const XML_Node& f0 = *nodes[0];
252  bool dualRange = (nodes.size() > 1);
253 
254  double tmin0 = fpValue(f0["Tmin"]);
255  double tmax0 = fpValue(f0["Tmax"]);
256 
257  doublereal p0 = OneAtm;
258  if (f0.hasAttrib("P0")) {
259  p0 = fpValue(f0["P0"]);
260  }
261  if (f0.hasAttrib("Pref")) {
262  p0 = fpValue(f0["Pref"]);
263  }
264  p0 = OneAtm;
265 
266  double tmin1 = tmax0;
267  double tmax1 = tmin1 + 0.0001;
268  if (dualRange) {
269  tmin1 = fpValue(nodes[1]->attrib("Tmin"));
270  tmax1 = fpValue(nodes[1]->attrib("Tmax"));
271  }
272 
273  vector_fp c0, c1;
274  doublereal tmin, tmid, tmax;
275  if (fabs(tmax0 - tmin1) < 0.01) {
276  // f0 has the lower T data, and f1 the higher T data
277  tmin = tmin0;
278  tmid = tmax0;
279  tmax = tmax1;
280  getFloatArray(f0.child("floatArray"), c0, false);
281  if (dualRange) {
282  getFloatArray(nodes[1]->child("floatArray"), c1, false);
283  } else {
284  // if there is no higher range data, then copy c0 to c1.
285  c1.resize(7,0.0);
286  copy(c0.begin(), c0.end(), c1.begin());
287  }
288  } else if (fabs(tmax1 - tmin0) < 0.01) {
289  // f1 has the lower T data, and f0 the higher T data
290  tmin = tmin1;
291  tmid = tmax1;
292  tmax = tmax0;
293  getFloatArray(nodes[1]->child("floatArray"), c0, false);
294  getFloatArray(f0.child("floatArray"), c1, false);
295  } else {
296  throw CanteraError("installNasaThermo",
297  "non-continuous temperature ranges.");
298  }
299 
300  vector_fp c(15);
301  c[0] = tmid;
302  copy(c1.begin(), c1.begin()+7, c.begin() + 1); // high-T coefficients
303  copy(c0.begin(), c0.begin()+7, c.begin() + 8); // low-T coefficients
304  return newSpeciesThermoInterpType(NASA, tmin, tmax, p0, &c[0]);
305 }
306 
307 //! Create a Shomate polynomial from an XML node giving the 'EQ3' coefficients
308 /*!
309  * This is called if a 'MinEQ3' node is found in the XML input.
310  * @param MinEQ3node The XML_Node containing the MinEQ3 parameterization
311  */
313 {
314  doublereal tmin0 = strSItoDbl(MinEQ3node["Tmin"]);
315  doublereal tmax0 = strSItoDbl(MinEQ3node["Tmax"]);
316  doublereal p0 = strSItoDbl(MinEQ3node["Pref"]);
317 
318  doublereal deltaG_formation_pr_tr =
319  getFloatDefaultUnits(MinEQ3node, "DG0_f_Pr_Tr", "cal/gmol", "actEnergy");
320  doublereal deltaH_formation_pr_tr =
321  getFloatDefaultUnits(MinEQ3node, "DH0_f_Pr_Tr", "cal/gmol", "actEnergy");
322  doublereal Entrop_pr_tr = getFloatDefaultUnits(MinEQ3node, "S0_Pr_Tr", "cal/gmol/K");
323  doublereal a = getFloatDefaultUnits(MinEQ3node, "a", "cal/gmol/K");
324  doublereal b = getFloatDefaultUnits(MinEQ3node, "b", "cal/gmol/K2");
325  doublereal c = getFloatDefaultUnits(MinEQ3node, "c", "cal-K/gmol");
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;
332 
333  /*
334  * Now calculate the shomate polynomials
335  *
336  * Cp first
337  *
338  * Shomate: (Joules / gmol / K)
339  * Cp = As + Bs * t + Cs * t*t + Ds * t*t*t + Es / (t*t)
340  * where
341  * t = temperature(Kelvin) / 1000
342  */
343  double As = a * 4.184;
344  double Bs = b * 4.184 * 1000.;
345  double Cs = 0.0;
346  double Ds = 0.0;
347  double Es = c * 4.184 / (1.0E6);
348 
349  double t = 298.15 / 1000.;
350  double H298smFs = As * t + Bs * t * t / 2.0 - Es / t;
351 
352  double HcalcS = Hcalc / 1.0E6;
353  double Fs = HcalcS - H298smFs;
354 
355  double S298smGs = As * log(t) + Bs * t - Es/(2.0*t*t);
356  double ScalcS = e / 1.0E3;
357  double Gs = ScalcS - S298smGs;
358 
359  double c0[7] = {As, Bs, Cs, Ds, Es, Fs, Gs};
360 
361  return newSpeciesThermoInterpType(SHOMATE1, tmin0, tmax0, p0, c0);
362 }
363 
364 //! Create a Shomate polynomial thermodynamic property parameterization for a
365 //! species
366 /*!
367  * This is called if a 'Shomate' node is found in the XML input.
368  *
369  * @param nodes vector of 1 or 2 'Shomate' XML_Nodes, each defining the
370  * coefficients for a temperature range
371  */
373  vector<XML_Node*>& nodes)
374 {
375  bool dualRange = false;
376  if (nodes.size() == 2) {
377  dualRange = true;
378  }
379  double tmin0 = fpValue(nodes[0]->attrib("Tmin"));
380  double tmax0 = fpValue(nodes[0]->attrib("Tmax"));
381 
382  doublereal p0 = OneAtm;
383  if (nodes[0]->hasAttrib("P0")) {
384  p0 = fpValue(nodes[0]->attrib("P0"));
385  }
386  if (nodes[0]->hasAttrib("Pref")) {
387  p0 = fpValue(nodes[0]->attrib("Pref"));
388  }
389  p0 = OneAtm;
390 
391  double tmin1 = tmax0;
392  double tmax1 = tmin1 + 0.0001;
393  if (dualRange) {
394  tmin1 = fpValue(nodes[1]->attrib("Tmin"));
395  tmax1 = fpValue(nodes[1]->attrib("Tmax"));
396  }
397 
398  vector_fp c0, c1;
399  doublereal tmin, tmid, tmax;
400  if (fabs(tmax0 - tmin1) < 0.01) {
401  tmin = tmin0;
402  tmid = tmax0;
403  tmax = tmax1;
404  getFloatArray(nodes[0]->child("floatArray"), c0, false);
405  if (dualRange) {
406  getFloatArray(nodes[1]->child("floatArray"), c1, false);
407  } else {
408  if(c0.size() != 7)
409  {
410  throw CanteraError("installShomateThermoFromXML",
411  "Shomate thermo requires 7 coefficients in float array.");
412  }
413  c1.resize(7,0.0);
414  copy(c0.begin(), c0.begin()+7, c1.begin());
415  }
416  } else if (fabs(tmax1 - tmin0) < 0.01) {
417  tmin = tmin1;
418  tmid = tmax1;
419  tmax = tmax0;
420  getFloatArray(nodes[1]->child("floatArray"), c0, false);
421  getFloatArray(nodes[0]->child("floatArray"), c1, false);
422  } else {
423  throw CanteraError("installShomateThermoFromXML",
424  "non-continuous temperature ranges.");
425  }
426  if(c0.size() != 7 || c1.size() != 7)
427  {
428  throw CanteraError("installShomateThermoFromXML",
429  "Shomate thermo requires 7 coefficients in float array.");
430  }
431  vector_fp c(15);
432  c[0] = tmid;
433  copy(c0.begin(), c0.begin()+7, c.begin() + 1);
434  copy(c1.begin(), c1.begin()+7, c.begin() + 8);
435  return newSpeciesThermoInterpType(SHOMATE, tmin, tmax, p0, &c[0]);
436 }
437 
438 //! Create a "simple" constant heat capacity thermodynamic property
439 //! parameterization for a ! species
440 /*!
441  * This is called if a 'const_cp' XML node is found
442  *
443  * @param f 'const_cp' XML node
444  */
446 {
447  double tmin = fpValue(f["Tmin"]);
448  double tmax = fpValue(f["Tmax"]);
449  if (tmax == 0.0) {
450  tmax = 1.0e30;
451  }
452 
453  vector_fp c(4);
454  c[0] = getFloat(f, "t0", "toSI");
455  c[1] = getFloat(f, "h0", "toSI");
456  c[2] = getFloat(f, "s0", "toSI");
457  c[3] = getFloat(f, "cp0", "toSI");
458  doublereal p0 = OneAtm;
459  return newSpeciesThermoInterpType(CONSTANT_CP, tmin, tmax, p0, &c[0]);
460 }
461 
462 
463 //! Create a NASA9 polynomial thermodynamic property parameterization for a
464 //! species
465 /*!
466  * This is called if a 'NASA9' Node is found in the XML input.
467  *
468  * @param tp Vector of XML Nodes that make up the parameterization
469  */
471  const std::vector<XML_Node*>& tp)
472 {
473  int nRegions = 0;
474  vector_fp cPoly;
475  std::vector<Nasa9Poly1*> regionPtrs;
476  doublereal pref = OneAtm;
477  // Loop over all of the possible temperature regions
478  for (size_t i = 0; i < tp.size(); i++) {
479  const XML_Node& fptr = *tp[i];
480  if (fptr.name() == "NASA9" && fptr.hasChild("floatArray")) {
481  double tmin = fpValue(fptr["Tmin"]);
482  double tmax = fpValue(fptr["Tmax"]);
483  if (fptr.hasAttrib("P0")) {
484  pref = fpValue(fptr["P0"]);
485  }
486  if (fptr.hasAttrib("Pref")) {
487  pref = fpValue(fptr["Pref"]);
488  }
489 
490  getFloatArray(fptr.child("floatArray"), cPoly, false);
491  if (cPoly.size() != 9) {
492  throw CanteraError("installNasa9ThermoFromXML",
493  "Expected 9 coeff polynomial");
494  }
495  regionPtrs.push_back(new Nasa9Poly1(tmin, tmax, pref, &cPoly[0]));
496  nRegions++;
497  }
498  }
499  if (nRegions == 0) {
500  throw CanteraError("newNasa9ThermoFromXML", "zero regions found");
501  } else if (nRegions == 1) {
502  return regionPtrs[0];
503  } else {
504  return new Nasa9PolyMultiTempRegion(regionPtrs);
505  }
506 }
507 
508 /**
509  * Create a stat mech based property solver for a species
510  * @deprecated
511  */
513 {
514  doublereal tmin = fpValue(f["Tmin"]);
515  doublereal tmax = fpValue(f["Tmax"]);
516  doublereal pref = OneAtm;
517  if (f.hasAttrib("P0")) {
518  pref = fpValue(f["P0"]);
519  }
520  if (f.hasAttrib("Pref")) {
521  pref = fpValue(f["Pref"]);
522  }
523 
524  // set properties
525  tmin = 0.1;
526  vector_fp coeffs(1);
527  coeffs[0] = 0.0;
528  return new StatMech(0, tmin, tmax, pref, &coeffs[0], "");
529 }
530 
531 //! Create an Adsorbate polynomial thermodynamic property parameterization for a
532 //! species
533 /*!
534  * This is called if a 'Adsorbate' node is found in the XML input.
535  *
536  * @param f XML Node that contains the parameterization
537  */
539 {
540  vector_fp freqs;
541  doublereal pref = OneAtm;
542  double tmin = fpValue(f["Tmin"]);
543  double tmax = fpValue(f["Tmax"]);
544  if (f.hasAttrib("P0")) {
545  pref = fpValue(f["P0"]);
546  }
547  if (f.hasAttrib("Pref")) {
548  pref = fpValue(f["Pref"]);
549  }
550  if (tmax == 0.0) {
551  tmax = 1.0e30;
552  }
553 
554  if (f.hasChild("floatArray")) {
555  getFloatArray(f.child("floatArray"), freqs, false);
556  }
557  for (size_t n = 0; n < freqs.size(); n++) {
558  freqs[n] *= 3.0e10;
559  }
560  vector_fp coeffs(freqs.size() + 2);
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]);
565 }
566 
567 void SpeciesThermoFactory::installThermoForSpecies
568 (size_t k, const XML_Node& speciesNode, ThermoPhase* th_ptr,
569  SpeciesThermo& spthermo, const XML_Node* phaseNode_ptr) const
570 {
571  shared_ptr<SpeciesThermoInterpType> stit(
572  newSpeciesThermoInterpType(speciesNode.child("thermo")));
573  stit->validate(speciesNode["name"]);
574  spthermo.install_STIT(k, stit);
575 }
576 
577 void SpeciesThermoFactory::installVPThermoForSpecies(size_t k,
578  const XML_Node& speciesNode,
579  VPStandardStateTP* vp_ptr,
580  VPSSMgr* vpssmgr_ptr,
581  SpeciesThermo* spthermo_ptr,
582  const XML_Node* phaseNode_ptr) const
583 {
584  warn_deprecated("SpeciesThermoFactory::installVPThermoForSpecies",
585  "Call VPStandardStateTP::createInstallPDSS directly.");
586  // Call the VPStandardStateTP object to install the pressure dependent species
587  // standard state into the object.
588  //
589  // We don't need to pass spthermo_ptr down, because it's already installed
590  // into vp_ptr.
591  //
592  // We don't need to pass vpssmgr_ptr down, because it's already installed
593  // into vp_ptr.
594  vp_ptr->createInstallPDSS(k, speciesNode, phaseNode_ptr);
595 }
596 
598 {
599  // Get the children of the thermo XML node. In the next bit of code we take out the comments that
600  // may have been children of the thermo XML node by doing a selective copy.
601  // These shouldn't interfere with the algorithm at any point.
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]);
607  }
608  }
609 
610  std::string thermoType = lowercase(tp[0]->name());
611 
612  for (size_t i = 1; i < tp.size(); i++) {
613  if (lowercase(tp[i]->name()) != thermoType) {
614  throw CanteraError("newSpeciesThermoInterpType",
615  "Encountered unsupported mixed species thermo parameterizations");
616  }
617  }
618  if ((tp.size() > 2 && thermoType != "nasa9") ||
619  (tp.size() > 1 && (thermoType == "const_cp" ||
620  thermoType == "mu0" ||
621  thermoType == "adsorbate"))) {
622  throw CanteraError("newSpeciesThermoInterpType",
623  "Too many regions in thermo parameterization.");
624  }
625 
626  std::string model = lowercase(thermo["model"]);
627  if (model == "mineraleq3") {
628  if (thermoType != "mineq3") {
629  throw CanteraError("SpeciesThermoFactory::installThermoForSpecies",
630  "confused: expected MinEQ3");
631  }
632  return newShomateForMineralEQ3(*tp[0]);
633  } else if (thermoType == "shomate") {
634  return newShomateThermoFromXML(tp);
635  } else if (thermoType == "const_cp") {
636  return newConstCpThermoFromXML(*tp[0]);
637  } else if (thermoType == "nasa") {
638  return newNasaThermoFromXML(tp);
639  } else if (thermoType == "mu0") {
640  return newMu0ThermoFromXML(*tp[0]);
641  } else if (thermoType == "nasa9") {
642  return newNasa9ThermoFromXML(tp);
643  } else if (thermoType == "adsorbate") {
644  return newAdsorbateThermoFromXML(*tp[0]);
645  } else if (thermoType == "statmech") {
646  return newStatMechThermoFromXML(*tp[0]);
647  } else if (model == "hkft" || model == "ionfromneutral") {
648  // Some PDSS species use the 'thermo' node, but don't specify a
649  // SpeciesThermoInterpType parameterization. This function needs to just
650  // ignore this data.
651  return 0;
652  } else {
653  throw CanteraError("newSpeciesThermoInterpType",
654  "Unknown species thermo model '" + thermoType + "'.");
655  }
656 }
657 
659 {
660  warn_deprecated("newSpeciesThermoMgr", "To be removed after Cantera 2.2. "
661  "Use class GeneralSpeciesThermo directly.");
662  if (f == 0) {
663  f = SpeciesThermoFactory::factory();
664  }
665  return f->newSpeciesThermo(type);
666 }
667 
668 SpeciesThermo* newSpeciesThermoMgr(const std::string& stype,
670 {
671  warn_deprecated("newSpeciesThermoMgr", "To be removed after Cantera 2.2. "
672  "Use class GeneralSpeciesThermo directly.");
673  if (f == 0) {
674  f = SpeciesThermoFactory::factory();
675  }
676  return f->newSpeciesThermoManager(stype);
677 }
678 
679 SpeciesThermo* newSpeciesThermoMgr(std::vector<XML_Node*> spData_nodes,
681 {
682  warn_deprecated("newSpeciesThermoMgr", "To be removed after Cantera 2.2. "
683  "Use class GeneralSpeciesThermo directly.");
684  if (f == 0) {
685  f = SpeciesThermoFactory::factory();
686  }
687  return f->newSpeciesThermo(spData_nodes);
688 }
689 
690 }
Factory to build instances of classes that manage the standard-state thermodynamic properties of a se...
Statistical mechanics.
Definition: StatMech.h:27
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.
Definition: stringUtils.cpp:39
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.
Definition: global.cpp:126
#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.
Definition: NasaPoly2.h:48
const doublereal OneAtm
One atmosphere [Pa].
Definition: ct_defs.h:69
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
Definition: xml.cpp:527
const std::vector< XML_Node * > & children() const
Return an unchangeable reference to the vector of children of the current node.
Definition: xml.cpp:578
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:235
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.
Definition: xml.h:100
#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.
Definition: global.cpp:78
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 ...
Definition: Mu0Poly.h:71
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...
Definition: NasaThermo.h:46
std::string lowercase(const std::string &s)
Cast a copy of a string to lower case.
Definition: stringUtils.cpp:73
A constant-heat capacity species thermodynamic property manager class.
Definition: ConstCpPoly.h:47
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.
Definition: xml.cpp:573
#define MU0_INTERP
piecewise interpolation of mu0.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
#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.
Definition: ShomatePoly.h:56
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.
Definition: ShomatePoly.h:312
std::string name() const
Returns the name of the XML node.
Definition: xml.h:394
Header for the 2 regime 7 coefficient NASA thermodynamic polynomials for multiple species in a phase...
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
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.
Definition: xml.cpp:563
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.
Definition: ShomateThermo.h:61
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.
Definition: ct_defs.h:157
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...
Definition: ctml.cpp:323
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.
Definition: ctml.cpp:194
The NASA 9 polynomial parameterization for one temperature range.
Definition: Nasa9Poly1.h:71
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.
Definition: ctml.cpp:264
Header for a single-species standard state object derived from SpeciesThermoInterpType based on the e...
The NASA polynomial parameterization for one temperature range.
Definition: NasaPoly1.h:46
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.
Definition: Mu0Poly.cpp:125
#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.
Definition: xml.cpp:568
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.