Unspecify the phase after the HP solver with Brent - test added

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-08-18 18:52:06 +02:00
parent 9293c6355c
commit 99da465b06
2 changed files with 41 additions and 4 deletions

View File

@@ -520,13 +520,16 @@ void FlashRoutines::HSU_P_flash_singlephase_Brent(HelmholtzEOSMixtureBackend &HE
int other;
int iter;
long double r0, r1, T1, T0, pp;
solver_resid(HelmholtzEOSMixtureBackend *HEOS, long double p, long double value, int other) : HEOS(HEOS), p(p), value(value), other(other){iter = 0;};
solver_resid(HelmholtzEOSMixtureBackend *HEOS, long double p, long double value, int other) :
HEOS(HEOS), p(p), value(value), other(other)
{
iter = 0;
// Specify the state to avoid saturation calls
HEOS->specify_phase(HEOS->phase());
};
double call(double T){
this->T = T;
// Specify the state to avoid saturation calls
HEOS->specify_phase(HEOS->phase());
// Run the solver with T,P as inputs;
HEOS->update(PT_INPUTS, p, T);
@@ -561,6 +564,9 @@ void FlashRoutines::HSU_P_flash_singlephase_Brent(HelmholtzEOSMixtureBackend &HE
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);
int rr = 4;
}

View File

@@ -793,6 +793,37 @@ TEST_CASE("Tests for solvers in P,Y flash using Water", "[flash],[PH],[PS],[PU]"
}
}
TEST_CASE("Tests for solvers in P,H flash using Propane", "[flashdups],[flash],[PH],[consistency]")
{
double hmolar, hmass;
SECTION("5 times PH with HEOS AbstractState yields same results every time","")
{
shared_ptr<CoolProp::AbstractState> AS(CoolProp::AbstractState::factory("HEOS", "n-Propane"));
CHECK_NOTHROW(AS->update(CoolProp::PT_INPUTS, 101325, 300));
hmolar = AS->hmolar();
hmass = AS->hmass();
CHECK_NOTHROW(AS->update(CoolProp::HmassP_INPUTS, hmass, 101325));
CHECK_NOTHROW(AS->update(CoolProp::HmolarP_INPUTS, hmolar, 101325));
hmolar = AS->hmolar();
hmass = AS->hmass();
CHECK_NOTHROW(AS->update(CoolProp::HmassP_INPUTS, hmass, 101325));
CHECK_NOTHROW(AS->update(CoolProp::HmolarP_INPUTS, hmolar, 101325));
hmolar = AS->hmolar();
hmass = AS->hmass();
CHECK_NOTHROW(AS->update(CoolProp::HmassP_INPUTS, hmass, 101325));
CHECK_NOTHROW(AS->update(CoolProp::HmolarP_INPUTS, hmolar, 101325));
hmolar = AS->hmolar();
hmass = AS->hmass();
CHECK_NOTHROW(AS->update(CoolProp::HmassP_INPUTS, hmass, 101325));
CHECK_NOTHROW(AS->update(CoolProp::HmolarP_INPUTS, hmolar, 101325));
hmolar = AS->hmolar();
hmass = AS->hmass();
CHECK_NOTHROW(AS->update(CoolProp::HmassP_INPUTS, hmass, 101325));
CHECK_NOTHROW(AS->update(CoolProp::HmolarP_INPUTS, hmolar, 101325));
}
}
//TEST_CASE("Test that states agree with CoolProp", "[states]")
//{
// std::vector<std::string> fluids = strsplit(CoolProp::get_global_param_string("fluids_list"),',');