diff --git a/spec/regime_uniforme/regime_uniforme_rect.spec.ts b/spec/regime_uniforme/regime_uniforme_rect.spec.ts index 9ec0e6b6b8c7c80513c51f4801d8eec9a03c0588..991165ad9eb954291b514319fa746d7fdf90454c 100644 --- a/spec/regime_uniforme/regime_uniforme_rect.spec.ts +++ b/spec/regime_uniforme/regime_uniforme_rect.spec.ts @@ -1,3 +1,11 @@ +/** + * 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, xit } from "../mock_jasmine"; + import { RegimeUniforme } from "../../src/regime_uniforme"; import { cSnRectang, ParamsSectionRectang } from "../../src/section/section_rectang"; import { Result } from "../../src/util/result"; diff --git a/spec/remous/remous_rect_euler_pentefaible.spec.ts b/spec/remous/remous_rect_euler_pentefaible.spec.ts index 8959ff342fea7f7d0657703c43b92611401f4686..8de7d940757c9adebb608df7f21c76d26397db52 100644 --- a/spec/remous/remous_rect_euler_pentefaible.spec.ts +++ b/spec/remous/remous_rect_euler_pentefaible.spec.ts @@ -1,227 +1,23 @@ +/** + * 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, xit } from "../mock_jasmine"; + import { CourbeRemous, CourbeRemousParams, MethodeResolution } from "../../src/remous"; import { cSnRectang, ParamsSectionRectang } from "../../src/section/section_rectang"; import { cLog } from "../../src/util/log"; import { Message, MessageCode } from "../../src/util/message"; -import { compareArray, compareLog, compareObject } from "../test_func"; -import { precDist } from "../test_config"; import { Result } from "../../src/util/result"; +import { precDist } from "../test_config"; +import { compareArray, compareLog, compareObject } from "../test_func"; describe("Class Remous / section rectangulaire :", () => { describe("méthode Euler explicite :", () => { - // it("faible pente, ressaut avant l'amont (1)", () => { - // // cas non reproductible (fluvial =~ 17 sur toute la longueur du canal) - // let prms = new ParamsSectionRectang(undefined, // tirant d'eau - // 2.5, // largeur de fond - // 40, // Ks=Strickler - // 2, // Q=Débit - // 0.001, // If=pente du fond - // precDist, // précision - // 1 // YB=hauteur de berge - // ); - - // let sect = new cSnRectang(undefined, prms); - - // let prem = new CourbeRemousParams(sect, 0.3, // Yamont = tirant amont - // 0.403, // Yaval = tirant aval - // 100, // Long= Longueur du bief - // 5, // Dx=Pas d'espace - // MethodeResolution.EulerExplicite - // ); - - // let log = new cLog(); - // let rem = new CourbeRemous(sect, prem, log); - - // let res = rem.calculRemous(undefined); - - // // données de validation : version Typescript (Oct 2017) méthode des trapèzes - - // let f = { - // "0": 0.7554999999999994, "5": 0.7497499999999995, "10": 0.7439999999999996, "15": 0.7377499999999996, - // "20": 0.7314999999999996, "25": 0.7247499999999997, "30": 0.7174999999999997, "35": 0.7097499999999998, - // "40": 0.7014999999999998, "45": 0.6927499999999999, "50": 0.6834999999999999, "55": 0.6732499999999999, - // "60": 0.6619999999999999, "65": 0.6497499999999999, "70": 0.6365, "75": 0.62125, "80": 0.604, - // "85": 0.58325, "90": 0.558, "95": 0.52375, "100": 0.403 }; - // compareObject("Yfluvial", res["flu"], f, 0.03); - - // let t = {}; - // compareObject("Ytorrentiel", res["tor"], t, 0.03); - - // let x = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]; - // compareArray("abscisses", res["trX"], x); - - // let expLog = new cLog(); - // let m = new ErrorMessage(ErrorCode.ERROR_REMOUS_LARGEUR_BERGE); - // m.extraVar["B"] = 2.5; - // expLog.add(m); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_H_CRITIQUE); - // m.extraVar["Yc"] = 0.403; - // expLog.add(m); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_H_NORMALE); - // m.extraVar["Yn"] = 0.953; - // expLog.add(m); - - // expLog.add(new ErrorMessage(ErrorCode.ERROR_REMOUS_CALCUL_FLUVIAL)); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_PENTE_FORTE); - // m.extraVar["x"] = 95; - // expLog.add(m); - - // expLog.add(new ErrorMessage(ErrorCode.ERROR_REMOUS_CALCUL_TORRENTIEL)); - - // m = new ErrorMessage(ErrorCode.WARNING_REMOUS_ARRET_CRITIQUE) - // m.extraVar["x"] = 10; - // expLog.add(m); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_RESSAUT_DEHORS); - // m.extraVar["sens"] = "amont"; - // m.extraVar["x"] = 0; - // expLog.add(m); - - // compareLog(log, expLog); - // }); - - // it("faible pente, ressaut (1 point) à l'intérieur du bief", () => { - // // cas non reproductible (fluvial =~ 17 sur toute la longueur du canal) - - // let prms = new ParamsSectionRectang(undefined, // tirant d'eau - // 2.5, // largeur de fond - // 40, // Ks=Strickler - // 2, // Q=Débit - // 0.001, // If=pente du fond - // precDist, // précision - // 1 // YB=hauteur de berge - // ); - - // let sect = new cSnRectang(undefined, prms); - - // let prem = new CourbeRemousParams(sect, 0.15, // Yamont = tirant amont - // 0.403, // Yaval = tirant aval - // 100, // Long= Longueur du bief - // 5, // Dx=Pas d'espace - // MethodeResolution.EulerExplicite - // ); - - // let log = new cLog(); - // let rem = new CourbeRemous(sect, prem, log); - - // let res = rem.calculRemous(undefined); - - // // données de validation : version Typescript (Oct 2017) méthode des trapèzes - - // let f = { - // "0": 0.15, "5": 0.7497499999999995, "10": 0.7439999999999996, "15": 0.7377499999999996, - // "20": 0.7314999999999996, "25": 0.7247499999999997, "30": 0.7174999999999997, - // "35": 0.7097499999999998, "40": 0.7014999999999998, "45": 0.6927499999999999, - // "50": 0.6834999999999999, "55": 0.6732499999999999, "60": 0.6619999999999999, - // "65": 0.6497499999999999, "70": 0.6365, "75": 0.62125, "80": 0.604, "85": 0.58325, - // "90": 0.558, "95": 0.52375, "100": 0.403 }; - // compareObject("Yfluvial", res["flu"], f, 0.03); - - // let t = { "0": 0.15, "5": 0.7497499999999995 }; - // compareObject("Ytorrentiel", res["tor"], t, 0.03); - - // let x = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]; - // compareArray("abscisses", res["trX"], x); - - // let expLog = new cLog(); - // let m = new ErrorMessage(ErrorCode.ERROR_REMOUS_LARGEUR_BERGE); - // m.extraVar["B"] = 2.5; - // expLog.add(m); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_H_CRITIQUE); - // m.extraVar["Yc"] = 0.403; - // expLog.add(m); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_H_NORMALE); - // m.extraVar["Yn"] = 0.953; - // expLog.add(m); - - // expLog.add(new ErrorMessage(ErrorCode.ERROR_REMOUS_CALCUL_FLUVIAL)); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_PENTE_FORTE); - // m.extraVar["x"] = 95; - // expLog.add(m); - - // expLog.add(new ErrorMessage(ErrorCode.ERROR_REMOUS_CALCUL_TORRENTIEL)); - - // m = new ErrorMessage(ErrorCode.WARNING_REMOUS_ARRET_CRITIQUE) - // m.extraVar["x"] = 20; - // expLog.add(m); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_RESSAUT_DEHORS); - // m.extraVar["sens"] = "amont"; - // m.extraVar["x"] = 0; - // expLog.add(m); - - // compareLog(log, expLog); - // }); - - // it("faible pente, ressaut (plusieurs points) à l'intérieur du bief (1)", () => { - // let prms = new ParamsSectionRectang(undefined, // tirant d'eau - // 2.5, // largeur de fond - // 40, // Ks=Strickler - // 2, // Q=Débit - // 0.001, // If=pente du fond - // precDist, // précision - // 1 // YB=hauteur de berge - // ); - - // let sect = new cSnRectang(undefined, prms); - - // let prem = new CourbeRemousParams(sect, 0.01, // Yamont = tirant amont - // 0.403, // Yaval = tirant aval - // 5, // Long= Longueur du bief - // 0.05, // Dx=Pas d'espace - // MethodeResolution.EulerExplicite - // ); - - // let log = new cLog(); - // let rem = new CourbeRemous(sect, prem, log); - - // let res = rem.calculRemous(undefined); - - // // données de validation : version Typescript (Oct 2017) méthode des trapèzes - - // let f = { "0": 0.01, "1": 0.5005000000000004, "2": 0.4885000000000004, "3": 0.47393750000000023, "4": 0.45418750000000013, "5": 0.403, "4.95": 0.41471875, "4.9": 0.41956250000000006, "4.85": 0.42328125000000005, "4.8": 0.42637500000000006, "4.75": 0.42909375000000005, "4.7": 0.43156250000000007, "4.65": 0.43378125000000006, "4.6": 0.43587500000000007, "4.55": 0.4378437500000001, "4.5": 0.4396875000000001, "4.45": 0.4414062500000001, "4.4": 0.44306250000000014, "4.35": 0.44465625000000014, "4.3": 0.4461875000000001, "4.25": 0.44765625000000014, "4.2": 0.44906250000000014, "4.15": 0.4504062500000001, "4.1": 0.45168750000000013, "4.05": 0.45296875000000014, "3.95": 0.4554062500000001, "3.9": 0.4565625000000001, "3.85": 0.45771875000000006, "3.8": 0.45881250000000007, "3.75": 0.45990625000000007, "3.7": 0.4610000000000001, "3.65": 0.46203125000000006, "3.6": 0.46306250000000004, "3.55": 0.46403125000000006, "3.5": 0.4650000000000001, "3.45": 0.4659687500000001, "3.4": 0.4669375000000001, "3.35": 0.4678437500000001, "3.3": 0.4687500000000001, "3.25": 0.4696562500000001, "3.2": 0.4705625000000001, "3.15": 0.47140625000000014, "3.1": 0.47225000000000017, "3.05": 0.4730937500000002, "2.95": 0.47478125000000027, "2.9": 0.4755625000000003, "2.85": 0.4763437500000003, "2.8": 0.4771250000000003, "2.75": 0.4779062500000003, "2.7": 0.4786875000000003, "2.65": 0.47946875000000033, "2.6": 0.4801875000000003, "2.55": 0.4809062500000003, "2.5": 0.4816250000000003, "2.45": 0.4823437500000003, "2.4": 0.4830625000000003, "2.35": 0.4837812500000003, "2.3": 0.48450000000000026, "2.25": 0.48521875000000025, "2.2": 0.4858750000000003, "2.15": 0.4865312500000003, "2.1": 0.48718750000000033, "2.05": 0.48784375000000035, "1.95": 0.4891562500000004, "1.9": 0.48981250000000043, "1.85": 0.49046875000000045, "1.8": 0.4911250000000005, "1.75": 0.4917812500000005, "1.7": 0.4923750000000005, "1.65": 0.4929687500000005, "1.6": 0.4935625000000005, "1.55": 0.4941562500000005, "1.5": 0.4947500000000005, "1.45": 0.4953437500000005, "1.4": 0.49593750000000053, "1.35": 0.49653125000000053, "1.3": 0.49712500000000054, "1.25": 0.49771875000000054, "1.2": 0.49831250000000055, "1.15": 0.49890625000000055, "1.1": 0.49943750000000053, "1.05": 0.4999687500000005, "0.95": 0.5010312500000003, "0.9": 0.5015625000000001, "0.85": 0.50209375, "0.8": 0.5026249999999999, "0.75": 0.5031562499999997, "0.7": 0.5036874999999996, "0.65": 0.5042187499999995, "0.6": 0.5047499999999994, "0.55": 0.5052812499999992, "0.5": 0.5058124999999991, "0.45": 0.506343749999999, "0.4": 0.5068749999999989, "0.35": 0.5074062499999987, "0.3": 0.5079374999999986, "0.25": 0.5084062499999986, "0.2": 0.5088749999999986, "0.15": 0.5093437499999987, "0.1": 0.5098124999999987, "0.05": 0.5102812499999987 }; - // compareObject("Yfluvial", res["flu"], f, 0.03); - - // let t = { "0": 0.01, "0.05": 0.01146875, "0.1": 0.012812500000000001, "0.15": 0.014156250000000002, "0.2": 0.015437500000000003, "0.25": 0.01665625, "0.3": 0.017875, "0.35": 0.019093749999999996, "0.4": 0.020249999999999994, "0.45": 0.02140624999999999, "0.5": 0.02249999999999999, "0.55": 0.023593749999999986, "0.6": 0.024687499999999984, "0.65": 0.02578124999999998, "0.7": 0.02681249999999998, "0.75": 0.027843749999999976, "0.8": 0.028874999999999974, "0.85": 0.02990624999999997, "0.9": 0.5015625000000001 }; - // compareObject("Ytorrentiel", res["tor"], t, 0.03); - - // let x = [0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45, 1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95, 2, 2.05, 2.1, 2.15, 2.2, 2.25, 2.3, 2.35, 2.4, 2.45, 2.5, 2.55, 2.6, 2.65, 2.7, 2.75, 2.8, 2.85, 2.9, 2.95, 3, 3.05, 3.1, 3.15, 3.2, 3.25, 3.3, 3.35, 3.4, 3.45, 3.5, 3.55, 3.6, 3.65, 3.7, 3.75, 3.8, 3.85, 3.9, 3.95, 4, 4.05, 4.1, 4.15, 4.2, 4.25, 4.3, 4.35, 4.4, 4.45, 4.5, 4.55, 4.6, 4.65, 4.7, 4.75, 4.8, 4.85, 4.9, 4.95, 5]; - // compareArray("abscisses", res["trX"], x); - - // let expLog = new cLog(); - // let m = new ErrorMessage(ErrorCode.ERROR_REMOUS_LARGEUR_BERGE); - // m.extraVar["B"] = 2.5; - // expLog.add(m); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_H_CRITIQUE); - // m.extraVar["Yc"] = 0.403; - // expLog.add(m); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_H_NORMALE); - // m.extraVar["Yn"] = 0.953; - // expLog.add(m); - - // expLog.add(new ErrorMessage(ErrorCode.ERROR_REMOUS_CALCUL_FLUVIAL)); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_PENTE_FORTE); - // m.extraVar["x"] = 4.75; - // expLog.add(m); - - // expLog.add(new ErrorMessage(ErrorCode.ERROR_REMOUS_CALCUL_TORRENTIEL)); - - // m = new ErrorMessage(ErrorCode.ERROR_REMOUS_RESSAUT_DEHORS); - // m.extraVar["sens"] = "amont"; - // m.extraVar["x"] = 0; - // expLog.add(m); - // }); - it("faible pente, pas de ressaut, Yamont > Yc, Yaval > Yn", () => { - let prms = new ParamsSectionRectang(undefined, // tirant d'eau + const prms = new ParamsSectionRectang(undefined, // tirant d'eau 2.5, // largeur de fond 40, // Ks=Strickler 2, // Q=Débit @@ -230,40 +26,50 @@ describe("Class Remous / section rectangulaire :", () => { 1 // YB=hauteur de berge ); - let sect = new cSnRectang(prms); + const sect = new cSnRectang(prms); - let prem = new CourbeRemousParams(sect, 0.5, // Yamont = tirant amont + const prem = new CourbeRemousParams(sect, 0.5, // Yamont = tirant amont 1, // Yaval = tirant aval 100, // Long= Longueur du bief 5, // Dx=Pas d'espace MethodeResolution.EulerExplicite ); - let rem = new CourbeRemous(prem); + const rem = new CourbeRemous(prem); - let res: Result = rem.calculRemous(undefined); + const res: Result = rem.calculRemous(undefined); // données de validation : version Typescript (Oct 2017) méthode des trapèzes - let f = { "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 }; + const f = { + "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 + }; compareObject("Yfluvial", res.getExtraResult("flu"), f, 0.03); - expect(res.extraResultLength("tor") == 0).toBeTruthy("la ligne d'eau torrentielle ne devrait comporter aucune valeur"); + expect( + res.extraResultLength("tor") == 0 + ).toBeTruthy("la ligne d'eau torrentielle ne devrait comporter aucune valeur"); - let x = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]; + const x = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]; compareArray("abscisses", res.getExtraResult("trX"), x); - let expLog = new cLog(); + const expLog = new cLog(); let m = new Message(MessageCode.INFO_REMOUS_LARGEUR_BERGE); - m.extraVar["B"] = 2.5; + m.extraVar.B = 2.5; expLog.add(m); m = new Message(MessageCode.INFO_REMOUS_H_CRITIQUE); - m.extraVar["Yc"] = 0.403; + m.extraVar.Yc = 0.403; expLog.add(m); m = new Message(MessageCode.INFO_REMOUS_H_NORMALE); - m.extraVar["Yn"] = 0.953; + m.extraVar.Yn = 0.953; expLog.add(m); expLog.add(new Message(MessageCode.INFO_REMOUS_CALCUL_FLUVIAL)); @@ -274,7 +80,7 @@ describe("Class Remous / section rectangulaire :", () => { }); it("faible pente, pas de ressaut, Yamont > Yc, Yc < Yaval < Yn", () => { - let prms = new ParamsSectionRectang(undefined, // tirant d'eau + const prms = new ParamsSectionRectang(undefined, // tirant d'eau 2.5, // largeur de fond 40, // Ks=Strickler 2, // Q=Débit @@ -283,40 +89,50 @@ describe("Class Remous / section rectangulaire :", () => { 1 // YB=hauteur de berge ); - let sect = new cSnRectang(prms); + const sect = new cSnRectang(prms); - let prem = new CourbeRemousParams(sect, 0.5, // Yamont = tirant amont + const prem = new CourbeRemousParams(sect, 0.5, // Yamont = tirant amont 0.7, // Yaval = tirant aval 100, // Long= Longueur du bief 5, // Dx=Pas d'espace MethodeResolution.EulerExplicite ); - let rem = new CourbeRemous(prem); + const rem = new CourbeRemous(prem); - let res = rem.calculRemous(undefined); + const res = rem.calculRemous(undefined); // données de validation : version Typescript (Oct 2017) méthode trapèzes - let f = { "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 }; + const f = { + "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 + }; compareObject("Yfluvial", res.getExtraResult("flu"), f, 0.03); - expect(res.extraResultLength("tor") == 0).toBeTruthy("la ligne d'eau torrentielle ne devrait comporter aucune valeur"); + expect( + res.extraResultLength("tor") === 0 + ).toBeTruthy("la ligne d'eau torrentielle ne devrait comporter aucune valeur"); - let x = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]; + const x = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]; compareArray("abscisses", res.getExtraResult("trX"), x); - let expLog = new cLog(); + const expLog = new cLog(); let m = new Message(MessageCode.INFO_REMOUS_LARGEUR_BERGE); - m.extraVar["B"] = 2.5; + m.extraVar.B = 2.5; expLog.add(m); m = new Message(MessageCode.INFO_REMOUS_H_CRITIQUE); - m.extraVar["Yc"] = 0.403; + m.extraVar.Yc = 0.403; expLog.add(m); m = new Message(MessageCode.INFO_REMOUS_H_NORMALE); - m.extraVar["Yn"] = 0.953; + m.extraVar.Yn = 0.953; expLog.add(m); expLog.add(new Message(MessageCode.INFO_REMOUS_CALCUL_FLUVIAL)); diff --git a/spec/structure/parallel_structure.spec.ts b/spec/structure/parallel_structure.spec.ts index 79f77158e2b5ca821957f3d12f0f1a9f54fbe60e..56bc6d092d1d86ed635ce0d43b2afd7961fc2dd9 100644 --- a/spec/structure/parallel_structure.spec.ts +++ b/spec/structure/parallel_structure.spec.ts @@ -7,12 +7,13 @@ // import { describe, expect, it, xdescribe, xit } from "../mock_jasmine"; import { ParamCalculability, ParamDefinition, ParamsEquation } from "../../src/param"; -import { CreateStructure, LoiDebit, StructureType } from "../../src/structure/factory_structure"; +import { CreateStructure, loiAdmissibles, LoiDebit, StructureType } from "../../src/structure/factory_structure"; import { ParallelStructure } from "../../src/structure/parallel_structure"; import { ParallelStructureParams } from "../../src/structure/parallel_structure_params"; import { Structure } from "../../src/structure/structure"; import { Describer } from "../../src/util/describer"; import { EnumEx } from "../../src/util/enum"; +import { MessageCode } from "../../src/util/message"; import { Result } from "../../src/util/result"; import { precDigits } from "../test_config"; import { checkResult } from "../test_func"; @@ -83,31 +84,30 @@ const ps2: ParallelStructure = new ParallelStructure( false // debug ); -// Ajout d'une structure de chaque type dans ParallelStructure -const iLoiDebits: number[] = []; -for (const s of EnumEx.getValues(StructureType)) { - for (const i of EnumEx.getValues(LoiDebit)) { - try { - ps2.addStructure(CreateStructure(s, i)); - iLoiDebits.push(i); - } catch (e) { - // Pour les combinaisons StructureType X LoiDebit impossibles rejetées par la Factory +// tslint:disable-next-line:prefer-for-of +describe("Class ParallelStructure: ", () => { + // Ajout d'une structure de chaque type dans ParallelStructure + const iLoiDebits: number[] = []; + const iStTypes: number[] = []; + for (const s of EnumEx.getValues(StructureType)) { + for (const la of loiAdmissibles[StructureType[s]]) { + ps2.addStructure(CreateStructure(s, la, false)); + iLoiDebits.push(la); + iStTypes.push(s); } } -} -ps2.prms.Q.v = ps2.Calc("Q").vCalc; + ps2.prms.Q.v = ps2.Calc("Q").vCalc; -// tslint:disable-next-line:prefer-for-of -describe("Class ParallelStructure: ", () => { for (let i = 0; i < ps2.structures.length; i++) { const st: Structure = ps2.structures[i]; - describe(`this.structures[${i}]: Structure${LoiDebit[iLoiDebits[i]]}: `, () => { - // tslint:disable-next-line:forin + describe(`this.structures[${i}]: ${StructureType[iStTypes[i]]} Structure${LoiDebit[iLoiDebits[i]]}: `, () => { for (const prm of st.prms) { - if (prm.calculability === ParamCalculability.DICHO && - prm.symbol !== "Z1" && prm.symbol !== "Z2") { - + if ( + prm.calculability === ParamCalculability.DICHO && + prm.symbol !== "Z1" && prm.symbol !== "Z2" + ) { + const ref: number = prm.v; if (prm.symbol === "W" && prm.v === Infinity) { // Le calcul de l'ouverture sur les seuils doit renvoyer une exception (cas impossible) it(`Calc(${prm.symbol}) should return exception`, () => { @@ -115,23 +115,25 @@ describe("Class ParallelStructure: ", () => { () => { ps2.Calc(i + "." + prm.symbol); } ).toThrow(new Error("Structure:Calc : Calcul de W impossible sur un seuil")); }); + } else if ( + iStTypes[i] === StructureType.VanneRectangulaire && + !ps2.structures[i].isZDVcalculable && + prm.symbol === "ZDV" + ) { + // Les lois CEM88D et CUNGE80 ne font pas intervenir ZDV dans le calcul d'un orifice noyé + // TODO Il faudrait générer une erreur pour dire que le résultat est indéfini + it(`Calc(${prm.symbol}) should return an error`, () => { + expect( + ps2.Calc(i + "." + prm.symbol).code + ).toBe(MessageCode.ERROR_STRUCTURE_ZDV_PAS_CALCULABLE); + }); } else { - const ref: number = prm.v; - const res: Result = ps2.Calc(i + "." + prm.symbol); - if ((iLoiDebits[i] === 2 || iLoiDebits[i] === 4) && prm.symbol === "ZDV") { - // Les lois CEM88D et CUNGE80 ne font pas intervenir ZDV dans le calcul d'un orifice noyé - // TODO Il faudrait générer une erreur pour dire que le résultat est indéfini - xit(`Calc(${prm.symbol}) should return undefined`, () => { - checkResult(res, undefined); - }); - } else { - // On ne teste pas le calcul de l'ouverture sur les seuils - it(`Calc(${prm.symbol}) should return ${ref}`, () => { - checkResult(res, ref); - }); - } - prm.v = ref; // Go back to initial value for following tests + // Cas normal : On teste la valeur calculée + it(`Calc(${prm.symbol}) should return ${ref}`, () => { + checkResult(ps2.Calc(i + "." + prm.symbol), ref); + }); } + prm.v = ref; // Go back to initial value for following tests } } }); diff --git a/spec/structure/structure_kivi.spec.ts b/spec/structure/structure_kivi.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..26aa64e79e2044682954629647bf32a538d770dc --- /dev/null +++ b/spec/structure/structure_kivi.spec.ts @@ -0,0 +1,47 @@ +/** + * 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 et structure_test.ts + */ +// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine"; + +import { StructureFlowMode, StructureFlowRegime, MessageCode } from "../../src"; +import { CreateStructure, LoiDebit, StructureType } from "../../src/structure/factory_structure"; +import { StructureKivi } from "../../src/structure/structure_kivi"; +import { StructureKiviParams } from "../../src/structure/structure_kivi_params"; +import { testStructure } from "./structure_test"; + +const structTest: StructureKivi = CreateStructure( + StructureType.SeuilRectangulaire, LoiDebit.KIVI +) as StructureKivi; + +describe("Class StructureKivi: ", () => { + describe("Ecoulement noyé", () => { + testStructure(structTest, StructureFlowMode.WEIR, StructureFlowRegime.SUBMERGED); + }); + describe("Ecoulement dénoyé beta=0", () => { + structTest.prms.beta.v = 0; + structTest.prms.Z2.v = 101; + structTest.prms.Q.v = 10.024; + testStructure(structTest, StructureFlowMode.WEIR, StructureFlowRegime.FREE); + }); + describe("Ecoulement dénoyé beta=0.001", () => { + structTest.prms.beta.v = 0.001; + structTest.prms.Z2.v = 101; + structTest.prms.Q.v = 10.074; + testStructure(structTest, StructureFlowMode.WEIR, StructureFlowRegime.FREE); + }); + describe("Pelle trop faible", () => { + structTest.prms.ZRAM.v = 100.95; + it("Calc(Q) should return 2 messages", () => { + expect(structTest.Calc("Q").result.log.messages.length).toBe(2); + expect( + structTest.Calc("Q").result.log.messages[0].code + ).toBe(MessageCode.WARNING_STRUCTUREKIVI_PELLE_TROP_FAIBLE); + expect( + structTest.Calc("Q").result.log.messages[1].code + ).toBe(MessageCode.WARNING_STRUCTUREKIVI_HP_TROP_ELEVE); + }); + }); +}); diff --git a/spec/structure/structure_test.ts b/spec/structure/structure_test.ts index c4e582feafa5f8011717b2fe3b84eec917649034..1cf6216b0cd7bb4368b0b90d5220a4a1132d6934 100644 --- a/spec/structure/structure_test.ts +++ b/spec/structure/structure_test.ts @@ -1,5 +1,15 @@ -import { Structure, StructureParams } from "../../src/structure/structure"; +/** + * 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, xit } from "../mock_jasmine"; + +import { ParamCalculability, ParamDefinition, ParamsEquation } from "../../src/param"; +import { Structure, StructureParams, StructureFlowRegime, StructureFlowMode } from "../../src/structure/structure"; import { Result } from "../../src/util/result"; +import { checkResult } from "../test_func"; class StructureTest extends Structure { @@ -41,3 +51,44 @@ class StructureTest extends Structure { */ export const structTestPrm: StructureParams = new StructureParams(1, 0, 30, 15); export const structTest: StructureTest = new StructureTest(structTestPrm, false); + +/** + * Test de calcul de tous les paramètres d'une loi de débit + * @param st Structure à tester + * @param bNotZDV Loi de débit ne permettant pas de calculer ZDV + */ +export function testStructure( + st: Structure, + mode: StructureFlowMode, + regime: StructureFlowRegime, + bNotZDV: boolean = false +) { + for (const prm of st.prms) { + if ([ParamCalculability.DICHO, ParamCalculability.EQUATION].includes(prm.calculability)) { + if (prm.symbol === "W" && prm.v === Infinity) { + // Le calcul de l'ouverture sur les seuils doit renvoyer une exception (cas impossible) + it(`Calc(${prm.symbol}) should return exception`, () => { + expect( + () => { st.Calc(prm.symbol); } + ).toThrow(new Error("Structure:Calc : Calcul de W impossible sur un seuil")); + }); + } else { + const ref: number = prm.v; + const res: Result = st.Calc(prm.symbol); + if (bNotZDV) { + // Les lois CEM88D et CUNGE80 ne font pas intervenir ZDV dans le calcul d'un orifice noyé + // TODO Il faudrait générer une erreur pour dire que le résultat est indéfini + xit(`Calc(${prm.symbol}) should return undefined`, () => { + checkResult(res, undefined); + }); + } else { + // On ne teste pas le calcul de l'ouverture sur les seuils + it(`Calc(${prm.symbol}) should return ${ref}`, () => { + checkResult(res, ref); + }); + } + prm.v = ref; // Go back to initial value for following tests + } + } + } +} \ No newline at end of file diff --git a/src/param.ts b/src/param.ts index ed9b00ad9757e8e0802c2d630b33854b06e97587..af75f075398ef76a139b4dcdf3e6107c4d021925 100644 --- a/src/param.ts +++ b/src/param.ts @@ -1,9 +1,9 @@ import { Debug } from "./base"; +import { JalhydObject } from "./jalhyd_object"; import { DefinedNumber } from "./util/definedvalue"; import { Interval } from "./util/interval"; -import { Message, MessageCode } from "./util/message"; import { MapIterator } from "./util/iterator"; -import { JalhydObject } from "./jalhyd_object"; +import { Message, MessageCode } from "./util/message"; /** * domaine de définition du paramètre @@ -307,7 +307,7 @@ export class ParamDefinition extends BaseParam { constructor(s: string, d: ParamDomain | ParamDomainValue, val?: number) { super(s, d, val); - this._calc = undefined; + this._calc = ParamCalculability.FREE; this.checkValue(val); } @@ -364,11 +364,27 @@ export class ParamDefinition extends BaseParam { export abstract class ParamsEquation implements Iterable<ParamDefinition> { protected _paramMap: { [key: string]: ParamDefinition } = {}; + private _calculabilityDefined: boolean; + + public constructor() { + this._calculabilityDefined = false; + } + + get calculabilityDefined(): boolean { + return this._calculabilityDefined; + } + + public DefineCalculability() { + this._calculabilityDefined = true; + } + public hasParameter(name: string): boolean { for (const ps in this._paramMap) { - const p: ParamDefinition = this._paramMap[ps]; - if (p.symbol === name) { - return true; + if (this._paramMap.hasOwnProperty(ps)) { + const p: ParamDefinition = this._paramMap[ps]; + if (p.symbol === name) { + return true; + } } } @@ -377,9 +393,11 @@ export abstract class ParamsEquation implements Iterable<ParamDefinition> { public getParameter(name: string): ParamDefinition { for (const ps in this._paramMap) { - const p: ParamDefinition = this._paramMap[ps]; - if (p.symbol === name) { - return p; + if (this._paramMap.hasOwnProperty(ps)) { + const p: ParamDefinition = this._paramMap[ps]; + if (p.symbol === name) { + return p; + } } } @@ -388,37 +406,38 @@ export abstract class ParamsEquation implements Iterable<ParamDefinition> { public getFirstAnalyticalParameter(): ParamDefinition { for (const ps in this._paramMap) { - const p: ParamDefinition = this._paramMap[ps]; - if (p.isAnalytical()) { - return p; + if (this._paramMap.hasOwnProperty(ps)) { + const p: ParamDefinition = this._paramMap[ps]; + if (p.isAnalytical()) { + return p; + } } } return undefined; } - protected addParamDefinition(p: ParamDefinition) { - if (!this.hasParameter(p.symbol)) { - this._paramMap[p.symbol] = p; - } + public get map(): { [key: string]: ParamDefinition } { + return this._paramMap; } - protected addParamDefinitions(ps: ParamsEquation) { - for (const pi in ps._paramMap) { - this.addParamDefinition(ps._paramMap[pi]); + public resetParametersCalculability() { + for (const ps in this._paramMap) { + if (this._paramMap.hasOwnProperty(ps)) { + const p: ParamDefinition = this._paramMap[ps]; + p.calculability = undefined + } } } - public get map(): { [key: string]: ParamDefinition } { - return this._paramMap; - } - - protected checkParametersCalculability() { + public checkParametersCalculability() { const res = []; for (const ps in this._paramMap) { - const p: ParamDefinition = this._paramMap[ps]; - if (p.calculability === undefined) { - res.push(p.symbol); + if (this._paramMap.hasOwnProperty(ps)) { + const p: ParamDefinition = this._paramMap[ps]; + if (p.calculability === undefined) { + res.push(p.symbol); + } } } @@ -427,16 +446,31 @@ export abstract class ParamsEquation implements Iterable<ParamDefinition> { } } - [Symbol.iterator](): Iterator<ParamDefinition> { + public [Symbol.iterator](): Iterator<ParamDefinition> { return this.iterator; } public get iterator() { return new MapIterator(this._paramMap); } + + protected addParamDefinition(p: ParamDefinition) { + if (!this.hasParameter(p.symbol)) { + this._paramMap[p.symbol] = p; + } + } + + protected addParamDefinitions(ps: ParamsEquation) { + for (const pi in ps._paramMap) { + if (ps._paramMap.hasOwnProperty(pi)) { + this.addParamDefinition(ps._paramMap[pi]); + } + } + } + } -/** +/** * type de calculette */ export enum CalculatorType { @@ -468,7 +502,11 @@ export abstract class ComputeNode extends Debug { constructor(prms: ParamsEquation, dbg: boolean = false) { super(dbg); this._prms = prms; + if (!this._prms.calculabilityDefined) { + this._prms.resetParametersCalculability(); + } this.setParametersCalculability(); + this._prms.DefineCalculability(); } public getParameter(name: string): ParamDefinition { diff --git a/src/regime_uniforme.ts b/src/regime_uniforme.ts index 9e67d5e85581c4bdcd0bcaa955b46cef8e834091..df983a2b937f20dc17d1bafd17e3ef5a017a8941 100644 --- a/src/regime_uniforme.ts +++ b/src/regime_uniforme.ts @@ -1,7 +1,7 @@ -import { Result } from "./util/result"; import { Nub } from "./nub"; -import { ParamsSection, acSection } from "./section/section_type"; -import { ParamDefinition, ParamCalculability } from "./param" +import { ParamCalculability, ParamDefinition } from "./param" +import { acSection, ParamsSection } from "./section/section_type"; +import { Result } from "./util/result"; export class RegimeUniforme extends Nub { private Sn: acSection; @@ -11,52 +11,51 @@ export class RegimeUniforme extends Nub { this.Sn = s; } + get prms(): ParamsSection { + return this._prms as ParamsSection; + } + + public Equation(sVarCalc: string): Result { + this.debug("RU: Equation(" + sVarCalc + ")") + + switch (sVarCalc) { + case "Y": + return this.Sn.Calc("Yn"); + + case "Q": + return this.Calc_Qn(); + + default: + throw new Error("RegimeUniforme.Equation() : invalid variable name " + sVarCalc); + } + } + protected setParametersCalculability() { this.prms.Q.calculability = ParamCalculability.EQUATION; this.prms.Y.calculability = ParamCalculability.EQUATION; } - get prms(): ParamsSection { - return <ParamsSection>this._prms; - } - /** - * Calcul du débit en régime uniforme. - * @return Débit en régime uniforme - */ - Calc_Qn(): Result { - if (this.Sn.prms.If.v <= 0) + * Calcul du débit en régime uniforme. + * @return Débit en régime uniforme + */ + private Calc_Qn(): Result { + if (this.Sn.prms.If.v <= 0) { return new Result(0); - - // this.debug("RU: Calc_Qn : "); - // this.debug(this.Sn.prms); - - // return this.Sn.prms.Ks.v * Math.pow(this.Sn.Calc("R", this.Sn.prms.Y.v), 2 / 3) * this.Sn.Calc("S", this.Sn.prms.Y.v) * Math.sqrt(this.Sn.prms.If.v); + } const rR: Result = this.Sn.Calc("R", this.Sn.prms.Y.v); - if (!rR) + if (!rR) { return rR; + } const rS: Result = this.Sn.Calc("S", this.Sn.prms.Y.v) - if (!rS) + if (!rS) { return rS; + } const v = this.Sn.prms.Ks.v * Math.pow(rR.vCalc, 2 / 3) * rS.vCalc * Math.sqrt(this.Sn.prms.If.v); return new Result(v); } - Equation(sVarCalc: string): Result { - this.debug("RU: Equation(" + sVarCalc + ")") - - switch (sVarCalc) { - case 'Y': - return this.Sn.Calc("Yn"); - - case 'Q': - return this.Calc_Qn(); - - default: - throw "RegimeUniforme.Equation() : invalid variable name " + sVarCalc; - } - } } diff --git a/src/remous.ts b/src/remous.ts index 554f5f3c96b2a86a0746c55970c1963b6d6013c4..a769963ef0d2edbfe6baec1de229ff6f6bf05b69 100644 --- a/src/remous.ts +++ b/src/remous.ts @@ -65,6 +65,7 @@ export class CourbeRemousParams extends ParamsEquation { this.addParamDefinition(this._Long); this.addParamDefinition(this._Dx); this.addParamDefinitions(this._section.prms); + this.DefineCalculability(); // Pour ne pas remettre en undefined les prms de _section } get Sn() { diff --git a/src/structure/factory_structure.ts b/src/structure/factory_structure.ts index d5fe52f42eff286c6168e3e3e7dae331fcde6ea3..787daa1f7999c71e0143ca7aea8ba98c11a47d0e 100644 --- a/src/structure/factory_structure.ts +++ b/src/structure/factory_structure.ts @@ -3,12 +3,14 @@ import { Structure } from "./structure"; import { StructureCem88d } from "./structure_cem88d"; import { StructureCem88v } from "./structure_cem88v"; import { StructureCunge80 } from "./structure_cunge80"; +import { StructureKivi } from "./structure_kivi"; +import { StructureKiviParams } from "./structure_kivi_params"; import { StructureOrificeFree } from "./structure_orifice_free"; import { StructureOrificeSubmerged } from "./structure_orifice_submerged"; import { StructureWeirFree } from "./structure_weir_free"; export enum StructureType { - VanneRectangulaire, SeuilRectangulaire, + SeuilRectangulaire, VanneRectangulaire // VanneCirculaire, // VanneTrapezoidale, SeuilTrapezoidal } @@ -25,42 +27,47 @@ export enum LoiDebit { // loi de débit pour vanne noyée OrificeSubmerged, // loi de débit pour seuil dénoyé - WeirFree + WeirFree, + // Loi Kindsvater-Carter et Villemonte + KIVI } -const loiAdmissibles: { [key: string]: LoiDebit[] } = { - "VanneRectangulaire": [LoiDebit.Cem88d, LoiDebit.Cem88v, LoiDebit.WeirFree, LoiDebit.Cunge80], - "SeuilRectangulaire": [LoiDebit.Cem88d, LoiDebit.Cem88v, LoiDebit.Cunge80, LoiDebit.OrificeFree, LoiDebit.OrificeSubmerged] -} +export const loiAdmissibles: { [key: string]: LoiDebit[] } = { + SeuilRectangulaire: [ + LoiDebit.Cem88d, LoiDebit.Cem88v, LoiDebit.Cunge80, LoiDebit.WeirFree, + LoiDebit.KIVI + ], + VanneRectangulaire: [ + LoiDebit.Cem88d, LoiDebit.Cem88v, LoiDebit.Cunge80, LoiDebit.OrificeFree, + LoiDebit.OrificeSubmerged + ] +}; -export function CreateStructure(structureType: StructureType, loiDebit: LoiDebit): Structure { +export function CreateStructure(structureType: StructureType, loiDebit: LoiDebit, dbg: boolean = false): Structure { + const rectStructPrms: RectangularStructureParams = new RectangularStructureParams( + 0, // Q + 100, // ZDV + 102, // Z1 + 101.5, // Z2 + 2, // L + 0.4 // Cd pour un seuil rectangulaire + // W = Infinity par défaut pour un seuil + ); switch (structureType) { case StructureType.VanneRectangulaire: - var structPrms: RectangularStructureParams = new RectangularStructureParams( - 0, // Q - 100, // ZDV - 102, // Z1 - 101.5, // Z2 - 2, // L - 0.6, // Cd - 0.5 // W - ); - if (!(loiDebit in loiAdmissibles["VanneRectangulaire"])) { - throw new Error(`la loi de débit ${LoiDebit[loiDebit]} n'est pas admissible pour les vannes rectangulaires`); + rectStructPrms.W.v = 0.5; + rectStructPrms.Cd.v = 0.6; // Cd pour une vanne rectangulaire + if (!(loiAdmissibles.VanneRectangulaire.includes(loiDebit))) { + throw new Error( + `la loi de débit ${LoiDebit[loiDebit]} n'est pas admissible pour les vannes rectangulaires` + ); } break; - case StructureType.SeuilRectangulaire: - structPrms = new RectangularStructureParams( - 0, // Q - 100, // ZDV - 102, // Z1 - 101.5, // Z2 - 2, // L - 0.6 // Cd - ); - if (!(loiDebit in loiAdmissibles["SeuilRectangulaire"])) { - throw new Error(`la loi de débit ${LoiDebit[loiDebit]} n'est pas admissible pour les seuils rectangulaires`); + if (!loiAdmissibles.SeuilRectangulaire.includes(loiDebit)) { + throw new Error( + `la loi de débit ${LoiDebit[loiDebit]} n'est pas admissible pour les seuils rectangulaires` + ); } break; @@ -70,23 +77,38 @@ export function CreateStructure(structureType: StructureType, loiDebit: LoiDebit switch (loiDebit) { case LoiDebit.Cem88d: - return new StructureCem88d(structPrms); + rectStructPrms.Cd.v = 0.4; // Cd Cem88d qu'on soit en seuil ou vanne + return new StructureCem88d(rectStructPrms, dbg); case LoiDebit.Cem88v: - return new StructureCem88v(structPrms); + rectStructPrms.Cd.v = 0.6; // Cd Cem88d qu'on soit en seuil ou vanne + return new StructureCem88v(rectStructPrms, dbg); case LoiDebit.Cunge80: - return new StructureCunge80(structPrms); + rectStructPrms.Cd.v = 0.6; // Cd Cunge80 qu'on soit en seuil ou vanne + return new StructureCunge80(rectStructPrms, dbg); case LoiDebit.OrificeFree: - return new StructureOrificeFree(structPrms); + return new StructureOrificeFree(rectStructPrms, dbg); case LoiDebit.OrificeSubmerged: - return new StructureOrificeSubmerged(structPrms); + return new StructureOrificeSubmerged(rectStructPrms, dbg); case LoiDebit.WeirFree: - const st: StructureWeirFree = new StructureWeirFree(structPrms); - st.prms.Cd.v = 0.4; - return st; + return new StructureWeirFree(rectStructPrms, dbg); + case LoiDebit.KIVI: + const structKiviPrm: StructureKiviParams = new StructureKiviParams( + 8.516, // Q + 101, // ZDV + 103, // Z1 + 102, // Z2 + 2, // L + 0.4, // alpha + 0.001, // béta + 100); // ZRAM : cote Radier Amont + return new StructureKivi(structKiviPrm, dbg); + default: + throw new Error(`type de LoiDebit ${LoiDebit[loiDebit]} non pris en charge`); + } } diff --git a/src/structure/structure.ts b/src/structure/structure.ts index 6a7a3ca3979ef69d93eef158b2a98172d8b818d8..c8b84578ae478789aca85f8d60f783b9b06e0cc0 100644 --- a/src/structure/structure.ts +++ b/src/structure/structure.ts @@ -1,6 +1,6 @@ import { Nub } from "../nub"; import { ParamCalculability } from "../param"; -import { Message } from "../util/message"; +import { Message, MessageCode } from "../util/message"; import { Result } from "../util/result"; import { StructureParams } from "./structure_params"; @@ -48,8 +48,16 @@ export abstract class Structure extends Nub { /** Constante utile : Racine de 2g */ protected static readonly R2G: number = Math.sqrt(2 * 9.81); + /** Peut-on calculer ZDV ? */ + protected _isZDVcalculable: boolean; + constructor(prms: StructureParams, dbg: boolean = false) { super(prms, dbg); + this._isZDVcalculable = true; + } + + get isZDVcalculable(): boolean { + return this._isZDVcalculable; } /** @@ -74,6 +82,12 @@ export abstract class Structure extends Nub { if (sVarCalc === "W" && rInit === Infinity) { throw new Error("Structure:Calc : Calcul de W impossible sur un seuil"); } + // Gestion de l'erreur de calcul de ZDV quand il n'est pas calculable + if (sVarCalc === "ZDV" && !this.isZDVcalculable) { + return new Result( + new Message(MessageCode.ERROR_STRUCTURE_ZDV_PAS_CALCULABLE) + ); + } // Mise à jour de h1 et h2 this.prms.update_h1h2(); diff --git a/src/structure/structure_cem88d.ts b/src/structure/structure_cem88d.ts index 27c2405d7bc35b16eb5633bcd088feac5ea74d3d..0ddac7bdb41187a71f3eed1a07fa3bd55ae6f6a3 100644 --- a/src/structure/structure_cem88d.ts +++ b/src/structure/structure_cem88d.ts @@ -10,6 +10,13 @@ export { RectangularStructureParams }; */ export class StructureCem88d extends RectangularStructure { + constructor(prms: RectangularStructureParams, dbg: boolean = false) { + super(prms, dbg); + if (prms.W.v !== Infinity) { + this._isZDVcalculable = false; + } + } + /** * Calcul analytique Q = f(Cd, L, h1, h2, W) CEM88D * @param sVarCalc Variable à calculer (doit être "Q") diff --git a/src/structure/structure_cunge80.ts b/src/structure/structure_cunge80.ts index 155aa52ccefcc731842e9645cc77b26d3ffe6060..b278eadca75c9feb578e12a9cfdbcad4162ad789 100644 --- a/src/structure/structure_cunge80.ts +++ b/src/structure/structure_cunge80.ts @@ -9,6 +9,14 @@ export { RectangularStructureParams }; * Equation Cunge80 */ export class StructureCunge80 extends RectangularStructure { + + constructor(prms: RectangularStructureParams, dbg: boolean = false) { + super(prms, dbg); + if (prms.W.v !== Infinity) { + this._isZDVcalculable = false; + } + } + /** * Calcul du débit avec l'équation Cunge80 * @param sVarCalc Variable à calculer (doit être égale à Q ici) diff --git a/src/structure/structure_kivi.ts b/src/structure/structure_kivi.ts index 2d2be5ecbba10a7bb8dba52eacd1bc391441452a..6779bf80ef3c671653742f3a1f8ac05fbdd2e3bc 100644 --- a/src/structure/structure_kivi.ts +++ b/src/structure/structure_kivi.ts @@ -20,7 +20,7 @@ export class StructureKivi extends Structure { public Equation(sVarCalc: string): Result { Structure.CheckEquation(sVarCalc); - const res: Result = new Result(undefined, this.getResultData()); + const res: Result = new Result(0, this.getResultData()); // p : pelle let p: number = this.prms.ZDV.v - this.prms.ZRAM.v; @@ -29,20 +29,21 @@ export class StructureKivi extends Structure { if (p < 0.1) { // - p ne doit pas être inférieur à 0,10 m (Norme NF X10-311-1983) res.result.addMessage(new Message(MessageCode.WARNING_STRUCTUREKIVI_PELLE_TROP_FAIBLE)); - h1p = 0; - } else { - h1p = this.prms.h1.v / p; - if (h1p > 2.5) { - // - h/p ne doit pas être supérieur à 2,5 (Norme NF X10-311-1983) - res.result.addMessage(new Message(MessageCode.WARNING_STRUCTUREKIVI_HP_TROP_ELEVE)); - h1p = 2.5; - } + p = 0.1; + } + + h1p = this.prms.h1.v / p; + if (h1p > 2.5) { + // - h/p ne doit pas être supérieur à 2,5 (Norme NF X10-311-1983) + res.result.addMessage(new Message(MessageCode.WARNING_STRUCTUREKIVI_HP_TROP_ELEVE)); + h1p = 2.5; } + const cd: number = this.prms.alpha.v + this.prms.beta.v * h1p; let Q = cd * this.prms.L.v * Structure.R2G * Math.pow(this.prms.h1.v, 1.5); - if (res.extraResults.FlowRegime === StructureFlowRegime.SUBMERGED) { + if (res.extraResults.Regime === StructureFlowRegime.SUBMERGED) { Q = Villemonte(this.prms.h1.v, this.prms.h2.v, 1.5) * Q; } diff --git a/src/structure/structure_kivi_params.ts b/src/structure/structure_kivi_params.ts index 3072f5f062953dc2ad11542e73d08634a9ba628f..062b11d079d5d889043dc891b3bfdd4e24c2e79d 100644 --- a/src/structure/structure_kivi_params.ts +++ b/src/structure/structure_kivi_params.ts @@ -33,9 +33,9 @@ export class StructureKiviParams extends StructureParams { this.addParamDefinition(this.L); this.alpha = new ParamDefinition("alpha", ParamDomainValue.POS, rAlpha); this.addParamDefinition(this.alpha); - this.beta = new ParamDefinition("beta", ParamDomainValue.POS, rBeta); + this.beta = new ParamDefinition("beta", ParamDomainValue.POS_NULL, rBeta); this.addParamDefinition(this.beta); - this.ZRAM = new ParamDefinition("ZRAM", ParamDomainValue.POS, rZRAM); + this.ZRAM = new ParamDefinition("ZRAM", ParamDomainValue.ANY, rZRAM); this.addParamDefinition(this.ZRAM); } } diff --git a/src/structure/structure_orifice_submerged.ts b/src/structure/structure_orifice_submerged.ts index dd91446e475f119e28d99423f07863ba4d8662df..be0dae154c58eb52a64140a5644f4425b83c516b 100644 --- a/src/structure/structure_orifice_submerged.ts +++ b/src/structure/structure_orifice_submerged.ts @@ -9,6 +9,14 @@ export { RectangularStructureParams }; * Equation classique orifice noyé */ export class StructureOrificeSubmerged extends RectangularStructure { + + constructor(prms: RectangularStructureParams, dbg: boolean = false) { + super(prms, dbg); + if (prms.W.v !== Infinity) { + this._isZDVcalculable = false; + } + } + /** * Calcul du débit avec l'équation classique d'un orifice noyé * @param sVarCalc Variable à calculer (doit être égale à Q ici) diff --git a/src/util/message.ts b/src/util/message.ts index a6ececce4b9b6ee428fc34497a9ac1a82391996e..0a08e11ef7623473d6a073b1a78898b1eddb368c 100644 --- a/src/util/message.ts +++ b/src/util/message.ts @@ -213,6 +213,12 @@ export enum MessageCode { */ ERROR_NEWTON_DERIVEE_NULLE = -701, + /** + * Le paramètre "Cote de radier" ne peut pas être calculé avec cette loi de débit + */ + ERROR_STRUCTURE_ZDV_PAS_CALCULABLE = -800, + + /** * StructureKivi : La pelle du seuil doit mesurer au moins 0,1 m. Le coefficient béta est forcé à 0. */ diff --git a/tsconfig.json b/tsconfig.json index c345304ba5072030805570231b733fcf0c9e0745..3f76d4b32e96674eb88bd0c40670d39401670301 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es6", + "target": "es2016", "module": "commonjs", "outDir": "./build", "noImplicitAny": true,