Allow non-positive atomic weights for custom elements

This commit is contained in:
Ray Speth 2016-08-30 20:28:35 -04:00
parent f0cdb6df8c
commit abf71c4cb1
2 changed files with 8 additions and 10 deletions

View file

@ -705,12 +705,14 @@ size_t Phase::addElement(const std::string& symbol, doublereal weight,
int elem_type)
{
// Look up the atomic weight if not given
if (weight == -12345.0) {
weight = getElementWeight(symbol);
if (weight < 0.0) {
throw CanteraError("Phase::addElement",
"No atomic weight found for element: " + symbol);
if (weight == 0.0) {
try {
weight = getElementWeight(symbol);
} catch (CanteraError&) {
// assume this is just a custom element with zero atomic weight
}
} else if (weight == -12345.0) {
weight = getElementWeight(symbol);
}
// Check for duplicates

View file

@ -474,11 +474,7 @@ void installElements(Phase& th, const XML_Node& phaseNode)
entropy298 = fpValueCheck(e298Node["value"]);
}
}
if (weight != 0.0) {
th.addElement(symbol, weight, anum, entropy298);
} else {
th.addElement(symbol);
}
th.addElement(symbol, weight, anum, entropy298);
}
}