diff --git a/spec/cloisons/cloisons_fente.spec.ts b/spec/cloisons/cloisons_fente.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..d953f5dfc7388a6b447fc52e7a633ae89981630b --- /dev/null +++ b/spec/cloisons/cloisons_fente.spec.ts @@ -0,0 +1,26 @@ +/** + * IMPORTANT ! + * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine") + * Pour exécuter ce code dans le débugger. + * Faire de même avec le fichier ../structure/functions.ts + */ +// import { describe, expect, it, xdescribe } from "../mock_jasmine"; + +import { CloisonsFente, CloisonsFenteParams } from "../../src/cloisons/cloisons_fente"; +import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure"; +import { itCalcQ } from "../structure/functions"; + +const prms: CloisonsFenteParams = new CloisonsFenteParams(0, 102, 0.5, 0.5, 0.2, 0.65); +const test: CloisonsFente = new CloisonsFente(prms, false); + +describe("Class CloisonsFente: ", () => { + describe("Calc(Q): ", () => { + const h1: number[] = [102]; + const Q: number[] = [0.204]; + const mode: StructureFlowMode = StructureFlowMode.WEIR; + const regime: StructureFlowRegime = StructureFlowRegime.SUBMERGED; + for (let i = 0; i < Q.length; i++) { + itCalcQ(test, h1[i], Infinity, Q[i], mode, regime); + } + }); +}); diff --git a/spec/cloisons/cloisons_orifice.spec.ts b/spec/cloisons/cloisons_orifice.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..92fa2e0603ea6ecdd440e447bcba7abfc744cb91 --- /dev/null +++ b/spec/cloisons/cloisons_orifice.spec.ts @@ -0,0 +1,26 @@ +/** + * IMPORTANT ! + * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine") + * Pour exécuter ce code dans le débugger. + * Faire de même avec le fichier ../structure/functions.ts + */ +// import { describe, expect, it, xdescribe } from "../mock_jasmine"; + +import { CloisonsOrifice, CloisonsOrificeParams } from "../../src/cloisons/cloisons_orifice"; +import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure"; +import { itCalcQ } from "../structure/functions"; + +const prms: CloisonsOrificeParams = new CloisonsOrificeParams(0, 102, 0.5, 0.7, 0.1); +const test: CloisonsOrifice = new CloisonsOrifice(prms, false); + +describe("Class CloisonsOrifice: ", () => { + describe("Calc(Q): ", () => { + const h1: number[] = [102]; + const Q: number[] = [0.219]; + const mode: StructureFlowMode = StructureFlowMode.ORIFICE; + const regime: StructureFlowRegime = StructureFlowRegime.SUBMERGED; + for (let i = 0; i < Q.length; i++) { + itCalcQ(test, h1[i], Infinity, Q[i], mode, regime); + } + }); +}); diff --git a/spec/structure/functions.ts b/spec/structure/functions.ts index 853eecc881d2d7c2c0664b6683830320e41f99d9..e00be7b8058826711e1eb57728f7eb7e61594f4f 100644 --- a/spec/structure/functions.ts +++ b/spec/structure/functions.ts @@ -3,7 +3,7 @@ * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine") * Pour exécuter ce code dans le débugger. */ -// import { describe, expect, it, xdescribe } from "../mock_jasmine"; +import { describe, expect, it, xdescribe } from "../mock_jasmine"; import { Structure } from "../../src/structure/structure"; import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure"; diff --git a/spec/structure/structure_triangular_trunc_weir_free.spec.ts b/spec/structure/structure_triangular_trunc_weir_free.spec.ts index f0e771dc22e8980e24039838f8173c26d7926660..117cdc05250b3d60b975651b17a44dc9d9af9db3 100644 --- a/spec/structure/structure_triangular_trunc_weir_free.spec.ts +++ b/spec/structure/structure_triangular_trunc_weir_free.spec.ts @@ -4,7 +4,7 @@ * Pour exécuter ce code dans le débugger. * Faire de même avec ./functions.ts */ -// import { describe, expect, it, xdescribe } from "../mock_jasmine"; +import { describe, expect, it, xdescribe } from "../mock_jasmine"; import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure"; import { StructureTriangularTruncWeirFree } from "../../src/structure/structure_triangular_trunc_weir_free"; diff --git a/src/cloisons/cloisons_fente.ts b/src/cloisons/cloisons_fente.ts new file mode 100644 index 0000000000000000000000000000000000000000..b714d97ffc91613d94af81e326c64e195f252a5b --- /dev/null +++ b/src/cloisons/cloisons_fente.ts @@ -0,0 +1,45 @@ +import { ParamCalculability } from "../param/param-definition"; +import { StructureWeirSubmergedLarinier } from "../structure/structure_weir_submerged_larinier"; +import { Result } from "../util/result"; +import { CloisonsFenteParams } from "./cloisons_fente_params"; + +export { CloisonsFenteParams }; + +/** + * Equation de la fente noyé pour l'outil "Cloisons" + * d'après Larinier, M., Travade, F., Porcher, J.-P., Gosset, C., 1992. + * Passes à poissons : expertise et conception des ouvrages de franchissement + */ +export class CloisonsFente extends StructureWeirSubmergedLarinier { + + constructor(prms: CloisonsFenteParams, dbg: boolean = false) { + super(prms, dbg); + this._isZDVcalculable = false; + } + + /** + * paramètres castés au bon type + */ + get prms(): CloisonsFenteParams { + return this._prms as CloisonsFenteParams; + } + + /** + * Calcul analytique Q = f(Cd, L, h1, h2, W) seuil dénoyé + * @param sVarCalc Variable à calculer (doit être "Q") + */ + public Equation(sVarCalc: string): Result { + return super.Equation(sVarCalc); + } + + /** + * paramétrage de la calculabilité des paramètres + */ + protected setParametersCalculability() { + super.setParametersCalculability(); + this.prms.H1.calculability = ParamCalculability.DICHO; + this.prms.DH.calculability = ParamCalculability.DICHO; + this.prms.Z2.calculability = ParamCalculability.FREE; + this.prms.ZDV.calculability = ParamCalculability.FREE; + } +} diff --git a/src/cloisons/cloisons_fente_params.ts b/src/cloisons/cloisons_fente_params.ts new file mode 100644 index 0000000000000000000000000000000000000000..57bb275bd4ab51f1d8798322100cfafb44dd194a --- /dev/null +++ b/src/cloisons/cloisons_fente_params.ts @@ -0,0 +1,42 @@ +import { ParamDefinition } from "../param/param-definition"; +import { ParamDomainValue } from "../param/param-domain"; +import { RectangularStructureParams } from "../structure/rectangular_structure_params"; + +/** + * Parameters for rectangular structures (common for all rectangular structure equations) + */ +export class CloisonsFenteParams extends RectangularStructureParams { + /** Head (m) */ + public H1: ParamDefinition; + + /** Drop (m) */ + public DH: ParamDefinition; + + /** + * Constructeur d'une structure rectangulaire + * @param rQ Débit (m3/s) + * @param rZ1 Cote de l'eau amont (m) + * @param rH1 Charge amont sur la fente (m) + * @param rDH Chute (m) + * @param rL Largeur de la fente (m) + * @param rCd Coefficient de débit (-) + */ + constructor( + rQ: number, rZ1: number, rH1: number, rDH: number, + rL: number, rCd: number + ) { + super(rQ, rZ1 - rH1, rZ1, - Infinity, rL, rCd); + this.H1 = new ParamDefinition("H1", ParamDomainValue.POS_NULL, rH1); + this.addParamDefinition(this.H1); + this.DH = new ParamDefinition("DH", ParamDomainValue.POS_NULL, rDH); + this.addParamDefinition(this.DH); + this.Cd = new ParamDefinition("Cd", ParamDomainValue.POS, rCd); + this.addParamDefinition(this.Cd); + } + + public update_h1h2() { + this.ZDV.v = this.Z1.v - this.H1.v; + this.Z2.v = this.Z1.v - this.DH.v; + super.update_h1h2(); + } +} diff --git a/src/cloisons/cloisons_orifice.ts b/src/cloisons/cloisons_orifice.ts new file mode 100644 index 0000000000000000000000000000000000000000..9cc10df7ed74732437e09b05b2fccf0621eff0db --- /dev/null +++ b/src/cloisons/cloisons_orifice.ts @@ -0,0 +1,61 @@ +import { ParamCalculability } from "../param/param-definition"; +import { Structure, StructureFlowMode, StructureFlowRegime } from "../structure/structure"; +import { Result } from "../util/result"; +import { CloisonsOrificeParams } from "./cloisons_orifice_params"; + +export { CloisonsOrificeParams }; + +/** + * Equation classique orifice noyé + */ +export class CloisonsOrifice extends Structure { + + constructor(prms: CloisonsOrificeParams, dbg: boolean = false) { + super(prms, dbg); + this._isZDVcalculable = false; + } + + /** + * paramètres castés au bon type + */ + get prms(): CloisonsOrificeParams { + return this._prms as CloisonsOrificeParams; + } + + /** + * Calcul du débit avec l'équation classique d'un orifice noyé + * @param sVarCalc Variable à calculer (doit être égale à Q ici) + */ + public Equation(sVarCalc: string): Result { + Structure.CheckEquation(sVarCalc); + const data = this.getResultData(); + + const v = this.prms.Cd.v * this.prms.S.v * Structure.R2G * Math.sqrt(this.prms.DH.v); + + return new Result(v, data); + } + + public calcA(): number { + return this.prms.S.v; + } + + protected getFlowRegime() { + return StructureFlowRegime.SUBMERGED; + } + + protected getFlowMode() { + return StructureFlowMode.ORIFICE; + } + + /** + * paramétrage de la calculabilité des paramètres + */ + protected setParametersCalculability() { + super.setParametersCalculability(); + this.prms.DH.calculability = ParamCalculability.DICHO; + this.prms.S.calculability = ParamCalculability.DICHO; + this.prms.Cd.calculability = ParamCalculability.DICHO; + this.prms.Z2.calculability = ParamCalculability.NONE; + this.prms.ZDV.calculability = ParamCalculability.NONE; + } +} diff --git a/src/cloisons/cloisons_orifice_params.ts b/src/cloisons/cloisons_orifice_params.ts new file mode 100644 index 0000000000000000000000000000000000000000..b33a17408e056c40e49f82704ff08f0843020175 --- /dev/null +++ b/src/cloisons/cloisons_orifice_params.ts @@ -0,0 +1,45 @@ +import { ParamDefinition } from "../param/param-definition"; +import { ParamDomainValue } from "../param/param-domain"; +import { StructureParams } from "../structure/structure_params"; + +/** + * Parameters for rectangular structures (common for all rectangular structure equations) + */ +export class CloisonsOrificeParams extends StructureParams { + + /** Drop (m) */ + public DH: ParamDefinition; + + /** Area of the orifice (m2) */ + public S: ParamDefinition; + + /** Discharge coefficient */ + // tslint:disable-next-line:variable-name + public Cd: ParamDefinition; + + /** + * Constructeur d'une structure rectangulaire + * @param rQ Débit (m3/s) + * @param rZ1 Cote de l'eau amont (m) + * @param rDH Chute (m) + * @param rCd Coefficient de débit (-) + * @param rS Surface de l'orifice (m2) + */ + constructor(rQ: number, rZ1: number, rDH: number, rCd: number, rS: number) { + super(rQ, -Infinity, rZ1, rZ1 - rDH); + this.DH = new ParamDefinition("DH", ParamDomainValue.POS_NULL, rDH); + this.addParamDefinition(this.DH); + this.S = new ParamDefinition("S", ParamDomainValue.POS_NULL, rS); + this.addParamDefinition(this.S); + this.Cd = new ParamDefinition("Cd", ParamDomainValue.POS_NULL, rCd); + this.addParamDefinition(this.Cd); + } + + /** + * Mise à jour de h1 et h2 + */ + public update_h1h2() { + // Inutile pour cette équation qui ne fait pas intervenir ces variables + } + +} diff --git a/src/structure/structure.ts b/src/structure/structure.ts index 8965a98e88998f5072715bb6c92c961b4df3985e..fcd0e5e12eeee7e89de207c6bd55614f3735aabf 100644 --- a/src/structure/structure.ts +++ b/src/structure/structure.ts @@ -100,16 +100,16 @@ export abstract class Structure extends Nub { // Gestion du débit nul const flagsNull = { Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL }; if (sVarCalc === "Q") { - if (this.prms.h1.v === this.prms.h2.v || this.prms.W.v <= 0) { + if (this.prms.h1.v <= 0 || this.prms.Z1.v === this.prms.Z2.v || this.prms.W.v <= 0) { return new Result(0, flagsNull); } } else if (this.prms.Q.v === 0) { // Débit nul <=> tirant d'eau amont = tirant d'eau aval ou tout autre paramètre nul switch (sVarCalc) { case "Z1": - return new Result(this.prms.h2.v, flagsNull); + return new Result(this.prms.Z2.v, flagsNull); case "Z2": - return new Result(this.prms.h1.v, flagsNull); + return new Result(this.prms.Z1.v, flagsNull); default: // Est-ce toujours vrai ? Nécessitera peut-être d'étendre la méthode return new Result(0, flagsNull);