diff --git a/src/open-channel/remous.ts b/src/open-channel/remous.ts index 2e2f15a8031fce2e5c5087d6706383ae3df67570..7eab9c0c23ed1d8b7e9691b29f30874fd70dd649 100644 --- a/src/open-channel/remous.ts +++ b/src/open-channel/remous.ts @@ -757,7 +757,7 @@ export class CourbeRemous extends SectionNub { } // 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) { return rDXDY2; } @@ -768,7 +768,7 @@ export class CourbeRemous extends SectionNub { } // 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) { return rDXDY3; } @@ -779,14 +779,14 @@ export class CourbeRemous extends SectionNub { } // 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) { return rDXDY4; } const k4 = rDXDY4.vCalc; // 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 (XOR(rDx > 0, !(Yout < hc))) {