From 23f183a8e8fb26ab7e8fe589d89b6d21a32ce1fd Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sat, 26 Aug 2023 15:11:12 -0400 Subject: [PATCH] [Input] Improve error message for missing 'equation-of-state' field Without this, the error message confusingly mentions being unable to find the now-removed 'ideal-gas' PDSS model. --- src/thermo/ThermoFactory.cpp | 40 +++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/thermo/ThermoFactory.cpp b/src/thermo/ThermoFactory.cpp index 822e7b0de..c3d76bc4e 100644 --- a/src/thermo/ThermoFactory.cpp +++ b/src/thermo/ThermoFactory.cpp @@ -313,26 +313,28 @@ void setupPhase(ThermoPhase& thermo, const AnyMap& phaseNode, const AnyMap& root if (vpssThermo) { for (size_t k = 0; k < thermo.nSpecies(); k++) { unique_ptr pdss; - if (thermo.species(k)->input.hasKey("equation-of-state")) { - // Use the first node which specifies a valid PDSS model - auto& eos = thermo.species(k)->input["equation-of-state"]; - bool found = false; - for (auto& node : eos.asVector()) { - string model = node["model"].asString(); - if (PDSSFactory::factory()->exists(model)) { - pdss.reset(newPDSS(model)); - pdss->setParameters(node); - found = true; - break; - } + if (!thermo.species(k)->input.hasKey("equation-of-state")) { + throw InputFileError("setupPhase", thermo.species(k)->input, + "Species '{}' in use by a ThermoPhase model of type '{}'\n" + "must define an 'equation-of-state' field.", + thermo.speciesName(k), thermo.type()); + } + // Use the first node which specifies a valid PDSS model + auto& eos = thermo.species(k)->input["equation-of-state"]; + bool found = false; + for (auto& node : eos.asVector()) { + string model = node["model"].asString(); + if (PDSSFactory::factory()->exists(model)) { + pdss.reset(newPDSS(model)); + pdss->setParameters(node); + found = true; + break; } - if (!found) { - throw InputFileError("setupPhase", eos, - "Could not find an equation-of-state specification " - "which defines a known PDSS model."); - } - } else { - pdss.reset(newPDSS("ideal-gas")); + } + if (!found) { + throw InputFileError("setupPhase", eos, + "Could not find an equation-of-state specification " + "which defines a known PDSS model."); } vpssThermo->installPDSS(k, std::move(pdss)); }