| Cantera 3.0.0

Loading...
Searching...
No Matches
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#include "cantera/base/global.h"
9
10#include "CarbonDioxide.h"
11#include "Heptane.h"
12#include "HFC134a.h"
13#include "Hydrogen.h"
14#include "Methane.h"
15#include "Nitrogen.h"
16#include "Oxygen.h"
17#include "Water.h"
18
19 namespace tpx
20{
21 Substance* newSubstance(const std::string& name)
22{
23 std::string lcname = Cantera::toLowerCopy(name);
24 if (lcname == "water") {
25 return new water;
26 } else if (lcname == "nitrogen") {
27 return new nitrogen;
28 } else if (lcname == "methane") {
29 return new methane;
30 } else if (lcname == "hydrogen") {
31 return new hydrogen;
32 } else if (lcname == "oxygen") {
33 return new oxygen;
34 } else if (lcname == "hfc-134a" || lcname == "hfc134a") {
35 return new HFC134a;
36 } else if (lcname == "carbon-dioxide" || lcname == "carbondioxide") {
37 return new CarbonDioxide;
38 } else if (lcname == "heptane") {
39 return new Heptane;
40 } else {
41 throw Cantera::CanteraError("tpx::newSubstance", "No Substance"
42 " definition known for '{}'.", name);
43 }
44}
45
46 Substance* GetSub(int isub)
47{
48 Cantera::warn_deprecated("tpx::GetSub", "To be removed after Cantera 3.0. "
49 "Use tpx::newSubstance(string) instead.");
50 if (isub == 0) {
51 return new water;
52 } else if (isub == 1) {
53 return new nitrogen;
54 } else if (isub == 2) {
55 return new methane;
56 } else if (isub == 3) {
57 return new hydrogen;
58 } else if (isub == 4) {
59 return new oxygen;
60 } else if (isub == 5) {
61 return new HFC134a;
62 } else if (isub == 7) {
63 return new CarbonDioxide;
64 } else if (isub == 8) {
65 return new Heptane;
66 } else {
67 throw Cantera::CanteraError("tpx::GetSub", "No substance definition "
68 "known for id '{}'.", isub);
69 }
70}
71
72}
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:66
tpx::CarbonDioxide
Pure species representation of carbon dioxide.
Definition CarbonDioxide.h:17
tpx::HFC134a
Equation of state for HFC-134a.
Definition HFC134a.h:18
tpx::Heptane
Pure species representation of heptane.
Definition Heptane.h:16
tpx::Substance
Base class from which all pure substances are derived.
Definition Sub.h:37
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
global.h
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
Cantera::toLowerCopy
string toLowerCopy(const string &input)
Convert to lower case.
Definition stringUtils.cpp:219
Cantera::warn_deprecated
void warn_deprecated(const string &source, const AnyBase &node, const string &message)
A deprecation warning for syntax in an input file.
Definition AnyMap.cpp:1926
stringUtils.h
Contains declarations for string manipulation functions within Cantera.
tpx::GetSub
Substance * GetSub(int isub)
Definition utils.cpp:46
tpx::newSubstance
Substance * newSubstance(const std::string &name)
Create a new Substance object corresponding to the specified name.
Definition utils.cpp:21
utils.h