diff --git a/spec/mock_jasmine.ts b/spec/mock_jasmine.ts
index acb2b503f4896e06cc625e3af4e671d86f6a8d80..8f03ee968fd9695c3b0ce6b1619a724d6b577bfb 100644
--- a/spec/mock_jasmine.ts
+++ b/spec/mock_jasmine.ts
@@ -1,10 +1,10 @@
+// tslint:disable:no-console
/**
* Mock fonction describe de Jasmine
* @param sTxt Texte de la suite de test
* @param fFun Fonction de la suite de test
*/
export function describe(sTxt: string, fFun: () => void) {
- // tslint:disable-next-line:no-console
console.log(sTxt);
fFun();
}
@@ -15,7 +15,6 @@ export function describe(sTxt: string, fFun: () => void) {
* @param fFun Fonction de la suite de test
*/
export function xdescribe(sTxt: string, fFun: () => void) {
- // tslint:disable-next-line:no-console
console.log(sTxt + " ignored ***");
}
@@ -25,7 +24,6 @@ export function xdescribe(sTxt: string, fFun: () => void) {
* @param fFun Function à lancer pour la spec
*/
export function it(sTxt: string, fFun: () => void) {
- // tslint:disable-next-line:no-console
console.log(sTxt);
fFun();
}
@@ -52,7 +50,6 @@ class Expect {
const delta = Math.abs(expected - this.actual);
const maxDelta = Math.pow(10, -precision) / 2;
if (Math.round(delta * pow) / pow > maxDelta) {
- // tslint:disable-next-line:no-console
console.error("Expected " + this.actual + " to be close to " + expected + "," + precision);
}
return this;
@@ -64,8 +61,9 @@ class Expect {
*/
public toBe(expected: any) {
const res = this.actual === expected;
- if (!res)
+ if (!res) {
console.error("Error : expected " + this.actual + " to be " + expected);
+ }
return res;
}
@@ -75,8 +73,9 @@ class Expect {
*/
public toEqual(expected: any) {
const res = this.actual === expected;
- if (!res)
- console.error("Error : expected " + this.actual + " to be equal to " + expected);
+ if (!res) {
+ console.warn("Warning : test 'to be equal to' not tested");
+ }
return res;
}
@@ -85,8 +84,9 @@ class Expect {
* @param message message d'erreur
*/
public toBeTruthy(message: string) {
- if (!this.actual)
+ if (!this.actual) {
console.error(message);
+ }
}
/**
@@ -94,8 +94,9 @@ class Expect {
* @param message message d'erreur
*/
public toBeFalsy(message: string) {
- if (this.actual)
+ if (this.actual) {
console.error(message);
+ }
}
}
diff --git a/spec/structure/rectangular_structure.ts b/spec/structure/rectangular_structure.ts
index e960a7135be139759e2677ced7a28866cb055f16..a55774991cd3e5994d151cb9d9a4b94c07b1f703 100644
--- a/spec/structure/rectangular_structure.ts
+++ b/spec/structure/rectangular_structure.ts
@@ -1,9 +1,13 @@
-// tslint:disable-next-line:no-reference
-/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
+/**
+ * IMPORTANT !
+ * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine")
+ * Pour exécuter ce code dans le débugger.
+ */
+// import { describe, expect, it, xdescribe } from "../mock_jasmine";
-import { Result } from "../../src/util/result";
import { RectangularStructure } from "../../src/structure/rectangular_structure";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
+import { Result } from "../../src/util/result";
import { precDigits } from "../test_config";
/**
@@ -23,27 +27,27 @@ export class Describer {
}
export function itCalcQ(
- struct: RectangularStructure, h1: number, W: number, Q: number,
+ struct: RectangularStructure, Z1: number, W: number, Q: number,
mode?: StructureFlowMode, regime?: StructureFlowRegime) {
- struct.debug("itCalQ " + Describer.getName(struct) + " h1=" + h1 + " W=" + W + " Q=" + Q);
+ struct.debug("itCalQ " + Describer.getName(struct) + " Z1=" + Z1 + " W=" + W + " Q=" + Q);
- struct.prms.h1.v = h1;
+ struct.prms.Z1.v = Z1;
struct.prms.W.v = W;
const res: Result = struct.Calc("Q");
struct.debug("struct.Calc(Q)=" + res.vCalc);
- it("Q(h1=" + h1 + ",W=" + W + ") should be " + Q, () => {
+ it("Q(Z1=" + Z1 + ",W=" + W + ") should be " + Q, () => {
struct.debug("struct.Calc(Q)=" + res.vCalc);
expect(res.vCalc).toBeCloseTo(Q, precDigits);
});
if (mode !== undefined) {
- it("Q(h1=" + h1 + ",W=" + W + ") Mode should be " + mode, () => {
+ it("Q(Z1=" + Z1 + ",W=" + W + ") Mode should be " + mode, () => {
expect(res.extraVar.Mode).toBe(mode);
});
}
if (regime !== undefined) {
- it("Q(h1=" + h1 + ",W=" + W + ") Regime should be " + regime, () => {
+ it("Q(Z1=" + Z1 + ",W=" + W + ") Regime should be " + regime, () => {
expect(res.extraVar.Regime).toBe(regime);
});
}
diff --git a/spec/structure/structure.spec.ts b/spec/structure/structure.spec.ts
index 1c764d056c924e95878ba26b401b06fb0f8b9e63..53e0a6741aa47e9d21e231284d2e087e76e879bf 100644
--- a/spec/structure/structure.spec.ts
+++ b/spec/structure/structure.spec.ts
@@ -1,8 +1,13 @@
-// tslint:disable-next-line:no-reference
-/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
+/**
+ * IMPORTANT !
+ * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine")
+ * Pour exécuter ce code dans le débugger.
+ * Faire de même avec le fichier test_func.ts
+ */
+// import { describe, expect, it, xdescribe } from "../mock_jasmine";
-import { Result } from "../../src/util/result";
import { Structure, StructureFlowMode, StructureFlowRegime, StructureParams } from "../../src/structure/structure";
+import { Result } from "../../src/util/result";
import { checkResult } from "../test_func";
class StructureTest extends Structure {
@@ -15,6 +20,7 @@ class StructureTest extends Structure {
* Test of getFlowMode
*/
public testGetFlowMode() {
+ this.prms.update_h1h2();
return this.getFlowMode();
}
@@ -22,24 +28,19 @@ class StructureTest extends Structure {
* Test of getFlowRegime
*/
public testGetFlowRegime() {
+ this.prms.update_h1h2();
return this.getFlowRegime();
}
public Equation(sVarCalc: string): Result {
- let v: number;
- switch (sVarCalc) {
- case "Q":
- v = this.prms.h1.v - this.prms.h2.v;
- break;
- default:
- throw new Error("StructureTest.Equation() : invalid parameter name " + sVarCalc);
- }
- return new Result(v);
+ this.prms.update_h1h2();
+ this.CheckEquation(sVarCalc);
+ return new Result(this.prms.Z1.v - this.prms.Z2.v);
}
}
-const structTestPrm: StructureParams = new StructureParams(1, 30, 15);
+const structTestPrm: StructureParams = new StructureParams(1, 0, 30, 15);
const structTest: StructureTest = new StructureTest(structTestPrm, false);
describe("Class Structure: ", () => {
@@ -60,30 +61,30 @@ describe("Class Structure: ", () => {
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.FREE);
});
it("Flow Regime should be SUBMERGED (WEIR)", () => {
- structTest.prms.h2.v = 21;
+ structTest.prms.Z2.v = 21;
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.SUBMERGED);
});
it("Flow Regime should be PARTIAL (ORIFICE)", () => {
- structTest.prms.h2.v = 21;
+ structTest.prms.Z2.v = 21;
structTest.prms.W.v = 15;
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.PARTIAL);
});
it("Flow Regime should be SUBMERGED (ORIFICE)", () => {
- structTest.prms.h2.v = 25;
+ structTest.prms.Z2.v = 25;
structTest.prms.W.v = 15;
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.SUBMERGED);
});
- structTest.prms.h2.v = 15;
+ structTest.prms.Z2.v = 15;
structTest.prms.W.v = Infinity;
});
describe("Calc()", () => {
const flagsNull = { Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL };
it("h1=h2 => Q=0", () => {
- structTest.prms.h2.v = structTest.prms.h1.v;
+ structTest.prms.Z2.v = structTest.prms.Z1.v;
checkResult(structTest.Calc("Q"), 0);
expect(structTest.Calc("Q").extraVar).toEqual(flagsNull);
- structTest.prms.h2.v = 15;
+ structTest.prms.Z2.v = 15;
});
it("W=0 => Q=0", () => {
structTest.prms.W.v = 0;
diff --git a/spec/structure/structure_cem88d.spec.ts b/spec/structure/structure_cem88d.spec.ts
index 779ee7423d1ff6d3781bd4c14bfde3f70556f469..42521b8d504b04cc5149adef88d7e86e4e575de7 100644
--- a/spec/structure/structure_cem88d.spec.ts
+++ b/spec/structure/structure_cem88d.spec.ts
@@ -1,12 +1,18 @@
-// tslint:disable-next-line:no-reference
-/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
+/**
+ * IMPORTANT !
+ * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine")
+ * Pour exécuter ce code dans le débugger.
+ * Faire de même avec le fichier rectangular_structure.ts
+ */
+// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureCem88d } from "../../src/structure/structure_cem88d";
+import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
-const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
+const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureCem88d = new StructureCem88d(structPrm, false);
describe("Class StructureCem88d: ", () => {
diff --git a/spec/structure/structure_cem88v.spec.ts b/spec/structure/structure_cem88v.spec.ts
index e7b440612f8ebfc0464817761bd8fbbe0a7ac042..fe40920cfa0a6637ecb83faf2ac32e0946b5e277 100644
--- a/spec/structure/structure_cem88v.spec.ts
+++ b/spec/structure/structure_cem88v.spec.ts
@@ -1,12 +1,18 @@
-// tslint:disable-next-line:no-reference
-/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
+/**
+ * IMPORTANT !
+ * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine")
+ * Pour exécuter ce code dans le débugger.
+ * Faire de même avec le fichier rectangular_structure.ts
+ */
+// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureCem88v } from "../../src/structure/structure_cem88v";
+import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
-const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
+const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureCem88v = new StructureCem88v(structPrm, false);
describe("Class StructureCem88v: ", () => {
diff --git a/spec/structure/structure_cunge80.spec.ts b/spec/structure/structure_cunge80.spec.ts
index 31fd7bb11e06a8c2fedadc99586edea3052bd6f0..0940fce515add3c730bd89b412ca0485aae88bf6 100644
--- a/spec/structure/structure_cunge80.spec.ts
+++ b/spec/structure/structure_cunge80.spec.ts
@@ -1,12 +1,18 @@
-// tslint:disable-next-line:no-reference
-/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
+/**
+ * IMPORTANT !
+ * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine")
+ * Pour exécuter ce code dans le débugger.
+ * Faire de même avec le fichier rectangular_structure.ts
+ */
+// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureCunge80 } from "../../src/structure/structure_cunge80";
+import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
-const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
+const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureCunge80 = new StructureCunge80(structPrm, false);
describe("Class StructureCunge80: ", () => {
diff --git a/spec/structure/structure_orifice_free.spec.ts b/spec/structure/structure_orifice_free.spec.ts
index 04323a813216e56b81fd778c45772ff35cf82cdc..0cefcda138e7e9ce69e938888858c6b059b26fae 100644
--- a/spec/structure/structure_orifice_free.spec.ts
+++ b/spec/structure/structure_orifice_free.spec.ts
@@ -1,12 +1,18 @@
-// tslint:disable-next-line:no-reference
-/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
+/**
+ * IMPORTANT !
+ * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine")
+ * Pour exécuter ce code dans le débugger.
+ * Faire de même avec le fichier rectangular_structure.ts
+ */
+// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureOrificeFree } from "../../src/structure/structure_orifice_free";
+import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
-const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
+const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureOrificeFree = new StructureOrificeFree(structPrm, false);
describe("Class StructureOrificeFree: ", () => {
diff --git a/spec/structure/structure_orifice_submerged.spec.ts b/spec/structure/structure_orifice_submerged.spec.ts
index 3f18b07f1f1dbedb6c8886f32c97771719e8fc68..37537f16f9708a8d3739e40e4f2fd984d5fd48b9 100644
--- a/spec/structure/structure_orifice_submerged.spec.ts
+++ b/spec/structure/structure_orifice_submerged.spec.ts
@@ -1,12 +1,18 @@
-// tslint:disable-next-line:no-reference
-/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
+/**
+ * IMPORTANT !
+ * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine")
+ * Pour exécuter ce code dans le débugger.
+ * Faire de même avec le fichier rectangular_structure.ts
+ */
+// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureOrificeSubmerged } from "../../src/structure/structure_orifice_submerged";
+import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
-const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
+const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureOrificeSubmerged = new StructureOrificeSubmerged(structPrm, false);
describe("Class StructureOrificeSubmerged: ", () => {
diff --git a/spec/structure/structure_weir_free.spec.ts b/spec/structure/structure_weir_free.spec.ts
index 49bd92967d325fc580dc1bfb31c668f85f915a12..6b04ce6a65737f30b8e687bbeb1aba08ba68f4be 100644
--- a/spec/structure/structure_weir_free.spec.ts
+++ b/spec/structure/structure_weir_free.spec.ts
@@ -1,12 +1,18 @@
-// tslint:disable-next-line:no-reference
-/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
+/**
+ * IMPORTANT !
+ * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine")
+ * Pour exécuter ce code dans le débugger.
+ * Faire de même avec le fichier rectangular_structure.ts
+ */
+// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureWeirFree } from "../../src/structure/structure_weir_free";
+import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
-const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
+const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureWeirFree = new StructureWeirFree(structPrm, false);
describe("Class StructureWeirFree: ", () => {
diff --git a/spec/structure/test_rectangular_structure.ts b/spec/structure/test_rectangular_structure.ts
deleted file mode 100644
index 77742fc64b5ccfcaac670eea6fa0e05b0a79e066..0000000000000000000000000000000000000000
--- a/spec/structure/test_rectangular_structure.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { Result } from "../../src/util/result";
-import { RectangularStructure } from "../../src/structure/rectangular_structure";
-import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
-import { expect, it } from "../mock_jasmine";
-import { precDigits } from "../test_config";
-import { Describer } from "./rectangular_structure";
-
-export function itCalcQ(
- struct: RectangularStructure, h1: number, W: number, Q: number,
- mode?: StructureFlowMode, regime?: StructureFlowRegime) {
-
- struct.debug("itCalQ " + Describer.getName(struct) + " h1=" + h1 + " W=" + W + " Q=" + Q);
-
- struct.prms.h1.v = h1;
- struct.prms.W.v = W;
- const res: Result = struct.Calc("Q");
- struct.debug("struct.Calc(Q)=" + res.vCalc);
-
- it("Q(h1=" + h1 + ",W=" + W + ") should be " + Q, () => {
- struct.debug("struct.Calc(Q)=" + res.vCalc);
- expect(res.vCalc).toBeCloseTo(Q, precDigits);
- });
- if (mode !== undefined) {
- it("Q(h1=" + h1 + ",W=" + W + ") Mode should be " + mode, () => {
- expect(res.extraVar.Mode).toBe(mode);
- });
- }
- if (regime !== undefined) {
- it("Q(h1=" + h1 + ",W=" + W + ") Regime should be " + regime, () => {
- expect(res.extraVar.Regime).toBe(regime);
- });
- }
-}
diff --git a/spec/structure/test_structure_cem88d.ts b/spec/structure/test_structure_cem88d.ts
deleted file mode 100644
index 75b888335df45667732855186d49601563540f34..0000000000000000000000000000000000000000
--- a/spec/structure/test_structure_cem88d.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { RectangularStructureParams, StructureCem88d } from "../../src/structure/structure_cem88d";
-import { describe, xdescribe } from "../mock_jasmine";
-import { itCalcQ } from "./test_rectangular_structure";
-
-const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
-const structTest: StructureCem88d = new StructureCem88d(structPrm, true);
-
-describe("Class StructureCem88d: ", () => {
-
- describe("Calcul Q avec W croissant: ", () => {
- const W: number[] = [0.000000, 0.100000, 0.200000, 0.300000, 0.400000, 0.500000,
- 0.600000, 0.700000, 0.800000, 0.900000, 1.000000, 1.100000, 1.200000, 1.300000];
- const h1: number = 1.200000;
- const Q: number[] = [0.000000, 0.617586, 1.235173, 1.852759, 2.470345, 3.087931, 3.705518,
- 4.296608, 4.831177, 5.302464, 5.700445, 6.007777, 6.175863, 6.175863];
-
- for (let i = 0; i < Q.length; i++) {
- itCalcQ(structTest, h1, W[i], Q[i]);
- }
- });
- describe("Calcul Q en charge avec h1 croissant: ", () => {
- const W: number = 0.8;
- const h1: number[] = [1.050000, 1.300000, 1.500000];
- const Q: number[] = [2.470345, 5.684601, 6.651906];
-
- for (let i = 0; i < Q.length; i++) {
- itCalcQ(structTest, h1[i], W, Q[i]);
- }
- });
- describe("Calcul Q a surface libre avec h1 croissant: ", () => {
- const W: number = Infinity;
- const h1: number[] = [1.100000, 1.500000];
- const Q: number[] = [4.366994, 9.764896];
-
- for (let i = 0; i < Q.length; i++) {
- itCalcQ(structTest, h1[i], W, Q[i]);
- }
- });
-});
diff --git a/spec/structure/test_structure_cem88v.ts b/spec/structure/test_structure_cem88v.ts
deleted file mode 100644
index a996471ce38b2c620cd2e4a65962028a520478ef..0000000000000000000000000000000000000000
--- a/spec/structure/test_structure_cem88v.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { RectangularStructureParams, StructureCem88v } from "../../src/structure/structure_cem88v";
-import { describe, xdescribe } from "../mock_jasmine";
-import { itCalcQ } from "./test_rectangular_structure";
-
-const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
-const structTest: StructureCem88v = new StructureCem88v(structPrm, true);
-
-describe("Class StructureCem88v: ", () => {
- describe("Calcul Q avec W croissant: ", () => {
- const W: number[] = [0.000000, 0.100000, 0.200000, 0.300000, 0.400000, 0.500000, 0.600000,
- 0.700000, 0.800000, 0.900000, 1.000000, 1.100000, 1.200000, 1.300000];
- const h1: number = 1.200000;
- const Q: number[] = [.000000, 0.328260, 0.641822, 0.823867, 1.117381, 1.720738,
- 2.225472, 2.575336, 2.873893, 3.113250, 3.280545, 3.349403, 3.149324, 3.149324];
-
- for (let i = 0; i < Q.length; i++) {
- itCalcQ(structTest, h1, W[i], Q[i]);
- }
- });
- xdescribe("Calcul Q en charge avec h1 croissant: ", () => {
- const W: number = 0.8;
- const h1: number[] = [1.05, 1.3, 1.5];
- const Q: number[] = [1.365897, 3.623277, 4.214572];
-
- for (let i = 0; i < Q.length; i++) {
- itCalcQ(structTest, h1[i], W, Q[i]);
- }
- });
- xdescribe("Calcul Q a surface libre avec h1 croissant: ", () => {
- const W: number = Infinity;
- const h1: number[] = [1.100000, 1.500000];
- const Q: number[] = [2.086781, 5.207945];
-
- for (let i = 0; i < Q.length; i++) {
- itCalcQ(structTest, h1[i], W, Q[i]);
- }
- });
-});
diff --git a/spec/structure/test_structure_cunge80.ts b/spec/structure/test_structure_cunge80.ts
deleted file mode 100644
index 7969dc9d92212d1e20e702445b972cdf8e85b096..0000000000000000000000000000000000000000
--- a/spec/structure/test_structure_cunge80.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
-import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
-import { StructureCunge80 } from "../../src/structure/structure_cunge80";
-import { describe, xdescribe } from "../mock_jasmine";
-import { itCalcQ } from "./test_rectangular_structure";
-
-const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
-const structTest: StructureCunge80 = new StructureCunge80(structPrm, true);
-
-describe("Class StructureCunge80: ", () => {
- describe("Calcul Q avec W croissant: ", () => {
- const W: number[] = [
- 0.000000, 0.100000, 0.200000, 0.300000, 0.400000, 0.500000, 0.600000,
- 0.700000, 0.800000, 0.900000, 1.000000, 1.100000, 1.200000, 1.300000];
- const h1: number = 1.200000;
- const Q: number[] = [0.000000, 0.237709, 0.475418, 0.713127, 0.950836, 1.188545,
- 1.426254, 1.663963, 1.901673, 2.139382, 2.377091, 2.377091, 2.377091, 2.377091];
-
- for (let i = 0; i < Q.length; i++) {
- itCalcQ(structTest, h1, W[i], Q[i]);
- }
- });
- describe("Calcul Q en charge avec h1 croissant: ", () => {
- const W: number = 0.8;
- const h1: number[] = [1.050000, 1.300000, 1.500000];
- const Q: number[] = [0.950836, 2.329064, 3.557704];
- const mode: StructureFlowMode[] = [
- StructureFlowMode.ORIFICE, StructureFlowMode.ORIFICE, StructureFlowMode.ORIFICE];
- const regime: StructureFlowRegime[] = [
- StructureFlowRegime.SUBMERGED, StructureFlowRegime.SUBMERGED, StructureFlowRegime.FREE];
-
- for (let i = 0; i < Q.length; i++) {
- itCalcQ(structTest, h1[i], W, Q[i], mode[i], regime[i]);
- }
- });
- describe("Calcul Q a surface libre avec h1 croissant: ", () => {
- const W: number = Infinity;
- const h1: number[] = [1.100000, 1.500000];
- const Q: number[] = [1.680857, 3.758510];
- const mode: StructureFlowMode[] = [
- StructureFlowMode.WEIR, StructureFlowMode.WEIR];
- const regime: StructureFlowRegime[] = [
- StructureFlowRegime.SUBMERGED, StructureFlowRegime.FREE];
-
- for (let i = 0; i < Q.length; i++) {
- itCalcQ(structTest, h1[i], W, Q[i], mode[i], regime[i]);
- }
- });
-});
diff --git a/spec/test_func.ts b/spec/test_func.ts
index 1cf84cdd4627d8f03e5c4ba494515ead74e0c05b..dbf9a5aff6f4e278a637280856dd477cbf636a84 100644
--- a/spec/test_func.ts
+++ b/spec/test_func.ts
@@ -3,13 +3,13 @@
* décommenter la ligne suivante (import { expect } from "./mock_jasmine") dans le cas d'une fonction
* qui utilise la fonction expect() de Jasmine mais qui doit être exécutée en dehors de tests Jasmine
*/
-//import { expect } from "./mock_jasmine"
+// import { describe, expect, it, xdescribe } from "./mock_jasmine";
import { cLog } from "../src/util/log";
import { Message, MessageCode } from "../src/util/message";
-import { precDist } from "./test_config";
import { Result } from "../src/util/result";
-import { precDigits } from "./test_config"
+import { precDist } from "./test_config";
+import { precDigits } from "./test_config";
/**
* Compare deux valeurs réelles à un epsilon près
@@ -140,7 +140,7 @@ export function compareLog(logTest: cLog, logValid: cLog) {
// clés des données
- for (const j in m1.extraVar) {
+ for (let j = 0; j < m1.extraVar.length; j++) {
b = m2.extraVar[j] !== undefined;
expect(b).toBeTruthy(
"journal : message n°" + i + ", code " + code1 + " : la donnée " + j + "=" + m1.extraVar[j]
@@ -148,7 +148,7 @@ export function compareLog(logTest: cLog, logValid: cLog) {
// if (!b) return;
}
- for (const j in m2.extraVar) {
+ for (let j = 0; j < m2.extraVar.length; j++) {
b = m1.extraVar[j] !== undefined;
expect(b).toBeTruthy(
"journal : message n°" + i + ", code " + code1 + " : la donnée " + j + "=" + m2.extraVar[j]
@@ -158,7 +158,7 @@ export function compareLog(logTest: cLog, logValid: cLog) {
// type des données
- for (const j in m1.extraVar) {
+ for (let j = 0; j < m1.extraVar.length; j++) {
b = typeof m1.extraVar[j] === typeof m2.extraVar[j];
expect(b).toBeTruthy(
"journal : " + i + "ieme message, code " + code1 + " : la donnée " + j + "=" + m1.extraVar[j]
@@ -169,7 +169,7 @@ export function compareLog(logTest: cLog, logValid: cLog) {
// valeur des données
- for (const j in m1.extraVar) {
+ for (let j = 0; j < m1.extraVar.length; j++) {
const d: any = m1.extraVar[j];
if (typeof d === "number") {
b = equalEpsilon(d, m2.extraVar[j]);
@@ -184,7 +184,7 @@ export function compareLog(logTest: cLog, logValid: cLog) {
}
}
-export function checkResult(val1: Result, val2: number, prec: number = undefined) {
+export function checkResult(val1: Result, val2: number, prec?: number) {
expect(val1.ok).toBeTruthy("Result : computation error on Result " + val1.toString());
if (val1.ok) {
/*
@@ -195,8 +195,9 @@ export function checkResult(val1: Result, val2: number, prec: number = undefined
* valeur attendue 1.301
* valeur calculée 1.3016, arrondie à 1.302, faisant échouer le test
*/
- if (prec == undefined)
+ if (prec === undefined) {
prec = Math.max(0, precDigits - 1);
+ }
expect(val1.vCalc).toBeCloseTo(val2, prec);
}
diff --git a/src/structure/rectangular_structure_params.ts b/src/structure/rectangular_structure_params.ts
index edd24882d4056e5269a8d5361f6cb193c92fb18c..4d5d267e1a5f90482132903ea625e6d31aadd612 100644
--- a/src/structure/rectangular_structure_params.ts
+++ b/src/structure/rectangular_structure_params.ts
@@ -12,8 +12,18 @@ export class RectangularStructureParams extends StructureParams {
/** Discharge coefficient */
public Cd: ParamDefinition;
- constructor(rQ: number, rh1: number, rh2: number, rL: number, rCd: number, rW: number = Infinity) {
- super(rQ, rh1, rh2, rW);
+ /**
+ * Constructeur d'une structure rectangulaire
+ * @param rQ Débit (m3/s)
+ * @param rZDV Cote de la crête du déversoir ou du radier de la vanne (m)
+ * @param rZ1 Cote de l'eau amont (m)
+ * @param rZ2 Cote de l'eau aval (m)
+ * @param rL Largeur de la vanne ou du déversoir (m)
+ * @param rCd Coefficient de débit (-)
+ * @param rW Ouverture de la vanne (m) (Valeur par défaut +infinity pour les déversoirs)
+ */
+ constructor(rQ: number, rZDV: number, rZ1: number, rZ2: number, rL: number, rCd: number, rW: number = Infinity) {
+ super(rQ, rZDV, rZ1, rZ2, rW);
this.L = new ParamDefinition(ComputeNodeType.CondDistri, "L", ParamDomainValue.POS, rL);
this.addParamDefinition(this.L);
this.Cd = new ParamDefinition(ComputeNodeType.CondDistri, "Cd", ParamDomainValue.POS, rCd);
diff --git a/src/structure/structure.ts b/src/structure/structure.ts
index c9f43ae1a0e69ad7595bf9b4b3ab1dd7d93a07dc..612c197fb6ebb9ec7c39ec285675904da9135d3e 100644
--- a/src/structure/structure.ts
+++ b/src/structure/structure.ts
@@ -1,7 +1,7 @@
-import { Result } from "../util/result";
import { Nub } from "../nub";
import { ParamCalculability } from "../param";
import { Message } from "../util/message";
+import { Result } from "../util/result";
import { StructureParams } from "./structure_params";
@@ -57,13 +57,6 @@ export abstract class Structure extends Nub {
*/
public abstract Equation(sVarCalc: string): Result;
- protected defaultResultData() {
- return {
- Mode: this.getFlowMode(),
- Regime: this.getFlowRegime()
- };
- }
-
/**
* Calcul d'une équation quelque soit l'inconnue à calculer.
* Gestion du débit nul et de l'inversion de débit
@@ -72,8 +65,11 @@ export abstract class Structure extends Nub {
* @param rPrec précision de calcul
*/
public Calc(sVarCalc: string, rInit: number = 0, rPrec: number = 0.001): Result {
- const flagsNull = {Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL};
+ // Mise à jour de h1 et h2
+ this.prms.update_h1h2();
+
// Gestion du débit nul
+ const flagsNull = {Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL};
if (sVarCalc === "Q") {
if (this.prms.h1.v === this.prms.h2.v || this.prms.W.v <= 0) {
return new Result(0, flagsNull);
@@ -102,8 +98,15 @@ export abstract class Structure extends Nub {
return res;
}
+ // Calcul normal hors débit nul et inversion de débit
return super.Calc(sVarCalc, rInit, rPrec);
+ }
+ protected defaultResultData() {
+ return {
+ Mode: this.getFlowMode(),
+ Regime: this.getFlowRegime(),
+ };
}
/**
@@ -111,8 +114,11 @@ export abstract class Structure extends Nub {
*/
protected setParametersCalculability() {
this.prms.Q.calculability = ParamCalculability.EQUATION;
- this.prms.h1.calculability = ParamCalculability.DICHO;
- this.prms.h2.calculability = ParamCalculability.DICHO;
+ this.prms.ZDV.calculability = ParamCalculability.DICHO;
+ this.prms.Z1.calculability = ParamCalculability.DICHO;
+ this.prms.Z2.calculability = ParamCalculability.DICHO;
+ this.prms.h1.calculability = ParamCalculability.FREE;
+ this.prms.h2.calculability = ParamCalculability.FREE;
this.prms.W.calculability = ParamCalculability.DICHO;
}
diff --git a/src/structure/structure_params.ts b/src/structure/structure_params.ts
index 539047181ae3b3e4971914c9a2f535b19f3bc33e..5929b5bc684b4804d56edf25b92a05ed895728bf 100644
--- a/src/structure/structure_params.ts
+++ b/src/structure/structure_params.ts
@@ -1,19 +1,26 @@
-import { Result } from "../util/result";
import { Nub } from "../nub";
-import { ComputeNodeType, ParamDefinition, ParamDomain, ParamDomainValue, ParamsEquation } from "../param";
-import { Message } from "../util/message";
+import { ComputeNodeType, ParamDefinition, ParamDomainValue, ParamsEquation } from "../param";
/**
* Common parameters of hydraulic structure equations
*/
export class StructureParams extends ParamsEquation {
- /** Débit */
+ /** Débit (m3/s) */
public Q: ParamDefinition;
- /** Tirant d'eau amont */
+ /** Cote de la crête du déversoir ou du radier de la vanne (m) */
+ public ZDV: ParamDefinition;
+
+ /** Cote de l'eau amont (m) */
+ public Z1: ParamDefinition;
+
+ /** Cote de l'eau aval (m) */
+ public Z2: ParamDefinition;
+
+ /** Tirant d'eau amont (m) */
public h1: ParamDefinition;
- /** Tirant d'eau aval */
+ /** Tirant d'eau aval (m) */
public h2: ParamDefinition;
/** Ouverture de la vanne
@@ -24,19 +31,34 @@ export class StructureParams extends ParamsEquation {
/**
* Paramètres communs à toutes les équations de structure
* @param rQ Débit (m3/s)
- * @param rh1 Hauteur amont au dessus de la crête (m)
- * @param rh2 Hauteur aval au dessus de la crête (m)
+ * @param rZDV Cote de la crête du déversoir ou du radier de la vanne (m)
+ * @param rZ1 Cote de l'eau amont (m)
+ * @param rZ2 Cote de l'eau aval (m)
* @param rW Ouverture de vanne (m) (infinity pour un seuil)
*/
- constructor(rQ: number, rh1: number, rh2: number, rW: number = Infinity ) {
+ constructor(rQ: number, rZDV: number, rZ1: number, rZ2: number, rW: number = Infinity ) {
super();
this.Q = new ParamDefinition(ComputeNodeType.CondDistri, "Q", ParamDomainValue.POS_NULL, rQ);
this.addParamDefinition(this.Q);
- this.h1 = new ParamDefinition(ComputeNodeType.CondDistri, "h1", ParamDomainValue.POS_NULL, rh1);
+ this.ZDV = new ParamDefinition(ComputeNodeType.CondDistri, "ZDV", ParamDomainValue.POS_NULL, rZDV);
+ this.addParamDefinition(this.ZDV);
+ this.Z1 = new ParamDefinition(ComputeNodeType.CondDistri, "Z1", ParamDomainValue.POS_NULL, rZ1);
+ this.addParamDefinition(this.Z1);
+ this.Z2 = new ParamDefinition(ComputeNodeType.CondDistri, "Z2", ParamDomainValue.POS_NULL, rZ2);
+ this.addParamDefinition(this.Z2);
+ this.h1 = new ParamDefinition(ComputeNodeType.CondDistri, "h1", ParamDomainValue.POS_NULL,
+ Math.max(0, this.Z1.v - this.ZDV.v));
this.addParamDefinition(this.h1);
- this.h2 = new ParamDefinition(ComputeNodeType.CondDistri, "h2", ParamDomainValue.POS_NULL, rh2);
+ this.h2 = new ParamDefinition(ComputeNodeType.CondDistri, "h2", ParamDomainValue.POS_NULL,
+ Math.max(0, this.Z2.v - this.ZDV.v));
this.addParamDefinition(this.h2);
this.W = new ParamDefinition(ComputeNodeType.CondDistri, "W", ParamDomainValue.POS_NULL, rW);
this.addParamDefinition(this.W);
}
+
+ /** Mise à jour des paramètres h1 et h2 à partir de Z1, Z2 et ZDV */
+ public update_h1h2() {
+ this.h1.v = Math.max(0, this.Z1.v - this.ZDV.v);
+ this.h2.v = Math.max(0, this.Z2.v - this.ZDV.v);
+ }
}