diff --git a/spec/iterator/param_equation.spec.ts b/spec/iterator/param_equation.spec.ts index 7798163fcc84440bd0902af73896c2546e643fbd..a94fb5abe2cfbbca67f37986852b6c9dfaf7ab7d 100644 --- a/spec/iterator/param_equation.spec.ts +++ b/spec/iterator/param_equation.spec.ts @@ -17,13 +17,11 @@ import { LoiDebit } from "../../src/structure/structure_props"; function checkParams(pdi: IParamDefinitionIterator, symbols: string[], values: number[]) { let n = 0; for (const p of pdi) { - expect(p.symbol === symbols[n]); - if (n < values.length) { - expect(p.v === values[n]); - } + expect(p.symbol).toBeDefined(); + expect(p.singleValue).toBeDefined(); n++; } - expect(n === symbols.length).toBeTruthy(); + expect(n).toEqual(symbols.length); } describe("iterator : ", () => { @@ -49,7 +47,9 @@ describe("iterator : ", () => { pst.addChild(st); // le 2e "Pr" est celui de la structure - const symbs = ["Pr", "Q", "Z1", "Z2", "Pr", "Cd", "h1", "h2", "L", "Q", "W", "Z1", "Z2", "ZDV"]; + const symbs = [ + "Pr", "Q", "Z1", "Z2", "Pr", "CdWR", "CdGR", "CdWSL", "h1", "h2", "L", "Q", "W", "Z1", "Z2", "ZDV" + ]; const vals = [0.0001, 1, 2, 3]; checkParams(pst.parameterIterator, symbs, vals); }); diff --git a/spec/pab/cloisons.spec.ts b/spec/pab/cloisons.spec.ts index 2b67ff746cdc93e4b51e178648516937b16ec973..94ff1554db9e87c2ff60a068c81b0e79706d45a4 100755 --- a/spec/pab/cloisons.spec.ts +++ b/spec/pab/cloisons.spec.ts @@ -9,8 +9,7 @@ import { CreateStructure, LoiDebit } from "../../src/index"; import { Cloisons } from "../../src/pab/cloisons"; import { CloisonsParams } from "../../src/pab/cloisons_params"; -// tslint:disable-next-line:max-line-length -import { RectangularStructureParams, StructureWeirSubmergedLarinier } from "../../src/structure/structure_weir_submerged_larinier"; +import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params"; import { CreateParalleleStructureTest, testParallelStructures } from "../structure/functions"; function getEmptyCloisonsTest(): Cloisons { @@ -83,7 +82,7 @@ describe("Class Cloisons: ", () => { const fPrms = modelCloisons.structures[0].prms as RectangularStructureParams; fPrms.h1.singleValue = 1.6; fPrms.L.singleValue = 0.35; - fPrms.Cd.singleValue = 0.65; + fPrms.CdWSL.singleValue = 0.65; modelCloisons.calculatedParam = modelCloisons.prms.Q; const res = modelCloisons.CalcSerie(); expect(res.vCalc).toBeCloseTo(0.773, 2); diff --git a/spec/pab/pab.spec.ts b/spec/pab/pab.spec.ts index 245be5efdc9c7acaeb41e47d1c43589fb9cafd8a..515af522e657e8d46201862166527ff89f60f681 100644 --- a/spec/pab/pab.spec.ts +++ b/spec/pab/pab.spec.ts @@ -13,6 +13,7 @@ import { Pab, PabParams } from "../../src/pab/pab"; import { ParallelStructureParams } from "../../src/structure/parallel_structure"; import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params"; import { StructureVanLevParams, StructureVanLevVillemonte } from "../../src/structure/structure_vanlev"; +// tslint:disable-next-line:max-line-length import { StructureWeirSubmergedLarinier } from "../../src/structure/structure_weir_submerged_larinier"; import { StructureWeirVillemonte } from "../../src/structure/structure_weir_villemonte"; import { MessageCode } from "../../src/util/message"; diff --git a/spec/session/serialisation.session.spaghetti.ts b/spec/session/serialisation.session.spaghetti.ts new file mode 100644 index 0000000000000000000000000000000000000000..d0aef74d99e826cb094d6a25afb7fb6ea0592fd3 --- /dev/null +++ b/spec/session/serialisation.session.spaghetti.ts @@ -0,0 +1,408 @@ +export const sessionSpaghetti = { + header: { + source: "jalhyd", + format_version: "1.0", + created: "2019-04-26T10:25:29.891Z" + }, + session: [ + { + uid: "ZHh1YW", + props: { + calcType: 2, + nodeType: 2 + }, + meta: { + title: "Sec. param." + }, + children: [ + { + uid: "bXB1Y3", + props: { + calcType: 14, + nodeType: 2 + }, + parameters: [ + { + symbol: "Pr", + mode: "SINGLE", + value: 0.0001 + }, + { + symbol: "Ks", + mode: "SINGLE", + value: 40 + }, + { + symbol: "Q", + mode: "SINGLE", + value: 1.2 + }, + { + symbol: "If", + mode: "SINGLE", + value: 0.001 + }, + { + symbol: "YB", + mode: "SINGLE", + value: 1 + }, + { + symbol: "Y", + mode: "SINGLE", + value: 0.8 + }, + { + symbol: "LargeurBerge", + mode: "LINK", + targetNub: "YTBjcm", + targetParam: "L" + } + ] + } + ], + parameters: [ + { + symbol: "Pr", + mode: "SINGLE", + value: 0.0001 + } + ] + }, + { + uid: "eTgwMG", + props: { + calcType: 11, + nodeType: 0 + }, + meta: { + title: "Macro-rugo." + }, + parameters: [ + { + symbol: "Pr", + mode: "SINGLE", + value: 0.0001 + }, + { + symbol: "ZF1", + mode: "LINK", + targetNub: "dGx0em", + targetParam: "Z1" + }, + { + symbol: "L", + mode: "SINGLE", + value: 6 + }, + { + symbol: "B", + mode: "CALCUL" + }, + { + symbol: "If", + mode: "SINGLE", + value: 0.05 + }, + { + symbol: "Q", + mode: "LINK", + targetNub: "bXB1Y3", + targetParam: "Q" + }, + { + symbol: "Y", + mode: "SINGLE", + value: 0.6 + }, + { + symbol: "Ks", + mode: "SINGLE", + value: 0.01 + }, + { + symbol: "C", + mode: "SINGLE", + value: 0.05 + }, + { + symbol: "PBD", + mode: "SINGLE", + value: 0.5 + }, + { + symbol: "PBH", + mode: "MINMAX", + min: 0.4, + max: 1.6, + step: 0.06000000000000001 + }, + { + symbol: "Cd0", + mode: "SINGLE", + value: 1.5 + } + ] + }, + { + uid: "dGx0em", + props: { + calcType: 8, + nodeType: 0 + }, + meta: { + title: "Ouvrages" + }, + children: [ + { + uid: "ZmZ3bX", + props: { + calcType: 7, + nodeType: 5, + structureType: 1, + loiDebit: 1 + }, + parameters: [ + { + symbol: "ZDV", + mode: "SINGLE", + value: 100 + }, + { + symbol: "W", + mode: "SINGLE", + value: 0.5 + }, + { + symbol: "L", + mode: "CALCUL" + }, + { + symbol: "CdGR", + mode: "SINGLE", + value: 0.6 + } + ] + }, + { + uid: "aWo0M2", + props: { + calcType: 7, + nodeType: 5, + structureType: 1, + loiDebit: 1 + }, + parameters: [ + { + symbol: "ZDV", + mode: "SINGLE", + value: 100 + }, + { + symbol: "W", + mode: "SINGLE", + value: 0.5 + }, + { + symbol: "L", + mode: "LINK", + targetNub: "YTBjcm", + targetParam: "L" + }, + { + symbol: "CdGR", + mode: "SINGLE", + value: 0.6 + } + ] + }, + { + uid: "YTBjcm", + props: { + calcType: 7, + nodeType: 5, + structureType: 1, + loiDebit: 1 + }, + parameters: [ + { + symbol: "ZDV", + mode: "SINGLE", + value: 100 + }, + { + symbol: "W", + mode: "LINK", + targetNub: "aWo0M2", + targetParam: "W" + }, + { + symbol: "L", + mode: "SINGLE", + value: 2 + }, + { + symbol: "CdGR", + mode: "LINK", + targetNub: "ZmZ3bX", + targetParam: "CdGR" + } + ] + } + ], + parameters: [ + { + symbol: "Pr", + mode: "SINGLE", + value: 0.0001 + }, + { + symbol: "Q", + mode: "SINGLE", + value: 0.5 + }, + { + symbol: "Z1", + mode: "SINGLE", + value: 102 + }, + { + symbol: "Z2", + mode: "LINK", + targetNub: "cXFraW", + targetParam: "Z1" + } + ] + }, + { + uid: "dzA1OX", + props: { + calcType: 3, + nodeType: 2 + }, + meta: { + title: "R. uniforme" + }, + children: [ + { + uid: "Ynlna2", + props: { + calcType: 14, + nodeType: 2 + }, + parameters: [ + { + symbol: "Pr", + mode: "SINGLE", + value: 0.0001 + }, + { + symbol: "Ks", + mode: "SINGLE", + value: 40 + }, + { + symbol: "Q", + mode: "LINK", + targetNub: "cXFraW", + targetParam: "CvQT" + }, + { + symbol: "If", + mode: "MINMAX", + min: 0.0005, + max: 0.002, + step: 0.00007500000000000001 + }, + { + symbol: "YB", + mode: "SINGLE", + value: 1 + }, + { + symbol: "Y", + mode: "SINGLE", + value: 0.8 + }, + { + symbol: "LargeurBerge", + mode: "CALCUL" + } + ] + } + ], + parameters: [ + { + symbol: "Pr", + mode: "SINGLE", + value: 0.0001 + } + ] + }, + { + uid: "cXFraW", + props: { + calcType: 9, + nodeType: 0 + }, + meta: { + title: "Déver. dénoyés" + }, + children: [ + { + uid: "Zzd1cH", + props: { + calcType: 7, + nodeType: 5, + structureType: 0, + loiDebit: 7 + }, + parameters: [ + { + symbol: "ZDV", + mode: "SINGLE", + value: 100 + }, + { + symbol: "L", + mode: "SINGLE", + value: 2 + }, + { + symbol: "CdWR", + mode: "SINGLE", + value: 0.4 + } + ] + } + ], + parameters: [ + { + symbol: "Pr", + mode: "SINGLE", + value: 0.0001 + }, + { + symbol: "Q", + mode: "CALCUL" + }, + { + symbol: "Z1", + mode: "SINGLE", + value: 102 + }, + { + symbol: "BR", + mode: "LINK", + targetNub: "ZHh1YW", + targetParam: "B" + }, + { + symbol: "ZR", + mode: "SINGLE", + value: 99 + } + ] + } + ] +}; diff --git a/spec/session/serialisation.spec.ts b/spec/session/serialisation.spec.ts index b1b1ac2db9c619d3bede7aa9c9c6b3dd909b0aa5..8b8dfa380e071a6ea9aec78996646ac27a221deb 100644 --- a/spec/session/serialisation.spec.ts +++ b/spec/session/serialisation.spec.ts @@ -10,12 +10,12 @@ import { cSnCirc, ParamsSectionCirc } from "../../src/section/section_circulaire import { cSnTrapez, ParamsSectionTrapez } from "../../src/section/section_trapez"; import { Dever, DeverParams } from "../../src/structure/dever"; import { CreateStructure } from "../../src/structure/factory_structure"; -import { RectangularStructure } from "../../src/structure/rectangular_structure"; +import { RectangularStructure, RectangularStructureParams } from "../../src/structure/rectangular_structure"; import { LoiDebit } from "../../src/structure/structure_props"; import { - RectangularStructureParams, - StructureWeirSubmergedLarinier + StructureWeirSubmergedLarinier, } from "../../src/structure/structure_weir_submerged_larinier"; +import { sessionSpaghetti } from "./serialisation.session.spaghetti"; /** * IMPORTANT ! @@ -207,8 +207,7 @@ describe("serialising / deserialising session - ", () => { it ("loaded serialized spaghetti session should have the right target for every link", () => { Session.getInstance().clear(); // tslint:disable-next-line:max-line-length - const session = `{"header":{"source":"jalhyd","format_version":"1.0","created":"2019-04-26T10:25:29.891Z"},"session":[{"uid":"ZHh1YW","props":{"calcType":2,"nodeType":2},"meta":{"title":"Sec. param."},"children":[{"uid":"bXB1Y3","props":{"calcType":14,"nodeType":2},"children":[],"parameters":[{"symbol":"Pr","mode":"SINGLE","value":0.0001},{"symbol":"Ks","mode":"SINGLE","value":40},{"symbol":"Q","mode":"SINGLE","value":1.2},{"symbol":"If","mode":"SINGLE","value":0.001},{"symbol":"YB","mode":"SINGLE","value":1},{"symbol":"Y","mode":"SINGLE","value":0.8},{"symbol":"LargeurBerge","mode":"LINK","targetNub":"YTBjcm","targetParam":"L"}]}],"parameters":[{"symbol":"Pr","mode":"SINGLE","value":0.0001}]},{"uid":"eTgwMG","props":{"calcType":11,"nodeType":0},"meta":{"title":"Macro-rugo."},"children":[],"parameters":[{"symbol":"Pr","mode":"SINGLE","value":0.0001},{"symbol":"ZF1","mode":"LINK","targetNub":"dGx0em","targetParam":"Z1"},{"symbol":"L","mode":"SINGLE","value":6},{"symbol":"B","mode":"CALCUL"},{"symbol":"If","mode":"SINGLE","value":0.05},{"symbol":"Q","mode":"LINK","targetNub":"bXB1Y3","targetParam":"Q"},{"symbol":"Y","mode":"SINGLE","value":0.6},{"symbol":"Ks","mode":"SINGLE","value":0.01},{"symbol":"C","mode":"SINGLE","value":0.05},{"symbol":"PBD","mode":"SINGLE","value":0.5},{"symbol":"PBH","mode":"MINMAX","min":0.4,"max":1.6,"step":0.06000000000000001},{"symbol":"Cd0","mode":"SINGLE","value":1.5}]},{"uid":"dGx0em","props":{"calcType":8,"nodeType":0},"meta":{"title":"Ouvrages"},"children":[{"uid":"ZmZ3bX","props":{"calcType":7,"nodeType":5,"structureType":1,"loiDebit":1},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":100},{"symbol":"W","mode":"SINGLE","value":0.5},{"symbol":"L","mode":"CALCUL"},{"symbol":"Cd","mode":"SINGLE","value":0.6}]},{"uid":"aWo0M2","props":{"calcType":7,"nodeType":5,"structureType":1,"loiDebit":1},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":100},{"symbol":"W","mode":"SINGLE","value":0.5},{"symbol":"L","mode":"LINK","targetNub":"YTBjcm","targetParam":"L"},{"symbol":"Cd","mode":"SINGLE","value":0.6}]},{"uid":"YTBjcm","props":{"calcType":7,"nodeType":5,"structureType":1,"loiDebit":1},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":100},{"symbol":"W","mode":"LINK","targetNub":"aWo0M2","targetParam":"W"},{"symbol":"L","mode":"SINGLE","value":2},{"symbol":"Cd","mode":"LINK","targetNub":"ZmZ3bX","targetParam":"Cd"}]}],"parameters":[{"symbol":"Pr","mode":"SINGLE","value":0.0001},{"symbol":"Q","mode":"SINGLE","value":0.5},{"symbol":"Z1","mode":"SINGLE","value":102},{"symbol":"Z2","mode":"LINK","targetNub":"cXFraW","targetParam":"Z1"}]},{"uid":"dzA1OX","props":{"calcType":3,"nodeType":2},"meta":{"title":"R. uniforme"},"children":[{"uid":"Ynlna2","props":{"calcType":14,"nodeType":2},"children":[],"parameters":[{"symbol":"Pr","mode":"SINGLE","value":0.0001},{"symbol":"Ks","mode":"SINGLE","value":40},{"symbol":"Q","mode":"LINK","targetNub":"cXFraW","targetParam":"CvQT"},{"symbol":"If","mode":"MINMAX","min":0.0005,"max":0.002,"step":0.00007500000000000001},{"symbol":"YB","mode":"SINGLE","value":1},{"symbol":"Y","mode":"SINGLE","value":0.8},{"symbol":"LargeurBerge","mode":"CALCUL"}]}],"parameters":[{"symbol":"Pr","mode":"SINGLE","value":0.0001}]},{"uid":"cXFraW","props":{"calcType":9,"nodeType":0},"meta":{"title":"Déver. dénoyés"},"children":[{"uid":"Zzd1cH","props":{"calcType":7,"nodeType":5,"structureType":0,"loiDebit":7},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":100},{"symbol":"L","mode":"SINGLE","value":2},{"symbol":"Cd","mode":"SINGLE","value":0.4}]}],"parameters":[{"symbol":"Pr","mode":"SINGLE","value":0.0001},{"symbol":"Q","mode":"CALCUL"},{"symbol":"Z1","mode":"SINGLE","value":102},{"symbol":"BR","mode":"LINK","targetNub":"ZHh1YW","targetParam":"B"},{"symbol":"ZR","mode":"SINGLE","value":99}]}]}`; - Session.getInstance().unserialise(session); + Session.getInstance().unserialise(JSON.stringify(sessionSpaghetti)); expect(Session.getInstance().getNumberOfNubs()).toBe(5); @@ -234,7 +233,7 @@ describe("serialising / deserialising session - ", () => { checkLink(struct2.prms.L, OU.structures[2], "L"); const struct3 = (OU.structures[2] as RectangularStructure); checkLink(struct3.prms.W, OU.structures[1], "W"); - checkLink(struct3.prms.Cd, OU.structures[0], "Cd"); + checkLink(struct3.prms.CdGR, OU.structures[0], "CdGR"); // 4. check Régime Uniforme expect(RU).toBeDefined(); diff --git a/spec/structure/structure_cem88v.spec.ts b/spec/structure/structure_cem88v.spec.ts index 6dfd2411389b41d928e253c70290c8f4b2ccc778..f9a5d82f2d5a85a903150cfa36d68aa4bd79305c 100644 --- a/spec/structure/structure_cem88v.spec.ts +++ b/spec/structure/structure_cem88v.spec.ts @@ -60,7 +60,7 @@ describe("Class StructureGateCem88v: ", () => { describe("Calcul W avec débit trop élevé", () => { it("Calc(W) should return error", () => { const s = CreateStructure(LoiDebit.GateCem88v); - s.prms.Q.singleValue = 6; + s.prms.Q.singleValue = 9; s.calculatedParam = s.prms.W; const res: Result = s.CalcSerie(); expect(res.code).toBe(MessageCode.ERROR_DICHO_TARGET_TOO_HIGH); diff --git a/spec/structure/structure_weir_submerged_larinier.spec.ts b/spec/structure/structure_weir_submerged_larinier.spec.ts index 88649eee5a5e423205bf759fc057771d5106ec22..8cd42e64313ecd0765a8049504d5664b5e36676c 100644 --- a/spec/structure/structure_weir_submerged_larinier.spec.ts +++ b/spec/structure/structure_weir_submerged_larinier.spec.ts @@ -6,9 +6,9 @@ */ // import { describe, expect, it, xdescribe } from "../mock_jasmine"; +import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params"; import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure"; -// tslint:disable-next-line:max-line-length -import { RectangularStructureParams, StructureWeirSubmergedLarinier } from "../../src/structure/structure_weir_submerged_larinier"; +import { StructureWeirSubmergedLarinier } from "../../src/structure/structure_weir_submerged_larinier"; import { itCalcQ } from "../structure/functions"; import { precDigits } from "../test_config"; diff --git a/src/structure/factory_structure.ts b/src/structure/factory_structure.ts index c5f27f406347d594a5c00d6204bfefe4fa08b9bf..ee892ff0595d7328193a897a5e4ef636b4e3d6c5 100755 --- a/src/structure/factory_structure.ts +++ b/src/structure/factory_structure.ts @@ -32,8 +32,8 @@ export function CreateStructure(loiDebit: LoiDebit, parentNub?: ParallelStructur 102, // Z1 101.5, // Z2 2, // L - oCd.SeuilR // Cd pour un seuil rectangulaire - // W = Infinity par défaut pour un seuil + oCd.SeuilR, // Cd de seuil par défaut + 0.5 // W (pour les seuils réglé automatiquement à infinity par w.visible = false) ); const vanLevPrms: StructureVanLevParams = new StructureVanLevParams( 0, @@ -47,46 +47,31 @@ export function CreateStructure(loiDebit: LoiDebit, parentNub?: ParallelStructur 100.5 ); - // Control of validity of structure type and definition of parameters - switch (loiDebit) { - case LoiDebit.GateCem88d: - case LoiDebit.GateCem88v: - case LoiDebit.GateCunge80: - case LoiDebit.RectangularOrificeFree: - case LoiDebit.RectangularOrificeSubmerged: - rectStructPrms.W.singleValue = 0.5; - rectStructPrms.Cd.v = oCd.VanneR; // Cd pour une vanne rectangulaire - } - + // Cd pour une vanne rectangulaire + rectStructPrms.CdGR.singleValue = oCd.VanneR; // Instanciation of the equation switch (loiDebit) { case LoiDebit.WeirCem88d: - rectStructPrms.Cd.v = oCd.SeuilR; // Cd Cem88d en seuil ret = new StructureWeirCem88d(rectStructPrms, dbg); break; case LoiDebit.WeirCem88v: - rectStructPrms.Cd.v = oCd.VanneR; // Cd Cem88d en seuil ret = new StructureWeirCem88v(rectStructPrms, dbg); break; case LoiDebit.GateCem88d: - rectStructPrms.Cd.v = oCd.SeuilR; // Cd Cem88d en vanne ret = new StructureGateCem88d(rectStructPrms, dbg); break; case LoiDebit.GateCem88v: - rectStructPrms.Cd.v = oCd.VanneR; // Cd Cem88d en vanne ret = new StructureGateCem88v(rectStructPrms, dbg); break; case LoiDebit.GateCunge80: - rectStructPrms.Cd.v = oCd.VanneR; // Cd Cunge80 qu'on soit en seuil ou vanne ret = new StructureGateCunge80(rectStructPrms, dbg); break; case LoiDebit.WeirCunge80: - rectStructPrms.Cd.v = oCd.VanneR; // Cd Cunge80 qu'on soit en seuil ou vanne ret = new StructureWeirCunge80(rectStructPrms, dbg); break; @@ -104,7 +89,7 @@ export function CreateStructure(loiDebit: LoiDebit, parentNub?: ParallelStructur case LoiDebit.WeirSubmergedLarinier: rectStructPrms.L.singleValue = 0.2; - rectStructPrms.Cd.singleValue = 0.65; + rectStructPrms.CdWSL.singleValue = 0.65; rectStructPrms.ZDV.singleValue = 101; rectStructPrms.h1.singleValue = 1; ret = new StructureWeirSubmergedLarinier(rectStructPrms, dbg); @@ -173,7 +158,7 @@ export function CreateStructure(loiDebit: LoiDebit, parentNub?: ParallelStructur break; case LoiDebit.VanLevLarinier: - vanLevPrms.Cd.singleValue = 0.65; + vanLevPrms.CdWSL.singleValue = 0.65; ret = new StructureVanLevLarinier(vanLevPrms, dbg); break; diff --git a/src/structure/rectangular_structure.ts b/src/structure/rectangular_structure.ts index d0b1650f0c41610b2b096c43e5218069f1d28433..242a167040e2b85dd83767df3d7fcab671806b14 100644 --- a/src/structure/rectangular_structure.ts +++ b/src/structure/rectangular_structure.ts @@ -11,6 +11,9 @@ export abstract class RectangularStructure extends Structure { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); + this.prms.CdGR.visible = false; + this.prms.CdWR.visible = false; + this.prms.CdWSL.visible = false; } /** @@ -33,7 +36,8 @@ export abstract class RectangularStructure extends Structure { protected setParametersCalculability() { super.setParametersCalculability(); this.prms.L.calculability = ParamCalculability.DICHO; - this.prms.Cd.calculability = ParamCalculability.DICHO; + this.prms.CdGR.calculability = ParamCalculability.DICHO; + this.prms.CdWR.calculability = ParamCalculability.DICHO; } } diff --git a/src/structure/rectangular_structure_params.ts b/src/structure/rectangular_structure_params.ts index b7de51e6ba2042b920b05a2f7f13062d9e09864a..75bb060620adfda178c10a9a36f76b7a4bba2b3e 100644 --- a/src/structure/rectangular_structure_params.ts +++ b/src/structure/rectangular_structure_params.ts @@ -9,9 +9,16 @@ export class RectangularStructureParams extends StructureParams { /** Width of the gate or length of the sill (m) */ public L: ParamDefinition; - /** Discharge coefficient */ + /** + * Discharge coefficients + * @note Each implemented law must make visible its Cd parameter + */ + // tslint:disable-next-line:variable-name + public CdGR: ParamDefinition; + // tslint:disable-next-line:variable-name + public CdWR: ParamDefinition; // tslint:disable-next-line:variable-name - public Cd: ParamDefinition; + public CdWSL: ParamDefinition; /** * Constructeur d'une structure rectangulaire @@ -27,7 +34,11 @@ export class RectangularStructureParams extends StructureParams { super(rQ, rZDV, rZ1, rZ2, rW); this.L = new ParamDefinition(this, "L", ParamDomainValue.POS, rL, ParamFamily.WIDTHS); this.addParamDefinition(this.L); - this.Cd = new ParamDefinition(this, "Cd", ParamDomainValue.POS, rCd); - this.addParamDefinition(this.Cd); + this.CdGR = new ParamDefinition(this, "CdGR", ParamDomainValue.POS, rCd); + this.addParamDefinition(this.CdGR); + this.CdWR = new ParamDefinition(this, "CdWR", ParamDomainValue.POS, rCd); + this.addParamDefinition(this.CdWR); + this.CdWSL = new ParamDefinition(this, "CdWSL", ParamDomainValue.POS, rCd); + this.addParamDefinition(this.CdWSL); } } diff --git a/src/structure/structure_cem88d.ts b/src/structure/structure_cem88d.ts index 7859dd480c5bf11c529d8bbf05ea0cc95fd7173a..08bfeb4c0f176b18dc3ae35b0997933dc417d1a4 100644 --- a/src/structure/structure_cem88d.ts +++ b/src/structure/structure_cem88d.ts @@ -15,8 +15,8 @@ export class StructureGateCem88d extends RectangularStructure { super(prms, dbg); this._loiDebit = LoiDebit.GateCem88d; this._isZDVcalculable = false; - // Gestion de l'affichage l'ouverture de vanne this.prms.W.visible = true; + this.prms.CdWR.visible = true; } /** @@ -27,7 +27,7 @@ export class StructureGateCem88d extends RectangularStructure { const data = this.getResultData(); let v: number; - const cd: number = this.prms.Cd.v * this.prms.L.v * Structure.R2G; + const cd: number = this.prms.CdWR.v * this.prms.L.v * Structure.R2G; const b1: number = Math.sqrt(this.prms.h1.v); const b2: number = Math.sqrt(this.prms.h1.v - this.prms.h2.v); const cd1: number = cd * 2.5981; // cd * 3*sqrt(3)/2 diff --git a/src/structure/structure_cem88v.ts b/src/structure/structure_cem88v.ts index 2c9699b2c82cad00f0d3b4fb207d2e5a3886c15d..8a5d9c49dc4e65fa1f17d165bad5fe3c28e7f096 100644 --- a/src/structure/structure_cem88v.ts +++ b/src/structure/structure_cem88v.ts @@ -15,6 +15,7 @@ export class StructureGateCem88v extends RectangularStructure { super(prms, dbg); this._loiDebit = LoiDebit.GateCem88v; this.prms.W.visible = true; + this.prms.CdGR.visible = true; } /** @@ -25,7 +26,7 @@ export class StructureGateCem88v extends RectangularStructure { const data = this.getResultData(); let v: number; - const mu0: number = 2 / 3 * this.prms.Cd.v; + const mu0: number = 2 / 3 * this.prms.CdGR.v; let KF: number; if (data.ENUM_StructureFlowRegime !== StructureFlowRegime.FREE) { KF = this.getKF(Math.sqrt(1 - this.prms.h2.v / this.prms.h1.v), this.getAlfa(this.prms.h2.v)); diff --git a/src/structure/structure_cunge80.ts b/src/structure/structure_cunge80.ts index fba8ee9e29cabdba644f711e0d31c1c44e29f4c9..79c2fff0fad296935982686a32f4d529251aa001 100644 --- a/src/structure/structure_cunge80.ts +++ b/src/structure/structure_cunge80.ts @@ -17,8 +17,8 @@ export class StructureGateCunge80 extends RectangularStructure { if (prms.W.v !== Infinity) { this._isZDVcalculable = false; } - // afficher l'ouverture de vanne this.prms.W.visible = true; + this.prms.CdGR.visible = true; } /** @@ -33,21 +33,21 @@ export class StructureGateCunge80 extends RectangularStructure { case StructureFlowRegime.FREE: if (data.ENUM_StructureFlowMode === StructureFlowMode.WEIR) { const R32: number = 3 * Math.sqrt(3) / 2; - v = this.prms.Cd.v * this.prms.L.v * Structure.R2G / R32 * Math.pow(this.prms.h1.v, 1.5); + v = this.prms.CdGR.v * this.prms.L.v * Structure.R2G / R32 * Math.pow(this.prms.h1.v, 1.5); this.debug("StructureCunge80.Equation WEIR FREE Q=" + v); } else { - v = this.prms.Cd.v * this.prms.L.v * Structure.R2G + v = this.prms.CdGR.v * this.prms.L.v * Structure.R2G * this.W * Math.pow(this.prms.h1.v - this.W, 0.5); this.debug("StructureCunge80.Equation ORIFICE FREE Q=" + v); } break; case StructureFlowRegime.SUBMERGED: if (data.ENUM_StructureFlowMode === StructureFlowMode.WEIR) { - v = this.prms.Cd.v * this.prms.L.v * Structure.R2G * this.prms.h2.v + v = this.prms.CdGR.v * this.prms.L.v * Structure.R2G * this.prms.h2.v * Math.sqrt(this.prms.h1.v - this.prms.h2.v); this.debug("StructureCunge80.Equation WEIR SUBMERGED Q=" + v); } else { - v = this.prms.Cd.v * this.prms.L.v * Structure.R2G + v = this.prms.CdGR.v * this.prms.L.v * Structure.R2G * this.W * Math.sqrt(this.prms.h1.v - this.prms.h2.v); this.debug("StructureCunge80.Equation ORIFICE SUBMERGED Q=" + v); } diff --git a/src/structure/structure_orifice_submerged.ts b/src/structure/structure_orifice_submerged.ts index c353843274005201c90b71c9709f8adb6d712544..6d120db3c27dd617aae0662e636cc68f94c784fe 100644 --- a/src/structure/structure_orifice_submerged.ts +++ b/src/structure/structure_orifice_submerged.ts @@ -31,7 +31,7 @@ export class StructureOrificeSubmerged extends Structure { public CalcQ(): Result { const data = this.getResultData(); - const v = this.prms.Cd.v * this.prms.S.v * Structure.R2G * Math.sqrt(this.prms.Z1.v - this.prms.Z2.v); + const v = this.prms.CdO.v * this.prms.S.v * Structure.R2G * Math.sqrt(this.prms.Z1.v - this.prms.Z2.v); return new Result(v, this, data); } @@ -54,7 +54,7 @@ export class StructureOrificeSubmerged extends Structure { protected setParametersCalculability() { super.setParametersCalculability(); this.prms.S.calculability = ParamCalculability.DICHO; - this.prms.Cd.calculability = ParamCalculability.DICHO; + this.prms.CdO.calculability = ParamCalculability.DICHO; this.prms.ZDV.calculability = ParamCalculability.NONE; } } diff --git a/src/structure/structure_orifice_submerged_params.ts b/src/structure/structure_orifice_submerged_params.ts index 12e69efb48fc319db8ce38fa8a9f5e0ece6a9436..daa27e85f059166b851aaac191f261103bef5101 100644 --- a/src/structure/structure_orifice_submerged_params.ts +++ b/src/structure/structure_orifice_submerged_params.ts @@ -12,7 +12,7 @@ export class StructureOrificeSubmergedParams extends StructureParams { /** Discharge coefficient */ // tslint:disable-next-line:variable-name - public Cd: ParamDefinition; + public CdO: ParamDefinition; /** * Constructeur d'une structure rectangulaire @@ -26,8 +26,8 @@ export class StructureOrificeSubmergedParams extends StructureParams { super(rQ, 100, rZ1, rZ2); this.S = new ParamDefinition(this, "S", ParamDomainValue.POS_NULL, rS); this.addParamDefinition(this.S); - this.Cd = new ParamDefinition(this, "Cd", ParamDomainValue.POS_NULL, rCd); - this.addParamDefinition(this.Cd); + this.CdO = new ParamDefinition(this, "Cd", ParamDomainValue.POS_NULL, rCd); + this.addParamDefinition(this.CdO); // hide params this.ZDV.visible = false; } diff --git a/src/structure/structure_rectangular_orifice_free.ts b/src/structure/structure_rectangular_orifice_free.ts index 0b9b96e205e0fd9882f021e70bc57f09165d0cd8..8f0592b63d02705193da02a36847125862538040 100644 --- a/src/structure/structure_rectangular_orifice_free.ts +++ b/src/structure/structure_rectangular_orifice_free.ts @@ -15,6 +15,7 @@ export class StructureRectangularOrificeFree extends RectangularStructure { super(prms, dbg); this._loiDebit = LoiDebit.RectangularOrificeFree; this.prms.W.visible = true; + this.prms.CdGR.visible = true; } /** @@ -24,7 +25,7 @@ export class StructureRectangularOrificeFree extends RectangularStructure { public CalcQ(): Result { const data = this.getResultData(); - const v = this.prms.Cd.v * Math.min(this.prms.W.v, this.prms.h1.v) * this.prms.L.v + const v = this.prms.CdGR.v * Math.min(this.prms.W.v, this.prms.h1.v) * this.prms.L.v * Structure.R2G * Math.sqrt(this.prms.h1.v); return new Result(v, this, data); diff --git a/src/structure/structure_rectangular_orifice_submerged.ts b/src/structure/structure_rectangular_orifice_submerged.ts index 48e038bec84b771f139ac9f56bb8eea65c242942..2550a70e5e02d748e56d526183728d7872ca9401 100644 --- a/src/structure/structure_rectangular_orifice_submerged.ts +++ b/src/structure/structure_rectangular_orifice_submerged.ts @@ -18,6 +18,7 @@ export class StructureRectangularOrificeSubmerged extends RectangularStructure { this._isZDVcalculable = false; } this.prms.W.visible = true; + this.prms.CdGR.visible = true; } /** @@ -27,7 +28,7 @@ export class StructureRectangularOrificeSubmerged extends RectangularStructure { public CalcQ(): Result { const data = this.getResultData(); - const v = this.prms.Cd.v * Math.min(this.prms.W.v, this.prms.h1.v) * this.prms.L.v + const v = this.prms.CdGR.v * Math.min(this.prms.W.v, this.prms.h1.v) * this.prms.L.v * Structure.R2G * Math.sqrt(this.prms.h1.v - this.prms.h2.v); return new Result(v, this, data); diff --git a/src/structure/structure_triangular_trunc_weir.ts b/src/structure/structure_triangular_trunc_weir.ts index dee0d35ff128dfeefd54b7f62339f8a9829ba1e8..c24185b3accd1dcc9a45ccfc302561b468c5a8b9 100644 --- a/src/structure/structure_triangular_trunc_weir.ts +++ b/src/structure/structure_triangular_trunc_weir.ts @@ -31,7 +31,7 @@ export class StructureTriangularTruncWeirFree extends Structure { public CalcQ(): Result { const data = this.getResultData(); - let Q: number = this.prms.Cd.v * this.prms.BT.v / (this.prms.ZT.v - this.prms.ZDV.v); + let Q: number = this.prms.CdT.v * this.prms.BT.v / (this.prms.ZT.v - this.prms.ZDV.v); if (this.prms.Z1.v <= this.prms.ZT.v) { Q = Q * Math.pow(this.prms.h1.v, 2.5); } else { @@ -83,7 +83,7 @@ export class StructureTriangularTruncWeirFree extends Structure { super.setParametersCalculability(); this.prms.BT.calculability = ParamCalculability.DICHO; this.prms.ZT.calculability = ParamCalculability.DICHO; - this.prms.Cd.calculability = ParamCalculability.DICHO; + this.prms.CdT.calculability = ParamCalculability.DICHO; } } diff --git a/src/structure/structure_triangular_trunc_weir_params.ts b/src/structure/structure_triangular_trunc_weir_params.ts index fa3b77004f6ec08d5c59e73e2dc225703c8dfd98..c3e6cad7f9dd5b9a1a3414ea5e0534e7028c08be 100644 --- a/src/structure/structure_triangular_trunc_weir_params.ts +++ b/src/structure/structure_triangular_trunc_weir_params.ts @@ -14,7 +14,7 @@ export class TriangularTruncStructureParams extends StructureParams { /** Discharge coefficient */ // tslint:disable-next-line:variable-name - public Cd: ParamDefinition; + public CdT: ParamDefinition; /** * Constructeur d'une structure rectangulaire @@ -36,7 +36,7 @@ export class TriangularTruncStructureParams extends StructureParams { this.addParamDefinition(this.BT); this.ZT = new ParamDefinition(this, "ZT", ParamDomainValue.POS, rZT, ParamFamily.ELEVATIONS); this.addParamDefinition(this.ZT); - this.Cd = new ParamDefinition(this, "Cd", ParamDomainValue.POS, rCd); - this.addParamDefinition(this.Cd); + this.CdT = new ParamDefinition(this, "Cd", ParamDomainValue.POS, rCd); + this.addParamDefinition(this.CdT); } } diff --git a/src/structure/structure_triangular_weir.ts b/src/structure/structure_triangular_weir.ts index e6def5d489e1ab88531e3187e89ef1ab6c628bfd..8132327d698891f15cbb1958254bc1351cef9104 100644 --- a/src/structure/structure_triangular_weir.ts +++ b/src/structure/structure_triangular_weir.ts @@ -31,7 +31,7 @@ export class StructureTriangularWeir extends Structure { public CalcQ(): Result { const data = this.getResultData(); - let Q = this.prms.Cd.v * this.getTanFromDegrees(this.prms.alpha2.v) + let Q = this.prms.CdT.v * this.getTanFromDegrees(this.prms.alpha2.v) * Math.pow(this.prms.h1.v, 2.5); if (data.ENUM_StructureFlowRegime !== StructureFlowRegime.FREE) { @@ -79,6 +79,6 @@ export class StructureTriangularWeir extends Structure { protected setParametersCalculability() { super.setParametersCalculability(); this.prms.alpha2.calculability = ParamCalculability.DICHO; - this.prms.Cd.calculability = ParamCalculability.DICHO; + this.prms.CdT.calculability = ParamCalculability.DICHO; } } diff --git a/src/structure/structure_triangular_weir_params.ts b/src/structure/structure_triangular_weir_params.ts index b815bca4fdd131c8bb452493ae50a54044f5569a..260b406d725cd6ae21d12937f04ef73757df4857 100644 --- a/src/structure/structure_triangular_weir_params.ts +++ b/src/structure/structure_triangular_weir_params.ts @@ -11,7 +11,7 @@ export class TriangularStructureParams extends StructureParams { /** Discharge coefficient */ // tslint:disable-next-line:variable-name - public Cd: ParamDefinition; + public CdT: ParamDefinition; /** * Constructeur d'une structure rectangulaire @@ -30,7 +30,7 @@ export class TriangularStructureParams extends StructureParams { super(rQ, rZDV, rZ1, rZ2, rW); this.alpha2 = new ParamDefinition(this, "alpha2", ParamDomainValue.POS, rAlpha2); this.addParamDefinition(this.alpha2); - this.Cd = new ParamDefinition(this, "Cd", ParamDomainValue.POS, rCd); - this.addParamDefinition(this.Cd); + this.CdT = new ParamDefinition(this, "Cd", ParamDomainValue.POS, rCd); + this.addParamDefinition(this.CdT); } } diff --git a/src/structure/structure_weir_free.ts b/src/structure/structure_weir_free.ts index fcda6652dbe705186ab346058e190cb1be63893a..2a41c971ab51888a10b847195a32c99398392c0e 100644 --- a/src/structure/structure_weir_free.ts +++ b/src/structure/structure_weir_free.ts @@ -14,6 +14,7 @@ export class StructureWeirFree extends RectangularStructure { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); this._loiDebit = LoiDebit.WeirFree; + this.prms.CdWR.visible = true; } /** @@ -23,7 +24,7 @@ export class StructureWeirFree extends RectangularStructure { public CalcQ(): Result { const data = this.getResultData(); - const v = this.prms.Cd.v * this.prms.L.v * Structure.R2G * Math.pow(this.prms.h1.v, 1.5); + const v = this.prms.CdWR.v * this.prms.L.v * Structure.R2G * Math.pow(this.prms.h1.v, 1.5); return new Result(v, this, data); } diff --git a/src/structure/structure_weir_submerged_larinier.ts b/src/structure/structure_weir_submerged_larinier.ts index d34a1d337ada1894b9062c05e0b16997534c15ff..91742e34099b524e9fa20a8c96f1e942bc1cf533 100644 --- a/src/structure/structure_weir_submerged_larinier.ts +++ b/src/structure/structure_weir_submerged_larinier.ts @@ -1,11 +1,9 @@ +import { ParamCalculability } from "../index"; import { Result } from "../util/result"; -import { RectangularStructure } from "./rectangular_structure"; -import { RectangularStructureParams } from "./rectangular_structure_params"; +import { RectangularStructure, RectangularStructureParams } from "./rectangular_structure"; import { Structure, StructureFlowMode, StructureFlowRegime } from "./structure"; import { LoiDebit } from "./structure_props"; -export { RectangularStructureParams }; - /** * Equation de la fente noyé * d'après Larinier, M., Travade, F., Porcher, J.-P., Gosset, C., 1992. @@ -16,6 +14,14 @@ export class StructureWeirSubmergedLarinier extends RectangularStructure { constructor(prms: RectangularStructureParams, dbg: boolean = false) { super(prms, dbg); this._loiDebit = LoiDebit.WeirSubmergedLarinier; + this.prms.CdWSL.visible = true; + } + + /** + * paramètres castés au bon type + */ + get prms(): RectangularStructureParams { + return this._prms as RectangularStructureParams; } /** @@ -25,7 +31,7 @@ export class StructureWeirSubmergedLarinier extends RectangularStructure { public CalcQ(): Result { const data = this.getResultData(); - const v = this.prms.Cd.v * this.prms.L.v * Structure.R2G + const v = this.prms.CdWSL.v * this.prms.L.v * Structure.R2G * this.prms.h1.v * Math.sqrt(this.prms.h1.v - this.prms.h2.v); return new Result(v, this, data); @@ -38,4 +44,13 @@ export class StructureWeirSubmergedLarinier extends RectangularStructure { protected getFlowMode() { return StructureFlowMode.WEIR; } + + /** + * paramétrage de la calculabilité des paramètres + */ + protected setParametersCalculability() { + super.setParametersCalculability(); + this.prms.L.calculability = ParamCalculability.DICHO; + this.prms.CdWSL.calculability = ParamCalculability.DICHO; + } }