From 50ed3f2e7265baf3ae65629ba67edfa68e199f11 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sun, 12 Feb 2017 09:54:07 -0500 Subject: [PATCH] [Thermo] PDSS objects store their own data --- include/cantera/thermo/MultiSpeciesThermo.h | 13 +++ include/cantera/thermo/PDSS.h | 90 ++++----------------- include/cantera/thermo/PDSS_SSVol.h | 2 +- include/cantera/thermo/VPSSMgr.h | 70 ---------------- src/thermo/MultiSpeciesThermo.cpp | 11 +++ src/thermo/PDSS.cpp | 55 ++++--------- src/thermo/PDSS_ConstVol.cpp | 49 ++++++----- src/thermo/PDSS_IdealGas.cpp | 39 +++++---- src/thermo/PDSS_IonsFromNeutral.cpp | 2 +- src/thermo/PDSS_SSVol.cpp | 76 ++++++++--------- src/thermo/PureFluidPhase.cpp | 2 +- src/thermo/VPSSMgr.cpp | 12 --- 12 files changed, 138 insertions(+), 283 deletions(-) diff --git a/include/cantera/thermo/MultiSpeciesThermo.h b/include/cantera/thermo/MultiSpeciesThermo.h index 73e74efc0..536aed2ad 100644 --- a/include/cantera/thermo/MultiSpeciesThermo.h +++ b/include/cantera/thermo/MultiSpeciesThermo.h @@ -90,11 +90,24 @@ public: * @param cp_R Vector of Dimensionless heat capacities. (length m_kk). * @param h_RT Vector of Dimensionless enthalpies. (length m_kk). * @param s_R Vector of Dimensionless entropies. (length m_kk). + * @deprecated Use update_single() instead. + * To be removed after Cantera 2.4. */ virtual void update_one(size_t k, doublereal T, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const; + //! Like update_one, but without applying offsets to the output pointers + /*! + * @param k species index + * @param T Temperature (Kelvin) + * @param cp_R Dimensionless heat capacity + * @param h_RT Dimensionless enthalpy + * @param s_R Dimensionless entropy + */ + virtual void update_single(size_t k, double T, double* cp_R, + double* h_RT, double* s_R) const; + //! Compute the reference-state properties for all species. /*! * Given temperature T in K, this method updates the values of the non- diff --git a/include/cantera/thermo/PDSS.h b/include/cantera/thermo/PDSS.h index e369471af..1b9f722e0 100644 --- a/include/cantera/thermo/PDSS.h +++ b/include/cantera/thermo/PDSS.h @@ -484,13 +484,6 @@ public: doublereal& minTemp, doublereal& maxTemp, doublereal& refPressure) const; -private: - //! Initialize all of the internal shallow pointers that can be initialized - /*! - * This routine isn't virtual. It's only applicable for the current class - */ - void initPtrs(); - //@} protected: @@ -534,75 +527,6 @@ protected: * zero. */ MultiSpeciesThermo* m_spthermo; - - //! Reference state enthalpy divided by RT. - /*! - * Storage for the thermo properties is provided by VPSSMgr. This object - * owns a shallow pointer. Calculated at the current value of T and m_p0 - */ - doublereal* m_h0_RT_ptr; - - //! Reference state heat capacity divided by R. - /*! - * Storage for the thermo properties is provided by VPSSMgr. Calculated - * at the current value of T and m_p0 - */ - doublereal* m_cp0_R_ptr; - - //! Reference state entropy divided by R. - /*! - * Storage for the thermo properties is provided by VPSSMgr. Calculated - * at the current value of T and m_p0 - */ - doublereal* m_s0_R_ptr; - - //! Reference state Gibbs free energy divided by RT. - /*! - * Calculated at the current value of T and m_p0 - */ - doublereal* m_g0_RT_ptr; - - //! Reference state molar volume (m3 kg-1) - /*! - * Storage for the thermo properties is provided by VPSSMgr. Calculated - * at the current value of T and m_p0 - */ - doublereal* m_V0_ptr; - - //! Standard state enthalpy divided by RT. - /*! - * Storage for the thermo properties is provided by VPSSMgr. Calculated - * at the current value of T and P. - */ - doublereal* m_hss_RT_ptr; - - //! Standard state heat capacity divided by R. - /*! - * Storage for the thermo properties is provided by VPSSMgr. Calculated - * at the current value of T and P. - */ - doublereal* m_cpss_R_ptr; - - //! Standard state entropy divided by R. - /*! - * Storage for the thermo properties is provided by VPSSMgr. Calculated - * at the current value of T and P. - */ - doublereal* m_sss_R_ptr; - - //! Standard state Gibbs free energy divided by RT. - /*! - * Storage for the thermo properties is provided by VPSSMgr. Calculated - * at the current value of T and P. - */ - doublereal* m_gss_RT_ptr; - - //! Standard State molar volume (m3 kg-1) - /*! - * Storage for the thermo properties is provided by VPSSMgr. Calculated - * at the current value of T and P. - */ - doublereal* m_Vss_ptr; }; //! Base class for PDSS classes which compute molar properties directly @@ -619,10 +543,24 @@ public: class PDSS_Nondimensional : public virtual PDSS { public: + PDSS_Nondimensional(); + virtual doublereal enthalpy_mole() const; virtual doublereal entropy_mole() const; virtual doublereal gibbs_mole() const; virtual doublereal cp_mole() const; + +protected: + double m_h0_RT; //!< Reference state enthalpy divided by RT + double m_cp0_R; //!< Reference state heat capacity divided by R + double m_s0_R; //!< Reference state entropy divided by R + double m_g0_RT; //!< Reference state Gibbs free energy divided by RT + double m_V0; //!< Reference state molar volume (m3 kg-1) + double m_hss_RT; //!< Standard state enthalpy divided by RT + double m_cpss_R; //!< Standard state heat capacity divided by R + double m_sss_R; //!< Standard state entropy divided by R + double m_gss_RT; //!< Standard state Gibbs free energy divided by RT + double m_Vss; //!< Standard State molar volume (m3 kg-1) }; } diff --git a/include/cantera/thermo/PDSS_SSVol.h b/include/cantera/thermo/PDSS_SSVol.h index c89b42049..9efd00b5f 100644 --- a/include/cantera/thermo/PDSS_SSVol.h +++ b/include/cantera/thermo/PDSS_SSVol.h @@ -216,7 +216,7 @@ public: private: //! Does the internal calculation of the volume - void calcMolarVolume() const; + void calcMolarVolume(); //! @name Mechanical Equation of State Properties //! @{ diff --git a/include/cantera/thermo/VPSSMgr.h b/include/cantera/thermo/VPSSMgr.h index 7155a4d2b..b22092aa9 100644 --- a/include/cantera/thermo/VPSSMgr.h +++ b/include/cantera/thermo/VPSSMgr.h @@ -733,76 +733,6 @@ protected: //! P = m_plast mutable vector_fp m_Vss; - //! species reference enthalpies - used by individual PDSS objects - /*! - * Vector containing the species reference enthalpies at T = m_tlast - * and P = p_ref. - */ - mutable vector_fp mPDSS_h0_RT; - - //! species reference heat capacities - used by individual PDSS objects - /** - * Vector containing the species reference constant pressure - * heat capacities at T = m_tlast and P = p_ref. - */ - mutable vector_fp mPDSS_cp0_R; - - //! species reference Gibbs free energies - used by individual PDSS objects - /** - * Vector containing the species reference Gibbs functions - * at T = m_tlast and P = p_ref. - */ - mutable vector_fp mPDSS_g0_RT; - - //! species reference entropies - used by individual PDSS objects - /** - * Vector containing the species reference entropies - * at T = m_tlast and P = p_ref. - */ - mutable vector_fp mPDSS_s0_R; - - //! species reference state molar Volumes - used by individual PDSS objects - /** - * Vector containing the rf molar volumes - * at T = m_tlast and P = p_ref. - */ - mutable vector_fp mPDSS_V0; - - //! species standard state enthalpies - used by individual PDSS objects - /*! - * Vector containing the species standard state enthalpies at T = m_tlast - * and P = p_ref. - */ - mutable vector_fp mPDSS_hss_RT; - - //! species standard state heat capacities - used by individual PDSS objects - /** - * Vector containing the species standard state constant pressure - * heat capacities at T = m_tlast and P = p_ref. - */ - mutable vector_fp mPDSS_cpss_R; - - //! species standard state Gibbs free energies - used by individual PDSS objects - /** - * Vector containing the species standard state Gibbs functions - * at T = m_tlast and P = p_ref. - */ - mutable vector_fp mPDSS_gss_RT; - - //! species standard state entropies - used by individual PDSS objects - /** - * Vector containing the species standard state entropies - * at T = m_tlast and P = p_ref. - */ - mutable vector_fp mPDSS_sss_R; - - //! species standard state molar Volumes - used by individual PDSS objects - /** - * Vector containing the ss molar volumes - * at T = m_tlast and P = p_ref. - */ - mutable vector_fp mPDSS_Vss; - friend class PDSS; }; //@} diff --git a/src/thermo/MultiSpeciesThermo.cpp b/src/thermo/MultiSpeciesThermo.cpp index 27cda86f7..1b13fa3e9 100644 --- a/src/thermo/MultiSpeciesThermo.cpp +++ b/src/thermo/MultiSpeciesThermo.cpp @@ -88,12 +88,23 @@ void MultiSpeciesThermo::installPDSShandler(size_t k, PDSS* PDSS_ptr, void MultiSpeciesThermo::update_one(size_t k, doublereal t, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { + warn_deprecated("MultiSpeciesThermo::update_one", + "Use update_single instead. To be removed after Cantera 2.4"); const SpeciesThermoInterpType* sp_ptr = provideSTIT(k); if (sp_ptr) { sp_ptr->updatePropertiesTemp(t, cp_R+k, h_RT+k, s_R+k); } } +void MultiSpeciesThermo::update_single(size_t k, double t, double* cp_R, + double* h_RT, double* s_R) const +{ + const SpeciesThermoInterpType* sp_ptr = provideSTIT(k); + if (sp_ptr) { + sp_ptr->updatePropertiesTemp(t, cp_R, h_RT, s_R); + } +} + void MultiSpeciesThermo::update(doublereal t, doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const { diff --git a/src/thermo/PDSS.cpp b/src/thermo/PDSS.cpp index be43def6d..c15210295 100644 --- a/src/thermo/PDSS.cpp +++ b/src/thermo/PDSS.cpp @@ -24,17 +24,7 @@ PDSS::PDSS() : m_vpssmgr_ptr(0), m_mw(0.0), m_spindex(npos), - m_spthermo(0), - m_h0_RT_ptr(0), - m_cp0_R_ptr(0), - m_s0_R_ptr(0), - m_g0_RT_ptr(0), - m_V0_ptr(0), - m_hss_RT_ptr(0), - m_cpss_R_ptr(0), - m_sss_R_ptr(0), - m_gss_RT_ptr(0), - m_Vss_ptr(0) + m_spthermo(0) { } @@ -48,17 +38,7 @@ PDSS::PDSS(VPStandardStateTP* tp, size_t spindex) : m_vpssmgr_ptr(0), m_mw(0.0), m_spindex(spindex), - m_spthermo(0), - m_h0_RT_ptr(0), - m_cp0_R_ptr(0), - m_s0_R_ptr(0), - m_g0_RT_ptr(0), - m_V0_ptr(0), - m_hss_RT_ptr(0), - m_cpss_R_ptr(0), - m_sss_R_ptr(0), - m_gss_RT_ptr(0), - m_Vss_ptr(0) + m_spthermo(0) { if (tp) { m_spthermo = &tp->speciesThermo(); @@ -81,26 +61,9 @@ void PDSS::initThermo() AssertThrow(m_tp != 0, "PDSS::initThermo()"); m_vpssmgr_ptr = m_tp->provideVPSSMgr(); m_vpssmgr_ptr->initThermo(); - initPtrs(); m_mw = m_tp->molecularWeight(m_spindex); } -void PDSS::initPtrs() -{ - AssertThrow(m_vpssmgr_ptr->mPDSS_h0_RT.size() != 0, "PDSS::initPtrs()"); - m_h0_RT_ptr = &m_vpssmgr_ptr->mPDSS_h0_RT[0]; - m_cp0_R_ptr = &m_vpssmgr_ptr->mPDSS_cp0_R[0]; - m_s0_R_ptr = &m_vpssmgr_ptr->mPDSS_s0_R[0]; - m_g0_RT_ptr = &m_vpssmgr_ptr->mPDSS_g0_RT[0]; - m_V0_ptr = &m_vpssmgr_ptr->mPDSS_V0[0]; - - m_hss_RT_ptr = &m_vpssmgr_ptr->mPDSS_hss_RT[0]; - m_cpss_R_ptr = &m_vpssmgr_ptr->mPDSS_cpss_R[0]; - m_sss_R_ptr = &m_vpssmgr_ptr->mPDSS_sss_R[0]; - m_gss_RT_ptr = &m_vpssmgr_ptr->mPDSS_gss_RT[0]; - m_Vss_ptr = &m_vpssmgr_ptr->mPDSS_Vss[0]; -} - doublereal PDSS::enthalpy_mole() const { throw NotImplementedError("PDSS::enthalpy_mole()"); @@ -307,6 +270,20 @@ doublereal PDSS_Molar::cp_R() const // PDSS_Nondimensional methods +PDSS_Nondimensional::PDSS_Nondimensional() + : m_h0_RT(0.0) + , m_cp0_R(0.0) + , m_s0_R(0.0) + , m_g0_RT(0.0) + , m_V0(0.0) + , m_hss_RT(0.0) + , m_cpss_R(0.0) + , m_sss_R(0.0) + , m_gss_RT(0.0) + , m_Vss(0.0) +{ +} + doublereal PDSS_Nondimensional::enthalpy_mole() const { return enthalpy_RT() * GasConstant * temperature(); diff --git a/src/thermo/PDSS_ConstVol.cpp b/src/thermo/PDSS_ConstVol.cpp index 7d776693c..7896bf35f 100644 --- a/src/thermo/PDSS_ConstVol.cpp +++ b/src/thermo/PDSS_ConstVol.cpp @@ -66,97 +66,96 @@ void PDSS_ConstVol::initThermo() { PDSS::initThermo(); m_p0 = m_tp->speciesThermo().refPressure(m_spindex); - m_V0_ptr[m_spindex] = m_constMolarVolume; - m_Vss_ptr[m_spindex] = m_constMolarVolume; + m_V0 = m_constMolarVolume; + m_Vss = m_constMolarVolume; } doublereal PDSS_ConstVol::enthalpy_RT() const { - return m_hss_RT_ptr[m_spindex]; + return m_hss_RT; } doublereal PDSS_ConstVol::intEnergy_mole() const { - doublereal pV = (m_pres * m_Vss_ptr[m_spindex]); - return m_h0_RT_ptr[m_spindex] * GasConstant * m_temp - pV; + doublereal pV = (m_pres * m_Vss); + return m_h0_RT * GasConstant * m_temp - pV; } doublereal PDSS_ConstVol::entropy_R() const { - return m_sss_R_ptr[m_spindex]; + return m_sss_R; } doublereal PDSS_ConstVol::gibbs_RT() const { - return m_gss_RT_ptr[m_spindex]; + return m_gss_RT; } doublereal PDSS_ConstVol::cp_R() const { - return m_cpss_R_ptr[m_spindex]; + return m_cpss_R; } doublereal PDSS_ConstVol::cv_mole() const { - return (cp_mole() - m_V0_ptr[m_spindex]); + return (cp_mole() - m_V0); } doublereal PDSS_ConstVol::molarVolume() const { - return m_Vss_ptr[m_spindex]; + return m_Vss; } doublereal PDSS_ConstVol::density() const { - return m_mw / m_Vss_ptr[m_spindex]; + return m_mw / m_Vss; } doublereal PDSS_ConstVol::gibbs_RT_ref() const { - return m_g0_RT_ptr[m_spindex]; + return m_g0_RT; } doublereal PDSS_ConstVol::enthalpy_RT_ref() const { - return m_h0_RT_ptr[m_spindex]; + return m_h0_RT; } doublereal PDSS_ConstVol::entropy_R_ref() const { - return m_s0_R_ptr[m_spindex]; + return m_s0_R; } doublereal PDSS_ConstVol::cp_R_ref() const { - return m_cp0_R_ptr[m_spindex]; + return m_cp0_R; } doublereal PDSS_ConstVol::molarVolume_ref() const { - return m_V0_ptr[m_spindex]; + return m_V0; } void PDSS_ConstVol::setPressure(doublereal p) { m_pres = p; doublereal del_pRT = (m_pres - m_p0) / (GasConstant * m_temp); - m_hss_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex] + del_pRT * m_Vss_ptr[m_spindex]; - m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; + m_hss_RT = m_h0_RT + del_pRT * m_Vss; + m_gss_RT = m_hss_RT - m_sss_R; } void PDSS_ConstVol::setTemperature(doublereal temp) { m_temp = temp; - m_spthermo->update_one(m_spindex, temp, - m_cp0_R_ptr, m_h0_RT_ptr, m_s0_R_ptr); - m_g0_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex] - m_s0_R_ptr[m_spindex]; + m_spthermo->update_single(m_spindex, temp, &m_cp0_R, &m_h0_RT, &m_s0_R); + m_g0_RT = m_h0_RT - m_s0_R; doublereal del_pRT = (m_pres - m_p0) / (GasConstant * m_temp); - m_hss_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex] + del_pRT * m_Vss_ptr[m_spindex]; - m_cpss_R_ptr[m_spindex] = m_cp0_R_ptr[m_spindex]; - m_sss_R_ptr[m_spindex] = m_s0_R_ptr[m_spindex]; - m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; + m_hss_RT = m_h0_RT + del_pRT * m_Vss; + m_cpss_R = m_cp0_R; + m_sss_R = m_s0_R; + m_gss_RT = m_hss_RT - m_sss_R; } void PDSS_ConstVol::setState_TP(doublereal temp, doublereal pres) diff --git a/src/thermo/PDSS_IdealGas.cpp b/src/thermo/PDSS_IdealGas.cpp index d14ebcab7..8f339b849 100644 --- a/src/thermo/PDSS_IdealGas.cpp +++ b/src/thermo/PDSS_IdealGas.cpp @@ -45,27 +45,27 @@ void PDSS_IdealGas::initThermo() doublereal PDSS_IdealGas::enthalpy_RT() const { - return m_h0_RT_ptr[m_spindex]; + return m_h0_RT; } doublereal PDSS_IdealGas::intEnergy_mole() const { - return (m_h0_RT_ptr[m_spindex] - 1.0) * GasConstant * m_temp; + return (m_h0_RT - 1.0) * GasConstant * m_temp; } doublereal PDSS_IdealGas::entropy_R() const { - return m_s0_R_ptr[m_spindex] - log(m_pres/m_p0); + return m_s0_R - log(m_pres/m_p0); } doublereal PDSS_IdealGas::gibbs_RT() const { - return m_g0_RT_ptr[m_spindex] + log(m_pres/m_p0); + return m_g0_RT + log(m_pres/m_p0); } doublereal PDSS_IdealGas::cp_R() const { - return m_cp0_R_ptr[m_spindex]; + return m_cp0_R; } doublereal PDSS_IdealGas::molarVolume() const @@ -85,17 +85,17 @@ doublereal PDSS_IdealGas::cv_mole() const doublereal PDSS_IdealGas::gibbs_RT_ref() const { - return m_g0_RT_ptr[m_spindex]; + return m_g0_RT; } doublereal PDSS_IdealGas::enthalpy_RT_ref() const { - return m_h0_RT_ptr[m_spindex]; + return m_h0_RT; } doublereal PDSS_IdealGas::entropy_R_ref() const { - return m_s0_R_ptr[m_spindex]; + return m_s0_R; } doublereal PDSS_IdealGas::cp_R_ref() const @@ -115,9 +115,9 @@ doublereal PDSS_IdealGas::pressure() const void PDSS_IdealGas::setPressure(doublereal p) { - m_sss_R_ptr[m_spindex] = m_s0_R_ptr[m_spindex] + log(m_pres/m_p0); - m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; - m_Vss_ptr[m_spindex] = GasConstant * m_temp / m_pres; + m_sss_R = m_s0_R + log(m_pres/m_p0); + m_gss_RT = m_hss_RT - m_sss_R; + m_Vss = GasConstant * m_temp / m_pres; } doublereal PDSS_IdealGas::temperature() const @@ -129,15 +129,14 @@ doublereal PDSS_IdealGas::temperature() const void PDSS_IdealGas::setTemperature(doublereal temp) { m_temp = temp; - m_spthermo->update_one(m_spindex, temp, - m_cp0_R_ptr, m_h0_RT_ptr, m_s0_R_ptr); - m_g0_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex] - m_s0_R_ptr[m_spindex]; - m_V0_ptr[m_spindex] = GasConstant * m_temp / m_p0; - m_hss_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex]; - m_cpss_R_ptr[m_spindex] = m_cp0_R_ptr[m_spindex]; - m_sss_R_ptr[m_spindex] = m_s0_R_ptr[m_spindex] + log(m_pres/m_p0); - m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; - m_Vss_ptr[m_spindex] = GasConstant * m_temp / m_pres; + m_spthermo->update_single(m_spindex, temp, &m_cp0_R, &m_h0_RT, &m_s0_R); + m_g0_RT = m_h0_RT - m_s0_R; + m_V0 = GasConstant * m_temp / m_p0; + m_hss_RT = m_h0_RT; + m_cpss_R = m_cp0_R; + m_sss_R = m_s0_R + log(m_pres/m_p0); + m_gss_RT = m_hss_RT - m_sss_R; + m_Vss = GasConstant * m_temp / m_pres; } void PDSS_IdealGas::setState_TP(doublereal temp, doublereal pres) diff --git a/src/thermo/PDSS_IonsFromNeutral.cpp b/src/thermo/PDSS_IonsFromNeutral.cpp index c3bcf29f9..9153ea7eb 100644 --- a/src/thermo/PDSS_IonsFromNeutral.cpp +++ b/src/thermo/PDSS_IonsFromNeutral.cpp @@ -112,7 +112,7 @@ doublereal PDSS_IonsFromNeutral::enthalpy_RT() const doublereal PDSS_IonsFromNeutral::intEnergy_mole() const { - return (m_h0_RT_ptr[m_spindex] - 1.0) * GasConstant * m_temp; + return (m_h0_RT - 1.0) * GasConstant * m_temp; } doublereal PDSS_IonsFromNeutral::entropy_R() const diff --git a/src/thermo/PDSS_SSVol.cpp b/src/thermo/PDSS_SSVol.cpp index ddcc72aee..7e81b01fa 100644 --- a/src/thermo/PDSS_SSVol.cpp +++ b/src/thermo/PDSS_SSVol.cpp @@ -89,87 +89,87 @@ void PDSS_SSVol::initThermo() { PDSS::initThermo(); m_p0 = m_tp->speciesThermo().refPressure(m_spindex); - m_V0_ptr[m_spindex] = m_constMolarVolume; - m_Vss_ptr[m_spindex] = m_constMolarVolume; + m_V0 = m_constMolarVolume; + m_Vss = m_constMolarVolume; } doublereal PDSS_SSVol::enthalpy_RT() const { - return m_hss_RT_ptr[m_spindex]; + return m_hss_RT; } doublereal PDSS_SSVol::intEnergy_mole() const { - doublereal pV = m_pres * m_Vss_ptr[m_spindex]; - return m_h0_RT_ptr[m_spindex] * GasConstant * m_temp - pV; + doublereal pV = m_pres * m_Vss; + return m_h0_RT * GasConstant * m_temp - pV; } doublereal PDSS_SSVol::entropy_R() const { - return m_sss_R_ptr[m_spindex]; + return m_sss_R; } doublereal PDSS_SSVol::gibbs_RT() const { - return m_gss_RT_ptr[m_spindex]; + return m_gss_RT; } doublereal PDSS_SSVol::cp_R() const { - return m_cpss_R_ptr[m_spindex]; + return m_cpss_R; } doublereal PDSS_SSVol::cv_mole() const { - return (cp_mole() - m_V0_ptr[m_spindex]); + return (cp_mole() - m_V0); } doublereal PDSS_SSVol::molarVolume() const { - return m_Vss_ptr[m_spindex]; + return m_Vss; } doublereal PDSS_SSVol::density() const { - return m_mw / m_Vss_ptr[m_spindex]; + return m_mw / m_Vss; } doublereal PDSS_SSVol::gibbs_RT_ref() const { - return m_g0_RT_ptr[m_spindex]; + return m_g0_RT; } doublereal PDSS_SSVol::enthalpy_RT_ref() const { - return m_h0_RT_ptr[m_spindex]; + return m_h0_RT; } doublereal PDSS_SSVol::entropy_R_ref() const { - return m_s0_R_ptr[m_spindex]; + return m_s0_R; } doublereal PDSS_SSVol::cp_R_ref() const { - return m_cp0_R_ptr[m_spindex]; + return m_cp0_R; } doublereal PDSS_SSVol::molarVolume_ref() const { - return m_V0_ptr[m_spindex]; + return m_V0; } -void PDSS_SSVol::calcMolarVolume() const +void PDSS_SSVol::calcMolarVolume() { if (volumeModel_ == SSVolume_Model::constant) { - m_Vss_ptr[m_spindex] = m_constMolarVolume; + m_Vss = m_constMolarVolume; } else if (volumeModel_ == SSVolume_Model::tpoly) { - m_Vss_ptr[m_spindex] = TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * (TCoeff_[2] + m_temp * TCoeff_[3])); + m_Vss = TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * (TCoeff_[2] + m_temp * TCoeff_[3])); dVdT_ = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2] + 3.0 * m_temp * m_temp * TCoeff_[3]; d2VdT2_ = 2.0 * TCoeff_[2] + 6.0 * m_temp * TCoeff_[3]; } else if (volumeModel_ == SSVolume_Model::density_tpoly) { doublereal dens = TCoeff_[0] + m_temp * (TCoeff_[1] + m_temp * (TCoeff_[2] + m_temp * TCoeff_[3])); - m_Vss_ptr[m_spindex] = m_mw / dens; + m_Vss = m_mw / dens; doublereal dens2 = dens * dens; doublereal ddensdT = TCoeff_[1] + 2.0 * m_temp * TCoeff_[2] + 3.0 * m_temp * m_temp * TCoeff_[3]; doublereal d2densdT2 = 2.0 * TCoeff_[2] + 6.0 * m_temp * TCoeff_[3]; @@ -185,39 +185,39 @@ void PDSS_SSVol::setPressure(doublereal p) m_pres = p; doublereal deltaP = m_pres - m_p0; if (fabs(deltaP) < 1.0E-10) { - m_hss_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex]; - m_sss_R_ptr[m_spindex] = m_s0_R_ptr[m_spindex]; - m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; - m_cpss_R_ptr[m_spindex] = m_cp0_R_ptr[m_spindex]; + m_hss_RT = m_h0_RT; + m_sss_R = m_s0_R; + m_gss_RT = m_hss_RT - m_sss_R; + m_cpss_R = m_cp0_R; } else { doublereal del_pRT = deltaP / (GasConstant * m_temp); doublereal sV_term = - deltaP / GasConstant * dVdT_; - m_hss_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex] + sV_term + del_pRT * m_Vss_ptr[m_spindex]; - m_sss_R_ptr[m_spindex] = m_s0_R_ptr[m_spindex] + sV_term; - m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; - m_cpss_R_ptr[m_spindex] = m_cp0_R_ptr[m_spindex] - m_temp * deltaP * d2VdT2_; + m_hss_RT = m_h0_RT + sV_term + del_pRT * m_Vss; + m_sss_R = m_s0_R + sV_term; + m_gss_RT = m_hss_RT - m_sss_R; + m_cpss_R = m_cp0_R - m_temp * deltaP * d2VdT2_; } } void PDSS_SSVol::setTemperature(doublereal temp) { m_temp = temp; - m_spthermo->update_one(m_spindex, temp, m_cp0_R_ptr, m_h0_RT_ptr, m_s0_R_ptr); + m_spthermo->update_single(m_spindex, temp, &m_cp0_R, &m_h0_RT, &m_s0_R); calcMolarVolume(); - m_g0_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex] - m_s0_R_ptr[m_spindex]; + m_g0_RT = m_h0_RT - m_s0_R; doublereal deltaP = m_pres - m_p0; if (fabs(deltaP) < 1.0E-10) { - m_hss_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex]; - m_sss_R_ptr[m_spindex] = m_s0_R_ptr[m_spindex]; - m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; - m_cpss_R_ptr[m_spindex] = m_cp0_R_ptr[m_spindex]; + m_hss_RT = m_h0_RT; + m_sss_R = m_s0_R; + m_gss_RT = m_hss_RT - m_sss_R; + m_cpss_R = m_cp0_R; } else { doublereal del_pRT = deltaP / (GasConstant * m_temp); doublereal sV_term = - deltaP / GasConstant * dVdT_; - m_hss_RT_ptr[m_spindex] = m_h0_RT_ptr[m_spindex] + sV_term + del_pRT * m_Vss_ptr[m_spindex]; - m_sss_R_ptr[m_spindex] = m_s0_R_ptr[m_spindex] + sV_term; - m_gss_RT_ptr[m_spindex] = m_hss_RT_ptr[m_spindex] - m_sss_R_ptr[m_spindex]; - m_cpss_R_ptr[m_spindex] = m_cp0_R_ptr[m_spindex] - m_temp * deltaP * d2VdT2_; + m_hss_RT = m_h0_RT + sV_term + del_pRT * m_Vss; + m_sss_R = m_s0_R + sV_term; + m_gss_RT = m_hss_RT - m_sss_R; + m_cpss_R = m_cp0_R - m_temp * deltaP * d2VdT2_; } } diff --git a/src/thermo/PureFluidPhase.cpp b/src/thermo/PureFluidPhase.cpp index dd51006a0..5f3631662 100644 --- a/src/thermo/PureFluidPhase.cpp +++ b/src/thermo/PureFluidPhase.cpp @@ -55,7 +55,7 @@ void PureFluidPhase::initThermo() p = 0.001 * p; m_sub->Set(tpx::PropertyPair::TP, T0, p); - m_spthermo->update_one(0, T0, &cp0_R, &h0_RT, &s0_R); + m_spthermo->update_single(0, T0, &cp0_R, &h0_RT, &s0_R); double s_R = s0_R - log(p/refPressure()); m_sub->setStdState(h0_RT*GasConstant*298.15/m_mw, s_R*GasConstant/m_mw, T0, p); diff --git a/src/thermo/VPSSMgr.cpp b/src/thermo/VPSSMgr.cpp index 98e871f19..0736ee1c9 100644 --- a/src/thermo/VPSSMgr.cpp +++ b/src/thermo/VPSSMgr.cpp @@ -249,18 +249,6 @@ void VPSSMgr::initLengths() m_gss_RT.resize(m_kk, 0.0); m_sss_R.resize(m_kk, 0.0); m_Vss.resize(m_kk, 0.0); - - // Storage used by the PDSS objects to store their answers. - mPDSS_h0_RT.resize(m_kk, 0.0); - mPDSS_cp0_R.resize(m_kk, 0.0); - mPDSS_g0_RT.resize(m_kk, 0.0); - mPDSS_s0_R.resize(m_kk, 0.0); - mPDSS_V0.resize(m_kk, 0.0); - mPDSS_hss_RT.resize(m_kk, 0.0); - mPDSS_cpss_R.resize(m_kk, 0.0); - mPDSS_gss_RT.resize(m_kk, 0.0); - mPDSS_sss_R.resize(m_kk, 0.0); - mPDSS_Vss.resize(m_kk, 0.0); } void VPSSMgr::initThermoXML(XML_Node& phaseNode, const std::string& id)