Really this time un-specify the phase

More logical debug output for invalid phases

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-08-18 19:26:31 +02:00
parent 39a99e183c
commit dd71b1ac22
3 changed files with 22 additions and 10 deletions

View File

@@ -563,10 +563,17 @@ void FlashRoutines::HSU_P_flash_singlephase_Brent(HelmholtzEOSMixtureBackend &HE
solver_resid resid(&HEOS, HEOS._p, value, other);
std::string errstr;
double T = Brent(resid, Tmin, Tmax, DBL_EPSILON, 1e-12, 100, errstr);
// Un-impose the phase of the fluid
HEOS.specify_phase(iphase_not_imposed);
try{
double T = Brent(resid, Tmin, Tmax, DBL_EPSILON, 1e-12, 100, errstr);
// Un-specify the phase of the fluid
HEOS.unspecify_phase();
}
catch(std::exception &e){
// Un-specify the phase of the fluid
HEOS.unspecify_phase();
throw;
}
int rr = 4;
}

View File

@@ -590,7 +590,7 @@ void HelmholtzEOSMixtureBackend::mass_to_molar_inputs(long &input_pair, double &
}
void HelmholtzEOSMixtureBackend::update(long input_pair, double value1, double value2 )
{
if (get_debug_level() > 0){std::cout << format("%s (%d): update called with (%d: (%s), %g, %g)",__FILE__,__LINE__, input_pair, get_input_pair_short_desc(input_pair).c_str(), value1, value2) << std::endl;}
if (get_debug_level() > 10){std::cout << format("%s (%d): update called with (%d: (%s), %g, %g)",__FILE__,__LINE__, input_pair, get_input_pair_short_desc(input_pair).c_str(), value1, value2) << std::endl;}
clear();
@@ -1688,7 +1688,7 @@ long double HelmholtzEOSMixtureBackend::calc_hmolar(void)
return static_cast<long double>(_hmolar);
}
else{
throw ValueError(format("phase is invalid"));
throw ValueError(format("phase is invalid in calc_hmolar"));
}
}
long double HelmholtzEOSMixtureBackend::calc_smolar_nocache(long double T, long double rhomolar)
@@ -1734,7 +1734,7 @@ long double HelmholtzEOSMixtureBackend::calc_smolar(void)
return static_cast<long double>(_smolar);
}
else{
throw ValueError(format("phase is invalid"));
throw ValueError(format("phase is invalid in calc_smolar"));
}
}
long double HelmholtzEOSMixtureBackend::calc_umolar_nocache(long double T, long double rhomolar)
@@ -1775,7 +1775,7 @@ long double HelmholtzEOSMixtureBackend::calc_umolar(void)
return static_cast<long double>(_umolar);
}
else{
throw ValueError(format("phase is invalid"));
throw ValueError(format("phase is invalid in calc_umolar"));
}
}
long double HelmholtzEOSMixtureBackend::calc_cvmolar(void)
@@ -1865,13 +1865,13 @@ long double HelmholtzEOSMixtureBackend::calc_gibbsmolar(void)
long double dar_dDelta = dalphar_dDelta();
long double R_u = gas_constant();
// Get molar entropy
// Get molar gibbs function
_gibbsmolar = R_u*_T*(1 + a0 + ar +_delta.pt()*dar_dDelta);
return static_cast<long double>(_gibbsmolar);
}
else{
throw ValueError(format("phase is invalid"));
throw ValueError(format("phase is invalid in calc_gibbsmolar"));
}
}
long double HelmholtzEOSMixtureBackend::calc_fugacity_coefficient(int i)

View File

@@ -74,6 +74,11 @@ public:
@param phase_index The index from CoolProp::phases
*/
void specify_phase(phases phase_index){imposed_phase_index = phase_index; _phase = phase_index;};
/**
\brief Unspecify the phase - the phase is no longer imposed, different solvers can do as they like
*/
void unspecify_phase(){imposed_phase_index = iphase_not_imposed;};
void set_reducing_function();
void set_excess_term();