From c192196f747eeeda2207a40938c4d290e7089c48 Mon Sep 17 00:00:00 2001
From: Dorchies David <david.dorchies@irstea.fr>
Date: Thu, 16 Apr 2020 12:03:55 +0200
Subject: [PATCH] Fix #206 again. Good test and good correction (Hope so!)

---
 .../regime_uniforme/regime_uniforme_rect.spec.ts         | 9 +++++----
 spec/value_ref/value_ref_variable_extraresult.spec.ts    | 2 +-
 src/open-channel/regime_uniforme.ts                      | 4 ++--
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/spec/open-channel/regime_uniforme/regime_uniforme_rect.spec.ts b/spec/open-channel/regime_uniforme/regime_uniforme_rect.spec.ts
index 4204d341..9d2d70da 100644
--- a/spec/open-channel/regime_uniforme/regime_uniforme_rect.spec.ts
+++ b/spec/open-channel/regime_uniforme/regime_uniforme_rect.spec.ts
@@ -31,11 +31,12 @@ describe("Class RegimeUniforme / section rectangulaire :", () => {
             ruRect1 = generateRegimeUniforme(generateRectangularSection());
             SessionSettings.precision = 1E-7;
         })
-        for (const p of ruRect1.calculableParameters) {
-            it(`${p.symbol} should be ${p.singleValue}`, () => {
+        for (const p0 of ruRect1.calculableParameters) {
+            it(`${p0.symbol} should be ${p0.singleValue}`, () => {
+                const p = ruRect1.section.prms.get(p0.symbol);
                 const ref: number = p.singleValue;
-                p.singleValue = undefined;
-                p.initValue = 1e-8;
+                p.singleValue = 1e-8;
+                p.v = p.initValue;
                 ruRect1.calculatedParam = p;
                 checkResult(ruRect1.CalcSerie(), ref);
                 expect(ruRect1.result.values.V).toBeCloseTo(0.784, 3);
diff --git a/spec/value_ref/value_ref_variable_extraresult.spec.ts b/spec/value_ref/value_ref_variable_extraresult.spec.ts
index 2a8195fe..942c529c 100644
--- a/spec/value_ref/value_ref_variable_extraresult.spec.ts
+++ b/spec/value_ref/value_ref_variable_extraresult.spec.ts
@@ -33,7 +33,7 @@ describe("référence d'un paramètre à un résultat complémentaire multivalu
         nub2.prms.V0.defineReference(nub1, "V");
         nub2.CalcSerie();
 
-        const refVals = [ 2.177, 2.011, 1.878, 1.769, 1.677, 1.598, 1.530, 1.469, 1.415, 1.367, 1.324 ];
+        const refVals = [ 0.554, 0.574, 0.590, 0.602, 0.613, 0.622, 0.630, 0.636, 0.642, 0.647, 0.652 ];
 
         let i = 0;
         for (const v of nub2.getParameter("V0").valueList) {
diff --git a/src/open-channel/regime_uniforme.ts b/src/open-channel/regime_uniforme.ts
index 857622bc..58593617 100644
--- a/src/open-channel/regime_uniforme.ts
+++ b/src/open-channel/regime_uniforme.ts
@@ -107,8 +107,8 @@ export class RegimeUniforme extends SectionNub {
             return rS;
         }
 
-        const v = this.section.prms.Ks.v * Math.pow(rR.vCalc, 2 / 3) * rS.vCalc * Math.sqrt(this.section.prms.If.v);
-        return new Result(v, this);
+        this.section.prms.Q.v = this.section.prms.Ks.v * Math.pow(rR.vCalc, 2 / 3) * rS.vCalc * Math.sqrt(this.section.prms.If.v);
+        return new Result(this.section.prms.Q.v, this);
     }
 
 }
-- 
GitLab