Skip to content

Commit

Permalink
Allow non-positive atomic weights for custom elements
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Aug 31, 2016
1 parent f0cdb6d commit abf71c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/thermo/Phase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions src/thermo/ThermoFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit abf71c4

Please sign in to comment.