structure_weir_submerged.spec.ts 1.99 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureWeirSubmerged } from "../../src/structure/structure_weir_submerged";
import { MessageCode } from "../../src/util/message";
import { itCalcQ } from "../structure/functions";
import { precDigits } from "../test_config";

function getStructTest(): StructureWeirSubmerged {
    return  new StructureWeirSubmerged(new RectangularStructureParams(0, 101, 102, 101.5, 0.2, 0.9), false);
}

describe("Class StructureWeirSubmerged: ", () => {
    describe("Calc(Q): ", () => {
        const Z1: number[] = [102];
        const Q: number[] = [0.282];
        const mode: StructureFlowMode = StructureFlowMode.WEIR;
        const regime: StructureFlowRegime = StructureFlowRegime.SUBMERGED;
        for (let i = 0; i < Q.length; i++) {
            itCalcQ(getStructTest(), Z1[i], Infinity, Q[i], mode, regime);
        }
    });
    describe("Calc(Z1): ", () => {
        it("Z1(Q=0.780) should be 75.234", () => {
            const testZ1 = new StructureWeirSubmerged(
                new RectangularStructureParams(0.780, 73.665, 75.301, 75.077, 0.35, 0.9),
                false);
            testZ1.prms.Z1.v = 100; // Test with initial condition far from solution
            expect(testZ1.Calc("Z1").vCalc).toBeCloseTo(75.234, precDigits);
        });
    });
    describe("Calcul avec h2/h1 < 0.8 (=0.5) : ", () => {
        it("le log devrait contenir 1 message", () => {
            const structTest = getStructTest();
            structTest.prms.Z1.singleValue = 110;
            structTest.prms.Z2.singleValue = 105;
            structTest.prms.ZDV.singleValue = 100;
            const res = structTest.CalcSerie().resultElement;
            expect(res.log.messages.length).toBe(1);
            expect(
                res.log.messages[0].code
            ).toBe(MessageCode.WARNING_WEIR_SUBMERSION_LOWER_THAN_08);
        });
    });
});