From f6d19ccd599feb6a45e8178bd3e7ad2c8df90f0e Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 12 Nov 2015 15:04:45 -0500 Subject: [PATCH] [Thermo] Remove unnecessary overrides of VPStandardStateTP methods setPressure, setTemperature, and setState_TP are all implemented generally in VPStandardStateTP. The specialization in child classes is always handled in calcDensity(). --- include/cantera/thermo/DebyeHuckel.h | 31 ------------- include/cantera/thermo/GibbsExcessVPSSTP.h | 14 ------ include/cantera/thermo/HMWSoln.h | 33 ------------- include/cantera/thermo/IdealMolalSoln.h | 11 ----- .../cantera/thermo/IonsFromNeutralVPSSTP.h | 4 +- src/thermo/DebyeHuckel.cpp | 31 ------------- src/thermo/GibbsExcessVPSSTP.cpp | 20 -------- src/thermo/HMWSoln.cpp | 46 +++---------------- src/thermo/IdealMolalSoln.cpp | 13 ------ src/thermo/IonsFromNeutralVPSSTP.cpp | 15 +----- 10 files changed, 9 insertions(+), 209 deletions(-) diff --git a/include/cantera/thermo/DebyeHuckel.h b/include/cantera/thermo/DebyeHuckel.h index ed27df96e..37786204e 100644 --- a/include/cantera/thermo/DebyeHuckel.h +++ b/include/cantera/thermo/DebyeHuckel.h @@ -641,26 +641,6 @@ public: * cause an exception to be thrown. */ - //! Return the thermodynamic pressure (Pa). - /*! - * For this incompressible system, we return the internally stored - * independent value of the pressure. - */ - virtual doublereal pressure() const; - - //! Set the internally stored pressure (Pa) at constant temperature and - //! composition - /*! - * This method sets the pressure within the object. The water model is a - * completely compressible model. Also, the dielectric constant is pressure - * dependent. - * - * @param p input Pressure (Pa) - * - * @todo Implement a variable pressure capability - */ - virtual void setPressure(doublereal p); - protected: virtual void calcDensity(); @@ -699,17 +679,6 @@ public: */ virtual void setMolarDensity(const doublereal conc); - //! Set the temperature (K) - /*! - * This function sets the temperature, and makes sure that the value - * propagates to underlying objects, such as the water standard state model. - * - * @param temp Temperature in kelvin - */ - virtual void setTemperature(const doublereal temp); - - virtual void setState_TP(doublereal t, doublereal p); - /** * @} * @name Activities, Standard States, and Activity Concentrations diff --git a/include/cantera/thermo/GibbsExcessVPSSTP.h b/include/cantera/thermo/GibbsExcessVPSSTP.h index b277c5535..62a50e078 100644 --- a/include/cantera/thermo/GibbsExcessVPSSTP.h +++ b/include/cantera/thermo/GibbsExcessVPSSTP.h @@ -103,19 +103,6 @@ public: //! @name Mechanical Properties //! @{ - //! Set the internally stored pressure (Pa) at constant temperature and - //! composition - /*! - * This method sets the pressure within the object. The water model is a - * completely compressible model. Also, the dielectric constant is pressure - * dependent. - * - * @param p input Pressure (Pa) - * - * @todo Implement a variable pressure capability - */ - virtual void setPressure(doublereal p); - protected: /** * Calculate the density of the mixture using the partial molar volumes and @@ -252,7 +239,6 @@ public: * @{ */ - virtual void setState_TP(doublereal t, doublereal p); virtual void setMassFractions(const doublereal* const y); virtual void setMassFractions_NoNorm(const doublereal* const y); virtual void setMoleFractions(const doublereal* const x); diff --git a/include/cantera/thermo/HMWSoln.h b/include/cantera/thermo/HMWSoln.h index 1c65491d5..419d98b10 100644 --- a/include/cantera/thermo/HMWSoln.h +++ b/include/cantera/thermo/HMWSoln.h @@ -1305,26 +1305,6 @@ public: */ //!@{ - /** - * Pressure. Units: Pa. - * For this incompressible system, we return the internally stored - * independent value of the pressure. - */ - virtual doublereal pressure() const; - - //! Set the internally stored pressure (Pa) at constant temperature and - //! composition - /*! - * This method sets the pressure within the object. The water model is a - * completely compressible model. Also, the dielectric constant is pressure - * dependent. - * - * @param p input Pressure (Pa) - * - * @todo Implement a variable pressure capability - */ - virtual void setPressure(doublereal p); - protected: /** * Calculate the density of the mixture using the partial @@ -1350,8 +1330,6 @@ protected: void calcDensity(); public: - virtual doublereal density() const; - //! Set the internally stored density (kg/m^3) of the phase. /*! * Overwritten setDensity() function is necessary because the density is not @@ -1386,17 +1364,6 @@ public: */ void setMolarDensity(const doublereal conc); - //! Set the temperature (K) - /*! - * This function sets the temperature, and makes sure that the value - * propagates to underlying objects, such as the water standard state model. - * - * @param temp Temperature in kelvin - */ - virtual void setTemperature(const doublereal temp); - - virtual void setState_TP(doublereal t, doublereal p); - /** * @} * @name Activities, Standard States, and Activity Concentrations diff --git a/include/cantera/thermo/IdealMolalSoln.h b/include/cantera/thermo/IdealMolalSoln.h index 84da99417..96e383282 100644 --- a/include/cantera/thermo/IdealMolalSoln.h +++ b/include/cantera/thermo/IdealMolalSoln.h @@ -202,15 +202,6 @@ public: */ //@{ - /** - * Set the pressure at constant temperature. Units: Pa. This method sets a - * constant within the object. The mass density is not a function of - * pressure. - * - * @param p Input Pressure - */ - virtual void setPressure(doublereal p); - protected: /** * Calculate the density of the mixture using the partial molar volumes and @@ -257,8 +248,6 @@ public: */ void setMolarDensity(const doublereal rho); - virtual void setState_TP(doublereal t, doublereal p); - //! The isothermal compressibility. Units: 1/Pa. /*! * The isothermal compressibility is defined as diff --git a/include/cantera/thermo/IonsFromNeutralVPSSTP.h b/include/cantera/thermo/IonsFromNeutralVPSSTP.h index b83da4bd4..37d02cebf 100644 --- a/include/cantera/thermo/IonsFromNeutralVPSSTP.h +++ b/include/cantera/thermo/IonsFromNeutralVPSSTP.h @@ -296,9 +296,7 @@ public: * @{ */ - virtual void setTemperature(const doublereal t); - virtual void setPressure(doublereal p); - virtual void setState_TP(doublereal t, doublereal p); + virtual void calcDensity(); //! Calculate ion mole fractions from neutral molecule mole fractions. /*! diff --git a/src/thermo/DebyeHuckel.cpp b/src/thermo/DebyeHuckel.cpp index a187ce664..d595c20ee 100644 --- a/src/thermo/DebyeHuckel.cpp +++ b/src/thermo/DebyeHuckel.cpp @@ -195,32 +195,6 @@ doublereal DebyeHuckel::cv_mole() const // ------- Mechanical Equation of State Properties ------------------------ -doublereal DebyeHuckel::pressure() const -{ - return m_Pcurrent; -} - -void DebyeHuckel::setPressure(doublereal p) -{ - setState_TP(temperature(), p); -} - -void DebyeHuckel::setState_TP(doublereal t, doublereal p) -{ - Phase::setTemperature(t); - - // Store the current pressure - m_Pcurrent = p; - - // update the standard state thermo. This involves calling the water - // function and setting the pressure - _updateStandardStateThermo(); - - // Calculate all of the other standard volumes. Note these are constant for - // now - calcDensity(); -} - void DebyeHuckel::calcDensity() { if (m_waterSS) { @@ -258,11 +232,6 @@ void DebyeHuckel::setMolarDensity(const doublereal conc) } } -void DebyeHuckel::setTemperature(const doublereal temp) -{ - setState_TP(temp, m_Pcurrent); -} - // ------- Activities and Activity Concentrations void DebyeHuckel::getActivityConcentrations(doublereal* c) const diff --git a/src/thermo/GibbsExcessVPSSTP.cpp b/src/thermo/GibbsExcessVPSSTP.cpp index a789d4d0c..00fb20458 100644 --- a/src/thermo/GibbsExcessVPSSTP.cpp +++ b/src/thermo/GibbsExcessVPSSTP.cpp @@ -84,11 +84,6 @@ void GibbsExcessVPSSTP::setConcentrations(const doublereal* const c) // ------------ Mechanical Properties ------------------------------ -void GibbsExcessVPSSTP::setPressure(doublereal p) -{ - setState_TP(temperature(), p); -} - void GibbsExcessVPSSTP::calcDensity() { vector_fp vbar = getPartialMolarVolumesVector(); @@ -100,21 +95,6 @@ void GibbsExcessVPSSTP::calcDensity() Phase::setDensity(dd); } -void GibbsExcessVPSSTP::setState_TP(doublereal t, doublereal p) -{ - Phase::setTemperature(t); - - // Store the current pressure - m_Pcurrent = p; - - // update the standard state thermo. This involves calling the water - // function and setting the pressure - updateStandardStateThermo(); - - // Calculate the partial molar volumes, and then the density of the fluid - calcDensity(); -} - // - Activities, Standard States, Activity Concentrations ----------- void GibbsExcessVPSSTP::getActivityConcentrations(doublereal* c) const { diff --git a/src/thermo/HMWSoln.cpp b/src/thermo/HMWSoln.cpp index 43f8100b7..cfc8c0f49 100644 --- a/src/thermo/HMWSoln.cpp +++ b/src/thermo/HMWSoln.cpp @@ -482,16 +482,6 @@ doublereal HMWSoln::cv_mole() const // ------- Mechanical Equation of State Properties ------------------------ -doublereal HMWSoln::pressure() const -{ - return m_Pcurrent; -} - -void HMWSoln::setPressure(doublereal p) -{ - setState_TP(temperature(), p); -} - void HMWSoln::calcDensity() { static const int cacheId = m_cache.getId(); @@ -500,6 +490,12 @@ void HMWSoln::calcDensity() return; } + // Store the internal density of the water SS. Note, we would have to do + // this for all other species if they had pressure dependent properties. + m_densWaterSS = m_waterSS->density(); + + // 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]; @@ -512,11 +508,6 @@ void HMWSoln::calcDensity() Phase::setDensity(dd); } -double HMWSoln::density() const -{ - return Phase::density(); -} - void HMWSoln::setDensity(const doublereal rho) { double dens_old = density(); @@ -532,31 +523,6 @@ void HMWSoln::setMolarDensity(const doublereal rho) "Density is not an independent variable"); } -void HMWSoln::setTemperature(const doublereal temp) -{ - setState_TP(temp, m_Pcurrent); -} - -void HMWSoln::setState_TP(doublereal temp, doublereal pres) -{ - Phase::setTemperature(temp); - - // Store the current pressure - m_Pcurrent = pres; - - // update the standard state thermo. This involves calling the water - // function and setting the pressure - updateStandardStateThermo(); - - // Store the internal density of the water SS. Note, we would have to do - // this for all other species if they had pressure dependent properties. - m_densWaterSS = m_waterSS->density(); - - // Calculate all of the other standard volumes. Note these are constant for - // now - calcDensity(); -} - // ------- Activities and Activity Concentrations void HMWSoln::getActivityConcentrations(doublereal* c) const diff --git a/src/thermo/IdealMolalSoln.cpp b/src/thermo/IdealMolalSoln.cpp index faddfc1fa..b669d4fd7 100644 --- a/src/thermo/IdealMolalSoln.cpp +++ b/src/thermo/IdealMolalSoln.cpp @@ -168,11 +168,6 @@ doublereal IdealMolalSoln::cv_mole() const // ------- Mechanical Equation of State Properties ------------------------ -void IdealMolalSoln::setPressure(doublereal p) -{ - setState_TP(temperature(), p); -} - void IdealMolalSoln::calcDensity() { double* vbar = &m_pp[0]; @@ -213,14 +208,6 @@ void IdealMolalSoln::setMolarDensity(const doublereal conc) } } -void IdealMolalSoln::setState_TP(doublereal temp, doublereal pres) -{ - Phase::setTemperature(temp); - m_Pcurrent = pres; - updateStandardStateThermo(); - calcDensity(); -} - // ------- Activities and Activity Concentrations void IdealMolalSoln::getActivityConcentrations(doublereal* c) const diff --git a/src/thermo/IonsFromNeutralVPSSTP.cpp b/src/thermo/IonsFromNeutralVPSSTP.cpp index fee430caf..f9787c58f 100644 --- a/src/thermo/IonsFromNeutralVPSSTP.cpp +++ b/src/thermo/IonsFromNeutralVPSSTP.cpp @@ -406,22 +406,11 @@ void IonsFromNeutralVPSSTP::getdlnActCoeffdlnN(const size_t ld, doublereal* dlnA } } -void IonsFromNeutralVPSSTP::setTemperature(const doublereal temp) -{ - IonsFromNeutralVPSSTP::setState_TP(temp, pressure()); -} - -void IonsFromNeutralVPSSTP::setPressure(doublereal p) -{ - IonsFromNeutralVPSSTP::setState_TP(temperature(), p); -} - -void IonsFromNeutralVPSSTP::setState_TP(doublereal t, doublereal p) +void IonsFromNeutralVPSSTP::calcDensity() { // This is a two phase process. First, we calculate the standard states // within the neutral molecule phase. - neutralMoleculePhase_->setState_TP(t, p); - VPStandardStateTP::setState_TP(t,p); + neutralMoleculePhase_->setState_TP(temperature(), pressure()); // Calculate the partial molar volumes, and then the density of the fluid Phase::setDensity(neutralMoleculePhase_->density());