From 5b0d1234329b950e69c9a8f747f62861cc4b5707 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Mon, 13 May 2019 10:42:26 +0200 Subject: [PATCH] Fix #74 --- spec/structure/cloisons.spec.ts | 60 +++++++++++++++++++++++++++++++++ src/pab/pab_puissance.ts | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/spec/structure/cloisons.spec.ts b/spec/structure/cloisons.spec.ts index 9e52d240..6245b0bb 100644 --- a/spec/structure/cloisons.spec.ts +++ b/spec/structure/cloisons.spec.ts @@ -6,6 +6,7 @@ */ // import { describe, expect, it, xdescribe, xit } from "../mock_jasmine"; +import { ParamDefinition } from "../../src/index"; import { Cloisons } from "../../src/structure/cloisons"; import { CloisonsParams } from "../../src/structure/cloisons_params"; import { CreateStructure } from "../../src/structure/factory_structure"; @@ -41,6 +42,7 @@ const fente: StructureWeirSubmergedLarinier = new StructureWeirSubmergedLarinier cloisons.addChild(fente); describe("Class Cloisons: ", () => { + describe("Calc(Q) Fente noyée (Larinier 1992)", () => { it("vCalc should return 0.407", () => { expect(cloisons.Calc("Q").vCalc).toBeCloseTo(0.407, 3); @@ -82,4 +84,62 @@ describe("Class Cloisons: ", () => { expect(prmsKivi.ZRAM.v).toBeCloseTo(101, 3); }); }); + + describe("Calcul avec Calc - ", () => { + const descs = [ + "Q", + "Z1", + "DH" + ]; + for (const desc of descs) { + describe("calcul de " + JSON.stringify(desc), () => { + it("", () => { + expect(cloisons.Calc(desc).vCalc).toBeDefined(); + }); + }); + } + }); + + describe("Calcul avec CalcSerie - ", () => { + const descs = [ + "Q", + "Z1", + "DH", + { uid: fente.uid, symbol: "ZDV" }, + { uid: fente.uid, symbol: "L" }, + { uid: fente.uid, symbol: "Cd" } + ]; + for (const desc of descs) { + describe("calcul de " + JSON.stringify(desc), () => { + it("", () => { + expect(cloisons.CalcSerie(0, desc).vCalc).toBeDefined(); + }); + }); + } + }); + + describe("Calcul avec CalcSerie et calculatedParam - ", () => { + const descs = [ + "Q", + "Z1", + "DH", + { uid: fente.uid, symbol: "ZDV" }, + { uid: fente.uid, symbol: "L" }, + { uid: fente.uid, symbol: "Cd" } + ]; + for (const desc of descs) { + describe("calcul de " + JSON.stringify(desc), () => { + it("", () => { + let p: ParamDefinition; + if (typeof desc === "string") { + p = cloisons.getParameter(desc); + } else { + p = fente.getParameter(desc.symbol); + } + cloisons.calculatedParam = p; + expect(cloisons.CalcSerie().vCalc).toBeDefined(); + }); + }); + } + }); }); diff --git a/src/pab/pab_puissance.ts b/src/pab/pab_puissance.ts index 44368c50..460add1f 100644 --- a/src/pab/pab_puissance.ts +++ b/src/pab/pab_puissance.ts @@ -23,7 +23,7 @@ export class PabPuissanceParams extends ParamsEquation { constructor(rDH: number, rQ: number, rV: number, rPV?: number) { super(); this._DH = new ParamDefinition(this, "DH", ParamDomainValue.POS, rDH, ParamFamily.HEIGHTS); - this._Q = new ParamDefinition(this, "Q", ParamDomainValue.POS, rQ, ParamFamily.FLOWS); + this._Q = new ParamDefinition(this, "Q", ParamDomainValue.POS_NULL, rQ, ParamFamily.FLOWS); this._V = new ParamDefinition(this, "V", ParamDomainValue.POS, rV, ParamFamily.VOLUMES); this._PV = new ParamDefinition(this, "PV", ParamDomainValue.POS, rPV); -- GitLab