[Thermo] Add a version of Phase::mean_X that takes vector_fp

This simplifies all internal calls to this function
This commit is contained in:
Ray Speth 2015-02-20 23:44:21 +00:00
parent afb5b13eb4
commit 2ed8552939
15 changed files with 52 additions and 55 deletions

View file

@ -382,7 +382,7 @@ public:
* \see SpeciesThermo
*/
virtual doublereal enthalpy_mole() const {
return GasConstant * temperature() * mean_X(&enthalpy_RT_ref()[0]);
return GasConstant * temperature() * mean_X(enthalpy_RT_ref());
}
/**

View file

@ -648,6 +648,9 @@ public:
//! @return mole-fraction-weighted mean of Q
doublereal mean_X(const doublereal* const Q) const;
//! @copydoc Phase::mean_X(const doublereal* const Q) const
doublereal mean_X(const vector_fp& Q) const;
//! Evaluate the mass-fraction-weighted mean of an array Q.
//! \f[ \sum_k Y_k Q_k \f]
//! @param[in] Q Array of species property values in mass units.

View file

@ -55,19 +55,17 @@ doublereal ConstDensityThermo::enthalpy_mole() const
{
doublereal p0 = m_spthermo->refPressure();
return GasConstant * temperature() *
mean_X(&enthalpy_RT()[0])
+ (pressure() - p0)/molarDensity();
mean_X(enthalpy_RT()) + (pressure() - p0)/molarDensity();
}
doublereal ConstDensityThermo::entropy_mole() const
{
return GasConstant * (mean_X(&entropy_R()[0]) -
sum_xlogx());
return GasConstant * (mean_X(entropy_R()) - sum_xlogx());
}
doublereal ConstDensityThermo::cp_mole() const
{
return GasConstant * mean_X(&cp_R()[0]);
return GasConstant * mean_X(cp_R());
}
doublereal ConstDensityThermo::cv_mole() const

View file

@ -192,25 +192,25 @@ int DebyeHuckel::eosType() const
doublereal DebyeHuckel::enthalpy_mole() const
{
getPartialMolarEnthalpies(DATA_PTR(m_tmpV));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal DebyeHuckel::entropy_mole() const
{
getPartialMolarEntropies(DATA_PTR(m_tmpV));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal DebyeHuckel::gibbs_mole() const
{
getChemPotentials(DATA_PTR(m_tmpV));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal DebyeHuckel::cp_mole() const
{
getPartialMolarCp(DATA_PTR(m_tmpV));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal DebyeHuckel::cv_mole() const

View file

@ -426,19 +426,19 @@ doublereal HMWSoln::enthalpy_mole() const
{
getPartialMolarEnthalpies(DATA_PTR(m_tmpV));
getMoleFractions(DATA_PTR(m_pp));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal HMWSoln::relative_enthalpy() const
{
getPartialMolarEnthalpies(DATA_PTR(m_tmpV));
double hbar = mean_X(DATA_PTR(m_tmpV));
double hbar = mean_X(m_tmpV);
getEnthalpy_RT(DATA_PTR(m_gamma_tmp));
double RT = GasConstant * temperature();
for (size_t k = 0; k < m_kk; k++) {
m_gamma_tmp[k] *= RT;
}
double h0bar = mean_X(DATA_PTR(m_gamma_tmp));
double h0bar = mean_X(m_gamma_tmp);
return hbar - h0bar;
}
@ -485,19 +485,19 @@ doublereal HMWSoln::relative_molal_enthalpy() const
doublereal HMWSoln::entropy_mole() const
{
getPartialMolarEntropies(DATA_PTR(m_tmpV));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal HMWSoln::gibbs_mole() const
{
getChemPotentials(DATA_PTR(m_tmpV));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal HMWSoln::cp_mole() const
{
getPartialMolarCp(DATA_PTR(m_tmpV));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal HMWSoln::cv_mole() const

View file

@ -69,12 +69,12 @@ ThermoPhase* IdealGasPhase::duplMyselfAsThermoPhase() const
doublereal IdealGasPhase::entropy_mole() const
{
return GasConstant * (mean_X(&entropy_R_ref()[0]) - sum_xlogx() - std::log(pressure() / m_spthermo->refPressure()));
return GasConstant * (mean_X(entropy_R_ref()) - sum_xlogx() - std::log(pressure() / m_spthermo->refPressure()));
}
doublereal IdealGasPhase::cp_mole() const
{
return GasConstant * mean_X(&cp_R_ref()[0]);
return GasConstant * mean_X(cp_R_ref());
}
doublereal IdealGasPhase::cv_mole() const

View file

@ -139,31 +139,31 @@ doublereal IdealMolalSoln::enthalpy_mole() const
{
getPartialMolarEnthalpies(DATA_PTR(m_tmpV));
getMoleFractions(DATA_PTR(m_pp));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal IdealMolalSoln::intEnergy_mole() const
{
getPartialMolarEnthalpies(DATA_PTR(m_tmpV));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal IdealMolalSoln::entropy_mole() const
{
getPartialMolarEntropies(DATA_PTR(m_tmpV));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal IdealMolalSoln::gibbs_mole() const
{
getChemPotentials(DATA_PTR(m_tmpV));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal IdealMolalSoln::cp_mole() const
{
getPartialMolarCp(DATA_PTR(m_tmpV));
return mean_X(DATA_PTR(m_tmpV));
return mean_X(m_tmpV);
}
doublereal IdealMolalSoln::cv_mole() const

View file

@ -114,27 +114,23 @@ int IdealSolidSolnPhase::eosType() const
doublereal IdealSolidSolnPhase::enthalpy_mole() const
{
const double* eptr = &(enthalpy_RT_ref()[0]);
doublereal htp = (GasConstant * temperature() * mean_X(eptr));
doublereal htp = GasConstant * temperature() * mean_X(enthalpy_RT_ref());
return htp + (pressure() - m_Pref)/molarDensity();
}
doublereal IdealSolidSolnPhase::entropy_mole() const
{
const double* dptr = DATA_PTR(entropy_R_ref());
return GasConstant * (mean_X(dptr) - sum_xlogx());
return GasConstant * (mean_X(entropy_R_ref()) - sum_xlogx());
}
doublereal IdealSolidSolnPhase::gibbs_mole() const
{
const double* dptr = DATA_PTR(gibbs_RT_ref());
return GasConstant * temperature() * (mean_X(dptr) + sum_xlogx());
return GasConstant * temperature() * (mean_X(gibbs_RT_ref()) + sum_xlogx());
}
doublereal IdealSolidSolnPhase::cp_mole() const
{
const double* dptr = DATA_PTR(cp_R_ref());
return GasConstant * mean_X(dptr);
return GasConstant * mean_X(cp_R_ref());
}
/********************************************************************

View file

@ -89,24 +89,20 @@ int IdealSolnGasVPSS::eosType() const
doublereal IdealSolnGasVPSS::enthalpy_mole() const
{
updateStandardStateThermo();
const vector_fp& enth_RT = m_VPSS_ptr->enthalpy_RT();
return (GasConstant * temperature() *
mean_X(DATA_PTR(enth_RT)));
return GasConstant * temperature() * mean_X(m_VPSS_ptr->enthalpy_RT());
}
doublereal IdealSolnGasVPSS::entropy_mole() const
{
updateStandardStateThermo();
const vector_fp& entrop_R = m_VPSS_ptr->entropy_R();
return GasConstant * (mean_X(DATA_PTR(entrop_R)) - sum_xlogx());
return GasConstant * (mean_X(m_VPSS_ptr->entropy_R()) - sum_xlogx());
}
doublereal IdealSolnGasVPSS::cp_mole() const
{
updateStandardStateThermo();
const vector_fp& cp_R = m_VPSS_ptr->cp_R();
return GasConstant * (mean_X(DATA_PTR(cp_R)));
return GasConstant * mean_X(m_VPSS_ptr->cp_R());
}
doublereal IdealSolnGasVPSS::cv_mole() const

View file

@ -263,32 +263,32 @@ int IonsFromNeutralVPSSTP::eosType() const
doublereal IonsFromNeutralVPSSTP::enthalpy_mole() const
{
getPartialMolarEnthalpies(DATA_PTR(m_pp));
return mean_X(DATA_PTR(m_pp));
return mean_X(m_pp);
}
doublereal IonsFromNeutralVPSSTP::entropy_mole() const
{
getPartialMolarEntropies(DATA_PTR(m_pp));
return mean_X(DATA_PTR(m_pp));
return mean_X(m_pp);
}
doublereal IonsFromNeutralVPSSTP::gibbs_mole() const
{
getChemPotentials(DATA_PTR(m_pp));
return mean_X(DATA_PTR(m_pp));
return mean_X(m_pp);
}
doublereal IonsFromNeutralVPSSTP::cp_mole() const
{
getPartialMolarCp(DATA_PTR(m_pp));
return mean_X(DATA_PTR(m_pp));
return mean_X(m_pp);
}
doublereal IonsFromNeutralVPSSTP::cv_mole() const
{
// Need to revisit this, as it is wrong
getPartialMolarCp(DATA_PTR(m_pp));
return mean_X(DATA_PTR(m_pp));
return mean_X(m_pp);
}
/*

View file

@ -67,19 +67,18 @@ ThermoPhase* LatticePhase::duplMyselfAsThermoPhase() const
doublereal LatticePhase::enthalpy_mole() const
{
return GasConstant * temperature() *
mean_X(&enthalpy_RT_ref()[0])
+ (pressure() - m_Pref)/molarDensity();
return GasConstant * temperature() * mean_X(enthalpy_RT_ref()) +
(pressure() - m_Pref)/molarDensity();
}
doublereal LatticePhase::entropy_mole() const
{
return GasConstant * (mean_X(&entropy_R_ref()[0]) - sum_xlogx());
return GasConstant * (mean_X(entropy_R_ref()) - sum_xlogx());
}
doublereal LatticePhase::cp_mole() const
{
return GasConstant * mean_X(&cp_R_ref()[0]);
return GasConstant * mean_X(cp_R_ref());
}
doublereal LatticePhase::cv_mole() const

View file

@ -74,7 +74,7 @@ void MaskellSolidSolnPhase::getActivityConcentrations(doublereal* c) const
doublereal MaskellSolidSolnPhase::enthalpy_mole() const
{
_updateThermo();
const doublereal h0 = GasConstant * temperature() * mean_X(&m_h0_RT[0]);
const doublereal h0 = GasConstant * temperature() * mean_X(m_h0_RT);
const doublereal r = moleFraction(product_species_index);
const doublereal fmval = fm(r);
return h0 + r * fmval * h_mixing;
@ -88,7 +88,7 @@ doublereal xlogx(doublereal x)
doublereal MaskellSolidSolnPhase::entropy_mole() const
{
_updateThermo();
const doublereal s0 = GasConstant * mean_X(&m_s0_R[0]);
const doublereal s0 = GasConstant * mean_X(m_s0_R);
const doublereal r = moleFraction(product_species_index);
const doublereal fmval = fm(r);
const doublereal rfm = r * fmval;

View file

@ -687,6 +687,11 @@ doublereal Phase::mean_X(const doublereal* const Q) const
return m_mmw*std::inner_product(m_ym.begin(), m_ym.end(), Q, 0.0);
}
doublereal Phase::mean_X(const vector_fp& Q) const
{
return m_mmw*std::inner_product(m_ym.begin(), m_ym.end(), Q.begin(), 0.0);
}
doublereal Phase::mean_Y(const doublereal* const Q) const
{
return dot(m_y.begin(), m_y.end(), Q);

View file

@ -179,7 +179,7 @@ int RedlichKwongMFTP::eosType() const
doublereal RedlichKwongMFTP::enthalpy_mole() const
{
_updateReferenceStateThermo();
doublereal h_ideal = _RT() * mean_X(DATA_PTR(m_h0_RT));
doublereal h_ideal = _RT() * mean_X(m_h0_RT);
doublereal h_nonideal = hresid();
return h_ideal + h_nonideal;
}
@ -187,7 +187,7 @@ doublereal RedlichKwongMFTP::enthalpy_mole() const
doublereal RedlichKwongMFTP::entropy_mole() const
{
_updateReferenceStateThermo();
doublereal sr_ideal = GasConstant * (mean_X(DATA_PTR(m_s0_R))
doublereal sr_ideal = GasConstant * (mean_X(m_s0_R)
- sum_xlogx() - std::log(pressure()/m_spthermo->refPressure()));
doublereal sr_nonideal = sresid();
return sr_ideal + sr_nonideal;
@ -201,7 +201,7 @@ doublereal RedlichKwongMFTP::cp_mole() const
doublereal mv = molarVolume();
doublereal vpb = mv + m_b_current;
pressureDerivatives();
doublereal cpref = GasConstant * mean_X(DATA_PTR(m_cp0_R));
doublereal cpref = GasConstant * mean_X(m_cp0_R);
doublereal dadt = da_dt();
doublereal fac = TKelvin * dadt - 3.0 * m_a_current / 2.0;
doublereal dHdT_V = (cpref + mv * dpdT_ - GasConstant - 1.0 / (2.0 * m_b_current * TKelvin * sqt) * log(vpb/mv) * fac

View file

@ -102,7 +102,7 @@ doublereal SurfPhase::enthalpy_mole() const
return 0.0;
}
_updateThermo();
return mean_X(DATA_PTR(m_h0));
return mean_X(m_h0);
}
doublereal SurfPhase::intEnergy_mole() const
@ -124,7 +124,7 @@ doublereal SurfPhase::entropy_mole() const
doublereal SurfPhase::cp_mole() const
{
_updateThermo();
return mean_X(&m_cp0[0]);
return mean_X(m_cp0);
}
doublereal SurfPhase::cv_mole() const