diff --git a/spec/structure/dever.spec.ts b/spec/structure/dever.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..dc43499aa55727f4983a572c5ddb9b34ab4c8bec --- /dev/null +++ b/spec/structure/dever.spec.ts @@ -0,0 +1,44 @@ +/** + * IMPORTANT ! + * Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine") + * Pour exécuter ce code dans le débugger. + * Faire de même avec le fichier test_func.ts + */ +// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine"; + +import { Dever, DeverParams } from "../../src/structure/dever"; +import { CreateStructure } from "../../src/structure/factory_structure"; +import { LoiDebit, StructureType } from "../../src/structure/structure_props"; +import { Result } from "../../src/util/result"; + +const dever: Dever = new Dever( + new DeverParams( + 0, // rQ Débit total (m3/s) + 102, // rZ1 Cote de l'eau amont (m) + 2, // rBR Largeur du cours d'eau amont (m) + 100 // rZR Cote du lit du cours d'eau amont (m) + ), + false // debug +); + +dever.addStructure(CreateStructure(StructureType.SeuilTriangulaireTrunc, LoiDebit.TriangularTruncWeirFree, false)); + +describe("Class Dever: ", () => { + describe("Calc(Q) Seuil Triangulaire Trunc", () => { + it("vCalc should return 5.407", () => { + expect(dever.Calc("Q").vCalc).toBeCloseTo(5.407, 3); + }); + it("extraResults.V should return 1.352", () => { + expect(dever.Calc("Q").extraResults.V).toBeCloseTo(1.352, 3); + }); + it("extraResults.Ec should return 0.093", () => { + expect(dever.Calc("Q").extraResults.Ec).toBeCloseTo(0.093, 3); + }); + it("extraResults.Cv should return 1.116", () => { + expect(dever.Calc("Q").extraResults.Cv).toBeCloseTo(1.116, 3); + }); + it("extraResults.CvQT should return 6.036", () => { + expect(dever.Calc("Q").extraResults.CvQT).toBeCloseTo(6.036, 3); + }); + }); +}); diff --git a/src/structure/dever.ts b/src/structure/dever.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f9355881bd8ee3a03edb1bad4d63603305b0a6f --- /dev/null +++ b/src/structure/dever.ts @@ -0,0 +1,88 @@ +import { Nub } from "../nub"; +import { ParamCalculability, ParamDefinition } from "../param/param-definition"; +import { Result } from "../util/result"; +import { DeverParams } from "./dever_params"; +import { ParallelStructure } from "./parallel_structure"; + +export { DeverParams }; + +export class Dever extends ParallelStructure { + constructor(prms: DeverParams, dbg: boolean = false) { + super(prms, dbg); + } + + /** + * paramètres castés au bon type + */ + get prms(): DeverParams { + return this._prms as DeverParams; + } + + /** + * Calcul pour tous les paramètres + * @param sVarCalc Paramètre à calculer + * @returns Résultat avec résultats complémentaires et message + */ + public Equation(sVarCalc: string): Result { + const r: Result = super.Equation(sVarCalc); + let QT: number; + if (sVarCalc === "Q") { + QT = r.vCalc; + } else { + QT = this.prms.Q.v; + } + // Vitesse dans le cours d'eau amont + r.extraResults.V = QT / (this.prms.BR.v * Math.max(0, this.prms.Z1.v - this.prms.ZR.v)); + // Energie cinétique dans le cours d'eau amont + r.extraResults.Ec = r.extraResults.V * r.extraResults.V / (2 * 9.81); + // Calcul du rapport des aires sur les seuils et de l'aire du cours d'eau amont + const rA: number = this.calcA() / (this.prms.BR.v * Math.max(0, this.prms.Z1.v - this.prms.ZR.v)); + // Calcul de Cv + r.extraResults.Cv = this.calcCv(rA); + // Calcul de CV.QT + r.extraResults.CvQT = r.extraResults.Cv * QT; + return r; + } + + /** + * paramétrage de la calculabilité des paramètres + */ + protected setParametersCalculability() { + super.setParametersCalculability(); + this.prms.BR.calculability = ParamCalculability.FREE; + this.prms.ZR.calculability = ParamCalculability.FREE; + // On supprime Z2 de l'interface car régime dénoyé uniquement + this.prms.Z2.calculability = ParamCalculability.NONE; + } + + /** + * Calcul de la somme des aires des ouvrages. + * @note N.B. : doit être appelé après calcul si le calcul porte sur Z1 ou + */ + private calcA(): number { + let A: number = 0; + for (const st of this.structures) { + A += st.calcA(); + } + return A; + } + + /** + * Calcul du facteur de la correction du coefficient de débit dû à la vitesse d'approche + * @param rA Rapport entre l'aire d'écoulement des seuils et l'aire de la section amont + */ + private calcCv(rA: number): number { + const aA: number[] = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]; + const aCv: number[] = [1, 1.005, 1.015, 1.022, 1.035, 1.065, 1.09, 1.14, 1.21]; + // tslint:disable-next-line:prefer-for-of + for (let i = 1; i < aA.length; i++) { + if (rA < aA[i]) { + const k: number = (rA - aA[i - 1]) / (aA[i] - aA[i - 1]); + return aCv[i - 1] * (1 - k) + k * aCv[i]; + } + } + // Rapport des aires supérieur à 0.8 => Cv = 1.21 + return aCv[aCv.length - 1]; + } + +} diff --git a/src/structure/dever_params.ts b/src/structure/dever_params.ts new file mode 100644 index 0000000000000000000000000000000000000000..02bad78a7edb5257425ce8807e2ae0a83db797ea --- /dev/null +++ b/src/structure/dever_params.ts @@ -0,0 +1,29 @@ +import { ParamDefinition } from "../param/param-definition"; +import { ParamDomainValue } from "../param/param-domain"; +import { ParallelStructureParams } from "./parallel_structure_params"; + +/** + * Common parameters of hydraulic structure equations + */ +export class DeverParams extends ParallelStructureParams { + /** Largeur du cours d'eau amont (m) */ + public BR: ParamDefinition; + + /** Cote du lit du cours d'eau amont (m) */ + public ZR: ParamDefinition; + + /** + * Paramètres communs à toutes les équations de structure + * @param rQ Débit total (m3/s) + * @param rZ1 Cote de l'eau amont (m) + * @param rBR Largeur du cours d'eau amont (m) + * @param rZR Cote du lit du cours d'eau amont (m) + */ + constructor(rQ: number, rZ1: number, rBR: number, rZR: number) { + super(rQ, rZ1, - Infinity); + this.BR = new ParamDefinition("BR", ParamDomainValue.ANY, rBR); + this.addParamDefinition(this.BR); + this.ZR = new ParamDefinition("ZR", ParamDomainValue.ANY, rZR); + this.addParamDefinition(this.ZR); + } +} diff --git a/src/structure/factory_structure.ts b/src/structure/factory_structure.ts index 302113c65a33764816ee5e2e32a6c578ce5d3349..912003139efb808efcbcdb37fe04b14a001fe4cc 100644 --- a/src/structure/factory_structure.ts +++ b/src/structure/factory_structure.ts @@ -26,6 +26,7 @@ export function CreateStructure(structureType: StructureType, loiDebit: LoiDebit // W = Infinity par défaut pour un seuil ); + // Control of validity of structure type and definition of parameters switch (structureType) { case StructureType.VanneRectangulaire: rectStructPrms.W.v = 0.5; @@ -33,17 +34,21 @@ export function CreateStructure(structureType: StructureType, loiDebit: LoiDebit break; case StructureType.SeuilRectangulaire: case StructureType.SeuilTriangulaire: + case StructureType.SeuilTriangulaireTrunc: break; default: throw new Error(`type de structure ${StructureType[structureType]} non pris en charge`); } + + // Control validity of the couple Structure Type / Discharge equation if (!(StructureProperties.isCompatibleValues(structureType, loiDebit))) { throw new Error( `La loi de débit ${LoiDebit[loiDebit]} n'est pas admissible pour le type ${StructureType[structureType]}` ); } + // Instanciation of the equation switch (loiDebit) { case LoiDebit.Cem88d: rectStructPrms.Cd.v = oCd.SeuilR; // Cd Cem88d qu'on soit en seuil ou vanne @@ -82,7 +87,6 @@ export function CreateStructure(structureType: StructureType, loiDebit: LoiDebit 0, // Q 100, // ZDV 102, // Z1 - 101.5, // Z2 45, // Alpha2 oCd.SeuilT // Cd pour un seuil triangulaire // W = Infinity par défaut pour un seuil @@ -91,9 +95,8 @@ export function CreateStructure(structureType: StructureType, loiDebit: LoiDebit case LoiDebit.TriangularTruncWeirFree: const structTriTruncPrms: TriangularTruncStructureParams = new TriangularTruncStructureParams( 0, // Q - 100, // ZDV + 100.1, // ZDV 102, // Z1 - 101.5, // Z2 0.9, // BT 101, // ZT oCd.SeuilT // Cd pour un seuil triangulaire diff --git a/src/structure/structure_props.ts b/src/structure/structure_props.ts index e8bc5aa5c6e2900d291f8ed403a6045ce19cc95a..d7835ef44d4fed4e57e5f6bacc58b0d644eb3e78 100644 --- a/src/structure/structure_props.ts +++ b/src/structure/structure_props.ts @@ -1,5 +1,5 @@ export enum StructureType { - SeuilRectangulaire, VanneRectangulaire, SeuilTriangulaire + SeuilRectangulaire, VanneRectangulaire, SeuilTriangulaire, SeuilTriangulaireTrunc // VanneCirculaire, // VanneTrapezoidale, SeuilTrapezoidal } @@ -31,7 +31,10 @@ export const loiAdmissibles: { [key: string]: LoiDebit[] } = { LoiDebit.KIVI ], SeuilTriangulaire: [ - LoiDebit.TriangularWeirFree, LoiDebit.TriangularTruncWeirFree + LoiDebit.TriangularWeirFree + ], + SeuilTriangulaireTrunc: [ + LoiDebit.TriangularTruncWeirFree ], VanneRectangulaire: [ LoiDebit.Cem88d, LoiDebit.Cem88v, LoiDebit.Cunge80, LoiDebit.OrificeFree, diff --git a/src/structure/structure_triangular_trunc_weir_free_params.ts b/src/structure/structure_triangular_trunc_weir_free_params.ts index 81fc59fc21b39b37fa31e8f107ed4cde78c5d03d..7b3687b97e08529329e649b02d5ccf0b36c80193 100644 --- a/src/structure/structure_triangular_trunc_weir_free_params.ts +++ b/src/structure/structure_triangular_trunc_weir_free_params.ts @@ -21,17 +21,16 @@ export class TriangularTruncStructureParams extends StructureParams { * @param rQ Débit (m3/s) * @param rZDV Cote de la crête du déversoir ou du radier de la vanne (m) * @param rZ1 Cote de l'eau amont (m) - * @param rZ2 Cote de l'eau aval (m) * @param rBT Demi-ouverture du triangle (m) * @param rZT Cote haute du triangle (m) * @param rCd Coefficient de débit (-) * @param rW Ouverture de la vanne (m) (Valeur par défaut +infinity pour les déversoirs) */ constructor( - rQ: number, rZDV: number, rZ1: number, rZ2: number, + rQ: number, rZDV: number, rZ1: number, rBT: number, rZT: number, rCd: number, rW: number = Infinity ) { - super(rQ, rZDV, rZ1, rZ2, rW); + super(rQ, rZDV, rZ1, - Infinity, rW); this.BT = new ParamDefinition("BT", ParamDomainValue.POS, rBT); this.addParamDefinition(this.BT); this.ZT = new ParamDefinition("ZT", ParamDomainValue.POS, rZT); diff --git a/src/structure/structure_triangular_weir_free_params.ts b/src/structure/structure_triangular_weir_free_params.ts index 306b94ac91632c35c359f3fd73f604c5d318a628..7cfe3544665cc5baf041d100f783d13cf3563dfe 100644 --- a/src/structure/structure_triangular_weir_free_params.ts +++ b/src/structure/structure_triangular_weir_free_params.ts @@ -18,16 +18,15 @@ export class TriangularStructureParams extends StructureParams { * @param rQ Débit (m3/s) * @param rZDV Cote de la crête du déversoir ou du radier de la vanne (m) * @param rZ1 Cote de l'eau amont (m) - * @param rZ2 Cote de l'eau aval (m) * @param rAlpha2 Demi-angle au sommet du triangle (degrés) * @param rCd Coefficient de débit (-) * @param rW Ouverture de la vanne (m) (Valeur par défaut +infinity pour les déversoirs) */ constructor( - rQ: number, rZDV: number, rZ1: number, rZ2: number, + rQ: number, rZDV: number, rZ1: number, rAlpha2: number, rCd: number, rW: number = Infinity ) { - super(rQ, rZDV, rZ1, rZ2, rW); + super(rQ, rZDV, rZ1, - Infinity, rW); this.alpha2 = new ParamDefinition("alpha2", ParamDomainValue.POS, rAlpha2); this.addParamDefinition(this.alpha2); this.Cd = new ParamDefinition("Cd", ParamDomainValue.POS, rCd);