Cantera  2.0
utils.cpp
1 #include "subs.h"
2 #include "cantera/tpx/utils.h"
3 
4 using std::string;
5 
6 namespace tpx
7 {
8 
9 static string lowercase(string s)
10 {
11  size_t i, n = s.size();
12  string lc(s);
13  for (i = 0; i < n; i++) {
14  lc[i] = (char) tolower(s[i]);
15  }
16  return lc;
17 }
18 
19 Substance* GetSubstanceByName(string name)
20 {
21  string lcname = lowercase(name);
22  if (lcname == "water") {
23  return new water;
24  } else if (lcname == "nitrogen") {
25  return new nitrogen;
26  } else if (lcname == "methane") {
27  return new methane;
28  } else if (lcname == "hydrogen") {
29  return new hydrogen;
30  } else if (lcname == "oxygen") {
31  return new oxygen;
32  } else if (lcname == "hfc134a") {
33  return new HFC134a;
34  } else if (lcname == "rk") {
35  return new RedlichKwong;
36  } else if (lcname == "carbondioxide") {
37  return new CarbonDioxide;
38  } else if (lcname == "heptane") {
39  return new Heptane;
40  } else {
41  return 0;
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 == 6) {
60  return new RedlichKwong;
61  } else if (isub == 7) {
62  return new CarbonDioxide;
63  } else if (isub == 8) {
64  return new Heptane;
65  } else {
66  return 0;
67  }
68 }
69 
70 }
71