From 6648b9ec340ae6d55dc9b92f400e9e6574a73352 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 29 Apr 2015 22:12:00 -0400 Subject: [PATCH] [Kinetics] Falloff initialization checks for correct number of parameters --- include/cantera/kinetics/Falloff.h | 2 +- src/kinetics/Falloff.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/cantera/kinetics/Falloff.h b/include/cantera/kinetics/Falloff.h index 1497d5dcf..139bf7baf 100644 --- a/include/cantera/kinetics/Falloff.h +++ b/include/cantera/kinetics/Falloff.h @@ -32,7 +32,7 @@ public: * @param c Vector of coefficients of the parameterization. The number and * meaning of these coefficients is subclass-dependent. */ - virtual void init(const vector_fp& c) {} + virtual void init(const vector_fp& c); /** * Update the temperature-dependent portions of the falloff function, if diff --git a/src/kinetics/Falloff.cpp b/src/kinetics/Falloff.cpp index 05d81f438..a0978bba9 100644 --- a/src/kinetics/Falloff.cpp +++ b/src/kinetics/Falloff.cpp @@ -10,8 +10,22 @@ namespace Cantera { +void Falloff::init(const vector_fp& c) +{ + if (c.size() != 0) { + throw CanteraError("Falloff::init", + "Incorrect number of parameters. 0 required. Received " + + int2str(c.size()) + "."); + } +} + void Troe::init(const vector_fp& c) { + if (c.size() != 3 && c.size() != 4) { + throw CanteraError("Troe::init", + "Incorrect number of parameters. 3 or 4 required. Received " + + int2str(c.size()) + "."); + } m_a = c[0]; if (c[1] == 0.0) { m_rt3 = 1000.; @@ -57,6 +71,12 @@ void Troe::getParameters(double* params) const { void SRI::init(const vector_fp& c) { + if (c.size() != 3 && c.size() != 5) { + throw CanteraError("SRI::init", + "Incorrect number of parameters. 3 or 5 required. Received " + + int2str(c.size()) + "."); + } + if (c[2] < 0.0) { throw CanteraError("SRI::init()", "m_c parameter is less than zero: " + fp2str(c[2]));