added a setState_TPMoles() function that updates everything at once.

This commit is contained in:
Harry Moffat 2008-12-04 02:13:12 +00:00
parent dad3088736
commit 59d975920b
2 changed files with 18 additions and 2 deletions

View file

@ -426,7 +426,7 @@ namespace Cantera {
/// Set the species moles to the values in array \a n. The state
/// of each phase object is also updated to have the specified
/// composition and the mixture temperature and pressure.
void MultiPhase::setMoles(doublereal* n) {
void MultiPhase::setMoles(const doublereal* n) {
if (!m_init) init();
index_t ip, loc = 0;
index_t ik, k = 0, nsp;
@ -455,6 +455,13 @@ namespace Cantera {
}
}
void MultiPhase::setState_TPMoles(const doublereal T, const doublereal Pres,
const doublereal *n) {
m_temp = T;
m_press = Pres;
setMoles(n);
}
void MultiPhase::getElemAbundances(doublereal *elemAbundances) const {
index_t eGlobal;
calcElemAbundances();

View file

@ -319,6 +319,15 @@ namespace Cantera {
*/
void setTemperature(const doublereal T);
//! Set the state of the underlying ThermoPhase objects in one call
/*!
* @param T Temperature of the system (kelvin)
* @param Pres pressure of the system (pascal)
* @param Moles Vector of mole numbers of all the species in all the phases
* (kmol)
*/
void setState_TPMoles(const doublereal T, const doublereal Pres, const doublereal *Moles);
/// Pressure [Pa].
doublereal pressure() const {
return m_press;
@ -437,7 +446,7 @@ namespace Cantera {
* containing the global mole numbers
* (kmol).
*/
void setMoles(doublereal* n);
void setMoles(const doublereal* n);
//! Retrieves a vector of element abundances
/*!