WIP on additional caching.
I'll convert this over to the new caching framework once Ray adds it.
This commit is contained in:
parent
3eba9641ab
commit
2b92ad5684
2 changed files with 52 additions and 37 deletions
|
|
@ -1487,6 +1487,7 @@ protected:
|
||||||
* member of the ThermoPhase base class.
|
* member of the ThermoPhase base class.
|
||||||
*/
|
*/
|
||||||
void calcDensity();
|
void calcDensity();
|
||||||
|
mutable bool m_density_valid;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Returns the current value of the density
|
//! Returns the current value of the density
|
||||||
|
|
@ -3172,7 +3173,7 @@ private:
|
||||||
* natural logarithm of the molality activity coefficients
|
* natural logarithm of the molality activity coefficients
|
||||||
*/
|
*/
|
||||||
void s_update_lnMolalityActCoeff() const;
|
void s_update_lnMolalityActCoeff() const;
|
||||||
mutable bool s_update_lnMolalityActCoeff_valid;
|
mutable bool m_s_update_lnMolalityActCoeff_valid;
|
||||||
|
|
||||||
//! This function calculates the temperature derivative of the
|
//! This function calculates the temperature derivative of the
|
||||||
//! natural logarithm of the molality activity coefficients.
|
//! natural logarithm of the molality activity coefficients.
|
||||||
|
|
@ -3181,7 +3182,7 @@ private:
|
||||||
* coefficient is on the molality scale. It's derivative is too.
|
* coefficient is on the molality scale. It's derivative is too.
|
||||||
*/
|
*/
|
||||||
void s_update_dlnMolalityActCoeff_dT() const;
|
void s_update_dlnMolalityActCoeff_dT() const;
|
||||||
mutable bool s_update_dlnMolalityActCoeff_dT_valid;
|
mutable bool m_s_update_dlnMolalityActCoeff_dT_valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function calculates the temperature second derivative
|
* This function calculates the temperature second derivative
|
||||||
|
|
@ -3189,7 +3190,7 @@ private:
|
||||||
* coefficients.
|
* coefficients.
|
||||||
*/
|
*/
|
||||||
void s_update_d2lnMolalityActCoeff_dT2() const;
|
void s_update_d2lnMolalityActCoeff_dT2() const;
|
||||||
mutable bool s_update_d2lnMolalityActCoeff_dT2_valid;
|
mutable bool m_s_update_d2lnMolalityActCoeff_dT2_valid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function calculates the pressure derivative of the
|
* This function calculates the pressure derivative of the
|
||||||
|
|
@ -3198,7 +3199,7 @@ private:
|
||||||
* Assumes that the activity coefficients are current.
|
* Assumes that the activity coefficients are current.
|
||||||
*/
|
*/
|
||||||
void s_update_dlnMolalityActCoeff_dP() const;
|
void s_update_dlnMolalityActCoeff_dP() const;
|
||||||
mutable bool s_update_dlnMolalityActCoeff_dP_valid;
|
mutable bool m_s_update_dlnMolalityActCoeff_dP_valid;
|
||||||
|
|
||||||
//! This function will be called to update the internally stored
|
//! This function will be called to update the internally stored
|
||||||
//! natural logarithm of the molality activity coefficients
|
//! natural logarithm of the molality activity coefficients
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ namespace Cantera
|
||||||
|
|
||||||
HMWSoln::HMWSoln() :
|
HMWSoln::HMWSoln() :
|
||||||
MolalityVPSSTP(),
|
MolalityVPSSTP(),
|
||||||
|
m_density_valid(false),
|
||||||
m_formPitzer(PITZERFORM_BASE),
|
m_formPitzer(PITZERFORM_BASE),
|
||||||
m_formPitzerTemp(PITZER_TEMP_CONSTANT),
|
m_formPitzerTemp(PITZER_TEMP_CONSTANT),
|
||||||
m_formGC(2),
|
m_formGC(2),
|
||||||
|
|
@ -73,10 +74,10 @@ HMWSoln::HMWSoln() :
|
||||||
CROP_ln_gamma_o_max(3.0),
|
CROP_ln_gamma_o_max(3.0),
|
||||||
CROP_ln_gamma_k_min(-5.0),
|
CROP_ln_gamma_k_min(-5.0),
|
||||||
CROP_ln_gamma_k_max(15.0),
|
CROP_ln_gamma_k_max(15.0),
|
||||||
s_update_lnMolalityActCoeff_valid(false),
|
m_s_update_lnMolalityActCoeff_valid(false),
|
||||||
s_update_dlnMolalityActCoeff_dT_valid(false),
|
m_s_update_dlnMolalityActCoeff_dT_valid(false),
|
||||||
s_update_d2lnMolalityActCoeff_dT2_valid(false),
|
m_s_update_d2lnMolalityActCoeff_dT2_valid(false),
|
||||||
s_update_dlnMolalityActCoeff_dP_valid(false),
|
m_s_update_dlnMolalityActCoeff_dP_valid(false),
|
||||||
m_last_is(-1.0),
|
m_last_is(-1.0),
|
||||||
m_debugCalc(0)
|
m_debugCalc(0)
|
||||||
{
|
{
|
||||||
|
|
@ -88,6 +89,7 @@ HMWSoln::HMWSoln() :
|
||||||
|
|
||||||
HMWSoln::HMWSoln(const std::string& inputFile, const std::string& id_) :
|
HMWSoln::HMWSoln(const std::string& inputFile, const std::string& id_) :
|
||||||
MolalityVPSSTP(),
|
MolalityVPSSTP(),
|
||||||
|
m_density_valid(false),
|
||||||
m_formPitzer(PITZERFORM_BASE),
|
m_formPitzer(PITZERFORM_BASE),
|
||||||
m_formPitzerTemp(PITZER_TEMP_CONSTANT),
|
m_formPitzerTemp(PITZER_TEMP_CONSTANT),
|
||||||
m_formGC(2),
|
m_formGC(2),
|
||||||
|
|
@ -131,10 +133,10 @@ HMWSoln::HMWSoln(const std::string& inputFile, const std::string& id_) :
|
||||||
CROP_ln_gamma_o_max(3.0),
|
CROP_ln_gamma_o_max(3.0),
|
||||||
CROP_ln_gamma_k_min(-5.0),
|
CROP_ln_gamma_k_min(-5.0),
|
||||||
CROP_ln_gamma_k_max(15.0),
|
CROP_ln_gamma_k_max(15.0),
|
||||||
s_update_lnMolalityActCoeff_valid(false),
|
m_s_update_lnMolalityActCoeff_valid(false),
|
||||||
s_update_dlnMolalityActCoeff_dT_valid(false),
|
m_s_update_dlnMolalityActCoeff_dT_valid(false),
|
||||||
s_update_d2lnMolalityActCoeff_dT2_valid(false),
|
m_s_update_d2lnMolalityActCoeff_dT2_valid(false),
|
||||||
s_update_dlnMolalityActCoeff_dP_valid(false),
|
m_s_update_dlnMolalityActCoeff_dP_valid(false),
|
||||||
m_last_is(-1.0),
|
m_last_is(-1.0),
|
||||||
m_debugCalc(0)
|
m_debugCalc(0)
|
||||||
{
|
{
|
||||||
|
|
@ -147,6 +149,7 @@ HMWSoln::HMWSoln(const std::string& inputFile, const std::string& id_) :
|
||||||
|
|
||||||
HMWSoln::HMWSoln(XML_Node& phaseRoot, const std::string& id_) :
|
HMWSoln::HMWSoln(XML_Node& phaseRoot, const std::string& id_) :
|
||||||
MolalityVPSSTP(),
|
MolalityVPSSTP(),
|
||||||
|
m_density_valid(false),
|
||||||
m_formPitzer(PITZERFORM_BASE),
|
m_formPitzer(PITZERFORM_BASE),
|
||||||
m_formPitzerTemp(PITZER_TEMP_CONSTANT),
|
m_formPitzerTemp(PITZER_TEMP_CONSTANT),
|
||||||
m_formGC(2),
|
m_formGC(2),
|
||||||
|
|
@ -190,10 +193,10 @@ HMWSoln::HMWSoln(XML_Node& phaseRoot, const std::string& id_) :
|
||||||
CROP_ln_gamma_o_max(3.0),
|
CROP_ln_gamma_o_max(3.0),
|
||||||
CROP_ln_gamma_k_min(-5.0),
|
CROP_ln_gamma_k_min(-5.0),
|
||||||
CROP_ln_gamma_k_max(15.0),
|
CROP_ln_gamma_k_max(15.0),
|
||||||
s_update_lnMolalityActCoeff_valid(false),
|
m_s_update_lnMolalityActCoeff_valid(false),
|
||||||
s_update_dlnMolalityActCoeff_dT_valid(false),
|
m_s_update_dlnMolalityActCoeff_dT_valid(false),
|
||||||
s_update_d2lnMolalityActCoeff_dT2_valid(false),
|
m_s_update_d2lnMolalityActCoeff_dT2_valid(false),
|
||||||
s_update_dlnMolalityActCoeff_dP_valid(false),
|
m_s_update_dlnMolalityActCoeff_dP_valid(false),
|
||||||
m_last_is(-1.0),
|
m_last_is(-1.0),
|
||||||
m_debugCalc(0)
|
m_debugCalc(0)
|
||||||
{
|
{
|
||||||
|
|
@ -206,6 +209,7 @@ HMWSoln::HMWSoln(XML_Node& phaseRoot, const std::string& id_) :
|
||||||
|
|
||||||
HMWSoln::HMWSoln(const HMWSoln& b) :
|
HMWSoln::HMWSoln(const HMWSoln& b) :
|
||||||
MolalityVPSSTP(),
|
MolalityVPSSTP(),
|
||||||
|
m_density_valid(false),
|
||||||
m_formPitzer(PITZERFORM_BASE),
|
m_formPitzer(PITZERFORM_BASE),
|
||||||
m_formPitzerTemp(PITZER_TEMP_CONSTANT),
|
m_formPitzerTemp(PITZER_TEMP_CONSTANT),
|
||||||
m_formGC(2),
|
m_formGC(2),
|
||||||
|
|
@ -249,10 +253,10 @@ HMWSoln::HMWSoln(const HMWSoln& b) :
|
||||||
CROP_ln_gamma_o_max(3.0),
|
CROP_ln_gamma_o_max(3.0),
|
||||||
CROP_ln_gamma_k_min(-5.0),
|
CROP_ln_gamma_k_min(-5.0),
|
||||||
CROP_ln_gamma_k_max(15.0),
|
CROP_ln_gamma_k_max(15.0),
|
||||||
s_update_lnMolalityActCoeff_valid(false),
|
m_s_update_lnMolalityActCoeff_valid(false),
|
||||||
s_update_dlnMolalityActCoeff_dT_valid(false),
|
m_s_update_dlnMolalityActCoeff_dT_valid(false),
|
||||||
s_update_d2lnMolalityActCoeff_dT2_valid(false),
|
m_s_update_d2lnMolalityActCoeff_dT2_valid(false),
|
||||||
s_update_dlnMolalityActCoeff_dP_valid(false),
|
m_s_update_dlnMolalityActCoeff_dP_valid(false),
|
||||||
m_last_is(-1.0),
|
m_last_is(-1.0),
|
||||||
m_debugCalc(0)
|
m_debugCalc(0)
|
||||||
{
|
{
|
||||||
|
|
@ -424,6 +428,7 @@ operator=(const HMWSoln& b)
|
||||||
|
|
||||||
HMWSoln::HMWSoln(int testProb) :
|
HMWSoln::HMWSoln(int testProb) :
|
||||||
MolalityVPSSTP(),
|
MolalityVPSSTP(),
|
||||||
|
m_density_valid(false),
|
||||||
m_formPitzer(PITZERFORM_BASE),
|
m_formPitzer(PITZERFORM_BASE),
|
||||||
m_formPitzerTemp(PITZER_TEMP_CONSTANT),
|
m_formPitzerTemp(PITZER_TEMP_CONSTANT),
|
||||||
m_formGC(2),
|
m_formGC(2),
|
||||||
|
|
@ -467,10 +472,10 @@ HMWSoln::HMWSoln(int testProb) :
|
||||||
CROP_ln_gamma_o_max(3.0),
|
CROP_ln_gamma_o_max(3.0),
|
||||||
CROP_ln_gamma_k_min(-5.0),
|
CROP_ln_gamma_k_min(-5.0),
|
||||||
CROP_ln_gamma_k_max(15.0),
|
CROP_ln_gamma_k_max(15.0),
|
||||||
s_update_lnMolalityActCoeff_valid(false),
|
m_s_update_lnMolalityActCoeff_valid(false),
|
||||||
s_update_dlnMolalityActCoeff_dT_valid(false),
|
m_s_update_dlnMolalityActCoeff_dT_valid(false),
|
||||||
s_update_d2lnMolalityActCoeff_dT2_valid(false),
|
m_s_update_d2lnMolalityActCoeff_dT2_valid(false),
|
||||||
s_update_dlnMolalityActCoeff_dP_valid(false),
|
m_s_update_dlnMolalityActCoeff_dP_valid(false),
|
||||||
m_last_is(-1.0),
|
m_last_is(-1.0),
|
||||||
m_debugCalc(0)
|
m_debugCalc(0)
|
||||||
{
|
{
|
||||||
|
|
@ -716,6 +721,10 @@ void HMWSoln::setPressure(doublereal p)
|
||||||
|
|
||||||
void HMWSoln::calcDensity()
|
void HMWSoln::calcDensity()
|
||||||
{
|
{
|
||||||
|
if( m_density_valid ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_density_valid = true;
|
||||||
double* vbar = &m_pp[0];
|
double* vbar = &m_pp[0];
|
||||||
getPartialMolarVolumes(vbar);
|
getPartialMolarVolumes(vbar);
|
||||||
double* x = &m_tmpV[0];
|
double* x = &m_tmpV[0];
|
||||||
|
|
@ -775,13 +784,17 @@ void HMWSoln::setState_TP(doublereal temp, doublereal pres)
|
||||||
/*
|
/*
|
||||||
* Store the current pressure
|
* Store the current pressure
|
||||||
*/
|
*/
|
||||||
m_Pcurrent = pres;
|
if(m_Pcurrent != pres) {
|
||||||
|
m_Pcurrent = pres;
|
||||||
|
invalidateCachedDataOnStateChange(PRESSURE);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* update the standard state thermo
|
* update the standard state thermo
|
||||||
* -> This involves calling the water function and setting the pressure
|
* -> This involves calling the water function and setting the pressure
|
||||||
*/
|
*/
|
||||||
updateStandardStateThermo();
|
updateStandardStateThermo();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Store the internal density of the water SS.
|
* Store the internal density of the water SS.
|
||||||
* Note, we would have to do this for all other
|
* Note, we would have to do this for all other
|
||||||
|
|
@ -1359,10 +1372,10 @@ void HMWSoln::initLengths()
|
||||||
|
|
||||||
void HMWSoln::s_update_lnMolalityActCoeff() const
|
void HMWSoln::s_update_lnMolalityActCoeff() const
|
||||||
{
|
{
|
||||||
if(s_update_lnMolalityActCoeff_valid) {
|
if(m_s_update_lnMolalityActCoeff_valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s_update_lnMolalityActCoeff_valid = true;
|
m_s_update_lnMolalityActCoeff_valid = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate the molalities. Currently, the molalities
|
* Calculate the molalities. Currently, the molalities
|
||||||
|
|
@ -2944,10 +2957,10 @@ s_updatePitzer_lnMolalityActCoeff() const
|
||||||
|
|
||||||
void HMWSoln::s_update_dlnMolalityActCoeff_dT() const
|
void HMWSoln::s_update_dlnMolalityActCoeff_dT() const
|
||||||
{
|
{
|
||||||
if(s_update_dlnMolalityActCoeff_dT_valid) {
|
if(m_s_update_dlnMolalityActCoeff_dT_valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s_update_dlnMolalityActCoeff_dT_valid = true;
|
m_s_update_dlnMolalityActCoeff_dT_valid = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Zero the unscaled 2nd derivatives
|
* Zero the unscaled 2nd derivatives
|
||||||
|
|
@ -3798,10 +3811,10 @@ void HMWSoln::s_updatePitzer_dlnMolalityActCoeff_dT() const
|
||||||
|
|
||||||
void HMWSoln::s_update_d2lnMolalityActCoeff_dT2() const
|
void HMWSoln::s_update_d2lnMolalityActCoeff_dT2() const
|
||||||
{
|
{
|
||||||
if(s_update_d2lnMolalityActCoeff_dT2_valid) {
|
if(m_s_update_d2lnMolalityActCoeff_dT2_valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s_update_d2lnMolalityActCoeff_dT2_valid = true;
|
m_s_update_d2lnMolalityActCoeff_dT2_valid = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Zero the unscaled 2nd derivatives
|
* Zero the unscaled 2nd derivatives
|
||||||
|
|
@ -4657,10 +4670,10 @@ void HMWSoln::s_updatePitzer_d2lnMolalityActCoeff_dT2() const
|
||||||
|
|
||||||
void HMWSoln::s_update_dlnMolalityActCoeff_dP() const
|
void HMWSoln::s_update_dlnMolalityActCoeff_dP() const
|
||||||
{
|
{
|
||||||
if(s_update_dlnMolalityActCoeff_dP_valid) {
|
if(m_s_update_dlnMolalityActCoeff_dP_valid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s_update_dlnMolalityActCoeff_dP_valid = true;
|
m_s_update_dlnMolalityActCoeff_dP_valid = true;
|
||||||
m_dlnActCoeffMolaldP_Unscaled.assign(m_kk, 0.0);
|
m_dlnActCoeffMolaldP_Unscaled.assign(m_kk, 0.0);
|
||||||
s_updatePitzer_dlnMolalityActCoeff_dP();
|
s_updatePitzer_dlnMolalityActCoeff_dP();
|
||||||
|
|
||||||
|
|
@ -5884,10 +5897,11 @@ void HMWSoln::invalidateCachedDataOnStateChange(StateVariable changed_var)
|
||||||
m_A_Debye_valid = false;
|
m_A_Debye_valid = false;
|
||||||
m_dA_DebyedP_TP_valid = false;
|
m_dA_DebyedP_TP_valid = false;
|
||||||
}
|
}
|
||||||
s_update_lnMolalityActCoeff_valid = false;
|
m_density_valid = false;
|
||||||
s_update_dlnMolalityActCoeff_dT_valid = false;
|
m_s_update_lnMolalityActCoeff_valid = false;
|
||||||
s_update_d2lnMolalityActCoeff_dT2_valid = false;
|
m_s_update_dlnMolalityActCoeff_dT_valid = false;
|
||||||
s_update_dlnMolalityActCoeff_dP_valid = false;
|
m_s_update_d2lnMolalityActCoeff_dT2_valid = false;
|
||||||
|
m_s_update_dlnMolalityActCoeff_dP_valid = false;
|
||||||
MolalityVPSSTP::invalidateCachedDataOnStateChange(changed_var);
|
MolalityVPSSTP::invalidateCachedDataOnStateChange(changed_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue