remous_rect_euler_pentefaible.spec.ts 6.12 KB
Newer Older
1
import { MethodeResolution } from "../../src/remous/methode-resolution";
2
3
4
5
import { CourbeRemous } from "../../src/remous/remous";
import { CourbeRemousParams } from "../../src/remous/remous_params";
import { cSnRectang } from "../../src/section/section_rectang";
import { ParamsSectionRectang } from "../../src/section/section_rectang_params";
6
import { SessionSettings } from "../../src/session_settings";
7
8
import { cLog } from "../../src/util/log";
import { Message, MessageCode } from "../../src/util/message";
9
import { Result } from "../../src/util/result";
Dorchies David's avatar
Dorchies David committed
10
import { precDist } from "../test_config";
11
import { compareExtraResult, compareLog, extraResultLength } from "../test_func";
12
13
14

describe("Class Remous / section rectangulaire :", () => {
    describe("méthode Euler explicite :", () => {
15
        it("faible pente, pas de ressaut, Yamont > Yc, Yaval > Yn", () => {
Dorchies David's avatar
Dorchies David committed
16
            const prms = new ParamsSectionRectang(undefined, // tirant d'eau
17
18
19
20
                2.5, // largeur de fond
                40, //  Ks=Strickler
                2, // Q=Débit
                0.001, // If=pente du fond
21
                1 // YB=hauteur de berge
22
            );
23
            SessionSettings.precision = precDist;
24

Dorchies David's avatar
Dorchies David committed
25
            const sect = new cSnRectang(prms);
26

27
            const prem = new CourbeRemousParams(100.6, 101, 100.1, 100,
28
29
                100,  // Long= Longueur du bief
                5,  // Dx=Pas d'espace
30
31
            );

32
            const rem = new CourbeRemous(sect, prem, MethodeResolution.EulerExplicite);
33

Dorchies David's avatar
Dorchies David committed
34
            const res: Result = rem.calculRemous(undefined);
35
36
37

            // données de validation : version Typescript (Oct 2017) méthode des trapèzes

38
            const f: any = {
Mathias Chouet's avatar
Mathias Chouet committed
39
40
41
42
43
44
45
                0: 0.9872500000000014, 5: 0.9872500000000014, 10: 0.9872500000000014,
                15: 0.9872500000000014, 20: 0.9880000000000013, 25: 0.9887500000000012,
                30: 0.9895000000000012, 35: 0.9902500000000011, 40: 0.991000000000001,
                45: 0.9917500000000009, 50: 0.9925000000000008, 55: 0.9932500000000007,
                60: 0.9940000000000007, 65: 0.9947500000000006, 70: 0.9955000000000005,
                75: 0.9962500000000004, 80: 0.9970000000000003, 85: 0.9977500000000002,
                90: 0.9985000000000002, 95: 0.9992500000000001, 100: 1
Dorchies David's avatar
Dorchies David committed
46
            };
47
48
49
50
            // màj pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues
            for (const fk of Object.keys(f)) {
                f[fk] = f[fk] + rem.getCoteFond(Number(fk));
            }
51
            // compareObject("Yfluvial", res.getValue("flu"), f, 0.03);
52
            compareExtraResult("Yfluvial", res, "flu", f, 0.03);
53

Dorchies David's avatar
Dorchies David committed
54
            expect(
55
                extraResultLength(res, "tor") === 0
Dorchies David's avatar
Dorchies David committed
56
            ).toBeTruthy("la ligne d'eau torrentielle ne devrait comporter aucune valeur");
57

58
            // const x = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100];
59
            // compareArray("abscisses", res.getValue("trX"), x);
60

Dorchies David's avatar
Dorchies David committed
61
            const expLog = new cLog();
62

63
            let m = new Message(MessageCode.INFO_REMOUS_H_CRITIQUE);
Dorchies David's avatar
Dorchies David committed
64
            m.extraVar.Yc = 0.403;
65
66
            expLog.add(m);

67
            m = new Message(MessageCode.INFO_REMOUS_H_NORMALE);
Dorchies David's avatar
Dorchies David committed
68
            m.extraVar.Yn = 0.953;
69
70
            expLog.add(m);

Mathias Chouet's avatar
Mathias Chouet committed
71
            expLog.add(new Message(MessageCode.INFO_REMOUS_CALCUL_FLUVIAL));
72

73
74
            expLog.add(new Message(MessageCode.WARNING_REMOUS_PAS_CALCUL_DEPUIS_AMONT));

75
            compareLog(res.globalLog, expLog);
76
77
78
        });

        it("faible pente, pas de ressaut, Yamont > Yc, Yc < Yaval < Yn", () => {
Dorchies David's avatar
Dorchies David committed
79
            const prms = new ParamsSectionRectang(undefined, // tirant d'eau
80
81
82
83
                2.5, // largeur de fond
                40, //  Ks=Strickler
                2, // Q=Débit
                0.001, // If=pente du fond
84
                1 // YB=hauteur de berge
85
            );
86
            SessionSettings.precision = precDist;
87

Dorchies David's avatar
Dorchies David committed
88
            const sect = new cSnRectang(prms);
89

90
            const prem = new CourbeRemousParams(100.6, 100.7, 100.1, 100,
91
92
                100,  // Long= Longueur du bief
                5,  // Dx=Pas d'espace
93
94
            );

95
            const rem = new CourbeRemous(sect, prem, MethodeResolution.EulerExplicite);
96

Dorchies David's avatar
Dorchies David committed
97
            const res = rem.calculRemous(undefined);
98
99
100

            // données de validation : version Typescript (Oct 2017) méthode trapèzes

101
            const f: any = {
Mathias Chouet's avatar
Mathias Chouet committed
102
103
104
105
106
107
108
                0: 0.805499999999999, 5: 0.802249999999999, 10: 0.7984999999999991,
                15: 0.7947499999999992, 20: 0.7909999999999993, 25: 0.7867499999999993,
                30: 0.7824999999999993, 35: 0.7782499999999993, 40: 0.7739999999999994,
                45: 0.7692499999999994, 50: 0.7644999999999995, 55: 0.7592499999999995,
                60: 0.7539999999999996, 65: 0.7482499999999996, 70: 0.7424999999999997,
                75: 0.7362499999999997, 80: 0.7299999999999998, 85: 0.7232499999999998,
                90: 0.7159999999999999, 95: 0.7082499999999999, 100: 0.7
Dorchies David's avatar
Dorchies David committed
109
            };
110
111
112
113
            // màj pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues
            for (const fk of Object.keys(f)) {
                f[fk] = f[fk] + rem.getCoteFond(Number(fk));
            }
114
            // compareObject("Yfluvial", res.getValue("flu"), f, 0.03);
115
            compareExtraResult("Yfluvial", res, "flu", f, 0.03);
116

Dorchies David's avatar
Dorchies David committed
117
            expect(
118
                extraResultLength(res, "tor") === 0
Dorchies David's avatar
Dorchies David committed
119
            ).toBeTruthy("la ligne d'eau torrentielle ne devrait comporter aucune valeur");
120

121
            // const x = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100];
122
            // compareArray("abscisses", res.getValue("trX"), x);
123

Dorchies David's avatar
Dorchies David committed
124
            const expLog = new cLog();
125

126
            let m = new Message(MessageCode.INFO_REMOUS_H_CRITIQUE);
Dorchies David's avatar
Dorchies David committed
127
            m.extraVar.Yc = 0.403;
128
129
            expLog.add(m);

130
            m = new Message(MessageCode.INFO_REMOUS_H_NORMALE);
Dorchies David's avatar
Dorchies David committed
131
            m.extraVar.Yn = 0.953;
132
133
            expLog.add(m);

Mathias Chouet's avatar
Mathias Chouet committed
134
            expLog.add(new Message(MessageCode.INFO_REMOUS_CALCUL_FLUVIAL));
135

136
137
            expLog.add(new Message(MessageCode.WARNING_REMOUS_PAS_CALCUL_DEPUIS_AMONT));

138
            compareLog(res.globalLog, expLog);
139
140
141
        });
    });
});