Added a Check between the input charge and the composition of
the "E" element. At this point there doesn't seem to be a reason to let meaning of the definition of charge() and the elemental composition of E in each species to diverge.
This commit is contained in:
parent
39d60dd2d1
commit
705d934080
4 changed files with 22 additions and 9 deletions
|
|
@ -294,6 +294,19 @@ namespace Cantera {
|
|||
double wt = 0.0;
|
||||
int m_mm = m_Elements->nElements();
|
||||
const vector_fp &aw = m_Elements->atomicWeights();
|
||||
if (charge != 0.0) {
|
||||
int eindex = m_Elements->elementIndex("E");
|
||||
if (eindex >= 0) {
|
||||
doublereal ecomp = comp[eindex];
|
||||
if (fabs (charge + ecomp) > 0.001) {
|
||||
throw CanteraError("Constituents::addSpecies",
|
||||
"Input charge and element E compositions differ for species " + name);
|
||||
}
|
||||
} else {
|
||||
throw CanteraError("Constituents::addSpecies",
|
||||
"Input charge and element E compositions differ for species " + name);
|
||||
}
|
||||
}
|
||||
for (int m = 0; m < m_mm; m++) {
|
||||
m_speciesComp.push_back(comp[m]);
|
||||
wt += comp[m] * aw[m];
|
||||
|
|
|
|||
|
|
@ -394,7 +394,7 @@ namespace Cantera {
|
|||
getFloatArray(f0.child("floatArray"), c1, false);
|
||||
}
|
||||
else {
|
||||
throw CanteraError("installShomateThermo",
|
||||
throw CanteraError("installShomateThermoFromXML",
|
||||
"non-continuous temperature ranges.");
|
||||
}
|
||||
array_fp c(15);
|
||||
|
|
@ -443,7 +443,7 @@ namespace Cantera {
|
|||
* before processing. Throw an error if not there.
|
||||
*/
|
||||
if (!(s.hasChild("thermo"))) {
|
||||
throw UnknownSpeciesThermoModel("installSpecies",
|
||||
throw UnknownSpeciesThermoModel("installThermoForSpecies",
|
||||
s["name"], "<nonexistent>");
|
||||
}
|
||||
const XML_Node& thermo = s.child("thermo");
|
||||
|
|
@ -464,7 +464,7 @@ namespace Cantera {
|
|||
installMu0ThermoFromXML(s["name"], spthermo, k, f);
|
||||
}
|
||||
else {
|
||||
throw UnknownSpeciesThermoModel("installSpecies",
|
||||
throw UnknownSpeciesThermoModel("installThermoForSpecies",
|
||||
s["name"], f->name());
|
||||
}
|
||||
}
|
||||
|
|
@ -478,13 +478,13 @@ namespace Cantera {
|
|||
installShomateThermoFromXML(s["name"], spthermo, k, f0, f1);
|
||||
}
|
||||
else {
|
||||
throw UnknownSpeciesThermoModel("installSpecies", s["name"],
|
||||
throw UnknownSpeciesThermoModel("installThermoForSpecies", s["name"],
|
||||
f0->name() + " and "
|
||||
+ f1->name());
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw UnknownSpeciesThermoModel("installSpecies", s["name"],
|
||||
throw UnknownSpeciesThermoModel("installThermoForSpecies", s["name"],
|
||||
"multiple");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,8 +351,10 @@ namespace Cantera {
|
|||
#endif
|
||||
doublereal dd = m_sub->density(T, p, waterState, dens);
|
||||
if (dd <= 0.0) {
|
||||
printf("throw an error\n");
|
||||
throw CanteraError("WaterPDSS:pressure", "Failed to set water state");
|
||||
std::string stateString = "T = " +
|
||||
fp2str(T) + " K and p = " + fp2str(p) + " Pa";
|
||||
throw CanteraError("WaterPDSS:setPressure()",
|
||||
"Failed to set water SS state: " + stateString);
|
||||
}
|
||||
m_dens = dd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ namespace Cantera {
|
|||
* Format a summary of the mixture state for output.
|
||||
*/
|
||||
string report(const ThermoPhase& th, bool show_thermo) {
|
||||
cout << "in report... " << th.name() << endl;
|
||||
cout << "nSpecies = " << th.nSpecies() << endl;
|
||||
char p[200];
|
||||
string s = "";
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue