Cantera  2.4.0
utils.cpp
Go to the documentation of this file.
1 //! @file utils.cpp
2 
3 // This file is part of Cantera. See License.txt in the top-level directory or
4 // at http://www.cantera.org/license.txt for license and copyright information.
5 
6 #include "cantera/tpx/utils.h"
8 
9 #include "CarbonDioxide.h"
10 #include "Heptane.h"
11 #include "HFC134a.h"
12 #include "Hydrogen.h"
13 #include "Methane.h"
14 #include "Nitrogen.h"
15 #include "Oxygen.h"
16 #include "Water.h"
17 
18 namespace tpx
19 {
20 Substance* newSubstance(const std::string& name)
21 {
22  std::string lcname = Cantera::toLowerCopy(name);
23  if (lcname == "water") {
24  return new water;
25  } else if (lcname == "nitrogen") {
26  return new nitrogen;
27  } else if (lcname == "methane") {
28  return new methane;
29  } else if (lcname == "hydrogen") {
30  return new hydrogen;
31  } else if (lcname == "oxygen") {
32  return new oxygen;
33  } else if (lcname == "hfc134a") {
34  return new HFC134a;
35  } else if (lcname == "carbondioxide") {
36  return new CarbonDioxide;
37  } else if (lcname == "heptane") {
38  return new Heptane;
39  } else {
40  throw Cantera::CanteraError("tpx::newSubstance", "No Substance"
41  " definition known for '{}'.", name);
42  }
43 }
44 
45 Substance* GetSub(int isub)
46 {
47  if (isub == 0) {
48  return new water;
49  } else if (isub == 1) {
50  return new nitrogen;
51  } else if (isub == 2) {
52  return new methane;
53  } else if (isub == 3) {
54  return new hydrogen;
55  } else if (isub == 4) {
56  return new oxygen;
57  } else if (isub == 5) {
58  return new HFC134a;
59  } else if (isub == 7) {
60  return new CarbonDioxide;
61  } else if (isub == 8) {
62  return new Heptane;
63  } else {
64  return 0;
65  }
66 }
67 
68 }
Pure species representation of heptane.
Definition: Heptane.h:15
Pure species representation of water.
Definition: Water.h:15
Pure species representation of hydrogen.
Definition: Hydrogen.h:16
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:65
Equation of state for HFC-134a.
Definition: HFC134a.h:21
Substance * newSubstance(const std::string &name)
Create a new Substance object corresponding to the specified name.
Definition: utils.cpp:20
Pure species representation of nitrogen.
Definition: Nitrogen.h:16
Pure species representation of oxygen.
Definition: Oxygen.h:15
Contains declarations for string manipulation functions within Cantera.
std::string toLowerCopy(const std::string &input)
Convert to lower case.
Pure species representation of methane.
Definition: Methane.h:16
Pure species representation of carbon dioxide.
Definition: CarbonDioxide.h:16