remous_rect_rk4_penteforte.spec.ts 16.72 KiB
import { ParamsSectionRectang, cSnRectang } from "../src/section/section_rectang";
import { CourbeRemousParams, MethodeResolution, CourbeRemous } from "../src/remous";
import { precDigits, precDist, equalEpsilon, compareArray, compareObject, compareLog } from "./nubtest";
import { round } from "../src/base";
import { cLog } from "../src/util/log";
import { Message, MessageCode } from "../src/util/message";
describe('Class Remous / section rectangulaire :', () => {
    describe('méthode Runge-Kutta ordre 4 :', () => {
        it("forte pente, ressaut avant l'amont", () => {
            let prms = new ParamsSectionRectang(undefined, // tirant d'eau
                2.5, // largeur de fond
                40, //  Ks=Strickler
                2, // Q=Débit
                0.05, // If=pente du fond
                precDist, // précision
                1 // YB=hauteur de berge
            let sect = new cSnRectang(prms);
            let prem = new CourbeRemousParams(sect, 0.15, // Yamont = tirant amont
                6, // Yaval = tirant aval
                100,  // Long= Longueur du bief
                5,  // Dx=Pas d'espace
                MethodeResolution.RungeKutta4
            let rem = new CourbeRemous(prem);
            let res = rem.calculRemous(undefined);
            // données de validation : version PHP (Oct 2017) méthode RungeKutta4
            let f = { 100.000: 6, 95.000: 5.75, 90.000: 5.5, 85.000: 5.25, 80.000: 5, 75.000: 4.75, 70.000: 4.5, 65.000: 4.25, 60.000: 4, 55.000: 3.749, 50.000: 3.499, 45.000: 3.249, 40.000: 2.999, 35.000: 2.748, 30.000: 2.498, 25.000: 2.247, 20.000: 1.996, 15.000: 1.744, 10.000: 1.491, 5.000: 1.237, 0.000: 0.977 };
            compareObject("Yfluvial", res["flu"], f, 0.01);
            let t = {};
            compareObject("Ytorrentiel", res["tor"], t, 0.03);
            let x = [0.000, 5.000, 10.000, 15.000, 20.000, 25.000, 30.000, 35.000, 40.000, 45.000, 50.000, 55.000, 60.000, 65.000, 70.000, 75.000, 80.000, 85.000, 90.000, 95.000, 100.000];
            compareArray("abscisses", res["trX"], x);
            let expLog = new cLog();
            let m = new Message(MessageCode.ERROR_REMOUS_LARGEUR_BERGE);
            m.extraVar["B"] = 2.5;
            expLog.add(m);
            m = new Message(MessageCode.ERROR_REMOUS_H_CRITIQUE);
            m.extraVar["Yc"] = 0.403;
            expLog.add(m);
            m = new Message(MessageCode.ERROR_REMOUS_H_NORMALE);
            m.extraVar["Yn"] = 0.253;
            expLog.add(m);
            expLog.add(new Message(MessageCode.ERROR_REMOUS_CALCUL_FLUVIAL));
            expLog.add(new Message(MessageCode.ERROR_REMOUS_CALCUL_TORRENTIEL));
            m = new Message(MessageCode.ERROR_REMOUS_RESSAUT_DEHORS);
            m.extraVar["sens"] = "amont";
            m.extraVar["x"] = 0;
            expLog.add(m);
            compareLog(rem.log, expLog);
        });
        it("forte pente, ressaut après l'aval", () => {
            // TODO algo à reprendre
            let prms = new ParamsSectionRectang(undefined, // tirant d'eau
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
2.5, // largeur de fond 40, // Ks=Strickler 2, // Q=Débit 0.05, // If=pente du fond precDist, // précision 1 // YB=hauteur de berge ); let sect = new cSnRectang(prms); let prem = new CourbeRemousParams(sect, 0.15, // Yamont = tirant amont 0.45, // Yaval = tirant aval 100, // Long= Longueur du bief 5, // Dx=Pas d'espace MethodeResolution.RungeKutta4 ); let rem = new CourbeRemous(prem); let res = rem.calculRemous(undefined); // données de validation : version PHP (Oct 2017) méthode RungeKutta4 let f = {}; compareObject("Yfluvial", res["flu"], f, 0.03); let t = { 0.000: 0.15, 5.000: 0.198, 10.000: 0.228, 15.000: 0.243, 20.000: 0.249, 25.000: 0.251, 30.000: 0.252, 35.000: 0.253, 40.000: 0.253, 45.000: 0.253, 50.000: 0.253, 55.000: 0.253, 60.000: 0.253, 65.000: 0.253, 70.000: 0.253, 75.000: 0.253, 80.000: 0.253, 85.000: 0.253, 90.000: 0.253, 95.000: 0.253, 100.000: 0.45 }; compareObject("Ytorrentiel", res["tor"], t, 0.03); let x = [0.000, 5.000, 10.000, 15.000, 20.000, 25.000, 30.000, 35.000, 40.000, 45.000, 50.000, 55.000, 60.000, 65.000, 70.000, 75.000, 80.000, 85.000, 90.000, 95.000, 100.000]; compareArray("abscisses", res["trX"], x); let expLog = new cLog(); let m = new Message(MessageCode.ERROR_REMOUS_LARGEUR_BERGE); m.extraVar["B"] = 2.5; expLog.add(m); m = new Message(MessageCode.ERROR_REMOUS_H_CRITIQUE); m.extraVar["Yc"] = 0.403; expLog.add(m); m = new Message(MessageCode.ERROR_REMOUS_H_NORMALE); m.extraVar["Yn"] = 0.253; expLog.add(m); expLog.add(new Message(MessageCode.ERROR_REMOUS_CALCUL_FLUVIAL)); m = new Message(MessageCode.ERROR_REMOUS_ARRET_CRITIQUE) m.extraVar["x"] = 95; expLog.add(m); expLog.add(new Message(MessageCode.ERROR_REMOUS_CALCUL_TORRENTIEL)); m = new Message(MessageCode.ERROR_REMOUS_RESSAUT_DEHORS); m.extraVar["sens"] = "aval"; m.extraVar["x"] = 100; expLog.add(m); compareLog(rem.log, expLog); }); it("forte pente, ressaut (1 point) à l'intérieur du bief", () => { let prms = new ParamsSectionRectang(undefined, // tirant d'eau 2.5, // largeur de fond 40, // Ks=Strickler 2, // Q=Débit 0.05, // If=pente du fond precDist, // précision 1 // YB=hauteur de berge );