From a704df09d86f68baa6fc3e84961b2f62a01e3514 Mon Sep 17 00:00:00 2001 From: Victor Brunini Date: Tue, 18 Mar 2014 18:52:29 +0000 Subject: [PATCH] Convert recent changes to new caching method. --- include/cantera/thermo/HMWSoln.h | 11 -- .../cantera/thermo/MaskellSolidSolnPhase.h | 8 - include/cantera/thermo/Phase.h | 45 ------ src/thermo/HMWSoln.cpp | 146 ++++++++---------- src/thermo/MaskellSolidSolnPhase.cpp | 49 +++--- src/thermo/Phase.cpp | 28 ---- 6 files changed, 87 insertions(+), 200 deletions(-) diff --git a/include/cantera/thermo/HMWSoln.h b/include/cantera/thermo/HMWSoln.h index 63108c22e..957dac037 100644 --- a/include/cantera/thermo/HMWSoln.h +++ b/include/cantera/thermo/HMWSoln.h @@ -1487,7 +1487,6 @@ protected: * member of the ThermoPhase base class. */ void calcDensity(); - mutable bool m_density_valid; public: //! Returns the current value of the density @@ -2363,9 +2362,6 @@ public: */ int m_form_A_Debye; -protected: - virtual void invalidateCachedDataOnStateChange(StateVariable changed_var); - private: /** * A_Debye -> this expression appears on the top of the @@ -2398,10 +2394,7 @@ private: * dw = C_0 * M_0 (density of water) (kg/m3) * = 1.0E3 at 25C */ - mutable bool m_A_Debye_valid; mutable double m_A_Debye; - mutable bool m_dA_DebyedP_TP_valid; - mutable double m_dA_DebyedP_TP; //! Water standard state calculator /*! @@ -3173,7 +3166,6 @@ private: * natural logarithm of the molality activity coefficients */ void s_update_lnMolalityActCoeff() const; - mutable bool m_s_update_lnMolalityActCoeff_valid; //! This function calculates the temperature derivative of the //! natural logarithm of the molality activity coefficients. @@ -3182,7 +3174,6 @@ private: * coefficient is on the molality scale. It's derivative is too. */ void s_update_dlnMolalityActCoeff_dT() const; - mutable bool m_s_update_dlnMolalityActCoeff_dT_valid; /** * This function calculates the temperature second derivative @@ -3190,7 +3181,6 @@ private: * coefficients. */ void s_update_d2lnMolalityActCoeff_dT2() const; - mutable bool m_s_update_d2lnMolalityActCoeff_dT2_valid; /** * This function calculates the pressure derivative of the @@ -3199,7 +3189,6 @@ private: * Assumes that the activity coefficients are current. */ void s_update_dlnMolalityActCoeff_dP() const; - mutable bool m_s_update_dlnMolalityActCoeff_dP_valid; //! This function will be called to update the internally stored //! natural logarithm of the molality activity coefficients diff --git a/include/cantera/thermo/MaskellSolidSolnPhase.h b/include/cantera/thermo/MaskellSolidSolnPhase.h index 9fe8600ec..1a7bbf38d 100644 --- a/include/cantera/thermo/MaskellSolidSolnPhase.h +++ b/include/cantera/thermo/MaskellSolidSolnPhase.h @@ -275,9 +275,6 @@ public: void set_h_mix(const doublereal hmix) { h_mixing = hmix; } -protected: - void invalidateCachedDataOnStateChange(StateVariable changed_var); - private: /** * Value of the reference pressure for all species in this phase. @@ -299,11 +296,6 @@ private: * m_cp0_R, m_g0_RT, m_s0_R. */ void _updateThermo() const; - mutable bool m_updateThermo_valid; - - //! Vector containing the last computed activity coefficients at T = m_tlast and r = last_r - mutable std::vector m_activity_coeffs; - mutable bool m_activity_coeffs_valid; //! Vector containing the species reference enthalpies at T = m_tlast mutable vector_fp m_h0_RT; diff --git a/include/cantera/thermo/Phase.h b/include/cantera/thermo/Phase.h index dddfa3752..736bb164b 100644 --- a/include/cantera/thermo/Phase.h +++ b/include/cantera/thermo/Phase.h @@ -552,14 +552,7 @@ public: throw CanteraError("Phase::setDensity()", "density must be positive"); } m_dens = density_; - if(density_ != m_last_dens) { - invalidateCachedDataOnStateChange(DENSITY); - m_last_dens = density_; - } } -private: - mutable doublereal m_last_dens; -public: //! Set the internally stored molar density (kmol/m^3) of the phase. //! @param[in] molarDensity Input molar density (kmol/m^3). @@ -573,15 +566,8 @@ public: "temperature must be positive"); } m_temp = temp; - if(temp != m_last_temp) { - invalidateCachedDataOnStateChange(TEMPERATURE); - m_last_temp = temp; - } } //@} -private: - mutable doublereal m_last_temp; -public: //! @name Mean Properties //!@{ @@ -705,35 +691,6 @@ public: } protected: - //! Virtual function to simplify caching of extensive computations in child classes. - /*! - * The intent is that this virtual function should be called any time a state variable - * of a ThermoPhase class is changed the class can mark any cached data that is expensive to - * compute as invalid. For example: - * class APhase : public Phase - * { - * public: - * void update_activity_coeffs(); // Expensive function that only needs to run on state change - * void update_activity_coeffs_dT(); // Another expensive function - * private: - * // Variables that track whether the state has been changed since the expensive functions - * // were last run to avoid unnecessary work. These will be updated to false by invalidateCachedDataOnStateChange() - * bool m_activity_coeffs_valid; - * bool m_activity_coeffs_dT_valid; - * } - * - * This is somewhat easier to manage than having each individual expensive function track the last T, P, X_i, etc - * that it was calculated at to determine whether it is safe to skip the expensive computation. - */ - enum StateVariable { - PRESSURE, - TEMPERATURE, - SPECIES, - DENSITY, - OTHER - }; - virtual void invalidateCachedDataOnStateChange(StateVariable changed_var) {} - mutable ValueCache m_cache; //! Set the molecular weight of a single species to a given value @@ -787,8 +744,6 @@ private: mutable vector_fp m_ym; mutable vector_fp m_y; //!< species mass fractions - mutable vector_fp m_last_y; - bool massFractionsChanged(); vector_fp m_molwts; //!< species molecular weights (kg kmol-1) diff --git a/src/thermo/HMWSoln.cpp b/src/thermo/HMWSoln.cpp index 7622881ab..5a863f1f1 100644 --- a/src/thermo/HMWSoln.cpp +++ b/src/thermo/HMWSoln.cpp @@ -30,7 +30,6 @@ namespace Cantera HMWSoln::HMWSoln() : MolalityVPSSTP(), - m_density_valid(false), m_formPitzer(PITZERFORM_BASE), m_formPitzerTemp(PITZER_TEMP_CONSTANT), m_formGC(2), @@ -39,10 +38,7 @@ HMWSoln::HMWSoln() : m_TempPitzerRef(298.15), m_IionicMolalityStoich(0.0), m_form_A_Debye(A_DEBYE_WATER), - m_A_Debye_valid(false), m_A_Debye(1.172576), // units = sqrt(kg/gmol) - m_dA_DebyedP_TP_valid(false), - m_dA_DebyedP_TP(-1.0), m_waterSS(0), m_densWaterSS(1000.), m_waterProps(0), @@ -74,10 +70,6 @@ HMWSoln::HMWSoln() : CROP_ln_gamma_o_max(3.0), CROP_ln_gamma_k_min(-5.0), CROP_ln_gamma_k_max(15.0), - m_s_update_lnMolalityActCoeff_valid(false), - m_s_update_dlnMolalityActCoeff_dT_valid(false), - m_s_update_d2lnMolalityActCoeff_dT2_valid(false), - m_s_update_dlnMolalityActCoeff_dP_valid(false), m_last_is(-1.0), m_debugCalc(0) { @@ -89,7 +81,6 @@ HMWSoln::HMWSoln() : HMWSoln::HMWSoln(const std::string& inputFile, const std::string& id_) : MolalityVPSSTP(), - m_density_valid(false), m_formPitzer(PITZERFORM_BASE), m_formPitzerTemp(PITZER_TEMP_CONSTANT), m_formGC(2), @@ -98,10 +89,7 @@ HMWSoln::HMWSoln(const std::string& inputFile, const std::string& id_) : m_TempPitzerRef(298.15), m_IionicMolalityStoich(0.0), m_form_A_Debye(A_DEBYE_WATER), - m_A_Debye_valid(false), m_A_Debye(1.172576), // units = sqrt(kg/gmol) - m_dA_DebyedP_TP_valid(false), - m_dA_DebyedP_TP(-1.0), m_waterSS(0), m_densWaterSS(1000.), m_waterProps(0), @@ -133,10 +121,6 @@ HMWSoln::HMWSoln(const std::string& inputFile, const std::string& id_) : CROP_ln_gamma_o_max(3.0), CROP_ln_gamma_k_min(-5.0), CROP_ln_gamma_k_max(15.0), - m_s_update_lnMolalityActCoeff_valid(false), - m_s_update_dlnMolalityActCoeff_dT_valid(false), - m_s_update_d2lnMolalityActCoeff_dT2_valid(false), - m_s_update_dlnMolalityActCoeff_dP_valid(false), m_last_is(-1.0), m_debugCalc(0) { @@ -149,7 +133,6 @@ HMWSoln::HMWSoln(const std::string& inputFile, const std::string& id_) : HMWSoln::HMWSoln(XML_Node& phaseRoot, const std::string& id_) : MolalityVPSSTP(), - m_density_valid(false), m_formPitzer(PITZERFORM_BASE), m_formPitzerTemp(PITZER_TEMP_CONSTANT), m_formGC(2), @@ -158,10 +141,7 @@ HMWSoln::HMWSoln(XML_Node& phaseRoot, const std::string& id_) : m_TempPitzerRef(298.15), m_IionicMolalityStoich(0.0), m_form_A_Debye(A_DEBYE_WATER), - m_A_Debye_valid(false), m_A_Debye(1.172576), // units = sqrt(kg/gmol) - m_dA_DebyedP_TP_valid(false), - m_dA_DebyedP_TP(-1.0), m_waterSS(0), m_densWaterSS(1000.), m_waterProps(0), @@ -193,10 +173,6 @@ HMWSoln::HMWSoln(XML_Node& phaseRoot, const std::string& id_) : CROP_ln_gamma_o_max(3.0), CROP_ln_gamma_k_min(-5.0), CROP_ln_gamma_k_max(15.0), - m_s_update_lnMolalityActCoeff_valid(false), - m_s_update_dlnMolalityActCoeff_dT_valid(false), - m_s_update_d2lnMolalityActCoeff_dT2_valid(false), - m_s_update_dlnMolalityActCoeff_dP_valid(false), m_last_is(-1.0), m_debugCalc(0) { @@ -209,7 +185,6 @@ HMWSoln::HMWSoln(XML_Node& phaseRoot, const std::string& id_) : HMWSoln::HMWSoln(const HMWSoln& b) : MolalityVPSSTP(), - m_density_valid(false), m_formPitzer(PITZERFORM_BASE), m_formPitzerTemp(PITZER_TEMP_CONSTANT), m_formGC(2), @@ -218,10 +193,7 @@ HMWSoln::HMWSoln(const HMWSoln& b) : m_TempPitzerRef(298.15), m_IionicMolalityStoich(0.0), m_form_A_Debye(A_DEBYE_WATER), - m_A_Debye_valid(false), m_A_Debye(1.172576), // units = sqrt(kg/gmol) - m_dA_DebyedP_TP_valid(false), - m_dA_DebyedP_TP(-1.0), m_waterSS(0), m_densWaterSS(1000.), m_waterProps(0), @@ -253,10 +225,6 @@ HMWSoln::HMWSoln(const HMWSoln& b) : CROP_ln_gamma_o_max(3.0), CROP_ln_gamma_k_min(-5.0), CROP_ln_gamma_k_max(15.0), - m_s_update_lnMolalityActCoeff_valid(false), - m_s_update_dlnMolalityActCoeff_dT_valid(false), - m_s_update_d2lnMolalityActCoeff_dT2_valid(false), - m_s_update_dlnMolalityActCoeff_dP_valid(false), m_last_is(-1.0), m_debugCalc(0) { @@ -428,7 +396,6 @@ operator=(const HMWSoln& b) HMWSoln::HMWSoln(int testProb) : MolalityVPSSTP(), - m_density_valid(false), m_formPitzer(PITZERFORM_BASE), m_formPitzerTemp(PITZER_TEMP_CONSTANT), m_formGC(2), @@ -437,10 +404,7 @@ HMWSoln::HMWSoln(int testProb) : m_TempPitzerRef(298.15), m_IionicMolalityStoich(0.0), m_form_A_Debye(A_DEBYE_WATER), - m_A_Debye_valid(false), m_A_Debye(1.172576), // units = sqrt(kg/gmol) - m_dA_DebyedP_TP_valid(false), - m_dA_DebyedP_TP(-1.0), m_waterSS(0), m_densWaterSS(1000.), m_waterProps(0), @@ -472,10 +436,6 @@ HMWSoln::HMWSoln(int testProb) : CROP_ln_gamma_o_max(3.0), CROP_ln_gamma_k_min(-5.0), CROP_ln_gamma_k_max(15.0), - m_s_update_lnMolalityActCoeff_valid(false), - m_s_update_dlnMolalityActCoeff_dT_valid(false), - m_s_update_d2lnMolalityActCoeff_dT2_valid(false), - m_s_update_dlnMolalityActCoeff_dP_valid(false), m_last_is(-1.0), m_debugCalc(0) { @@ -721,10 +681,18 @@ void HMWSoln::setPressure(doublereal p) void HMWSoln::calcDensity() { - if( m_density_valid ) { + static const int cacheId = m_cache.getId(); + CachedScalar cached = m_cache.getScalar(cacheId); + const doublereal tnow = temperature(); + const doublereal pnow = pressure(); + const int stateNumNow = stateMFNumber(); + if( cached.state1 == tnow && cached.state2 == pnow && cached.stateNum == stateNumNow ) { return; } - m_density_valid = true; + cached.state1 = tnow; + cached.state2 = pnow; + cached.stateNum = stateNumNow; + double* vbar = &m_pp[0]; getPartialMolarVolumes(vbar); double* x = &m_tmpV[0]; @@ -784,10 +752,7 @@ void HMWSoln::setState_TP(doublereal temp, doublereal pres) /* * Store the current pressure */ - if(m_Pcurrent != pres) { - m_Pcurrent = pres; - invalidateCachedDataOnStateChange(PRESSURE); - } + m_Pcurrent = pres; /* * update the standard state thermo @@ -1074,11 +1039,6 @@ doublereal HMWSoln::satPressure(doublereal t) { double HMWSoln::A_Debye_TP(double tempArg, double presArg) const { - if(m_A_Debye_valid) { - return m_A_Debye; - } - m_A_Debye_valid = true; - double T = temperature(); double A; if (tempArg != -1.0) { @@ -1089,6 +1049,14 @@ double HMWSoln::A_Debye_TP(double tempArg, double presArg) const P = presArg; } + static const int cacheId = m_cache.getId(); + CachedScalar cached = m_cache.getScalar(cacheId); + if(cached.state1 == T && cached.state2 == P) { + return m_A_Debye; + } + cached.state1 = T; + cached.state2 = P; + switch (m_form_A_Debye) { case A_DEBYE_CONST: A = m_A_Debye; @@ -1140,18 +1108,22 @@ double HMWSoln::dA_DebyedP_TP(double tempArg, double presArg) const if (presArg != -1.0) { P = presArg; } + double dAdP; + static const int cacheId = m_cache.getId(); + CachedScalar cached = m_cache.getScalar(cacheId); switch (m_form_A_Debye) { case A_DEBYE_CONST: dAdP = 0.0; break; case A_DEBYE_WATER: - if(!m_dA_DebyedP_TP_valid) { - dAdP = m_waterProps->ADebye(T, P, 3); - m_dA_DebyedP_TP = dAdP; - m_dA_DebyedP_TP_valid = true; + if( cached.state1 == T && cached.state2 == P ) { + dAdP = cached.value; } else { - dAdP = m_dA_DebyedP_TP; + cached.state1 = T; + cached.state2 = P; + dAdP = m_waterProps->ADebye(T, P, 3); + cached.value = dAdP; } break; default: @@ -1372,10 +1344,16 @@ void HMWSoln::initLengths() void HMWSoln::s_update_lnMolalityActCoeff() const { - if(m_s_update_lnMolalityActCoeff_valid) { - return; + static const int cacheId = m_cache.getId(); + CachedScalar cached = m_cache.getScalar(cacheId); + const doublereal tnow = temperature(); + const doublereal pnow = pressure(); + const int stateNumNow = stateMFNumber(); + if( cached.state1 == tnow && cached.state2 == pnow && cached.stateNum == stateNumNow ) { + return; } - m_s_update_lnMolalityActCoeff_valid = true; + cached.state1 = tnow; + cached.state2 = pnow; /* * Calculate the molalities. Currently, the molalities @@ -2957,10 +2935,16 @@ s_updatePitzer_lnMolalityActCoeff() const void HMWSoln::s_update_dlnMolalityActCoeff_dT() const { - if(m_s_update_dlnMolalityActCoeff_dT_valid) { - return; + static const int cacheId = m_cache.getId(); + CachedScalar cached = m_cache.getScalar(cacheId); + const doublereal tnow = temperature(); + const doublereal pnow = pressure(); + const int stateNumNow = stateMFNumber(); + if( cached.state1 == tnow && cached.state2 == pnow && cached.stateNum == stateNumNow ) { + return; } - m_s_update_dlnMolalityActCoeff_dT_valid = true; + cached.state1 = tnow; + cached.state2 = pnow; /* * Zero the unscaled 2nd derivatives @@ -3811,10 +3795,16 @@ void HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dT() const void HMWSoln::s_update_d2lnMolalityActCoeff_dT2() const { - if(m_s_update_d2lnMolalityActCoeff_dT2_valid) { - return; + static const int cacheId = m_cache.getId(); + CachedScalar cached = m_cache.getScalar(cacheId); + const doublereal tnow = temperature(); + const doublereal pnow = pressure(); + const int stateNumNow = stateMFNumber(); + if( cached.state1 == tnow && cached.state2 == pnow && cached.stateNum == stateNumNow ) { + return; } - m_s_update_d2lnMolalityActCoeff_dT2_valid = true; + cached.state1 = tnow; + cached.state2 = pnow; /* * Zero the unscaled 2nd derivatives @@ -4670,10 +4660,16 @@ void HMWSoln::s_updatePitzer_d2lnMolalityActCoeff_dT2() const void HMWSoln::s_update_dlnMolalityActCoeff_dP() const { - if(m_s_update_dlnMolalityActCoeff_dP_valid) { - return; + static const int cacheId = m_cache.getId(); + CachedScalar cached = m_cache.getScalar(cacheId); + const doublereal tnow = temperature(); + const doublereal pnow = pressure(); + const int stateNumNow = stateMFNumber(); + if( cached.state1 == tnow && cached.state2 == pnow && cached.stateNum == stateNumNow ) { + return; } - m_s_update_dlnMolalityActCoeff_dP_valid = true; + cached.state1 = tnow; + cached.state2 = pnow; m_dlnActCoeffMolaldP_Unscaled.assign(m_kk, 0.0); s_updatePitzer_dlnMolalityActCoeff_dP(); @@ -5891,20 +5887,6 @@ doublereal HMWSoln::s_NBS_CLM_dlnMolalityActCoeff_dP() const return - dAdP * sqrtIs /(1.0 + 1.5 * sqrtIs); } -void HMWSoln::invalidateCachedDataOnStateChange(StateVariable changed_var) -{ - if( changed_var == PRESSURE || changed_var == TEMPERATURE ) { - m_A_Debye_valid = false; - m_dA_DebyedP_TP_valid = false; - } - m_density_valid = false; - m_s_update_lnMolalityActCoeff_valid = false; - m_s_update_dlnMolalityActCoeff_dT_valid = false; - m_s_update_d2lnMolalityActCoeff_dT2_valid = false; - m_s_update_dlnMolalityActCoeff_dP_valid = false; - MolalityVPSSTP::invalidateCachedDataOnStateChange(changed_var); -} - int HMWSoln::debugPrinting() { #ifdef DEBUG_MODE diff --git a/src/thermo/MaskellSolidSolnPhase.cpp b/src/thermo/MaskellSolidSolnPhase.cpp index 32d5fd8f1..176458af7 100644 --- a/src/thermo/MaskellSolidSolnPhase.cpp +++ b/src/thermo/MaskellSolidSolnPhase.cpp @@ -23,9 +23,6 @@ namespace Cantera MaskellSolidSolnPhase::MaskellSolidSolnPhase() : m_Pref(OneAtm), m_Pcurrent(OneAtm), - m_updateThermo_valid(false), - m_activity_coeffs(2), - m_activity_coeffs_valid(false), m_h0_RT(2), m_cp0_R(2), m_g0_RT(2), @@ -39,9 +36,6 @@ MaskellSolidSolnPhase::MaskellSolidSolnPhase() : MaskellSolidSolnPhase::MaskellSolidSolnPhase(const MaskellSolidSolnPhase& b) : m_Pref(OneAtm), m_Pcurrent(OneAtm), - m_updateThermo_valid(false), - m_activity_coeffs(2), - m_activity_coeffs_valid(false), m_h0_RT(2), m_cp0_R(2), m_g0_RT(2), @@ -160,8 +154,17 @@ void MaskellSolidSolnPhase:: getActivityCoefficients(doublereal* ac) const { _updateThermo(); - if( !m_activity_coeffs_valid ) { - m_activity_coeffs_valid = true; + static const int cacheId = m_cache.getId(); + CachedArray cached = m_cache.getArray(cacheId); + const doublereal tnow = temperature(); + const doublereal pnow = pressure(); + const int stateNumNow = stateMFNumber(); + if( cached.state1 != temperature() || cached.state2 != pressure() || cached.stateNum != stateNumNow ) { + cached.state1 = tnow; + cached.state2 = pnow; + cached.stateNum = stateNumNow; + cached.value.resize(2); + const doublereal r = moleFraction(product_species_index); const doublereal pval = p(r); const doublereal fmval = fm(r); @@ -170,10 +173,10 @@ getActivityCoefficients(doublereal* ac) const const doublereal A = (std::pow(1 - rfm, pval) * std::pow(rfm, pval) * std::pow(r - rfm, 1 - pval)) / (std::pow(1 - r - rfm, 1 + pval) * (1 - r)); const doublereal B = pval * h_mixing / RT; - m_activity_coeffs[product_species_index] = A * std::exp(B); - m_activity_coeffs[reactant_species_index] = 1 / (A * r * (1-r) ) * std::exp(-B); + cached.value[product_species_index] = A * std::exp(B); + cached.value[reactant_species_index] = 1 / (A * r * (1-r) ) * std::exp(-B); } - std::copy(m_activity_coeffs.begin(), m_activity_coeffs.end(), ac); + std::copy(cached.value.begin(), cached.value.end(), ac); } void MaskellSolidSolnPhase:: @@ -327,19 +330,20 @@ void MaskellSolidSolnPhase::initThermoXML(XML_Node& phaseNode, const std::string void MaskellSolidSolnPhase::_updateThermo() const { assert(m_kk == 2); - if (!m_updateThermo_valid) { - m_updateThermo_valid = true; - /* - * Update the thermodynamic functions of the reference state. - */ - doublereal tnow = temperature(); + static const int cacheId = m_cache.getId(); + CachedScalar cached = m_cache.getScalar(cacheId); + /* + * Update the thermodynamic functions of the reference state. + */ + doublereal tnow = temperature(); + if( cached.state1 != tnow ) + { + cached.state1 = tnow; m_spthermo->update(tnow, DATA_PTR(m_cp0_R), DATA_PTR(m_h0_RT), DATA_PTR(m_s0_R)); - m_tlast = tnow; for (size_t k = 0; k < m_kk; k++) { m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k]; } - m_tlast = tnow; } } @@ -360,11 +364,4 @@ doublereal MaskellSolidSolnPhase::p(const doublereal r) const return (1 - 2*r) / std::sqrt(sval*sval - 4 * sval * r + 4 * sval * r * r); } -void MaskellSolidSolnPhase::invalidateCachedDataOnStateChange(StateVariable changed_var) -{ - m_updateThermo_valid = false; - m_activity_coeffs_valid = false; - VPStandardStateTP::invalidateCachedDataOnStateChange(changed_var); -} - } // end namespace Cantera diff --git a/src/thermo/Phase.cpp b/src/thermo/Phase.cpp index 627f7443c..ae77b5dbc 100644 --- a/src/thermo/Phase.cpp +++ b/src/thermo/Phase.cpp @@ -332,9 +332,6 @@ void Phase::setMoleFractions(const doublereal* const x) */ m_mmw = sum/norm; m_stateNum++; - if(massFractionsChanged()) { - invalidateCachedDataOnStateChange(SPECIES); - } } void Phase::setMoleFractions_NoNorm(const doublereal* const x) @@ -345,9 +342,6 @@ void Phase::setMoleFractions_NoNorm(const doublereal* const x) transform(m_ym.begin(), m_ym.begin() + m_kk, m_molwts.begin(), m_y.begin(), multiplies()); m_stateNum++; - if(massFractionsChanged()) { - invalidateCachedDataOnStateChange(SPECIES); - } } void Phase::setMoleFractionsByName(compositionMap& xMap) @@ -382,9 +376,6 @@ void Phase::setMassFractions(const doublereal* const y) m_ym.begin(), multiplies()); m_mmw = 1.0 / accumulate(m_ym.begin(), m_ym.end(), 0.0); m_stateNum++; - if(massFractionsChanged()) { - invalidateCachedDataOnStateChange(SPECIES); - } } void Phase::setMassFractions_NoNorm(const doublereal* const y) @@ -396,9 +387,6 @@ void Phase::setMassFractions_NoNorm(const doublereal* const y) sum = accumulate(m_ym.begin(), m_ym.end(), 0.0); m_mmw = 1.0/sum; m_stateNum++; - if( massFractionsChanged() ) { - invalidateCachedDataOnStateChange(SPECIES); - } } void Phase::setMassFractionsByName(compositionMap& yMap) @@ -421,22 +409,6 @@ void Phase::setMassFractionsByName(const std::string& y) setMassFractionsByName(c); } -bool Phase::massFractionsChanged() -{ - if(m_last_y.size() != m_kk) { - m_last_y.resize(m_kk); - std::fill(m_last_y.begin(), m_last_y.end(), -1.0); - } - - bool result = false; - for(size_t k=0; k < m_kk; ++k) { - if(m_y[k] != m_last_y[k]) { - result = true; - } - } - return result; -} - void Phase::setState_TRX(doublereal t, doublereal dens, const doublereal* x) { setMoleFractions(x);