From 9e9ae783f8e82ad6382f999976bf6a67ee4bbdae Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 18 Apr 2016 15:36:23 -0400 Subject: [PATCH] Don't use a vector where a scalar will suffice --- include/cantera/thermo/SingleSpeciesTP.h | 6 +++--- src/thermo/FixedChemPotSSTP.cpp | 2 +- src/thermo/MetalSHEelectrons.cpp | 4 ++-- src/thermo/MineralEQ3.cpp | 8 ++++---- src/thermo/SingleSpeciesTP.cpp | 15 ++++++--------- src/thermo/StoichSubstance.cpp | 14 ++++---------- 6 files changed, 20 insertions(+), 29 deletions(-) diff --git a/include/cantera/thermo/SingleSpeciesTP.h b/include/cantera/thermo/SingleSpeciesTP.h index 758393044..ac7c07fa0 100644 --- a/include/cantera/thermo/SingleSpeciesTP.h +++ b/include/cantera/thermo/SingleSpeciesTP.h @@ -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 diff --git a/src/thermo/FixedChemPotSSTP.cpp b/src/thermo/FixedChemPotSSTP.cpp index a10583a9c..412e4b91f 100644 --- a/src/thermo/FixedChemPotSSTP.cpp +++ b/src/thermo/FixedChemPotSSTP.cpp @@ -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(); } } diff --git a/src/thermo/MetalSHEelectrons.cpp b/src/thermo/MetalSHEelectrons.cpp index 397b94297..2193818cd 100644 --- a/src/thermo/MetalSHEelectrons.cpp +++ b/src/thermo/MetalSHEelectrons.cpp @@ -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 diff --git a/src/thermo/MineralEQ3.cpp b/src/thermo/MineralEQ3.cpp index 7f0e063ff..156192cef 100644 --- a/src/thermo/MineralEQ3.cpp +++ b/src/thermo/MineralEQ3.cpp @@ -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 diff --git a/src/thermo/SingleSpeciesTP.cpp b/src/thermo/SingleSpeciesTP.cpp index a57f476bb..d9b1780b6 100644 --- a/src/thermo/SingleSpeciesTP.cpp +++ b/src/thermo/SingleSpeciesTP.cpp @@ -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; } } diff --git a/src/thermo/StoichSubstance.cpp b/src/thermo/StoichSubstance.cpp index a1c9f65b9..fbef58522 100644 --- a/src/thermo/StoichSubstance.cpp +++ b/src/thermo/StoichSubstance.cpp @@ -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(); }