From 78f60e2d5fb462e2cc208dc0efefb35e6fccdc41 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 29 May 2015 11:15:00 -0400 Subject: [PATCH] [Thermo] Improve error message generated by Substance::set_xy --- src/tpx/Sub.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tpx/Sub.cpp b/src/tpx/Sub.cpp index 9167ed4ef..87684558d 100644 --- a/src/tpx/Sub.cpp +++ b/src/tpx/Sub.cpp @@ -10,6 +10,11 @@ using std::string; using namespace Cantera; +namespace { +// these correspond to ordering withing propertyFlag::type +std::string propertySymbols[] = {"H", "S", "U", "V", "P", "T"}; +} + namespace tpx { Substance::Substance() : @@ -514,7 +519,15 @@ void Substance::set_xy(propertyFlag::type ifx, propertyFlag::type ify, Set(PropertyPair::TV, t_here, v_here); LoopCount++; if (LoopCount > 200) { - throw TPX_Error("Substance::set_xy","no convergence"); + std::string msg = "No convergence. " + + propertySymbols[ifx] + " = " + fp2str(X) + ", " + + propertySymbols[ify] + " = " + fp2str(Y); + if (t_here == Tmin()) { + msg += "\nAt temperature limit (Tmin = " + fp2str(Tmin()) + ")"; + } else if (t_here == Tmax()) { + msg += "\nAt temperature limit (Tmax = " + fp2str(Tmax()) + ")"; + } + throw TPX_Error("Substance::set_xy", msg); } } }