mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-01 03:00:13 -04:00
When changing reference state, hs_anchor is updated, and ancillary curves still work!! woohoo
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
@@ -238,6 +238,9 @@ protected:
|
||||
virtual long double calc_cpmass(void){return cpmolar()/molar_mass();}
|
||||
virtual long double calc_cvmass(void){return cvmolar()/molar_mass();}
|
||||
virtual long double calc_umass(void){return umolar()/molar_mass();}
|
||||
|
||||
/// Update the states after having changed the reference state for enthalpy and entropy
|
||||
virtual void update_states(void){throw NotImplementedError("This backend does not implement update states function");};
|
||||
|
||||
public:
|
||||
|
||||
@@ -280,6 +283,8 @@ public:
|
||||
virtual void set_mass_fractions(const std::vector<long double> &mass_fractions) = 0;
|
||||
virtual void set_volu_fractions(const std::vector<long double> &mass_fractions){throw NotImplementedError("Volume composition has not been implemented.");}
|
||||
|
||||
|
||||
|
||||
/// Clear all the cached values
|
||||
bool clear();
|
||||
|
||||
|
||||
@@ -111,6 +111,20 @@ void HelmholtzEOSMixtureBackend::set_excess_term()
|
||||
{
|
||||
Excess.construct(components);
|
||||
}
|
||||
void HelmholtzEOSMixtureBackend::update_states(void)
|
||||
{
|
||||
CoolPropFluid &component = *(components[0]);
|
||||
EquationOfState &EOS = component.EOSVector[0];
|
||||
long double rho, T;
|
||||
// Clear the state class
|
||||
clear();
|
||||
// Calculate the new enthalpy and entropy values
|
||||
update(DmolarT_INPUTS, EOS.hs_anchor.rhomolar, EOS.hs_anchor.T);
|
||||
EOS.hs_anchor.hmolar = hmolar();
|
||||
EOS.hs_anchor.smolar = smolar();
|
||||
// Clear again just to be sure
|
||||
clear();
|
||||
}
|
||||
long double HelmholtzEOSMixtureBackend::calc_gas_constant(void)
|
||||
{
|
||||
double summer = 0;
|
||||
@@ -649,12 +663,6 @@ void HelmholtzEOSMixtureBackend::p_phase_determination_pure_or_pseudopure(int ot
|
||||
long double h_liq_error_band = component.ancillaries.hL.get_max_abs_error();
|
||||
long double h_vap = h_liq + component.ancillaries.hLV.evaluate(_TLanc);
|
||||
long double h_vap_error_band = h_liq_error_band + component.ancillaries.hLV.get_max_abs_error();
|
||||
|
||||
#ifdef DEBUG
|
||||
HelmholtzEOSMixtureBackend HEOS(components);
|
||||
HEOS.update(QT_INPUTS, 0, _TLanc);
|
||||
long double hh = HEOS.hmolar();
|
||||
#endif
|
||||
|
||||
// Check if in range given the accuracy of the fit
|
||||
if (value > h_vap + h_vap_error_band){
|
||||
@@ -674,12 +682,6 @@ void HelmholtzEOSMixtureBackend::p_phase_determination_pure_or_pseudopure(int ot
|
||||
long double s_vap = s_liq + component.ancillaries.sLV.evaluate(_TLanc);
|
||||
long double s_vap_error_band = s_liq_error_band + component.ancillaries.sLV.get_max_abs_error();
|
||||
|
||||
#ifdef DEBUG
|
||||
HelmholtzEOSMixtureBackend HEOS(components);
|
||||
HEOS.update(QT_INPUTS, 0, _TLanc);
|
||||
long double ss = HEOS.smolar();
|
||||
#endif
|
||||
|
||||
// Check if in range given the accuracy of the fit
|
||||
if (value > s_vap + s_vap_error_band){
|
||||
this->_phase = iphase_gas; _Q = -1000; return;
|
||||
|
||||
@@ -185,6 +185,8 @@ public:
|
||||
*/
|
||||
long double calc_first_partial_deriv_nocache(long double T, long double rhomolar, int Of, int Wrt, int Constant);
|
||||
|
||||
void update_states();
|
||||
|
||||
void mass_to_molar_inputs(long &input_pair, double &value1, double &value2);
|
||||
|
||||
// ***************************************************************
|
||||
@@ -195,6 +197,8 @@ public:
|
||||
void T_phase_determination_pure_or_pseudopure(int other, long double value);
|
||||
void p_phase_determination_pure_or_pseudopure(int other, long double value);
|
||||
void DmolarP_phase_determination();
|
||||
|
||||
|
||||
|
||||
|
||||
// ***************************************************************
|
||||
|
||||
@@ -718,6 +718,7 @@ void set_reference_stateS(std::string Ref, std::string reference_state)
|
||||
double delta_a1 = deltas/(8.314472/HEOS->molar_mass());
|
||||
double delta_a2 = -deltah/(8.314472/HEOS->molar_mass()*HEOS->get_reducing().T);
|
||||
HEOS->get_components()[0]->pEOS->alpha0.EnthalpyEntropyOffset.set(delta_a1, delta_a2, "IIR");
|
||||
HEOS->update_states();
|
||||
}
|
||||
else if (!reference_state.compare("ASHRAE"))
|
||||
{
|
||||
@@ -729,6 +730,7 @@ void set_reference_stateS(std::string Ref, std::string reference_state)
|
||||
double delta_a1 = deltas/(8.314472/HEOS->molar_mass());
|
||||
double delta_a2 = -deltah/(8.314472/HEOS->molar_mass()*HEOS->get_reducing().T);
|
||||
HEOS->get_components()[0]->pEOS->alpha0.EnthalpyEntropyOffset.set(delta_a1, delta_a2, "ASHRAE");
|
||||
HEOS->update_states();
|
||||
}
|
||||
else if (!reference_state.compare("NBP"))
|
||||
{
|
||||
@@ -740,6 +742,7 @@ void set_reference_stateS(std::string Ref, std::string reference_state)
|
||||
double delta_a1 = deltas/(8.314472/HEOS->molar_mass());
|
||||
double delta_a2 = -deltah/(8.314472/HEOS->molar_mass()*HEOS->get_reducing().T);
|
||||
HEOS->get_components()[0]->pEOS->alpha0.EnthalpyEntropyOffset.set(delta_a1, delta_a2, "NBP");
|
||||
HEOS->update_states();
|
||||
}
|
||||
else if (!reference_state.compare("DEF"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user