From 6b9ffb8da2cfd9ea48d4fa5e2c4aeae4f156c149 Mon Sep 17 00:00:00 2001 From: "francois.grand" <francois.grand@irstea.fr> Date: Mon, 5 Feb 2018 14:53:46 +0100 Subject: [PATCH] =?UTF-8?q?ticket=20#36=20:=20modifs=20induites=20par=20le?= =?UTF-8?q?=20commit=20482226c=20sur=20dicchotomie/r=C3=A9gime=20uniforme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dichotomie.ts | 7 ++++++- src/regime_uniforme.ts | 26 ++++++++++++++++---------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/dichotomie.ts b/src/dichotomie.ts index 93c6676a..55e4b48a 100644 --- a/src/dichotomie.ts +++ b/src/dichotomie.ts @@ -245,7 +245,12 @@ export class Dichotomie extends Debug { } let intMax: Interval = new Interval(min, max); - intMax.checkValue(rInit); + try { + intMax.checkValue(rInit); + } + catch (m) { + return { ok: false, "res": m }; + } // initialisation de l'intervalle de recherche let intSearch: SearchInterval = new SearchInterval(this, rInit - step / 2, rInit + step / 2, step); diff --git a/src/regime_uniforme.ts b/src/regime_uniforme.ts index 5582c5e6..d1bd51e9 100644 --- a/src/regime_uniforme.ts +++ b/src/regime_uniforme.ts @@ -24,34 +24,40 @@ export class RegimeUniforme extends Nub { * Calcul du débit en régime uniforme. * @return Débit en régime uniforme */ - Calc_Qn(): number { + Calc_Qn(): Result { this.Sn.Reset(true); if (this.Sn.prms.If.v <= 0) - return 0; + return new Result(0); // this.debug("RU: Calc_Qn : "); // this.debug(this.Sn.prms); - return this.Sn.prms.Ks.v * Math.pow(this.Sn.Calc("R", this.Sn.prms.Y.v), 2 / 3) * this.Sn.Calc("S", this.Sn.prms.Y.v) * Math.sqrt(this.Sn.prms.If.v); + // return this.Sn.prms.Ks.v * Math.pow(this.Sn.Calc("R", this.Sn.prms.Y.v), 2 / 3) * this.Sn.Calc("S", this.Sn.prms.Y.v) * Math.sqrt(this.Sn.prms.If.v); + + const rR: Result = this.Sn.Calc("R", this.Sn.prms.Y.v); + if (!rR) + return rR; + + const rS: Result = this.Sn.Calc("S", this.Sn.prms.Y.v) + if (!rS) + return rS; + + const v = this.Sn.prms.Ks.v * Math.pow(rR.vCalc, 2 / 3) * rS.vCalc * Math.sqrt(this.Sn.prms.If.v); + return new Result(v); } Equation(sVarCalc: string): Result { this.debug("RU: Equation(" + sVarCalc + ")") - let v: number; switch (sVarCalc) { case 'Y': - v = this.Sn.Calc("Yn"); - break; + return this.Sn.Calc("Yn"); case 'Q': - v = this.Calc_Qn(); - break; + return this.Calc_Qn(); default: throw "RegimeUniforme.Equation() : invalid variable name " + sVarCalc; } - - return new Result(v); } } -- GitLab