From 705d934080b21b1d97190500a48f4c92b3dd2db6 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Sun, 20 May 2007 22:21:07 +0000 Subject: [PATCH] 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. --- Cantera/src/thermo/Constituents.cpp | 13 +++++++++++++ Cantera/src/thermo/SpeciesThermoFactory.cpp | 10 +++++----- Cantera/src/thermo/WaterPDSS.cpp | 6 ++++-- Cantera/src/thermo/phasereport.cpp | 2 -- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Cantera/src/thermo/Constituents.cpp b/Cantera/src/thermo/Constituents.cpp index 28301a6db..36d48ab2f 100755 --- a/Cantera/src/thermo/Constituents.cpp +++ b/Cantera/src/thermo/Constituents.cpp @@ -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]; diff --git a/Cantera/src/thermo/SpeciesThermoFactory.cpp b/Cantera/src/thermo/SpeciesThermoFactory.cpp index 25279635e..abd22e950 100755 --- a/Cantera/src/thermo/SpeciesThermoFactory.cpp +++ b/Cantera/src/thermo/SpeciesThermoFactory.cpp @@ -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"], ""); } 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"); } } diff --git a/Cantera/src/thermo/WaterPDSS.cpp b/Cantera/src/thermo/WaterPDSS.cpp index 628d408b0..7c886848b 100644 --- a/Cantera/src/thermo/WaterPDSS.cpp +++ b/Cantera/src/thermo/WaterPDSS.cpp @@ -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; } diff --git a/Cantera/src/thermo/phasereport.cpp b/Cantera/src/thermo/phasereport.cpp index 8d746d0f7..a944313ac 100644 --- a/Cantera/src/thermo/phasereport.cpp +++ b/Cantera/src/thermo/phasereport.cpp @@ -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 {