[Thermo] Check to make sure thermo data is installed for all species
This commit is contained in:
parent
89888e6697
commit
a8f4c76097
8 changed files with 44 additions and 1 deletions
|
|
@ -166,6 +166,7 @@ public:
|
|||
throw CanteraError("install()", "Species have different reference pressures");
|
||||
}
|
||||
m_p0 = refPressure_;
|
||||
markInstalled(index);
|
||||
}
|
||||
|
||||
virtual void install_STIT(SpeciesThermoInterpType* stit_ptr) {
|
||||
|
|
|
|||
|
|
@ -331,6 +331,15 @@ public:
|
|||
*/
|
||||
virtual void modifyOneHf298(const size_t k, const doublereal Hf298New) = 0;
|
||||
|
||||
//! Check if data for all species (0 through nSpecies-1) has been installed.
|
||||
bool ready(size_t nSpecies);
|
||||
|
||||
protected:
|
||||
//! Mark species *k* as having its thermodynamic data installed
|
||||
void markInstalled(size_t k);
|
||||
|
||||
private:
|
||||
std::vector<bool> m_installed; // indicates if data for species has been installed
|
||||
};
|
||||
//@}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,6 +174,7 @@ SpeciesThermoDuo<T1, T2>::install(const std::string& name, size_t sp, int type,
|
|||
} else {
|
||||
throw UnknownSpeciesThermo("SpeciesThermoDuo:install",type);
|
||||
}
|
||||
markInstalled(sp);
|
||||
}
|
||||
|
||||
template<class T1, class T2>
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ void GeneralSpeciesThermo::install(const std::string& name,
|
|||
}
|
||||
m_tlow_max = max(minTemp_, m_tlow_max);
|
||||
m_thigh_min = min(maxTemp_, m_thigh_min);
|
||||
markInstalled(index);
|
||||
}
|
||||
|
||||
void GeneralSpeciesThermo::install_STIT(SpeciesThermoInterpType* stit_ptr)
|
||||
|
|
@ -194,6 +195,7 @@ void GeneralSpeciesThermo::install_STIT(SpeciesThermoInterpType* stit_ptr)
|
|||
*/
|
||||
m_tlow_max = max(stit_ptr->minTemp(), m_tlow_max);
|
||||
m_thigh_min = min(stit_ptr->maxTemp(), m_thigh_min);
|
||||
markInstalled(index);
|
||||
}
|
||||
|
||||
void GeneralSpeciesThermo::installPDSShandler(size_t k, PDSS* PDSS_ptr,
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ void NasaThermo::install(const std::string& name, size_t index, int type,
|
|||
throw CanteraError("install()", "species have different reference pressures");
|
||||
}
|
||||
m_p0 = ref_pressure;
|
||||
markInstalled(index);
|
||||
}
|
||||
|
||||
void NasaThermo::update_one(size_t k, doublereal t, doublereal* cp_R,
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ public:
|
|||
throw CanteraError("install()", "Species have different reference pressures");
|
||||
}
|
||||
m_p0 = refPressure;
|
||||
|
||||
markInstalled(index);
|
||||
}
|
||||
|
||||
virtual void install_STIT(SpeciesThermoInterpType* stit_ptr) {
|
||||
|
|
|
|||
24
src/thermo/SpeciesThermo.cpp
Normal file
24
src/thermo/SpeciesThermo.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "cantera/thermo/SpeciesThermo.h"
|
||||
|
||||
namespace Cantera {
|
||||
|
||||
bool SpeciesThermo::ready(size_t nSpecies) {
|
||||
if (m_installed.size() < nSpecies) {
|
||||
return false;
|
||||
}
|
||||
for (size_t k = 0; k < nSpecies; k++) {
|
||||
if (!m_installed[k]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SpeciesThermo::markInstalled(size_t k) {
|
||||
if (k >= m_installed.size()) {
|
||||
m_installed.resize(k+1, false);
|
||||
}
|
||||
m_installed[k] = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -677,6 +677,11 @@ void ThermoPhase::initThermo()
|
|||
throw CanteraError("ThermoPhase::initThermo()",
|
||||
"Number of species is equal to zero");
|
||||
}
|
||||
// Check to see that all of the species thermo objects have been initialized
|
||||
if (!m_spthermo->ready(m_kk)) {
|
||||
throw CanteraError("ThermoPhase::initThermo()",
|
||||
"Missing species thermo data");
|
||||
}
|
||||
xMol_Ref.resize(m_kk, 0.0);
|
||||
}
|
||||
void ThermoPhase::installSlavePhases(Cantera::XML_Node* phaseNode)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue