Commit 1593583e authored by Grand Francois's avatar Grand Francois
Browse files

fix: NaN in CourbeRemous results due to negative Y values in Calc_Y_RK4()

refs #339
Showing with 4 additions and 4 deletions
+4 -4
...@@ -757,7 +757,7 @@ export class CourbeRemous extends SectionNub { ...@@ -757,7 +757,7 @@ export class CourbeRemous extends SectionNub {
} }
// let k2 = this.Calc_dYdX(Y + Dx / 2 * k1); // let k2 = this.Calc_dYdX(Y + Dx / 2 * k1);
const rDXDY2: Result = this.Calc_dYdX(Y + rDx / 2 * k1); const rDXDY2: Result = this.Calc_dYdX(Math.max(Y + rDx / 2 * k1, 0));
if (!rDXDY2.ok) { if (!rDXDY2.ok) {
return rDXDY2; return rDXDY2;
} }
...@@ -768,7 +768,7 @@ export class CourbeRemous extends SectionNub { ...@@ -768,7 +768,7 @@ export class CourbeRemous extends SectionNub {
} }
// let k3 = this.Calc_dYdX(Y + Dx / 2 * k2); // let k3 = this.Calc_dYdX(Y + Dx / 2 * k2);
const rDXDY3: Result = this.Calc_dYdX(Y + rDx / 2 * k2); const rDXDY3: Result = this.Calc_dYdX(Math.max(Y + rDx / 2 * k2, 0));
if (!rDXDY3.ok) { if (!rDXDY3.ok) {
return rDXDY3; return rDXDY3;
} }
...@@ -779,14 +779,14 @@ export class CourbeRemous extends SectionNub { ...@@ -779,14 +779,14 @@ export class CourbeRemous extends SectionNub {
} }
// let k4 = this.Calc_dYdX(Y + Dx * k3); // let k4 = this.Calc_dYdX(Y + Dx * k3);
const rDXDY4: Result = this.Calc_dYdX(Y + rDx * k3); const rDXDY4: Result = this.Calc_dYdX(Math.max(Y + rDx * k3, 0));
if (!rDXDY4.ok) { if (!rDXDY4.ok) {
return rDXDY4; return rDXDY4;
} }
const k4 = rDXDY4.vCalc; const k4 = rDXDY4.vCalc;
// tslint:disable-next-line:variable-name // tslint:disable-next-line:variable-name
const Yout = Y + rDx / 6 * (k1 + 2 * (k2 + k3) + k4); const Yout = Math.max(Y + rDx / 6 * (k1 + 2 * (k2 + k3) + k4), 0);
// if ($this ->rDx > 0 xor !($Yout < $this ->oSect ->rHautCritique)) { return false; } // if ($this ->rDx > 0 xor !($Yout < $this ->oSect ->rHautCritique)) { return false; }
if (XOR(rDx > 0, !(Yout < hc))) { if (XOR(rDx > 0, !(Yout < hc))) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment