From 62c67e4ad1f57763c25393382e7901c8fb131713 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 30 Jan 2017 23:24:58 -0500 Subject: [PATCH] [TPX] Add factory function for Substance from species name This function had been defined but not declared. --- include/cantera/tpx/utils.h | 16 ++++++++++++++++ src/tpx/utils.cpp | 5 +++-- 2 files changed, 19 insertions(+), 2 deletions(-) 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); } }