Don't use a vector where a scalar will suffice

This commit is contained in:
Ray Speth 2016-04-18 15:36:23 -04:00
parent 336271c395
commit 9e9ae783f8
6 changed files with 20 additions and 29 deletions

View file

@ -263,11 +263,11 @@ protected:
doublereal m_p0;
//! Dimensionless enthalpy at the (mtlast, m_p0)
mutable vector_fp m_h0_RT;
mutable double m_h0_RT;
//! Dimensionless heat capacity at the (mtlast, m_p0)
mutable vector_fp m_cp0_R;
mutable double m_cp0_R;
//! Dimensionless entropy at the (mtlast, m_p0)
mutable vector_fp m_s0_R;
mutable double m_s0_R;
/**
* @internal This crucial internal routine calls the species thermo update

View file

@ -239,7 +239,7 @@ void FixedChemPotSSTP::initThermoXML(XML_Node& phaseNode, const std::string& id_
chemPot_ = val;
} else {
_updateThermo();
chemPot_ = (m_h0_RT[0] - m_s0_R[0]) * RT();
chemPot_ = (m_h0_RT - m_s0_R) * RT();
}
}

View file

@ -131,7 +131,7 @@ void MetalSHEelectrons::getGibbs_RT(doublereal* grt) const
void MetalSHEelectrons::getCp_R(doublereal* cpr) const
{
_updateThermo();
cpr[0] = m_cp0_R[0];
cpr[0] = m_cp0_R;
}
void MetalSHEelectrons::getIntEnergy_RT(doublereal* urt) const
{
@ -142,7 +142,7 @@ void MetalSHEelectrons::getIntEnergy_RT(doublereal* urt) const
void MetalSHEelectrons::getIntEnergy_RT_ref(doublereal* urt) const
{
_updateThermo();
urt[0] = m_h0_RT[0] - m_p0 / molarDensity() / RT();
urt[0] = m_h0_RT - m_p0 / molarDensity() / RT();
}
// ---- Initialization and Internal functions

View file

@ -133,19 +133,19 @@ void MineralEQ3::getEntropy_R(doublereal* sr) const
void MineralEQ3::getGibbs_RT(doublereal* grt) const
{
getEnthalpy_RT(grt);
grt[0] -= m_s0_R[0];
grt[0] -= m_s0_R;
}
void MineralEQ3::getCp_R(doublereal* cpr) const
{
_updateThermo();
cpr[0] = m_cp0_R[0];
cpr[0] = m_cp0_R;
}
void MineralEQ3::getIntEnergy_RT(doublereal* urt) const
{
_updateThermo();
urt[0] = m_h0_RT[0] - m_p0 / molarDensity() / RT();
urt[0] = m_h0_RT - m_p0 / molarDensity() / RT();
}
// ---- Thermodynamic Values for the Species Reference States ----
@ -153,7 +153,7 @@ void MineralEQ3::getIntEnergy_RT(doublereal* urt) const
void MineralEQ3::getIntEnergy_RT_ref(doublereal* urt) const
{
_updateThermo();
urt[0] = m_h0_RT[0] - m_p0 / molarDensity() / RT();
urt[0] = m_h0_RT - m_p0 / molarDensity() / RT();
}
// ---- Initialization and Internal functions

View file

@ -20,10 +20,7 @@ namespace Cantera
{
SingleSpeciesTP::SingleSpeciesTP() :
m_press(OneAtm),
m_p0(OneAtm),
m_h0_RT(1),
m_cp0_R(1),
m_s0_R(1)
m_p0(OneAtm)
{
}
@ -181,13 +178,13 @@ void SingleSpeciesTP::getStandardVolumes(doublereal* vbar) const
void SingleSpeciesTP::getEnthalpy_RT_ref(doublereal* hrt) const
{
_updateThermo();
hrt[0] = m_h0_RT[0];
hrt[0] = m_h0_RT;
}
void SingleSpeciesTP::getGibbs_RT_ref(doublereal* grt) const
{
_updateThermo();
grt[0] = m_h0_RT[0] - m_s0_R[0];
grt[0] = m_h0_RT - m_s0_R;
}
void SingleSpeciesTP::getGibbs_ref(doublereal* g) const
@ -199,13 +196,13 @@ void SingleSpeciesTP::getGibbs_ref(doublereal* g) const
void SingleSpeciesTP::getEntropy_R_ref(doublereal* er) const
{
_updateThermo();
er[0] = m_s0_R[0];
er[0] = m_s0_R;
}
void SingleSpeciesTP::getCp_R_ref(doublereal* cpr) const
{
_updateThermo();
cpr[0] = m_cp0_R[0];
cpr[0] = m_cp0_R;
}
// ------------------ Setting the State ------------------------
@ -297,7 +294,7 @@ void SingleSpeciesTP::_updateThermo() const
{
doublereal tnow = temperature();
if (m_tlast != tnow) {
m_spthermo->update(tnow, m_cp0_R.data(), m_h0_RT.data(), m_s0_R.data());
m_spthermo->update(tnow, &m_cp0_R, &m_h0_RT, &m_s0_R);
m_tlast = tnow;
}
}

View file

@ -120,19 +120,19 @@ void StoichSubstance::getEntropy_R(doublereal* sr) const
void StoichSubstance::getGibbs_RT(doublereal* grt) const
{
getEnthalpy_RT(grt);
grt[0] -= m_s0_R[0];
grt[0] -= m_s0_R;
}
void StoichSubstance::getCp_R(doublereal* cpr) const
{
_updateThermo();
cpr[0] = m_cp0_R[0];
cpr[0] = m_cp0_R;
}
void StoichSubstance::getIntEnergy_RT(doublereal* urt) const
{
_updateThermo();
urt[0] = m_h0_RT[0] - m_p0 / molarDensity() / RT();
urt[0] = m_h0_RT - m_p0 / molarDensity() / RT();
}
// ---- Thermodynamic Values for the Species Reference States ----
@ -140,7 +140,7 @@ void StoichSubstance::getIntEnergy_RT(doublereal* urt) const
void StoichSubstance::getIntEnergy_RT_ref(doublereal* urt) const
{
_updateThermo();
urt[0] = m_h0_RT[0] - m_p0 / molarDensity() / RT();
urt[0] = m_h0_RT - m_p0 / molarDensity() / RT();
}
// ---- Initialization and Internal functions
@ -156,12 +156,6 @@ void StoichSubstance::initThermo()
// Store the reference pressure in the variables for the class.
m_p0 = refPressure();
// Resize temporary arrays.
int leng = 1;
m_h0_RT.resize(leng);
m_cp0_R.resize(leng);
m_s0_R.resize(leng);
// Call the base class thermo initializer
SingleSpeciesTP::initThermo();
}