[Thermo] make compositonMap a const argument

This commit is contained in:
Ray Speth 2014-04-08 16:26:20 +00:00
parent d2ff7dbaaa
commit 14ea7e64c6
10 changed files with 34 additions and 42 deletions

View file

@ -452,7 +452,7 @@ public:
* Mole numbers that are less than or equal to zero will be
* set to zero. units = kmol.
*/
void setMolesByName(compositionMap& xMap);
void setMolesByName(const compositionMap& xMap);
//! Set the moles via a string containing their names.
/*!

View file

@ -352,7 +352,7 @@ public:
*
* @param xMap Composition Map containing the molalities.
*/
void setMolalitiesByName(compositionMap& xMap);
void setMolalitiesByName(const compositionMap& xMap);
//! Set the molalities of a phase
/*!
@ -660,7 +660,7 @@ public:
* @param p Pressure (Pa)
* @param m compositionMap containing the molalities
*/
void setState_TPM(doublereal t, doublereal p, compositionMap& m);
void setState_TPM(doublereal t, doublereal p, const compositionMap& m);
//! Set the temperature (K), pressure (Pa), and molalities.
/*!

View file

@ -298,7 +298,7 @@ public:
//! Set the species mole fractions by name.
//! Species not listed by name in \c xMap are set to zero.
//! @param xMap map from species names to mole fraction values.
void setMoleFractionsByName(compositionMap& xMap);
void setMoleFractionsByName(const compositionMap& xMap);
//! Set the mole fractions of a group of species by name. Species which
//! are not listed by name in the composition map are set to zero.
@ -308,7 +308,7 @@ public:
//! Set the species mass fractions by name.
//! Species not listed by name in \c yMap are set to zero.
//! @param yMap map from species names to mass fraction values.
void setMassFractionsByName(compositionMap& yMap);
void setMassFractionsByName(const compositionMap& yMap);
//! Set the species mass fractions by name.
//! Species not listed by name in \c x are set to zero.
@ -327,7 +327,7 @@ public:
//! @param x Composition Map containing the mole fractions.
//! Species not included in the map are assumed to have
//! a zero mole fraction.
void setState_TRX(doublereal t, doublereal dens, compositionMap& x);
void setState_TRX(doublereal t, doublereal dens, const compositionMap& x);
//! Set the internally stored temperature (K), density, and mass fractions.
//! @param t Temperature in kelvin
@ -341,7 +341,7 @@ public:
//! @param y Composition Map containing the mass fractions.
//! Species not included in the map are assumed to have
//! a zero mass fraction.
void setState_TRY(doublereal t, doublereal dens, compositionMap& y);
void setState_TRY(doublereal t, doublereal dens, const compositionMap& y);
//! Set the internally stored temperature (K), molar density (kmol/m^3), and mole fractions.
//! @param t Temperature in kelvin

View file

@ -423,7 +423,7 @@ public:
* @param x String containing a composition map of the mole fractions. Species not in
* the composition map are assumed to have zero mole fraction
*/
void setState_TPX(doublereal t, doublereal p, compositionMap& x);
void setState_TPX(doublereal t, doublereal p, const compositionMap& x);
//! Set the temperature (K), pressure (Pa), and mole fractions.
/*!
@ -459,7 +459,7 @@ public:
* @param y Composition map of mass fractions. Species not in
* the composition map are assumed to have zero mass fraction
*/
void setState_TPY(doublereal t, doublereal p, compositionMap& y);
void setState_TPY(doublereal t, doublereal p, const compositionMap& y);
//! Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase
/*!

View file

@ -969,7 +969,7 @@ public:
* @param x Composition map of mole fractions. Species not in
* the composition map are assumed to have zero mole fraction
*/
virtual void setState_TPX(doublereal t, doublereal p, compositionMap& x);
virtual void setState_TPX(doublereal t, doublereal p, const compositionMap& x);
//! Set the temperature (K), pressure (Pa), and mole fractions.
/*!
@ -1005,7 +1005,7 @@ public:
* @param y Composition map of mass fractions. Species not in
* the composition map are assumed to have zero mass fraction
*/
virtual void setState_TPY(doublereal t, doublereal p, compositionMap& y);
virtual void setState_TPY(doublereal t, doublereal p, const compositionMap& y);
//! Set the internally stored temperature (K), pressure (Pa), and mass fractions of the phase
/*!

View file

@ -433,15 +433,14 @@ void MultiPhase::setPhaseMoleFractions(const size_t n, const doublereal* const x
}
}
void MultiPhase::setMolesByName(compositionMap& xMap)
void MultiPhase::setMolesByName(const compositionMap& xMap)
{
size_t kk = nSpecies();
doublereal x;
vector_fp moles(kk, 0.0);
for (size_t k = 0; k < kk; k++) {
x = xMap[speciesName(k)];
if (x > 0.0) {
moles[k] = x;
compositionMap::const_iterator iter = xMap.find(speciesName(k));
if (iter != xMap.end() && iter->second > 0.0) {
moles[k] = iter->second;
}
}
setMoles(DATA_PTR(moles));

View file

@ -178,7 +178,7 @@ void MolalityVPSSTP::setMolalities(const doublereal* const molal)
calcMolalities();
}
void MolalityVPSSTP::setMolalitiesByName(compositionMap& mMap)
void MolalityVPSSTP::setMolalitiesByName(const compositionMap& mMap)
{
/*
* HKM -> Might need to be more complicated here, setting
@ -186,7 +186,6 @@ void MolalityVPSSTP::setMolalitiesByName(compositionMap& mMap)
* preserved.
*/
size_t kk = nSpecies();
doublereal x;
/*
* Get a vector of mole fractions
*/
@ -194,14 +193,10 @@ void MolalityVPSSTP::setMolalitiesByName(compositionMap& mMap)
getMoleFractions(DATA_PTR(mf));
double xmolS = mf[m_indexSolvent];
double xmolSmin = std::max(xmolS, m_xmolSolventMIN);
compositionMap::iterator p;
for (size_t k = 0; k < kk; k++) {
p = mMap.find(speciesName(k));
if (p != mMap.end()) {
x = mMap[speciesName(k)];
if (x > 0.0) {
mf[k] = x * m_Mnaught * xmolSmin;
}
compositionMap::const_iterator iter = mMap.find(speciesName(k));
if (iter != mMap.end() && iter->second > 0.0) {
mf[k] = iter->second * m_Mnaught * xmolSmin;
}
}
/*
@ -403,7 +398,7 @@ void MolalityVPSSTP::setState_TPM(doublereal t, doublereal p,
setState_TP(t, p);
}
void MolalityVPSSTP::setState_TPM(doublereal t, doublereal p, compositionMap& m)
void MolalityVPSSTP::setState_TPM(doublereal t, doublereal p, const compositionMap& m)
{
setMolalitiesByName(m);
setState_TP(t, p);

View file

@ -344,15 +344,14 @@ void Phase::setMoleFractions_NoNorm(const doublereal* const x)
m_stateNum++;
}
void Phase::setMoleFractionsByName(compositionMap& xMap)
void Phase::setMoleFractionsByName(const compositionMap& xMap)
{
size_t kk = nSpecies();
doublereal x;
vector_fp mf(kk, 0.0);
for (size_t k = 0; k < kk; k++) {
x = xMap[speciesName(k)];
if (x > 0.0) {
mf[k] = x;
compositionMap::const_iterator iter = xMap.find(speciesName(k));
if (iter != xMap.end() && iter->second > 0.0) {
mf[k] = iter->second;
}
}
setMoleFractions(&mf[0]);
@ -389,15 +388,14 @@ void Phase::setMassFractions_NoNorm(const doublereal* const y)
m_stateNum++;
}
void Phase::setMassFractionsByName(compositionMap& yMap)
void Phase::setMassFractionsByName(const compositionMap& yMap)
{
size_t kk = nSpecies();
doublereal y;
vector_fp mf(kk, 0.0);
for (size_t k = 0; k < kk; k++) {
y = yMap[speciesName(k)];
if (y > 0.0) {
mf[k] = y;
compositionMap::const_iterator iter = yMap.find(speciesName(k));
if (iter != yMap.end() && iter->second > 0.0) {
mf[k] = iter->second;
}
}
setMassFractions(&mf[0]);
@ -423,7 +421,7 @@ void Phase::setState_TNX(doublereal t, doublereal n, const doublereal* x)
setMolarDensity(n);
}
void Phase::setState_TRX(doublereal t, doublereal dens, compositionMap& x)
void Phase::setState_TRX(doublereal t, doublereal dens, const compositionMap& x)
{
setMoleFractionsByName(x);
setTemperature(t);
@ -437,7 +435,7 @@ void Phase::setState_TRY(doublereal t, doublereal dens, const doublereal* y)
setDensity(dens);
}
void Phase::setState_TRY(doublereal t, doublereal dens, compositionMap& y)
void Phase::setState_TRY(doublereal t, doublereal dens, const compositionMap& y)
{
setMassFractionsByName(y);
setTemperature(t);

View file

@ -247,7 +247,7 @@ void SingleSpeciesTP::setState_TPX(doublereal t, doublereal p,
}
void SingleSpeciesTP::setState_TPX(doublereal t, doublereal p,
compositionMap& x)
const compositionMap& x)
{
setTemperature(t);
setPressure(p);
@ -268,7 +268,7 @@ void SingleSpeciesTP::setState_TPY(doublereal t, doublereal p,
}
void SingleSpeciesTP::setState_TPY(doublereal t, doublereal p,
compositionMap& y)
const compositionMap& y)
{
setTemperature(t);
setPressure(p);

View file

@ -139,7 +139,7 @@ void ThermoPhase::setState_TPX(doublereal t, doublereal p, const doublereal* x)
setState_TP(t,p);
}
void ThermoPhase::setState_TPX(doublereal t, doublereal p, compositionMap& x)
void ThermoPhase::setState_TPX(doublereal t, doublereal p, const compositionMap& x)
{
setMoleFractionsByName(x);
setState_TP(t,p);
@ -158,7 +158,7 @@ void ThermoPhase::setState_TPY(doublereal t, doublereal p, const doublereal* y)
setState_TP(t,p);
}
void ThermoPhase::setState_TPY(doublereal t, doublereal p, compositionMap& y)
void ThermoPhase::setState_TPY(doublereal t, doublereal p, const compositionMap& y)
{
setMassFractionsByName(y);
setState_TP(t,p);