diff --git a/src/prebarrage/pre_barrage.ts b/src/prebarrage/pre_barrage.ts index 49a40966175d904d11b11ea0438e1f50fe067b7f..79719f20578144d5cffa4f77706ab911ecbdf789 100644 --- a/src/prebarrage/pre_barrage.ts +++ b/src/prebarrage/pre_barrage.ts @@ -15,6 +15,7 @@ export class PreBarrage extends Nub { /** Liste des cloisons amont */ private _cloisonsAmont: PbCloison[]; + // public pour pouvoir le modifier depuis les tests public maxIterations: number; /** Pointeurs vers les bassins dans this.children */ @@ -31,7 +32,6 @@ export class PreBarrage extends Nub { this.setCalculatorType(CalculatorType.PreBarrage); this._cloisonsAmont = []; this._bassins = []; - this.maxIterations = SessionSettings.maxIterations; //this._intlType = "Cloison"; } @@ -359,6 +359,11 @@ export class PreBarrage extends Nub { * @param sVarCalc ignoré: Z1 uniquement */ public Equation(sVarCalc: string): Result { + const maxIter = this.maxIterations !== undefined ? this.maxIterations : SessionSettings.maxIterations; + if (maxIter === undefined || maxIter < 1) { + throw new Error("invalid iteration count"); + } + // Initialisation des cotes sur les bassins et la CL amont if (this.isMeshed()) { for(const b of this.bassins) { @@ -385,13 +390,13 @@ export class PreBarrage extends Nub { } } } - let iter: number = this.maxIterations; + let iter: number = maxIter; let bConverged; let z1stat: IPbBassinZstat; // const tZ1: IPbBassinZstat[] = []; // const tQ: number[][] = []; while (iter-- > 0) { - this._relax = Math.pow(iter / this.maxIterations, 3) * 0.25 + 0.05; + this._relax = Math.pow(iter / maxIter, 3) * 0.25 + 0.05; this.debug(`***** Iteration n°${iter} relax=${this._relax} *****`); bConverged = true; if (this.isMeshed()) {