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"
7#include "cantera/base/stringUtils.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 == "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}
CarbonDioxide.h
HFC134a.h
Heptane.h
Hydrogen.h
Methane.h
Nitrogen.h
Oxygen.h
Water.h
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:61
tpx::CarbonDioxide
Pure species representation of carbon dioxide.
Definition: CarbonDioxide.h:17
tpx::HFC134a
Equation of state for HFC-134a.
Definition: HFC134a.h:22
tpx::Heptane
Pure species representation of heptane.
Definition: Heptane.h:16
tpx::Substance
Definition: Sub.h:38
tpx::hydrogen
Pure species representation of hydrogen.
Definition: Hydrogen.h:17
tpx::methane
Pure species representation of methane.
Definition: Methane.h:17
tpx::nitrogen
Pure species representation of nitrogen.
Definition: Nitrogen.h:17
tpx::oxygen
Pure species representation of oxygen.
Definition: Oxygen.h:16
tpx::water
Pure species representation of water.
Definition: Water.h:16
Cantera::toLowerCopy
std::string toLowerCopy(const std::string &input)
Convert to lower case.
Definition: stringUtils.cpp:262
stringUtils.h
Contains declarations for string manipulation functions within Cantera.
tpx::newSubstance
Substance * newSubstance(const std::string &name)
Create a new Substance object corresponding to the specified name.
Definition: utils.cpp:20
utils.h