Cantera 2.6.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 https://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
18namespace tpx
19{
20Substance* 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 == "hfc-134a" || lcname == "hfc134a") {
34 return new HFC134a;
35 } else if (lcname == "carbon-dioxide" || 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
45Substance* 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 throw Cantera::CanteraError("tpx::GetSub", "No substance definition "
65 "known for id '{}'.", isub);
66 }
67}
68
69}
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
Pure species representation of carbon dioxide.
Definition: CarbonDioxide.h:17
Equation of state for HFC-134a.
Definition: HFC134a.h:22
Pure species representation of heptane.
Definition: Heptane.h:16
Pure species representation of hydrogen.
Definition: Hydrogen.h:17
Pure species representation of methane.
Definition: Methane.h:17
Pure species representation of nitrogen.
Definition: Nitrogen.h:17
Pure species representation of oxygen.
Definition: Oxygen.h:16
Pure species representation of water.
Definition: Water.h:16
std::string toLowerCopy(const std::string &input)
Convert to lower case.
Contains declarations for string manipulation functions within Cantera.
Substance * newSubstance(const std::string &name)
Create a new Substance object corresponding to the specified name.
Definition: utils.cpp:20