D(T,P) falls back to Brent if can't get good solution with other solvers

A guaranteed solution if the solution domain made wide enough

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-08-10 21:39:09 +02:00
parent 8bd4227f38
commit ce5d8a919f

View File

@@ -1497,7 +1497,7 @@ long double HelmholtzEOSMixtureBackend::solver_rho_Tp(long double T, long double
catch(std::exception &)
{
try{
// Next we try with Secant method
// Next we try with Secant method shooting off from the guess value
double rhomolar = Secant(resid, rhomolar_guess, 0.0001*rhomolar_guess, 1e-8, 100, errstring);
if (!ValidNumber(rhomolar)){throw ValueError();}
return rhomolar;
@@ -1505,7 +1505,10 @@ long double HelmholtzEOSMixtureBackend::solver_rho_Tp(long double T, long double
catch(std::exception &)
{
try{
Secant(resid, rhomolar_guess, 0.0001*rhomolar_guess, 1e-8, 100, errstring);
// Next we try with a Brent method bounded solver since the function is 1-1
double rhomolar = Brent(resid, 0.1*rhomolar_guess, 2*rhomolar_guess,DBL_EPSILON,1e-8,100,errstring);
if (!ValidNumber(rhomolar)){throw ValueError();}
return rhomolar;
}
catch(...){