Skip to content

Commit

Permalink
[Input] Improve error message for missing 'equation-of-state' field
Browse files Browse the repository at this point in the history
Without this, the error message confusingly mentions being unable to find
the now-removed 'ideal-gas' PDSS model.
  • Loading branch information
speth authored and ischoegl committed Aug 27, 2023
1 parent 55253a6 commit 23f183a
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/thermo/ThermoFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> 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<AnyMap>()) {
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.");
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<AnyMap>()) {
string model = node["model"].asString();
if (PDSSFactory::factory()->exists(model)) {
pdss.reset(newPDSS(model));
pdss->setParameters(node);
found = true;
break;
}
} 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));
}
Expand Down

0 comments on commit 23f183a

Please sign in to comment.