From 6e3812a82805ba22b2ceeda883f4562e8e5658cb Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 18 Apr 2016 17:52:08 -0400 Subject: [PATCH] [Thermo] Remove unnecessary temporary work vectors --- include/cantera/thermo/ConstDensityThermo.h | 3 --- include/cantera/thermo/DebyeHuckel.h | 3 --- include/cantera/thermo/GibbsExcessVPSSTP.h | 3 --- include/cantera/thermo/HMWSoln.h | 3 --- include/cantera/thermo/IdealMolalSoln.h | 3 --- .../cantera/thermo/IonsFromNeutralVPSSTP.h | 1 + src/thermo/ConstDensityThermo.cpp | 2 -- src/thermo/DebyeHuckel.cpp | 13 ++--------- src/thermo/GibbsExcessVPSSTP.cpp | 2 -- src/thermo/HMWSoln.cpp | 14 ++---------- src/thermo/IdealMolalSoln.cpp | 14 ++---------- src/thermo/IonsFromNeutralVPSSTP.cpp | 22 ++++++++++--------- 12 files changed, 19 insertions(+), 64 deletions(-) diff --git a/include/cantera/thermo/ConstDensityThermo.h b/include/cantera/thermo/ConstDensityThermo.h index 7088f8293..7c9f5537e 100644 --- a/include/cantera/thermo/ConstDensityThermo.h +++ b/include/cantera/thermo/ConstDensityThermo.h @@ -148,9 +148,6 @@ protected: //! Temporary storage for dimensionless reference state entropies mutable vector_fp m_s0_R; - //! Temporary array containing internally calculated partial pressures - mutable vector_fp m_pp; - //! Current pressure (Pa) doublereal m_press; diff --git a/include/cantera/thermo/DebyeHuckel.h b/include/cantera/thermo/DebyeHuckel.h index d133eedf7..f7cd57c5e 100644 --- a/include/cantera/thermo/DebyeHuckel.h +++ b/include/cantera/thermo/DebyeHuckel.h @@ -1114,9 +1114,6 @@ protected: //! Pointer to the water property calculator std::unique_ptr m_waterProps; - //! Temporary array used in equilibrium calculations - mutable vector_fp m_pp; - //! vector of size m_kk, used as a temporary holding area. mutable vector_fp m_tmpV; diff --git a/include/cantera/thermo/GibbsExcessVPSSTP.h b/include/cantera/thermo/GibbsExcessVPSSTP.h index 0519c6a23..ca0e68bed 100644 --- a/include/cantera/thermo/GibbsExcessVPSSTP.h +++ b/include/cantera/thermo/GibbsExcessVPSSTP.h @@ -277,9 +277,6 @@ protected: * number of species m */ mutable Array2D dlnActCoeffdlnN_; - - //! Temporary storage space that is fair game - mutable vector_fp m_pp; }; } diff --git a/include/cantera/thermo/HMWSoln.h b/include/cantera/thermo/HMWSoln.h index 0d899073f..1e9d3a3b2 100644 --- a/include/cantera/thermo/HMWSoln.h +++ b/include/cantera/thermo/HMWSoln.h @@ -1983,9 +1983,6 @@ private: //! Pointer to the water property calculator std::unique_ptr m_waterProps; - //! Temporary array used in equilibrium calculations - mutable vector_fp m_pp; - //! vector of size m_kk, used as a temporary holding area. mutable vector_fp m_tmpV; diff --git a/include/cantera/thermo/IdealMolalSoln.h b/include/cantera/thermo/IdealMolalSoln.h index 09da4e880..747cfd3bd 100644 --- a/include/cantera/thermo/IdealMolalSoln.h +++ b/include/cantera/thermo/IdealMolalSoln.h @@ -454,9 +454,6 @@ public: int IMS_typeCutoff_; private: - //! Temporary array used in equilibrium calculations - mutable vector_fp m_pp; - //! vector of size m_kk, used as a temporary holding area. mutable vector_fp m_tmpV; diff --git a/include/cantera/thermo/IonsFromNeutralVPSSTP.h b/include/cantera/thermo/IonsFromNeutralVPSSTP.h index 46e023034..f4bf2aad6 100644 --- a/include/cantera/thermo/IonsFromNeutralVPSSTP.h +++ b/include/cantera/thermo/IonsFromNeutralVPSSTP.h @@ -467,6 +467,7 @@ private: mutable vector_fp y_; mutable vector_fp dlnActCoeff_NeutralMolecule_; mutable vector_fp dX_NeutralMolecule_; + mutable vector_fp m_work; // length m_kk //! If true then we own the underlying neutral Molecule Phase /*! diff --git a/src/thermo/ConstDensityThermo.cpp b/src/thermo/ConstDensityThermo.cpp index 96d8a2aec..c7086da9a 100644 --- a/src/thermo/ConstDensityThermo.cpp +++ b/src/thermo/ConstDensityThermo.cpp @@ -28,7 +28,6 @@ ConstDensityThermo& ConstDensityThermo::operator=(const ConstDensityThermo& righ m_cp0_R = right.m_cp0_R; m_g0_RT = right.m_g0_RT; m_s0_R = right.m_s0_R; - m_pp = right.m_pp; return *this; @@ -117,7 +116,6 @@ bool ConstDensityThermo::addSpecies(shared_ptr spec) m_g0_RT.push_back(0.0); m_cp0_R.push_back(0.0); m_s0_R.push_back(0.0); - m_pp.push_back(0.0); } return added; } diff --git a/src/thermo/DebyeHuckel.cpp b/src/thermo/DebyeHuckel.cpp index 2e9eada3b..935ec46a0 100644 --- a/src/thermo/DebyeHuckel.cpp +++ b/src/thermo/DebyeHuckel.cpp @@ -121,7 +121,6 @@ DebyeHuckel& DebyeHuckel::operator=(const DebyeHuckel& b) m_waterProps.reset(new WaterProps(m_waterSS)); } - m_pp = b.m_pp; m_tmpV = b.m_tmpV; m_speciesCharge_Stoich= b.m_speciesCharge_Stoich; m_Beta_ij = b.m_Beta_ij; @@ -195,15 +194,8 @@ void DebyeHuckel::calcDensity() // this for all other species if they had pressure dependent properties. m_densWaterSS = m_waterSS->density(); } - double* vbar = &m_pp[0]; - getPartialMolarVolumes(vbar); - double* x = &m_tmpV[0]; - getMoleFractions(x); - doublereal vtotal = 0.0; - for (size_t i = 0; i < m_kk; i++) { - vtotal += vbar[i] * x[i]; - } - doublereal dd = meanMolecularWeight() / vtotal; + getPartialMolarVolumes(m_tmpV.data()); + double dd = meanMolecularWeight() / mean_X(m_tmpV); Phase::setDensity(dd); } @@ -939,7 +931,6 @@ bool DebyeHuckel::addSpecies(shared_ptr spec) m_d2lnActCoeffMolaldT2.push_back(0.0); m_dlnActCoeffMolaldP.push_back(0.0); m_B_Dot.push_back(0.0); - m_pp.push_back(0.0); m_tmpV.push_back(0.0); } return added; diff --git a/src/thermo/GibbsExcessVPSSTP.cpp b/src/thermo/GibbsExcessVPSSTP.cpp index 05cc09cf1..bee316091 100644 --- a/src/thermo/GibbsExcessVPSSTP.cpp +++ b/src/thermo/GibbsExcessVPSSTP.cpp @@ -42,7 +42,6 @@ GibbsExcessVPSSTP& GibbsExcessVPSSTP::operator=(const GibbsExcessVPSSTP& b) dlnActCoeffdlnX_diag_ = b.dlnActCoeffdlnX_diag_; dlnActCoeffdlnN_diag_ = b.dlnActCoeffdlnN_diag_; dlnActCoeffdlnN_ = b.dlnActCoeffdlnN_; - m_pp = b.m_pp; return *this; } @@ -148,7 +147,6 @@ bool GibbsExcessVPSSTP::addSpecies(shared_ptr spec) dlnActCoeffdlnX_diag_.push_back(0.0); dlnActCoeffdlnN_diag_.push_back(0.0); dlnActCoeffdlnN_.resize(m_kk, m_kk); - m_pp.push_back(0.0); } return added; } diff --git a/src/thermo/HMWSoln.cpp b/src/thermo/HMWSoln.cpp index 9e39f9279..e0e41dbba 100644 --- a/src/thermo/HMWSoln.cpp +++ b/src/thermo/HMWSoln.cpp @@ -239,7 +239,6 @@ HMWSoln& HMWSoln::operator=(const HMWSoln& b) m_waterProps.reset(new WaterProps(dynamic_cast(m_waterSS))); } - m_pp = b.m_pp; m_tmpV = b.m_tmpV; m_speciesCharge_Stoich= b.m_speciesCharge_Stoich; m_Beta0MX_ij = b.m_Beta0MX_ij; @@ -396,7 +395,6 @@ int HMWSoln::eosType() const doublereal HMWSoln::enthalpy_mole() const { getPartialMolarEnthalpies(m_tmpV.data()); - getMoleFractions(m_pp.data()); return mean_X(m_tmpV); } @@ -496,15 +494,8 @@ void HMWSoln::calcDensity() // Calculate all of the other standard volumes. Note these are constant for // now - double* vbar = &m_pp[0]; - getPartialMolarVolumes(vbar); - double* x = &m_tmpV[0]; - getMoleFractions(x); - doublereal vtotal = 0.0; - for (size_t i = 0; i < m_kk; i++) { - vtotal += vbar[i] * x[i]; - } - doublereal dd = meanMolecularWeight() / vtotal; + getPartialMolarVolumes(m_tmpV.data()); + double dd = meanMolecularWeight() / mean_X(m_tmpV); Phase::setDensity(dd); } @@ -864,7 +855,6 @@ void HMWSoln::initLengths() m_speciesSize.resize(m_kk); m_speciesCharge_Stoich.resize(m_kk, 0.0); m_Aionic.resize(m_kk, 0.0); - m_pp.resize(m_kk, 0.0); m_tmpV.resize(m_kk, 0.0); m_molalitiesCropped.resize(m_kk, 0.0); diff --git a/src/thermo/IdealMolalSoln.cpp b/src/thermo/IdealMolalSoln.cpp index 60e392c77..a488e122c 100644 --- a/src/thermo/IdealMolalSoln.cpp +++ b/src/thermo/IdealMolalSoln.cpp @@ -73,7 +73,6 @@ IdealMolalSoln& IdealMolalSoln::operator=(const IdealMolalSoln& b) IMS_egCut_ = b.IMS_egCut_; IMS_agCut_ = b.IMS_agCut_; IMS_bgCut_ = b.IMS_bgCut_; - m_pp = b.m_pp; m_tmpV = b.m_tmpV; IMS_lnActCoeffMolal_ = b.IMS_lnActCoeffMolal_; } @@ -133,7 +132,6 @@ ThermoPhase* IdealMolalSoln::duplMyselfAsThermoPhase() const doublereal IdealMolalSoln::enthalpy_mole() const { getPartialMolarEnthalpies(m_tmpV.data()); - getMoleFractions(m_pp.data()); return mean_X(m_tmpV); } @@ -165,15 +163,8 @@ doublereal IdealMolalSoln::cp_mole() const void IdealMolalSoln::calcDensity() { - double* vbar = &m_pp[0]; - getPartialMolarVolumes(vbar); - double* x = &m_tmpV[0]; - getMoleFractions(x); - doublereal vtotal = 0.0; - for (size_t i = 0; i < m_kk; i++) { - vtotal += vbar[i] * x[i]; - } - doublereal dd = meanMolecularWeight() / vtotal; + getPartialMolarVolumes(m_tmpV.data()); + doublereal dd = meanMolecularWeight() / mean_X(m_tmpV); Phase::setDensity(dd); } @@ -397,7 +388,6 @@ bool IdealMolalSoln::addSpecies(shared_ptr spec) { bool added = MolalityVPSSTP::addSpecies(spec); if (added) { - m_pp.push_back(0.0); m_speciesMolarVolume.push_back(0.0); m_tmpV.push_back(0.0); IMS_lnActCoeffMolal_.push_back(0.0); diff --git a/src/thermo/IonsFromNeutralVPSSTP.cpp b/src/thermo/IonsFromNeutralVPSSTP.cpp index acd7db67c..ff0342293 100644 --- a/src/thermo/IonsFromNeutralVPSSTP.cpp +++ b/src/thermo/IonsFromNeutralVPSSTP.cpp @@ -120,6 +120,7 @@ IonsFromNeutralVPSSTP::operator=(const IonsFromNeutralVPSSTP& b) y_ = b.y_; dlnActCoeff_NeutralMolecule_ = b.dlnActCoeff_NeutralMolecule_; dX_NeutralMolecule_ = b.dX_NeutralMolecule_; + m_work = b.m_work; IOwnNThermoPhase_ = b.IOwnNThermoPhase_; moleFractionsTmp_ = b.moleFractionsTmp_; muNeutralMolecule_ = b.muNeutralMolecule_; @@ -170,33 +171,33 @@ int IonsFromNeutralVPSSTP::eosType() const doublereal IonsFromNeutralVPSSTP::enthalpy_mole() const { - getPartialMolarEnthalpies(m_pp.data()); - return mean_X(m_pp); + getPartialMolarEnthalpies(m_work.data()); + return mean_X(m_work); } doublereal IonsFromNeutralVPSSTP::entropy_mole() const { - getPartialMolarEntropies(m_pp.data()); - return mean_X(m_pp); + getPartialMolarEntropies(m_work.data()); + return mean_X(m_work); } doublereal IonsFromNeutralVPSSTP::gibbs_mole() const { - getChemPotentials(m_pp.data()); - return mean_X(m_pp); + getChemPotentials(m_work.data()); + return mean_X(m_work); } doublereal IonsFromNeutralVPSSTP::cp_mole() const { - getPartialMolarCp(m_pp.data()); - return mean_X(m_pp); + getPartialMolarCp(m_work.data()); + return mean_X(m_work); } doublereal IonsFromNeutralVPSSTP::cv_mole() const { // Need to revisit this, as it is wrong - getPartialMolarCp(m_pp.data()); - return mean_X(m_pp); + getPartialMolarCp(m_work.data()); + return mean_X(m_work); } // -- Activities, Standard States, Activity Concentrations ----------- @@ -587,6 +588,7 @@ void IonsFromNeutralVPSSTP::initLengths() y_.resize(numNeutralMoleculeSpecies_, 0.0); dlnActCoeff_NeutralMolecule_.resize(numNeutralMoleculeSpecies_, 0.0); dX_NeutralMolecule_.resize(numNeutralMoleculeSpecies_, 0.0); + m_work.resize(m_kk); } //! Return the factor overlap