diff --git a/include/cantera/tpx/utils.h b/include/cantera/tpx/utils.h index 7e516005c..aad9c42c5 100644 --- a/include/cantera/tpx/utils.h +++ b/include/cantera/tpx/utils.h @@ -7,6 +7,22 @@ namespace tpx { Substance* GetSub(int isub); + +//! Create a new Substance object corresponding to the specified name. +/* + * Currently valid substances are: + * + * - water + * - nitrogen + * - methane + * - hydrogen + * - oxygen + * - hfc134a + * - carbondioxide + * - heptane + */ +Substance* newSubstance(const std::string& name); + } #endif diff --git a/src/tpx/utils.cpp b/src/tpx/utils.cpp index 400926ca6..f3cc70c73 100644 --- a/src/tpx/utils.cpp +++ b/src/tpx/utils.cpp @@ -18,7 +18,7 @@ namespace tpx { -Substance* GetSubstanceByName(std::string name) +Substance* newSubstance(const std::string& name) { std::string lcname = boost::algorithm::to_lower_copy(name); if (lcname == "water") { @@ -40,7 +40,8 @@ Substance* GetSubstanceByName(std::string name) } else if (lcname == "heptane") { return new Heptane; } else { - return 0; + throw Cantera::CanteraError("tpx::newSubstance", "No Substance" + " definition known for '{}'.", name); } }