[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.
This commit is contained in:
Ray Speth 2023-08-26 15:11:12 -04:00 committed by Ingmar Schoegl
parent 55253a6726
commit 23f183a8e8

View File

@ -313,26 +313,28 @@ void setupPhase(ThermoPhase& thermo, const AnyMap& phaseNode, const AnyMap& root
if (vpssThermo) { if (vpssThermo) {
for (size_t k = 0; k < thermo.nSpecies(); k++) { for (size_t k = 0; k < thermo.nSpecies(); k++) {
unique_ptr<PDSS> pdss; unique_ptr<PDSS> pdss;
if (thermo.species(k)->input.hasKey("equation-of-state")) { if (!thermo.species(k)->input.hasKey("equation-of-state")) {
// Use the first node which specifies a valid PDSS model throw InputFileError("setupPhase", thermo.species(k)->input,
auto& eos = thermo.species(k)->input["equation-of-state"]; "Species '{}' in use by a ThermoPhase model of type '{}'\n"
bool found = false; "must define an 'equation-of-state' field.",
for (auto& node : eos.asVector<AnyMap>()) { thermo.speciesName(k), thermo.type());
string model = node["model"].asString(); }
if (PDSSFactory::factory()->exists(model)) { // Use the first node which specifies a valid PDSS model
pdss.reset(newPDSS(model)); auto& eos = thermo.species(k)->input["equation-of-state"];
pdss->setParameters(node); bool found = false;
found = true; for (auto& node : eos.asVector<AnyMap>()) {
break; 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, if (!found) {
"Could not find an equation-of-state specification " throw InputFileError("setupPhase", eos,
"which defines a known PDSS model."); "Could not find an equation-of-state specification "
} "which defines a known PDSS model.");
} else {
pdss.reset(newPDSS("ideal-gas"));
} }
vpssThermo->installPDSS(k, std::move(pdss)); vpssThermo->installPDSS(k, std::move(pdss));
} }