diff --git a/spec/pab/pab.spec.ts b/spec/pab/pab.spec.ts index c32052ee021f9a024b921fa56ef7fe0ca23b5495..6fc2ab060490012f92543a230ebeb88620ba84d8 100644 --- a/spec/pab/pab.spec.ts +++ b/spec/pab/pab.spec.ts @@ -9,7 +9,9 @@ import { Pab, PabParams } from "../../src/pab/pab"; import { PabCloisons } from "../../src/pab/pab_cloisons"; import { Cloisons, CloisonsParams } from "../../src/structure/cloisons"; +import { ParallelStructure, ParallelStructureParams } from "../../src/structure/parallel_structure"; import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params"; +import { StructureKivi, StructureKiviParams } from "../../src/structure/structure_kivi"; import { StructureWeirSubmergedLarinier } from "../../src/structure/structure_weir_submerged_larinier"; const dbg: boolean = false; @@ -41,16 +43,30 @@ const rectStructPrms = new RectangularStructureParams( ); // Ajout d'ouvrage dans la cloison -modelCloisons.addChild(new StructureWeirSubmergedLarinier(rectStructPrms, dbg)); +modelCloisons.addChild(new StructureWeirSubmergedLarinier(rectStructPrms)); -// Création de la passe +// Création de la cloison aval +const downWall = new ParallelStructure(new ParallelStructureParams(0, 0, 0)); +const kiviPrms = new StructureKiviParams( + 0.773, // Q + 73.95, // ZDV + 0, // Z1 + 0, // Z2 + 0.6, // L + 0.4, // Cd pour un seuil rectangulaire + 0, + 73.435 +); +downWall.addChild(new StructureKivi(kiviPrms)); +// Création de la passe const pab: Pab = new Pab( new PabParams( modelCloisons.prms.Q.v, modelCloisons.prms.Z1.v, 74.86 ), + downWall, dbg ); @@ -58,7 +74,7 @@ const pab: Pab = new Pab( const pabCloison = new PabCloisons(modelCloisons, 0, dbg); -for (let i = 0; i < 15; i++) { +for (let i = 0; i < 14; i++) { pab.addChild(pabCloison); } diff --git a/src/pab/pab.ts b/src/pab/pab.ts index 12085da568b5f382ade55f74fa2015fd1bb923a0..166daefea7ab23d770cf346355e623fda73ac448 100644 --- a/src/pab/pab.ts +++ b/src/pab/pab.ts @@ -1,6 +1,7 @@ import { CalculatorType } from "../compute-node"; import { Nub } from "../nub"; import { ParamCalculability } from "../param/param-definition"; +import { ParallelStructure } from "../structure/parallel_structure"; import { Result } from "../util/result"; import { PabCloisons } from "./pab_cloisons"; import { PabParams } from "./pab_params"; @@ -9,8 +10,14 @@ export { PabParams }; export class Pab extends Nub { - constructor(prms: PabParams, dbg: boolean = false) { + /** + * Last wall at downstream + */ + public downWall: ParallelStructure; + + constructor(prms: PabParams, downWall: ParallelStructure, dbg: boolean = false) { super(prms, dbg); + this.downWall = downWall; this._calcType = CalculatorType.Pab; } @@ -34,13 +41,47 @@ export class Pab extends Nub { */ public Equation(sVarCalc: string): Result { const r: Result = new Result(0, this); + + // Up to down course : discharge distribution and bottom elevation + let Q: number = this.prms.Q.v; // Upstream discharge + // upstream basin apron elevation + let rZRam: number = this.children[0].prms.Z1.currentValue - this.children[0].Yam; + + for (const cl of this.children) { + Q += cl.prms.QA.v; // Discharge in the current basin + rZRam -= cl.prms.DH.currentValue; + } + + // Down to up course : water surface calculation let Z: number = this.prms.Z2.v; - for (const cloison of this.children) { - cloison.prms.Z2.v = Z; - cloison.Calc("Z1"); - Z = cloison.prms.Z1.v; + Z = this.calcZ1(this.downWall, Q, Z); + + for (let i = this.children.length - 1; i > 0; i--) { + + // Initialisations for current cloison + const cl: PabCloisons = this.children[i]; + rZRam += cl.prms.DH.currentValue; + cl.updateZDV(rZRam); + + // Calculation of upstream water elevation + Z = this.calcZ1(cl, Q, Z); + if (this.debug) { + for (const p of cl.prms) { + // tslint:disable-next-line:no-console + console.log(p.symbol + " = " + p.v); + } + for (const c of cl.getChildren()) { + console.log("Ouvrage"); + for (const p of c.prms) { + // tslint:disable-next-line:no-console + console.log(p.symbol + " = " + p.v); + } + } + } + Q -= cl.prms.QA.v; } - this.prms.Z1.v = Z; + + r.vCalc = Z; return r; } @@ -75,4 +116,18 @@ export class Pab extends Nub { this.prms.Z2.calculability = ParamCalculability.DICHO; this.prms.Q.calculability = ParamCalculability.DICHO; } + + private calcZ1(cl: ParallelStructure, Q: number, Z: number): number { + // Initialisations for current cloison + cl.prms.Q.v = Q; + cl.prms.Z2.v = Z; + + // Calculation of upstream water elevation + cl.Calc("Z1"); + + // TODO: Add extraresults: discharge, apron elevation upstream the wall, apron elevation at half basin + + // Update elevation and discharge for next basin + return cl.prms.Z1.v; + } } diff --git a/src/pab/pab_cloisons.ts b/src/pab/pab_cloisons.ts index 43ba681359439f497547b8194745a5ceb9e5a583..4328f9306f5b32c9d68f9d1bd3f39b415840234f 100644 --- a/src/pab/pab_cloisons.ts +++ b/src/pab/pab_cloisons.ts @@ -54,6 +54,21 @@ class PabCloisonsParams extends CloisonsParams { // tslint:disable-next-line:max-classes-per-file export class PabCloisons extends Cloisons { + /** + * paramètres castés au bon type + */ + get prms(): PabCloisonsParams { + return this._prms as PabCloisonsParams; + } + + /** + * Calculation of upstream water depth + */ + get Yam(): number { + // TODO: ajouter l'option radier horizontal + return this.prms.PB.currentValue + this.prms.DH.currentValue / 2; + } + public parent: Pab; constructor(modelCloisons: Cloisons, rQA: number = 0, dbg: boolean = false) { @@ -63,10 +78,14 @@ export class PabCloisons extends Cloisons { } /** - * paramètres castés au bon type + * Update crest elevations from upstream apron elevation */ - get prms(): PabCloisonsParams { - return this._prms as PabCloisonsParams; + public updateZDV(rZR: number) { + for (const st of this.structures) { + if (st.prms.ZDV.calculability !== ParamCalculability.NONE) { + st.prms.ZDV.v = st.prms.ZDV.currentValue + rZR - (this.prms.Z1.currentValue - this.Yam); + } + } } /** diff --git a/src/param/param-values.ts b/src/param/param-values.ts index e367f6173174cf6ee1fe1afbac0da1a33ba9a434..9d850c7d16bcf7c042d6e4f298ac74bf15b6b37b 100644 --- a/src/param/param-values.ts +++ b/src/param/param-values.ts @@ -42,6 +42,7 @@ export class ParamValues implements IterableValues { public set singleValue(v: number) { this._singleValue = v; + this.currentValue = v; } public count() { diff --git a/src/session.ts b/src/session.ts index 2432c89c05e7158ae02df8d33e67d3e24ee041d1..0880b8393962206cd6376e8fd35b6754ae0596b8 100644 --- a/src/session.ts +++ b/src/session.ts @@ -377,7 +377,7 @@ export class Session { 1.5, // Q 102, // Z1 99 // Z2 - ), dbg + ), undefined, dbg ); break;