diff --git a/spec/remous/remous_abscisse_manquante.spec.ts b/spec/remous/remous_abscisse_manquante.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef1776245572e6b543dfcce686e0c75888dce75f --- /dev/null +++ b/spec/remous/remous_abscisse_manquante.spec.ts @@ -0,0 +1,32 @@ +import { MethodeResolution } from "../../src/remous/methode-resolution"; +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"; + +describe("bug jalhyd#147", () => { + + it("", () => { + const prms = new ParamsSectionRectang( + undefined, // tirant d'eau + 2.5, // largeur de fond + 40, // Ks=Strickler + 1.2, // Q=Débit + undefined, // If=pente du fond + 1, // YB=hauteur de berge + ); + const sect = new cSnRectang(prms); + const prem = new CourbeRemousParams( + 100.25, // Z1 + 100.4, // Z2 + 100.1, // ZF1 + 100, // ZF2 + 10, // Long= Longueur du bief + 2, // Dx=Pas d'espace + ); + const cr = new CourbeRemous(sect, prem, MethodeResolution.Trapezes); + + const res = cr.CalcSerie(); + expect(res.resultElements.length).toBe(6); // 0, 2, 4, 6, 8, 10 + }); +}); diff --git a/spec/remous/remous_cotes.spec.ts b/spec/remous/remous_cotes.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3cf54d1c9be685f1f1128b3d8e1cb512d096ce6 --- /dev/null +++ b/spec/remous/remous_cotes.spec.ts @@ -0,0 +1,40 @@ +import { MethodeResolution } from "../../src/remous/methode-resolution"; +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"; +import { MessageCode } from "../../src/util/message"; + +describe("cote de l'eau par rapport à la cote du fond", () => { + + it("test 1", () => { + const prms = new ParamsSectionRectang( + undefined, // tirant d'eau + 2.5, // largeur de fond + 40, // Ks=Strickler + 2, // Q=Débit + undefined, // If=pente du fond + 1, // YB=hauteur de berge + ); + const sect = new cSnRectang(prms); + const prem = new CourbeRemousParams( + 100.25, // Z1 + 100.4, // Z2 + 100.3, // ZF1 + 100, // ZF2 + 100, // Long= Longueur du bief + 5, // Dx=Pas d'espace + ); + const cr = new CourbeRemous(sect, prem, MethodeResolution.Trapezes); + + let res = cr.CalcSerie(); + expect(res.hasLog()).toBe(true); + expect(res.globalLog.messages[0].code).toBe(MessageCode.WARNING_UPSTREAM_BOTTOM_HIGHER_THAN_WATER); + + cr.prms.ZF1.singleValue = 100.1; + cr.prms.ZF2.singleValue = 100.41; + res = cr.CalcSerie(); + expect(res.hasLog()).toBe(true); + expect(res.globalLog.messages[0].code).toBe(MessageCode.WARNING_DOWNSTREAM_BOTTOM_HIGHER_THAN_WATER); + }); +}); diff --git a/spec/remous/remous_rect_euler_pentefaible.spec.ts b/spec/remous/remous_rect_euler_pentefaible.spec.ts index d70879a87c5c6681ecc577e56b6d7e694ff95b68..1d3c626477f9580addbed251725f0d6b9f76d990 100644 --- a/spec/remous/remous_rect_euler_pentefaible.spec.ts +++ b/spec/remous/remous_rect_euler_pentefaible.spec.ts @@ -24,8 +24,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.5, // Yamont = tirant amont - 1, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.6, 101, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -36,7 +35,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version Typescript (Oct 2017) méthode des trapèzes - const f = { + const f: any = { 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,6 +44,10 @@ describe("Class Remous / section rectangulaire :", () => { 75: 0.9962500000000004, 80: 0.9970000000000003, 85: 0.9977500000000002, 90: 0.9985000000000002, 95: 0.9992500000000001, 100: 1 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -87,8 +90,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.5, // Yamont = tirant amont - 0.7, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.6, 100.7, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -99,7 +101,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version Typescript (Oct 2017) méthode trapèzes - const f = { + const f: any = { 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, @@ -108,6 +110,10 @@ describe("Class Remous / section rectangulaire :", () => { 75: 0.7362499999999997, 80: 0.7299999999999998, 85: 0.7232499999999998, 90: 0.7159999999999999, 95: 0.7082499999999999, 100: 0.7 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); diff --git a/spec/remous/remous_rect_euler_penteforte.spec.ts b/spec/remous/remous_rect_euler_penteforte.spec.ts index d2af319b60df28896c1e803f0c1ba24a8ae63785..a137f5e4e82115bd112bcc4166e2b3c53a07372e 100644 --- a/spec/remous/remous_rect_euler_penteforte.spec.ts +++ b/spec/remous/remous_rect_euler_penteforte.spec.ts @@ -38,8 +38,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 6, // Yaval = tirant aval + const prem = new CourbeRemousParams(105.15, 106, 105, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -50,7 +49,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version Typescript (Oct 2017) méthode des trapèzes - const f = { + const f: any = { 0: 0.9767500000000044, 5: 1.2360000000000044, 10: 1.4910000000000045, @@ -73,6 +72,10 @@ describe("Class Remous / section rectangulaire :", () => { 95: 5.750000000000001, 100: 6 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -121,8 +124,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 0.45, // Yaval = tirant aval + const prem = new CourbeRemousParams(105.15, 100.45, 105, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -137,7 +139,7 @@ describe("Class Remous / section rectangulaire :", () => { // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); - const t = { + const t: any = { 0: 0.15, 5: 0.20725000000000002, 10: 0.23500000000000001, @@ -160,6 +162,10 @@ describe("Class Remous / section rectangulaire :", () => { 95: 0.2527499999999999, 100: 0.253 }; // dernière valeur modifiée pour la raison en tête de fichier + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.03); compareExtraResult("Ytorrentiel", res, "tor", t, 0.03); @@ -195,76 +201,6 @@ describe("Class Remous / section rectangulaire :", () => { compareLog(res.globalLog, expLog); }); - // it("forte pente, ressaut (1 point) à l'intérieur du bief", () => { - // // cas non complètement reproductible car la méthode des trapèzes ne donne pas le même nombre de points - // 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(undefined, prms); - - // let prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - // 1, // Yaval = tirant aval - // 100 // Long= Longueur du bief - // 5, // Dx=Pas d'espace - // MethodeResolution.EulerExplicite - // ); - - // let log = new cLog(); - // let rem = new CourbeRemous(sect, sect, prem, log); - - // let res = rem.calculRemous(undefined); - - // // données de validation : version Typescript (Oct 2017) méthode des trapèzes - - // // let f = { 100.000: 1, 95.000: 0.737, 90.000: 0.451 }; - // let f = { "95": 0.72875, "100": 1 }; - // compareObject("Yfluvial", res["flu"], f, 0.03); - - // tslint:disable-next-line:max-line-length - // // let t = { 0.000: 0.15, 5.000: 0.207, 10.000: 0.241, 15.000: 0.252, 20.000: 0.253, 25.000: 0.253, 30.000: 0.253, 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.451 }; - // tslint:disable-next-line:max-line-length - // let t = { "0": 0.15, "5": 0.20725000000000002, "10": 0.23500000000000001, "15": 0.24675000000000002, "20": 0.251, "25": 0.25225, "30": 0.25249999999999995, "35": 0.2527499999999999, "40": 0.2529999999999999, "45": 0.2527499999999999, "50": 0.2529999999999999, "55": 0.2527499999999999, "60": 0.2529999999999999, "65": 0.2527499999999999, "70": 0.2529999999999999, "75": 0.2527499999999999, "80": 0.2529999999999999, "85": 0.2527499999999999, "90": 0.2529999999999999, "95": 0.72875 }; - // compareObject("Ytorrentiel", res["tor"], t, 0.03); - - // tslint:disable-next-line:max-line-length - // 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.WARNING_REMOUS_ARRET_CRITIQUE) - // m.extraVar["x"] = 85; - // expLog.add(m); - - // expLog.add(new Message(MessageCode.ERROR_REMOUS_CALCUL_TORRENTIEL)); - - // m = new Message(MessageCode.ERROR_REMOUS_RESSAUT_HYDRO); - // m.extraVar["xmin"] = 90; - // m.extraVar["xmax"] = 90; - // expLog.add(m); - - // compareLog(log, expLog); - // }); - xit("forte pente, ressaut (plusieurs points) à l'intérieur du bief", () => { // désactivé car échoue depuis les modifs apportées depuis la version PHP (calcul du ressaut hydraulique) @@ -279,8 +215,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 1, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.425, 101, 100.275, 100, 5.5, // Long= Longueur du bief 0.25, // Dx=Pas d'espace ); @@ -298,7 +233,7 @@ describe("Class Remous / section rectangulaire :", () => { // "2.5": 0.8395000000000004, "2.25": 0.8257500000000004, "1.75": 0.7982500000000006, // "1.5": 0.7845000000000006, "1.25": 0.7702500000000007, "0.75": 0.7417500000000007, // "0.5": 0.7275000000000007, "0.25": 0.7132500000000007 }; - const f = { + const f: any = { 0: 0.698, 1: 0.7560000000000007, 2: 0.8120000000000005, @@ -323,6 +258,10 @@ describe("Class Remous / section rectangulaire :", () => { 0.5: 0.7275000000000007, 0.25: 0.7132500000000007 }; // première valeur modifiée pour la raison en tête de fichier + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -389,8 +328,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.1, // Yamont = tirant amont - 0.3, // Yaval = tirant aval + const prem = new CourbeRemousParams(101.6, 100.3, 101.5, 100, 30, // Long= Longueur du bief 1, // Dx=Pas d'espace ); @@ -404,7 +342,7 @@ describe("Class Remous / section rectangulaire :", () => { expect(extraResultLength(res, "flu") === 0).toBeTruthy( "la ligne d'eau fluviale ne devrait comporter aucune valeur"); - const t = { + const t: any = { 0: 0.1, 1: 0.11425000000000002, 2: 0.12750000000000003, 3: 0.14025000000000004, 4: 0.15200000000000005, 5: 0.16325000000000006, 6: 0.17350000000000007, 7: 0.18325000000000008, 8: 0.1920000000000001, 9: 0.1997500000000001, 10: 0.2070000000000001, 11: 0.2137500000000001, @@ -414,6 +352,10 @@ describe("Class Remous / section rectangulaire :", () => { 24: 0.2492500000000001, 25: 0.2502500000000001, 26: 0.25050000000000006, 27: 0.25075000000000003, 28: 0.251, 29: 0.25125, 30: 0.25149999999999995 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.01); compareExtraResult("Ytorrentiel", res, "tor", t, 0.01); @@ -454,8 +396,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.35, // Yamont = tirant amont - 0.3, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.85, 100.3, 100.5, 100, 10, // Long= Longueur du bief 0.1, // Dx=Pas d'espace ); diff --git a/spec/remous/remous_rect_rk4_pentefaible.spec.ts b/spec/remous/remous_rect_rk4_pentefaible.spec.ts index 3a722f7c28b5c4c3d452e01d3d4f82bfb1fef41e..16fc19b8ac2ff9077efb5eceaa898e6e3363057b 100644 --- a/spec/remous/remous_rect_rk4_pentefaible.spec.ts +++ b/spec/remous/remous_rect_rk4_pentefaible.spec.ts @@ -30,8 +30,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.3, // Yamont = tirant amont - 0.41, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.4, 100.41, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -42,12 +41,16 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version PHP (Oct 2017) méthode RungeKutta4 - const f = { + const f: any = { 100.000: 0.41, 95.000: 0.876, 90.000: 0.877, 85.000: 0.879, 80.000: 0.88, 75.000: 0.881, 70.000: 0.883, 65.000: 0.884, 60.000: 0.885, 55.000: 0.886, 50.000: 0.888, 45.000: 0.889, 40.000: 0.89, 35.000: 0.891, 30.000: 0.892, 25.000: 0.893, 20.000: 0.894, 15.000: 0.895, 10.000: 0.896, 5.000: 0.897, 0.000: 0.898 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -101,8 +104,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 0.42, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.25, 100.42, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -115,7 +117,7 @@ describe("Class Remous / section rectangulaire :", () => { // tslint:disable-next-line:max-line-length // let f = { 100.000: 0.42, 95.000: 0.583, 90.000: 0.604, 85.000: 0.621, 80.000: 0.636, 75.000: 0.65, 70.000: 0.662, 65.000: 0.673, 60.000: 0.683, 55.000: 0.692, 50.000: 0.701, 45.000: 0.709, 40.000: 0.717, 35.000: 0.724, 30.000: 0.731, 25.000: 0.737, 20.000: 0.743, 15.000: 0.749, 10.000: 0.755, 5.000: 0.76, 0.000: 0.15 }; - const f = { + const f: any = { 100.000: 0.42, 95.000: 0.583, 90.000: 0.604, @@ -137,6 +139,10 @@ describe("Class Remous / section rectangulaire :", () => { 10.000: 0.755, 5.000: 0.76 }; // dernière valeur supprimée pour la raison en tête de fichier + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -191,8 +197,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.01, // Yamont = tirant amont - 0.42, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.015, 100.42, 100.005, 100, 5, // Long= Longueur du bief 0.25, // Dx=Pas d'espace ); @@ -203,7 +208,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version PHP (Oct 2017) méthode RungeKutta4 - const f = { + const f: any = { 5.000: 0.42, 4.750: 0.434, 4.500: 0.443, @@ -226,6 +231,10 @@ describe("Class Remous / section rectangulaire :", () => { 0.250: 0.509, 0.000: 0.01 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -274,8 +283,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.5, // Yamont = tirant amont - 1, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.6, 101, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -286,7 +294,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version PHP (Oct 2017) méthode RungeKutta4 - const f = { + const f: any = { 100.000: 1, 95.000: 0.999, 90.000: 0.999, @@ -309,6 +317,10 @@ describe("Class Remous / section rectangulaire :", () => { 5.000: 0.989, 0.000: 0.988 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -351,8 +363,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.5, // Yamont = tirant amont - 0.7, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.6, 100.7, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -363,7 +374,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version PHP (Oct 2017) méthode RungeKutta4 - const f = { + const f: any = { 100.000: 0.7, 95.000: 0.708, 90.000: 0.716, @@ -386,6 +397,10 @@ describe("Class Remous / section rectangulaire :", () => { 5.000: 0.802, 0.000: 0.806 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); diff --git a/spec/remous/remous_rect_rk4_penteforte.spec.ts b/spec/remous/remous_rect_rk4_penteforte.spec.ts index 715f925c8cead0b7722a30930ca97507acfa8255..a8b2092c48d57be6ef95817e18dfbe2d3fead57a 100644 --- a/spec/remous/remous_rect_rk4_penteforte.spec.ts +++ b/spec/remous/remous_rect_rk4_penteforte.spec.ts @@ -40,8 +40,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 6, // Yaval = tirant aval + const prem = new CourbeRemousParams(105.15, 106, 105, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -52,7 +51,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version PHP (Oct 2017) méthode RungeKutta4 - const f = { + const f: any = { 100.000: 6, 95.000: 5.75, 90.000: 5.5, @@ -75,6 +74,10 @@ describe("Class Remous / section rectangulaire :", () => { 5.000: 1.237, 0.000: 0.977 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.01); compareExtraResult("Yfluvial", res, "flu", f, 0.01); @@ -124,8 +127,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 0.45, // Yaval = tirant aval + const prem = new CourbeRemousParams(105.15, 100.45, 105, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -142,7 +144,7 @@ describe("Class Remous / section rectangulaire :", () => { // tslint:disable-next-line:max-line-length // 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 }; - const t = { + const t: any = { 0.000: 0.15, 5.000: 0.198, 10.000: 0.228, @@ -165,6 +167,10 @@ describe("Class Remous / section rectangulaire :", () => { 95.000: 0.253, 100.000: 0.253 }; // dernière valeur remplacée pour la raison 1 en tête de fichier + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.03); compareExtraResult("Ytorrentiel", res, "tor", t, 0.03); @@ -214,8 +220,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 1, // Yaval = tirant aval + const prem = new CourbeRemousParams(105.15, 101, 105, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -233,7 +238,7 @@ describe("Class Remous / section rectangulaire :", () => { // tslint:disable-next-line:max-line-length // 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.521 }; - const t = { + const t: any = { 0.000: 0.15, 5.000: 0.198, 10.000: 0.228, @@ -254,6 +259,10 @@ describe("Class Remous / section rectangulaire :", () => { 85.000: 0.253, 90.000: 0.25 }; // dernière valeur remplacée pour la raison 1 en tête de fichier + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.03); compareExtraResult("Ytorrentiel", res, "tor", t, 0.03); @@ -303,8 +312,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 1, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.425, 101, 100.275, 100, 5.5, // Long= Longueur du bief 0.25, // Dx=Pas d'espace ); @@ -317,7 +325,7 @@ describe("Class Remous / section rectangulaire :", () => { // tslint:disable-next-line:max-line-length // let f = { 5.500: 1, 5.250: 0.987, 5.000: 0.974, 4.750: 0.96, 4.500: 0.947, 4.250: 0.934, 4.000: 0.921, 3.750: 0.907, 3.500: 0.894, 3.250: 0.88, 3.000: 0.867, 2.750: 0.853, 2.500: 0.84, 2.250: 0.826, 2.000: 0.812, 1.750: 0.798, 1.500: 0.785, 1.250: 0.771, 1.000: 0.756, 0.750: 0.742, 0.500: 0.728, 0.250: 0.713, 0.000: 0.15 }; - const f = { + const f: any = { 5.500: 1, 5.250: 0.987, 5.000: 0.974, @@ -343,9 +351,13 @@ describe("Class Remous / section rectangulaire :", () => { 0.000: 0.699 }; // dernière valeur remplacée pour la raison 1 en tête de fichier // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); + // 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)); + } compareExtraResult("Yfluvial", res, "flu", f, 0.03); - const t = { + const t: any = { 0.000: 0.15, 0.250: 0.153, 0.500: 0.156, @@ -363,6 +375,10 @@ describe("Class Remous / section rectangulaire :", () => { 3.500: 0.186, 3.750: 0.907 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.03); compareExtraResult("Ytorrentiel", res, "tor", t, 0.03); @@ -408,8 +424,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.1, // Yamont = tirant amont - 0.3, // Yaval = tirant aval + const prem = new CourbeRemousParams(105.1, 100.3, 105, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -423,7 +438,7 @@ describe("Class Remous / section rectangulaire :", () => { expect(extraResultLength(res, "flu") === 0) .toBeTruthy("la ligne d'eau fluviale ne devrait comporter aucune valeur"); - const t = { + const t: any = { 0.000: 0.1, 5.000: 0.162, 10.000: 0.206, @@ -446,6 +461,10 @@ describe("Class Remous / section rectangulaire :", () => { 95.000: 0.253, 100.000: 0.253 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.01); compareExtraResult("Ytorrentiel", res, "tor", t, 0.01); @@ -486,8 +505,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.35, // Yamont = tirant amont - 0.3, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.85, 100.3, 100.5, 100, 10, // Long= Longueur du bief 0.1, // Dx=Pas d'espace ); @@ -501,7 +519,7 @@ describe("Class Remous / section rectangulaire :", () => { expect(extraResultLength(res, "flu") === 0) .toBeTruthy("la ligne d'eau fluviale ne devrait comporter aucune valeur"); - const t = { + const t: any = { 0.000: 0.35, 0.100: 0.344, 0.200: 0.34, @@ -604,6 +622,10 @@ describe("Class Remous / section rectangulaire :", () => { 9.900: 0.26, 10.000: 0.26 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.01); compareExtraResult("Ytorrentiel", res, "tor", t, 0.01); diff --git a/spec/remous/remous_rect_trapezes_pentefaible.spec.ts b/spec/remous/remous_rect_trapezes_pentefaible.spec.ts index 79d68af7efb02768dd933d5048147d0d29570aeb..33f0b3ddc8df2a648aff081d7e7a02ec02162695 100644 --- a/spec/remous/remous_rect_trapezes_pentefaible.spec.ts +++ b/spec/remous/remous_rect_trapezes_pentefaible.spec.ts @@ -30,8 +30,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.3, // Yamont = tirant amont - 0.403, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.4, 100.403, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -42,7 +41,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version PHP (Oct 2017) méthode trapèzes - const f = { + const f: any = { 100.000: 0.403, 95.000: 0.524, 90.000: 0.558, @@ -65,6 +64,10 @@ describe("Class Remous / section rectangulaire :", () => { 5.000: 0.75, 0.000: 0.755 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -118,8 +121,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 0.403, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.25, 100.403, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -132,7 +134,7 @@ describe("Class Remous / section rectangulaire :", () => { // tslint:disable-next-line:max-line-length // let f = { 100.000: 0.403, 95.000: 0.524, 90.000: 0.558, 85.000: 0.584, 80.000: 0.604, 75.000: 0.621, 70.000: 0.637, 65.000: 0.65, 60.000: 0.662, 55.000: 0.673, 50.000: 0.684, 45.000: 0.693, 40.000: 0.701, 35.000: 0.709, 30.000: 0.717, 25.000: 0.725, 20.000: 0.731, 15.000: 0.738, 10.000: 0.744, 5.000: 0.75, 0.000: 0.15 }; - const f = { + const f: any = { 100.000: 0.403, 95.000: 0.524, 90.000: 0.558, @@ -154,6 +156,10 @@ describe("Class Remous / section rectangulaire :", () => { 10.000: 0.744, 5.000: 0.75 }; // dernière valeur supprimée pour la raison en tête de fichier + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -208,8 +214,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.01, // Yamont = tirant amont - 0.403, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.015, 100.403, 100.005, 100, 5, // Long= Longueur du bief 0.25, // Dx=Pas d'espace ); @@ -236,7 +241,7 @@ describe("Class Remous / section rectangulaire :", () => { // compareArray("abscisses", res["trX"], x); // dx = 0.25 - const f = { + const f: any = { 5.000: 0.403, 4.750: 0.43, 4.500: 0.44, @@ -259,6 +264,10 @@ describe("Class Remous / section rectangulaire :", () => { 0.250: 0.508, 0.000: 0.01 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -308,8 +317,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.01, // Yamont = tirant amont - 0.403, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.015, 100.403, 100.005, 100, 5, // Long= Longueur du bief 0.05, // Dx=Pas d'espace ); @@ -320,7 +328,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version PHP (Oct 2017) méthode trapèzes - const f = { + const f: any = { 5.0000: 0.403, 4.9500: 0.415, 4.9000: 0.42, @@ -423,10 +431,14 @@ describe("Class Remous / section rectangulaire :", () => { 0.0500: 0.51, 0.0000: 0.01 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); - const t = { + const t: any = { 0.0000: 0.01, 0.0500: 0.011, 0.1000: 0.013, @@ -447,6 +459,10 @@ describe("Class Remous / section rectangulaire :", () => { 0.8500: 0.03, 0.9000: 0.502 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.03); compareExtraResult("Ytorrentiel", res, "tor", t, 0.03); @@ -492,8 +508,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.5, // Yamont = tirant amont - 1, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.6, 101, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -504,7 +519,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version PHP (Oct 2017) méthode trapèzes - const f = { + const f: any = { 100.000: 1, 95.000: 0.999, 90.000: 0.999, @@ -527,6 +542,10 @@ describe("Class Remous / section rectangulaire :", () => { 5.000: 0.988, 0.000: 0.988 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -569,8 +588,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.5, // Yamont = tirant amont - 0.7, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.6, 100.7, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -581,7 +599,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version PHP (Oct 2017) méthode trapèzes - const f = { + const f: any = { 100.000: 0.7, 95.000: 0.708, 90.000: 0.716, @@ -604,6 +622,10 @@ describe("Class Remous / section rectangulaire :", () => { 5.000: 0.803, 0.000: 0.806 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -646,8 +668,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 0.4, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.25, 100.4, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -661,14 +682,18 @@ describe("Class Remous / section rectangulaire :", () => { expect(extraResultLength(res, "flu") === 0) .toBeTruthy("la ligne d'eau fluviale ne devrait comporter aucune valeur"); - const t = { 0.000: 0.15, 5.000: 0.239, 10.000: 0.34 }; + const t: any = { 0.000: 0.15, 5.000: 0.239, 10.000: 0.34 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.008); compareExtraResult("Ytorrentiel", res, "tor", t, 0.008); // const x = [0.000, 5.000, 10.000]; // compareArray("abscisses", res.getValue("trX"), x); - const extraHS = { 0.000: 1.6, 5.000: 0.808, 10.000: 0.618 }; + const extraHS: any = { 0.000: 101.7, 5.000: 100.903, 10.000: 100.708 }; // compareObject("extra (Hs)", res.getValue("Hs"), extraHS, 0.001); compareExtraResult("extra (Hs)", res, "Hs", extraHS, 0.001); diff --git a/spec/remous/remous_rect_trapezes_penteforte.spec.ts b/spec/remous/remous_rect_trapezes_penteforte.spec.ts index 3d66a7abdfa59903a6f223378ad754b75211c010..edab1400f740ef5eabd0fb241312a3c60dbc28c2 100644 --- a/spec/remous/remous_rect_trapezes_penteforte.spec.ts +++ b/spec/remous/remous_rect_trapezes_penteforte.spec.ts @@ -40,8 +40,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 6, // Yaval = tirant aval + const prem = new CourbeRemousParams(105.15, 106, 105, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -52,7 +51,7 @@ describe("Class Remous / section rectangulaire :", () => { // données de validation : version PHP (Oct 2017) méthode trapèzes - const f = { + const f: any = { 100.000: 6, 95.000: 5.75, 90.000: 5.5, @@ -75,6 +74,10 @@ describe("Class Remous / section rectangulaire :", () => { 5.000: 1.237, 0.000: 0.977 }; + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); @@ -124,8 +127,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 0.45, // Yaval = tirant aval + const prem = new CourbeRemousParams(105.15, 100.45, 105, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -144,7 +146,7 @@ describe("Class Remous / section rectangulaire :", () => { // let t = { 0.000: 0.15, 5.000: 0.207, 10.000: 0.235, 15.000: 0.246, 20.000: 0.25, 25.000: 0.252, 30.000: 0.253, 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.253 }; // tslint:disable-next-line:max-line-length // let t = { 0.000: 0.15, 5.000: 0.207, 10.000: 0.235, 15.000: 0.246, 20.000: 0.25, 25.000: 0.252, 30.000: 0.253, 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 }; // dernière valeur modifiée pour la raison 1 en tête de fichier - const t = { + const t: any = { 0.000: 0.15, 5.000: 0.207, 10.000: 0.235, @@ -167,6 +169,10 @@ describe("Class Remous / section rectangulaire :", () => { 95.000: 0.253, 100.000: 0.253 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.03); compareExtraResult("Ytorrentiel", res, "tor", t, 0.03); @@ -216,8 +222,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 1, // Yaval = tirant aval + const prem = new CourbeRemousParams(105.15, 101, 105, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -234,7 +239,7 @@ describe("Class Remous / section rectangulaire :", () => { // tslint:disable-next-line:max-line-length // let t = { 0.000: 0.15, 5.000: 0.207, 10.000: 0.235, 15.000: 0.246, 20.000: 0.25, 25.000: 0.252, 30.000: 0.253, 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.729 }; - const t = { + const t: any = { 0.000: 0.15, 5.000: 0.207, 10.000: 0.235, @@ -255,6 +260,10 @@ describe("Class Remous / section rectangulaire :", () => { 85.000: 0.253, 90.000: 0.253 }; // dernière valeur supprimée pour la raison 2 en tête de fichier + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.03); compareExtraResult("Ytorrentiel", res, "tor", t, 0.03); @@ -304,8 +313,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 1, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.425, 101, 100.275, 100, 5.5, // Long= Longueur du bief 0.25, // Dx=Pas d'espace ); @@ -318,7 +326,7 @@ describe("Class Remous / section rectangulaire :", () => { // tslint:disable-next-line:max-line-length // let f = { 5.500: 1, 5.250: 0.987, 5.000: 0.974, 4.750: 0.96, 4.500: 0.947, 4.250: 0.933, 4.000: 0.92, 3.750: 0.906, 3.500: 0.893, 3.250: 0.88, 3.000: 0.866, 2.750: 0.853, 2.500: 0.839, 2.250: 0.826, 2.000: 0.812, 1.750: 0.798, 1.500: 0.784, 1.250: 0.77, 1.000: 0.756, 0.750: 0.742, 0.500: 0.727, 0.250: 0.712, 0.000: 0.15 }; - const f = { + const f: any = { 5.500: 1, 5.250: 0.987, 5.000: 0.974, @@ -343,10 +351,14 @@ describe("Class Remous / section rectangulaire :", () => { 0.250: 0.712, 0.000: 0.699 }; // dernière valeur modifiée pour la raison 1 en tête de fichier + // 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)); + } // compareObject("Yfluvial", res.getValue("flu"), f, 0.03); compareExtraResult("Yfluvial", res, "flu", f, 0.03); - const t = { + const t: any = { 0.000: 0.15, 0.250: 0.153, 0.500: 0.156, @@ -364,6 +376,10 @@ describe("Class Remous / section rectangulaire :", () => { 3.500: 0.184, 3.750: 0.906 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.03); compareExtraResult("Ytorrentiel", res, "tor", t, 0.03); @@ -409,8 +425,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.1, // Yamont = tirant amont - 0.3, // Yaval = tirant aval + const prem = new CourbeRemousParams(105.1, 100.3, 105, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -424,12 +439,16 @@ describe("Class Remous / section rectangulaire :", () => { expect(extraResultLength(res, "flu") === 0).toBeTruthy( "la ligne d'eau fluviale ne devrait comporter aucune valeur"); - const t = { + const t: any = { 0.000: 0.1, 5.000: 0.205, 10.000: 0.234, 15.000: 0.246, 20.000: 0.25, 25.000: 0.252, 30.000: 0.253, 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.253 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.01); compareExtraResult("Ytorrentiel", res, "tor", t, 0.01); @@ -470,8 +489,7 @@ describe("Class Remous / section rectangulaire :", () => { const sect = new cSnRectang(prms); - const prem = new CourbeRemousParams(0.35, // Yamont = tirant amont - 0.3, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.85, 100.3, 100.5, 100, 10, // Long= Longueur du bief 0.1, // Dx=Pas d'espace ); @@ -485,7 +503,7 @@ describe("Class Remous / section rectangulaire :", () => { expect(extraResultLength(res, "flu") === 0) .toBeTruthy("la ligne d'eau fluviale ne devrait comporter aucune valeur"); - const t = { + const t: any = { 0.000: 0.35, 0.100: 0.345, 0.200: 0.34, @@ -588,6 +606,10 @@ describe("Class Remous / section rectangulaire :", () => { 9.900: 0.269, 10.000: 0.269 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.01); compareExtraResult("Ytorrentiel", res, "tor", t, 0.01); diff --git a/spec/remous/remous_trapez.spec.ts b/spec/remous/remous_trapez.spec.ts index 684ed58cf40c517170f0d951c146334bdb084032..6575c401e3915959bc929fb65bfd19a00f9faa22 100644 --- a/spec/remous/remous_trapez.spec.ts +++ b/spec/remous/remous_trapez.spec.ts @@ -29,8 +29,7 @@ describe("Class Remous / section trapèze :", () => { const sect = new cSnTrapez(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 0.803, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.155, 100.803, 100.005, 100, 5, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -58,8 +57,7 @@ describe("Class Remous / section trapèze :", () => { const sect = new cSnTrapez(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 0.4, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.16, 100.4, 100.01, 100, 10, // Long= Longueur du bief 1, // Dx=Pas d'espace ); @@ -74,7 +72,7 @@ describe("Class Remous / section trapèze :", () => { // tslint:disable-next-line:max-line-length // let t = { 0.000: 0.15, 1.000: 0.16369914454109, 2.000: 0.17743613485223, 3.000: 0.19117312516337, 4.000: 0.20491011547451, 5.000: 0.21864710578565, 6.000: 0.23238409609679, 7.000: 0.24688425253633, 8.000: 0.26214757510426, 9.000: 0.27817406380059, 10.000: 0.4 }; - const t = { + const t: any = { 0.000: 0.15, 1.000: 0.16369914454109, 2.000: 0.17743613485223, @@ -87,6 +85,10 @@ describe("Class Remous / section trapèze :", () => { 9.000: 0.27817406380059, 10.000: 0.293 }; // dernière valeur modifiée pour la raison en tête de fichier + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const tk of Object.keys(t)) { + t[tk] = t[tk] + rem.getCoteFond(Number(tk)); + } // compareObject("Ytorrentiel", res.getValue("tor"), t, 0.002); compareExtraResult("Ytorrentiel", res, "tor", t, 0.002); @@ -94,43 +96,6 @@ describe("Class Remous / section trapèze :", () => { // compareArray("abcisses", res.getValue("trX"), x); }); - // it('pente forte, ressaut dans le bief sur plusieurs points', () => { - // let prms = new ParamsSectionTrapez(2.5, // largeur de fond - // 0.56, // fruit - // undefined, // tirant d'eau - // 40, // Ks=Strickler - // 2, // Q=Débit - // 0.05, // If=pente du fond - // precDist, // précision - // 1 // YB= hauteur de berge - // ); - - // let sect = new cSnTrapez(prms); - - // let prem = new CourbeRemousParams(sect, - // 0.15, // Yamont = tirant amont - // 1, // Yaval = tirant aval - // 8, // Long= Longueur du bief - // 0.1, // Dx=Pas d'espace - // MethodeResolution.Trapezes - // ); - - // let rem = new CourbeRemous(sect, prem); - - // let res = rem.calculRemous(undefined); - - // tslint:disable-next-line:max-line-length - // let f = { 8.000: 1, 7.900: 0.995, 7.800: 0.989, 7.700: 0.984, 7.600: 0.978, 7.500: 0.973, 7.400: 0.967, 7.300: 0.962, 7.200: 0.956, 7.100: 0.951, 7.000: 0.945, 6.900: 0.94, 6.800: 0.934, 6.700: 0.929, 6.600: 0.923, 6.500: 0.918, 6.400: 0.912, 6.300: 0.907, 6.200: 0.901, 6.100: 0.896, 6.000: 0.89, 5.900: 0.885, 5.800: 0.879, 5.700: 0.874, 5.600: 0.868, 5.500: 0.863, 5.400: 0.857, 5.300: 0.852, 5.200: 0.846, 5.100: 0.841, 5.000: 0.835, 4.900: 0.83, 4.800: 0.824, 4.700: 0.819, 4.600: 0.813, 4.500: 0.808, 4.400: 0.802, 4.300: 0.797, 4.200: 0.791, 4.100: 0.786, 4.000: 0.78, 3.900: 0.775, 3.800: 0.769, 3.700: 0.764, 3.600: 0.758, 3.500: 0.753, 3.400: 0.747, 3.300: 0.742, 3.200: 0.737, 3.100: 0.731, 3.000: 0.726, 2.900: 0.72, 2.800: 0.715, 2.700: 0.709, 2.600: 0.704, 2.500: 0.698, 2.400: 0.693, 2.300: 0.686, 2.200: 0.68, 2.100: 0.674, 2.000: 0.668, 1.900: 0.662, 1.800: 0.656, 1.700: 0.65, 1.600: 0.644, 1.500: 0.638, 1.400: 0.632, 1.300: 0.625, 1.200: 0.619, 1.100: 0.613, 1.000: 0.607, 0.900: 0.601, 0.800: 0.594, 0.700: 0.588, 0.600: 0.581, 0.500: 0.574, 0.400: 0.567, 0.300: 0.561, 0.200: 0.554, 0.100: 0.547, 0.000: 0.15 }; - // compareObject("Yfluvial", res["flu"], f, 0.011); - - // tslint:disable-next-line:max-line-length - // let t = { 0.000: 0.15, 0.100: 0.151, 0.200: 0.151, 0.300: 0.152, 0.400: 0.153, 0.500: 0.154, 0.600: 0.155, 0.700: 0.155, 0.800: 0.156, 0.900: 0.157, 1.000: 0.158, 1.100: 0.158, 1.200: 0.159, 1.300: 0.16, 1.400: 0.161, 1.500: 0.161, 1.600: 0.162, 1.700: 0.163, 1.800: 0.164, 1.900: 0.164, 2.000: 0.165, 2.100: 0.166, 2.200: 0.167, 2.300: 0.168, 2.400: 0.168, 2.500: 0.698, 2.6: 0.709500000000002 }; - // compareObject("Ytorrentiel", res["tor"], t, 0.004); - - // tslint:disable-next-line:max-line-length - // let x = [0.000, 0.100, 0.200, 0.300, 0.400, 0.500, 0.600, 0.700, 0.800, 0.900, 1.000, 1.100, 1.200, 1.300, 1.400, 1.500, 1.600, 1.700, 1.800, 1.900, 2.000, 2.100, 2.200, 2.300, 2.400, 2.500, 2.600, 2.700, 2.800, 2.900, 3.000, 3.100, 3.200, 3.300, 3.400, 3.500, 3.600, 3.700, 3.800, 3.900, 4.000, 4.100, 4.200, 4.300, 4.400, 4.500, 4.600, 4.700, 4.800, 4.900, 5.000, 5.100, 5.200, 5.300, 5.400, 5.500, 5.600, 5.700, 5.800, 5.900, 6.000, 6.100, 6.200, 6.300, 6.400, 6.500, 6.600, 6.700, 6.800, 6.900, 7.000, 7.100, 7.200, 7.300, 7.400, 7.500, 7.600, 7.700, 7.800, 7.900, 8.000]; - // compareArray("abcisses", res["trX"], x); - // }); }); describe("paramètre à calculer :", () => { @@ -149,8 +114,7 @@ describe("Class Remous / section trapèze :", () => { const sect = new cSnTrapez(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 0.4, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.25, 100.4, 100.1, 100, 100, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -160,7 +124,7 @@ describe("Class Remous / section trapèze :", () => { const res = rem.calculRemous("Hs"); // données de validation : version PHP (oct 2017) - const hs = { + const hs: any = { 0.000: 1.507, 5.000: 0.735, 10.000: 0.731, @@ -183,6 +147,10 @@ describe("Class Remous / section trapèze :", () => { 95.000: 0.603, 100.000: 0.572 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const hsk of Object.keys(hs)) { + hs[hsk] = hs[hsk] + rem.getCoteFond(Number(hsk)); + } // compareObject("Hs", res.getValue("Hs"), hs, 0.002); compareExtraResult("Hs", res, "Hs", hs, 0.002); }); @@ -202,8 +170,7 @@ describe("Class Remous / section trapèze :", () => { const sect = new cSnTrapez(prms); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 1, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.55, 101, 100.4, 100, 8, // Long= Longueur du bief 0.1, // Dx=Pas d'espace ); @@ -214,7 +181,7 @@ describe("Class Remous / section trapèze :", () => { // données de validation : version PHP (oct 2017) // ici j'ai supprimé un point (x=2.5) - const hs = { + const hs: any = { 0.000: 1.507, 2.600: 0.753, 2.700: 0.757, @@ -272,6 +239,10 @@ describe("Class Remous / section trapèze :", () => { 7.900: 1.017, 8.000: 1.022 }; + // mà j pour jalhyd#146 : ajout de la cote de fond aux valeurs attendues + for (const hsk of Object.keys(hs)) { + hs[hsk] = hs[hsk] + rem.getCoteFond(Number(hsk)); + } // compareObject("Hs", res.getValue("Hs"), hs, 0.009); compareExtraResult("Hs", res, "Hs", hs, 0.009); }); diff --git a/spec/session/serialisation.spec.ts b/spec/session/serialisation.spec.ts index f8053d8362bd42708ee488c49be56b1bf7274e68..3f1dd47695ea7e01dd409786e6a88af584747268 100644 --- a/spec/session/serialisation.spec.ts +++ b/spec/session/serialisation.spec.ts @@ -79,8 +79,7 @@ function createEnv() { 1, // YB= hauteur de berge ); const sect = new cSnTrapez(prmsST); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 0.803, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.155, 100.803, 100.005, 100, 5, // Long= Longueur du bief 5, // Dx=Pas d'espace ); @@ -288,8 +287,7 @@ describe("nodeType property - ", () => { 1, // YB= hauteur de berge ); const sect = new cSnTrapez(prmsST); - const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont - 0.803, // Yaval = tirant aval + const prem = new CourbeRemousParams(100.155, 100.803, 100.005, 100, 5, // Long= Longueur du bief 5, // Dx=Pas d'espace ); diff --git a/spec/value_ref/value_ref.spec.ts b/spec/value_ref/value_ref.spec.ts index ed59b5856e060731e924c4fcbcf5387737c5a5d4..8d5a1d0af010fc09a90b45c6da70a03b4ff63db0 100644 --- a/spec/value_ref/value_ref.spec.ts +++ b/spec/value_ref/value_ref.spec.ts @@ -119,13 +119,21 @@ describe("référence d'un paramètre à un autre : ", () => { prm2.B.singleValue = 0; // valeur esclave (doit être masquée par la valeur maître) prm2.B.defineReference(nub1, "B"); - expect(nub1.CalcSerie(undefined, "A").vCalc).toBeCloseTo(0, precDigits); - expect(nub1.CalcSerie(undefined, "B").vCalc).toBeCloseTo(2, precDigits); - expect(nub1.CalcSerie(undefined, "C").vCalc).toBeCloseTo(4, precDigits); - - expect(nub2.CalcSerie(undefined, "A").vCalc).toBeCloseTo(0, precDigits); - expect(nub2.CalcSerie(undefined, "B").vCalc).toBeCloseTo(2, precDigits); - expect(nub2.CalcSerie(undefined, "C").vCalc).toBeCloseTo(4, precDigits); + nub1.calculatedParam = nub1.prms.A; + expect(nub1.CalcSerie().vCalc).toBeCloseTo(0, precDigits); + nub1.calculatedParam = nub1.prms.B; + expect(nub1.CalcSerie().vCalc).toBeCloseTo(2, precDigits); + nub1.calculatedParam = nub1.prms.C; + expect(nub1.CalcSerie().vCalc).toBeCloseTo(4, precDigits); + + nub2.calculatedParam = nub2.prms.A; + expect(nub2.CalcSerie().vCalc).toBeCloseTo(0, precDigits); + nub2.calculatedParam = nub2.prms.C; + expect(nub2.CalcSerie().vCalc).toBeCloseTo(4, precDigits); + // définir B en calcul fait sauter le lien, donc on calcule C + // avant, pour ne pas avoir à redéfinir le lien + nub2.calculatedParam = nub2.prms.B; + expect(nub2.CalcSerie().vCalc).toBeCloseTo(2, precDigits); }); @@ -184,7 +192,8 @@ describe("référence d'un paramètre à un autre : ", () => { prm2.A.singleValue = 0; prm2.A.defineReference(nub1, "C"); - expect(nub2.CalcSerie(undefined, "C").vCalc).toBeCloseTo(5, precDigits); + nub2.calculatedParam = nub2.prms.C; + expect(nub2.CalcSerie().vCalc).toBeCloseTo(5, precDigits); }); it("test 3", () => { @@ -229,7 +238,8 @@ describe("référence d'un paramètre à un autre : ", () => { prm2.A.defineReference(nub1, "A"); SessionSettings.precision = 0.001; - const r: Result = nub2.CalcSerie(0.1, "C"); + nub2.calculatedParam = nub2.prms.C; + const r: Result = nub2.CalcSerie(0.1); let n = 0; for (const re of r.resultElements) { diff --git a/src/devalaison/grille.ts b/src/devalaison/grille.ts index 3845fee58daa9143917dc12234315f8124f49d91..6e17a53bdc6edd85bdaab45742bdfedc2c689812 100644 --- a/src/devalaison/grille.ts +++ b/src/devalaison/grille.ts @@ -245,7 +245,7 @@ export class Grille extends Nub { } // no calculated param - protected findCalculatedParameter(sDonnee: any): any { + protected findCalculatedParameter(): any { return undefined; } diff --git a/src/macrorugo/macrorugo_compound.ts b/src/macrorugo/macrorugo_compound.ts index 819026161133a1360af2040d917dea24cfd714bc..1b617c926e0360fa87f70ead5b0b56ed237c06c7 100644 --- a/src/macrorugo/macrorugo_compound.ts +++ b/src/macrorugo/macrorugo_compound.ts @@ -28,12 +28,12 @@ export class MacrorugoCompound extends MacroRugo implements Observer { this._childrenType = "MacroRugo"; } - public CalcSerie(rInit?: number, sDonnee?: any): Result { + public CalcSerie(rInit?: number): Result { if (this.properties.getPropValue("inclinedApron")) { // important to regenerate it here, at every iteration of CalcSerie() this.generateInclinedFishway(); } - return super.CalcSerie(rInit, sDonnee); + return super.CalcSerie(rInit); } /** diff --git a/src/nub.ts b/src/nub.ts index afaa5e56ab016fd168e11c08e79cb833c67bc417..706b0924d698b926f99fd3569aa231bdaef6eb87 100644 --- a/src/nub.ts +++ b/src/nub.ts @@ -377,7 +377,7 @@ export abstract class Nub extends ComputeNode implements IObservable { * @param rInit solution approximative du paramètre * @param sDonnee éventuel symbole / paire symbole-uid du paramètre à calculer */ - public CalcSerie(rInit?: number, sDonnee?: any): Result { + public CalcSerie(rInit?: number): Result { // variated parameters caracteristics const variated: Array<{ param: ParamDefinition, values: ParamValues }> = []; @@ -407,7 +407,7 @@ export abstract class Nub extends ComputeNode implements IObservable { } // find calculated parameter - const computedSymbol = this.findCalculatedParameter(sDonnee); + const computedSymbol = this.findCalculatedParameter(); if (rInit === undefined && this.calculatedParam) { rInit = this.calculatedParam.v; @@ -1295,16 +1295,12 @@ export abstract class Nub extends ComputeNode implements IObservable { return size; } - protected findCalculatedParameter(sDonnee: any): any { + protected findCalculatedParameter(): any { let computedSymbol: any; - if (sDonnee) { - computedSymbol = sDonnee; - } else { - if (this.calculatedParam === undefined) { - throw new Error(`CalcSerie() : aucun paramètre à calculer`); - } - computedSymbol = this.calculatedParamDescriptor; + if (this.calculatedParam === undefined) { + throw new Error(`CalcSerie() : aucun paramètre à calculer`); } + computedSymbol = this.calculatedParamDescriptor; return computedSymbol; } diff --git a/src/pab/pab.ts b/src/pab/pab.ts index 56af3ef99288431be2977691ce22c62baae8c247..708bc42d8362da532d8d1918cd873a4685550387 100644 --- a/src/pab/pab.ts +++ b/src/pab/pab.ts @@ -103,13 +103,13 @@ export class Pab extends Nub { } } - public CalcSerie(rInit?: number, sDonnee?: any): Result { + public CalcSerie(rInit?: number): Result { if (!this.downWall.checkVanneLevante()) { this._result = new Result(undefined, this); this._result.globalLog.insert(new Message(MessageCode.ERROR_CLOISON_AVAL_UN_OUVRAGE_REGULE)); return this._result; } - return super.CalcSerie(rInit, sDonnee); + return super.CalcSerie(rInit); } /** diff --git a/src/remous/remous.ts b/src/remous/remous.ts index d9790a28ba15de9a28f18795f42988c2ce402798..28a8a44855b6131d5752a807d7504817f839b65f 100644 --- a/src/remous/remous.ts +++ b/src/remous/remous.ts @@ -2,7 +2,6 @@ import { round, XOR } from "../base"; import { CalculatorType } from "../compute-node"; import { Dichotomie } from "../dichotomie"; import { ParamCalculability } from "../param/param-definition"; -import { ParamValueMode } from "../param/param-value-mode"; import { ParamValues } from "../param/param-values"; import { SectionNub } from "../section/section_nub"; import { acSection } from "../section/section_type"; @@ -68,6 +67,16 @@ export class CourbeRemous extends SectionNub { this.setParametersCalculability(); // to override acSection's tuning } + /** + * This needs to be called before calculation if Z1, Z2, ZF1 or ZF2 was modified + */ + public setIfFromElevations() { + if (this.section !== undefined) { + this.section.prms.If.singleValue = + (this.prms.ZF1.singleValue - this.prms.ZF2.singleValue) / this.prms.Long.singleValue; + } + } + public static get availableMethodeResolution() { return CourbeRemous._availableMethodeResolution; } @@ -79,18 +88,26 @@ export class CourbeRemous extends SectionNub { /** * @param valACal nom de la variable à calculer */ - public calculRemous(valACal: string): - // { - // "flu": { [key: number]: number; }, - // "tor": { [key: number]: number; }, - // "trX": string[], - // "tRes": { [key: number]: number } - // } - Result { + public calculRemous(valACal: string): Result { this.copySingleValuesToSandboxValues(); const res = new Result(undefined, this); + // vérifier qu'il y a de l'eau à l'amont / à l'aval + if (this.prms.ZF1.singleValue >= this.prms.Z1.singleValue) { + res.globalLog.add(new Message(MessageCode.WARNING_UPSTREAM_BOTTOM_HIGHER_THAN_WATER)); + } + if (this.prms.ZF2.singleValue >= this.prms.Z2.singleValue) { + res.globalLog.add(new Message(MessageCode.WARNING_DOWNSTREAM_BOTTOM_HIGHER_THAN_WATER)); + } + // s'il n'y en a nulle part, on arrête tout + if ( + this.prms.ZF1.singleValue >= this.prms.Z1.singleValue + && this.prms.ZF2.singleValue >= this.prms.Z2.singleValue + ) { + res.globalLog.add(new Message(MessageCode.ERROR_REMOUS_NO_WATER_LINE)); + return res; + } // let Yc: number = this.Sn.CalcSection("Yc"); const rYC = this.Sn.CalcSection("Yc"); @@ -119,18 +136,23 @@ export class CourbeRemous extends SectionNub { res.addMessage(m); const rYN = this.Sn.CalcSection("Yn"); + // tslint:disable-next-line:variable-name + let Yn: number; if (!rYN.ok) { - res.addLog(rYN.log); - return res; + const mc = rYN.log.messages[0].code; + if (mc === MessageCode.ERROR_SECTION_PENTE_NEG_NULLE_HNORMALE_INF) { + res.addMessage(new Message(MessageCode.WARNING_YN_SECTION_PENTE_NEG_NULLE_HNORMALE_INF)); + } else if (mc === MessageCode.ERROR_SECTION_NON_CONVERGENCE_NEWTON_HNORMALE) { + res.addMessage(new Message(MessageCode.WARNING_YN_SECTION_NON_CONVERGENCE_NEWTON_HNORMALE)); + } + Yn = 2 * Yc; // si le calcul de Yn échoue, on est en régime fluvial, d'où un Yn imposé > Yc + } else { + // tslint:disable-next-line:variable-name + Yn = rYN.vCalc; + m = new Message(MessageCode.INFO_REMOUS_H_NORMALE, { Yn }); + res.addMessage(m); } - // tslint:disable-next-line:variable-name - const Yn = rYN.vCalc; - m = new Message(MessageCode.INFO_REMOUS_H_NORMALE); - m.extraVar.Yn = Yn; - // this._log.add(m); - res.addMessage(m); - // this.debug("largeur berge " + this.Sn.CalcSection("B")); // const rB2: Result = this.Sn.CalcSection("B") // this.debug("largeur berge " + rB2.vCalc); @@ -143,26 +165,37 @@ export class CourbeRemous extends SectionNub { const xValues = new ParamValues(); xValues.setValues(0, this.prms.Long.v, this.prms.Dx.v); - xValues.valueMode = ParamValueMode.MINMAX; - const rCourbeFlu: ITrYResult = this.calculFluvial(xValues); - res.addLog(rCourbeFlu.log); + // on ne peut pas calculer la courbe fluviale s'il ny 'a pas d'eau à l'aval + let rCourbeFlu: ITrYResult; + if (this.prms.ZF2.singleValue < this.prms.Z2.singleValue) { + rCourbeFlu = this.calculFluvial(xValues); + res.addLog(rCourbeFlu.log); + } - const rCourbeTor: ITrYResult = this.calculTorrentiel(xValues); - res.addLog(rCourbeTor.log); + // on ne peut pas calculer la courbe torrentielle s'il ny 'a pas d'eau à l'amont + let rCourbeTor: ITrYResult; + if (this.prms.ZF1.singleValue < this.prms.Z1.singleValue) { + rCourbeTor = this.calculTorrentiel(xValues); + res.addLog(rCourbeTor.log); + } - let crbFlu = rCourbeFlu.trY; - if (crbFlu === undefined) { + let crbFlu; + if (rCourbeFlu !== undefined && rCourbeFlu.trY !== undefined) { + crbFlu = rCourbeFlu.trY; + } else { crbFlu = {}; } - let crbTor = rCourbeTor.trY; - if (crbTor === undefined) { + let crbTor; + if (rCourbeTor !== undefined && rCourbeTor.trY !== undefined) { + crbTor = rCourbeTor.trY; + } else { crbTor = {}; } // this.debug("HautCritique ", this.Sn.HautCritique); - this.debug("flu "); + this.debug("flu"); // this.logObject(crbFlu); this.debug(JSON.stringify(crbFlu)); @@ -377,7 +410,7 @@ export class CourbeRemous extends SectionNub { return 0; }); // this.debug("trX tri=" + trX); - trXabsc = trXabsc.filter((elem, index, array) => { + trXabsc = trXabsc.filter((elem, index, array) => { // deduplicate if (index > 0) { return elem !== array[index - 1]; } @@ -389,7 +422,6 @@ export class CourbeRemous extends SectionNub { this.logArray(trXabsc); // compilation des résultats - for (const x of trXabsc) { let ligneDeau; @@ -400,38 +432,41 @@ export class CourbeRemous extends SectionNub { } else { ligneDeau = Math.max(crbFlu[x], crbTor[x]); } - const re = new ResultElement({ Y: ligneDeau }); + const re = new ResultElement({ Y: ligneDeau + this.getCoteFond(x) }); if (crbFlu[x]) { - re.addExtraResult("flu", crbFlu[x]); + re.addExtraResult("flu", crbFlu[x] + this.getCoteFond(x)); } if (crbTor[x]) { - re.addExtraResult("tor", crbTor[x]); + re.addExtraResult("tor", crbTor[x] + this.getCoteFond(x)); } - res.addResultElement(re); - } - - // Calcul de la variable à calculer - if (valACal) { - for (const re of res.resultElements) { - const rY = re.vCalc; - if (rY !== undefined) { - const rVar = this.Sn.CalcSection(valACal, rY); + // Calcul de la variable à calculer + if (valACal) { + if (ligneDeau !== undefined) { + const rVar = this.Sn.CalcSection(valACal, ligneDeau); if (!rVar.ok) { res.addLog(rVar.log); } else { - re.addExtraResult(valACal, rVar.vCalc); + let val = rVar.vCalc; + if ([ "Hs", "Hsc", "Ycor", "Ycon" ].includes(valACal)) { + val += this.getCoteFond(x); + } + re.addExtraResult(valACal, val); } } } + + res.addResultElement(re); } return res; } public Calc(sVarCalc: string, rInit?: number): Result { + this.prms.setYamontYavalFromElevations(); + this.setIfFromElevations(); if (sVarCalc === "Hs") { return this.Equation("Hs"); } @@ -453,8 +488,12 @@ export class CourbeRemous extends SectionNub { * @param rInit solution approximative du paramètre * @param sDonnee éventuel symbole / paire symbole-uid du paramètre à calculer */ - public CalcSerie(rInit?: number, sDonnee?: any): Result { - return this.calculRemous(sDonnee); + public CalcSerie(rInit?: number): Result { + this.prms.setYamontYavalFromElevations(); + this.setIfFromElevations(); + const varCalc = this.properties.getPropValue("varCalc"); + const res = this.calculRemous(varCalc); + return res; } public CalcHS(): number { @@ -471,11 +510,23 @@ export class CourbeRemous extends SectionNub { return this._prms as CourbeRemousParams; } + /** + * Retourne la cote de fond à l'abscisse x + * @param x abscisse en m (0 = amont) + */ + public getCoteFond(x: number) { + return (this.prms.ZF1.v - this.prms.ZF2.v) * (1 - x / this.prms.Long.v) + this.prms.ZF2.v; + } + protected setParametersCalculability() { this.prms.Long.calculability = ParamCalculability.FIXED; this.prms.Dx.calculability = ParamCalculability.FIXED; this.prms.Yamont.calculability = ParamCalculability.FIXED; this.prms.Yaval.calculability = ParamCalculability.FIXED; + this.prms.Z1.calculability = ParamCalculability.FIXED; + this.prms.Z2.calculability = ParamCalculability.FIXED; + this.prms.ZF1.calculability = ParamCalculability.FIXED; + this.prms.ZF2.calculability = ParamCalculability.FIXED; // section params if (this.section) { this.section.prms.Ks.calculability = ParamCalculability.FIXED; @@ -793,8 +844,9 @@ export class CourbeRemous extends SectionNub { trY: {} }; + const abs0 = varParam.next().value; let lastY = YCL; - res.trY[round(varParam.next().value, this.section.prms.iPrec)] = lastY; + res.trY[round(abs0, this.section.prms.iPrec)] = lastY; // Boucle de calcul de la courbe de remous while (varParam.hasNext) { @@ -824,6 +876,7 @@ export class CourbeRemous extends SectionNub { res.log.add(m); } + // ligne d'eau res.trY[round(x, this.section.prms.iPrec)] = rY.vCalc; } else { const m = new Message(MessageCode.WARNING_REMOUS_ARRET_CRITIQUE); diff --git a/src/remous/remous_params.ts b/src/remous/remous_params.ts index c1c3d07da8c66a356973be744356187bb318dd52..291f9cdbff5867e876f3c64b34006fb1db8c5c57 100644 --- a/src/remous/remous_params.ts +++ b/src/remous/remous_params.ts @@ -7,42 +7,51 @@ import { ParamsEquation } from "../param/params-equation"; */ export class CourbeRemousParams extends ParamsEquation { - /** - * Débit amont - */ - // private _Qamont: ParamDefinition; - - /** - * Tirant imposé à l'amont - */ + /** Tirant imposé à l'amont */ private _Yamont: ParamDefinition; - /** - * Tirant imposé à l'aval - */ + /** Tirant imposé à l'aval */ private _Yaval: ParamDefinition; - /** - * Longueur du bief - */ + /** Longueur du bief */ private _Long: ParamDefinition; - /** - * Pas de discrétisation de l'espace (positif en partant de l'aval, négatif en partant de l'amont) - */ + /** Pas de discrétisation de l'espace (positif en partant de l'aval, négatif en partant de l'amont) */ private _Dx: ParamDefinition; - constructor(rYamont: number, rYAval: number, rLong: number, rDx: number) { + /** Cote de fond amont */ + private _ZF1: ParamDefinition; + + /** Cote de fond aval */ + private _ZF2: ParamDefinition; + + /** Cote de l'eau à l'amont */ + private _Z1: ParamDefinition; + + /** Cote de l'eau à l'aval */ + private _Z2: ParamDefinition; + + constructor(rZ1: number, rZ2: number, rZF1: number, rZF2: number, rLong: number, rDx: number) { super(); - this._Yamont = new ParamDefinition(this, "Yamont", ParamDomainValue.POS, "m", rYamont, ParamFamily.HEIGHTS); - this._Yaval = new ParamDefinition(this, "Yaval", ParamDomainValue.POS, "m", rYAval, ParamFamily.HEIGHTS); + this._Yamont = new ParamDefinition(this, "Yamont", ParamDomainValue.POS, "m", undefined, undefined, false); + this._Yaval = new ParamDefinition(this, "Yaval", ParamDomainValue.POS, "m", undefined, undefined, false); this._Long = new ParamDefinition(this, "Long", ParamDomainValue.POS, "m", rLong, ParamFamily.LENGTHS); this._Dx = new ParamDefinition(this, "Dx", ParamDomainValue.POS, "m", rDx); + this._Z1 = new ParamDefinition(this, "Z1", ParamDomainValue.ANY, "m", rZ1, ParamFamily.ELEVATIONS); + this._Z2 = new ParamDefinition(this, "Z2", ParamDomainValue.ANY, "m", rZ2, ParamFamily.ELEVATIONS); + this._ZF1 = new ParamDefinition(this, "ZF1", ParamDomainValue.ANY, "m", rZF1, ParamFamily.ELEVATIONS); + this._ZF2 = new ParamDefinition(this, "ZF2", ParamDomainValue.ANY, "m", rZF2, ParamFamily.ELEVATIONS); this.addParamDefinition(this._Yamont); this.addParamDefinition(this._Yaval); this.addParamDefinition(this._Long); this.addParamDefinition(this._Dx); + this.addParamDefinition(this._Z1); + this.addParamDefinition(this._Z2); + this.addParamDefinition(this._ZF1); + this.addParamDefinition(this._ZF2); + + this.setYamontYavalFromElevations(); } public addParamDefinition(p: ParamDefinition) { @@ -64,4 +73,28 @@ export class CourbeRemousParams extends ParamsEquation { get Dx(): ParamDefinition { return this._Dx; } + + get Z1(): ParamDefinition { + return this._Z1; + } + + get Z2(): ParamDefinition { + return this._Z2; + } + + get ZF1(): ParamDefinition { + return this._ZF1; + } + + get ZF2(): ParamDefinition { + return this._ZF2; + } + + /** + * Reconstruit Yamont et Yaval à partir de Z1/ZF1 et Z2/ZF2 + */ + public setYamontYavalFromElevations() { + this._Yamont.singleValue = (this._Z1.singleValue - this._ZF1.singleValue); + this._Yaval.singleValue = (this._Z2.singleValue - this._ZF2.singleValue); + } } diff --git a/src/section/section_nub.ts b/src/section/section_nub.ts index a7f06cfe82793485e8f8fb9ea5c2de25290a59d7..b7e8f9dff8b3c1baf03bf6860c8532812a00555c 100644 --- a/src/section/section_nub.ts +++ b/src/section/section_nub.ts @@ -10,7 +10,7 @@ import { acSection } from "./section_type"; */ export abstract class SectionNub extends Nub { - /** moved from SectionParametree @TODO make sure it is used by other SectionNubs */ + /** moved from SectionParametree */ protected _sectionVars: { [key: string]: ParamDefinition }; /** Section is always the first child */ diff --git a/src/section/section_parametree.ts b/src/section/section_parametree.ts index 8436ca9586903710a47a20cb5f919ce7f2818d56..734fdf812830a3741ebb930b42400b42d82ef313 100644 --- a/src/section/section_parametree.ts +++ b/src/section/section_parametree.ts @@ -135,7 +135,7 @@ export class SectionParametree extends SectionNub { } // calculated param is always "Y" - protected findCalculatedParameter(sDonnee: any): any { + protected findCalculatedParameter(): any { return undefined; } diff --git a/src/section/section_type.ts b/src/section/section_type.ts index b0b0418cc3f0f6a206e96d1d25431cb7bc1d1a25..c5752a1f73187c9e9e142e71a9e2615696f077dc 100644 --- a/src/section/section_type.ts +++ b/src/section/section_type.ts @@ -164,8 +164,8 @@ export abstract class acSection extends Nub { * result, to facilitate values reading by targetting modules * (used by triggerChainCalculation) */ - public CalcSerie(rInit?: number, sDonnee?: any): Result { - this.currentResult = this.parent.CalcSerie(rInit, sDonnee); + public CalcSerie(rInit?: number): Result { + this.currentResult = this.parent.CalcSerie(rInit); return this.result; } diff --git a/src/session.ts b/src/session.ts index da4240bed5f04e5b68c7faa91796ba5a971cdad4..d23638632ee3df94c62ffe92bb6ef444a37e5af3 100644 --- a/src/session.ts +++ b/src/session.ts @@ -339,10 +339,12 @@ export class Session { case CalculatorType.CourbeRemous: prms = new CourbeRemousParams( - 0.15, // Yamont = tirant amont - 0.4, // Yaval = tirant aval - 100, // Long= Longueur du bief - 5, // Dx=Pas d'espace + 100.25, // Z1 = cote de l'eau amont + 100.4, // Z2 = cote de l'eau aval + 100.1, // ZF1 = cote de fond amont + 100, // ZF2 = cote de fond aval + 100, // Long = Longueur du bief + 5, // Dx = Pas d'espace ); nub = new CourbeRemous(undefined, prms, MethodeResolution.EulerExplicite, dbg); break; diff --git a/src/util/message.ts b/src/util/message.ts index 1582547b570c240bcaac1eb98fd923533fb4f2bd..b0434f03d767ae1fe3d87b4a0b38c1d8cdc6af59 100644 --- a/src/util/message.ts +++ b/src/util/message.ts @@ -136,16 +136,19 @@ export enum MessageCode { */ ERROR_PAB_CALC_Z1_CLOISON, - /** - * Dever : La cote du lit de la rivière ne peut pas être supérieure à la cote de l'eau - */ - WARNING_DEVER_ZR_SUP_Z1, + /** Aucune ligne d'eau ne peut être calculée (aucun tirant d'eau à l'amont ni nà l'aval) */ + ERROR_REMOUS_NO_WATER_LINE, /** * internationalisation : langue non prise en charge */ ERROR_LANG_UNSUPPORTED, + /** + * Dever : La cote du lit de la rivière ne peut pas être supérieure à la cote de l'eau + */ + WARNING_DEVER_ZR_SUP_Z1, + /** * courbes de remous : Arrêt du calcul : hauteur critique atteinte à l'abscisse x */ @@ -212,6 +215,9 @@ export enum MessageCode { */ ERROR_SECTION_NON_CONVERGENCE_NEWTON_HNORMALE, + /** équivalent de l'erreur ci-dessus, pour la courbe de remous */ + WARNING_YN_SECTION_NON_CONVERGENCE_NEWTON_HNORMALE, + /** * section : Non convergence du calcul de la hauteur conjuguée (Méthode de Newton) */ @@ -227,6 +233,9 @@ export enum MessageCode { */ ERROR_SECTION_PENTE_NEG_NULLE_HNORMALE_INF, + /** équivalent de l'erreur ci-dessus, pour la courbe de remous */ + WARNING_YN_SECTION_PENTE_NEG_NULLE_HNORMALE_INF, + /** * section : calcul impossible à cause d'un périmètre nul */ @@ -270,6 +279,12 @@ export enum MessageCode { /** abstract showing number of warning messages encountered in an iterative calculation */ WARNING_ABSTRACT, + /** La cote de fond aval est plus élevée que la code de l'eau aval */ + WARNING_DOWNSTREAM_BOTTOM_HIGHER_THAN_WATER, + + /** La cote de fond amont est plus élevée que la code de l'eau amont */ + WARNING_UPSTREAM_BOTTOM_HIGHER_THAN_WATER, + /** * La cote de l'eau aval est plus élevée que la cote du seuil (ennoiement possible) */