mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Fixed (?) splines in critical region
I have no explanation for the broken code that used to be in the solve_cubic function. Seems it was related to the linear or quadratic cases but it makes no sense. Removed the code. Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
@@ -164,7 +164,7 @@ void solve_cubic(double a, double b, double c, double d, int &N, double &x0, dou
|
||||
{
|
||||
// 0 = ax^3 + b*x^2 + c*x + d
|
||||
|
||||
|
||||
// First check if the "cubic" is actually a second order or first order curve
|
||||
if (std::abs(a) < 10*DBL_EPSILON){
|
||||
if (std::abs(b) < 10*DBL_EPSILON){
|
||||
// Linear solution if a = 0 and b = 0
|
||||
@@ -185,26 +185,6 @@ void solve_cubic(double a, double b, double c, double d, int &N, double &x0, dou
|
||||
|
||||
// Discriminant
|
||||
double DELTA = 18*a*b*c*d-4*b*b*b*d+b*b*c*c-4*a*c*c*c-27*a*a*d*d;
|
||||
double DELTA0 = b*b*b-2*a*c;
|
||||
|
||||
// Deal with special cases
|
||||
if (std::abs(DELTA) < 10*DBL_EPSILON){
|
||||
if (std::abs(DELTA0)>0){
|
||||
x0 = (9*a*d-b*c)/(2*DELTA0);
|
||||
x1 = x0;
|
||||
x2 = (4*a*b*c - 9*a*a*d - b*b*b)/(a*DELTA0);
|
||||
N = 3;
|
||||
return;
|
||||
}
|
||||
else{
|
||||
x0 = -b/(3*a);
|
||||
x1 = x0;
|
||||
x2 = x0;
|
||||
N = 3;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Coefficients for the depressed cubic t^3+p*t+q = 0
|
||||
double p = (3*a*c-b*b)/(3*a*a);
|
||||
double q = (2*b*b*b-9*a*b*c+27*a*a*d)/(27*a*a*a);
|
||||
|
||||
Reference in New Issue
Block a user