pab.ts 8.28 KiB
import { CalculatorType } from "../compute-node";
import { Nub } from "../nub";
import { ParamCalculability } from "../param/param-definition";
import { IParamDefinitionIterator, ParamsEquation, ParamsEquationArrayIterator } from "../param/params-equation";
import { Session } from "../session";
import { ParallelStructure, ParallelStructureParams } from "../structure/parallel_structure";
import { StructureTriangularTruncWeirFree } from "../structure/structure_triangular_trunc_weir";
import { Result } from "../util/result";
import { Cloisons } from "./cloisons";
import { PabParams } from "./pab_params";
export { PabParams };
export class Pab extends Nub {
    /**
     * paramètres castés au bon type
    get prms(): PabParams {
        return this._prms as PabParams;
    /**
     * enfants castés au bon type
    get children(): Cloisons[] {
        return this._children as Cloisons[];
    private static consoleDbgWall(cl: ParallelStructure) {
        let s: string = "";
        for (const p of cl.prms) {
            // tslint:disable-next-line:no-console
            s += p.symbol + " = " + p.v + "; ";
        // tslint:disable-next-line:no-console
        console.log(s);
        for (const c of cl.getChildren()) {
            // tslint:disable-next-line:no-console
            console.log("Ouvrage");
            s = "";
            for (const p of c.prms) {
                if (p.visible) {
                    s += "*";
                s += p.symbol + " = " + p.v + "; ";
            // tslint:disable-next-line:no-console
            console.log(s);
    /**
     * Last wall at downstream
    private _downWall: ParallelStructure;
    constructor(prms: PabParams, downWall: ParallelStructure, dbg: boolean = false) {
        super(prms, dbg);
        this.downWall = downWall;
        this._calcType = CalculatorType.Pab;
    public get downWall() {
        return this._downWall;
    public set downWall(dw: ParallelStructure) {
        this._downWall = dw;
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
if (dw) { // might be undefined dw.parent = this; // important } } /** * Add Cloisons to the PAB from a cloison model * @param cloisonModel Cloison model parametrised as first upstream basin * @param n Number of walls (or falls) of the PAB (Number of basin = n - 1) */ public addCloisonsFromModel(cloisonModel: Cloisons , n: number) { // Fix some parameters of the upstream cloison (= Wall + basin) const DH: number = cloisonModel.prms.DH.currentValue; const ZRMB: number = this.prms.Z1.currentValue - cloisonModel.prms.PB.currentValue - DH; const ZRAM: number = ZRMB + DH / 2; // Generate an image of the object for multiplication const serialisedCloisonModel = cloisonModel.serialise(); for (let i = 0; i < n; i++) { const cl: Cloisons = Session.getInstance().unserialiseSingleNub(serialisedCloisonModel).nub as Cloisons; const p = cl.prms; for (const st of cl.structures) { if (st.prms.h1.visible) { // Set ZDV from h1 for rectangular weirs st.prms.ZDV.singleValue = this.prms.Z1.currentValue - st.prms.h1.currentValue; // Set parameter visibility for ZDV and h1 in PAB context st.prms.ZDV.visible = true; st.prms.h1.visible = false; } } p.ZRMB.singleValue = ZRMB - i * DH; p.ZRAM.singleValue = ZRAM - i * DH; // Set Structure ZDVs for (const st of cl.structures) { if (st.isZDVcalculable) { st.prms.ZDV.singleValue = st.prms.ZDV.currentValue - i * DH; if (st.getParameter("ZT") !== undefined) { const stTT = st as StructureTriangularTruncWeirFree; stTT.prms.ZT.singleValue = stTT.prms.ZT.currentValue - i * DH; } } } if (i !== n - 1) { // Add wall + basin = cloison this.addChild(cl); } else { // The last wall is a ParallelStructure (= Wall only, without basin) this.downWall = new ParallelStructure(new ParallelStructureParams(0, 0, 0)); this.downWall.structures = cl.structures; } } } /** * Calcul analytique * @warning Should be called by this.Calc only for parameter initialisations * @param sVarCalc Variable à calculer (Z1 uniquement) */ public Equation(sVarCalc: string): Result { const r: Result = new Result(0, this); // Up to down course : discharge distribution and bottom elevation if (this.children.length > 0) { this.children[0].prms.Q.v = this.prms.Q.v; } let l: number = 0; // Lenght of the fishway and wall abscissas for (let i = 0; i < this.children.length; i++) { let wall: ParallelStructure; if (i !== this.children.length - 1) { wall = this.children[i + 1];
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
} else { wall = this.downWall; } l += this.children[i].prms.LB.v; // Set discharge for the next wall from the current basin wall.prms.Q.v = this.children[i].prms.Q.v + this.children[i].prms.QA.v; } // Down to up course : water surface calculation let Z: number = this.prms.Z2.v; Z = this.calcCloisonZ1(this.downWall, Z); this.downWall.result.extraResults.ZRAM = this.children[this.children.length - 1].prms.ZRMB.v - this.children[this.children.length - 1].prms.DH.v / 2; this.downWall.result.extraResults.Q = this.downWall.prms.Q.v; this.downWall.result.extraResults.x = l; if (this.debug) { console.log("Downstream wall"); Pab.consoleDbgWall(this.downWall); } for (let i = this.children.length - 1; i >= 0; i--) { // Initialisations for current cloison const cl: Cloisons = this.children[i]; // Calculation of upstream water elevation cl.prms.PB.v = Z - cl.prms.ZRMB.v; Z = this.calcCloisonZ1(cl, Z); // Add extraresults: mean depth in pool and discharge cl.result.extraResults.YMOY = cl.prms.PB.v; cl.result.extraResults.Q = cl.prms.Q.v; cl.result.extraResults.QA = cl.prms.QA.v; l -= cl.prms.LB.v; cl.result.extraResults.x = l; if (this.debug) { console.log("Bassin n°" + i); Pab.consoleDbgWall(cl); } } r.vCalc = Z; return r; } /** * Returns an iterator over : * - own parameters (this._prms) * - children parameters (this._children[*]._prms) * Special treatment for PAB's downwall */ public get parameterIterator(): IParamDefinitionIterator { const prms: ParamsEquation[] = []; prms.push(this._prms); if (this._children) { Nub.concatPrms(prms, this.childrenPrms); } if (this.downWall) { Nub.concatPrms(prms, this.downWall.childrenPrms); } return new ParamsEquationArrayIterator(prms); } /** * paramétrage de la calculabilité des paramètres */ protected setParametersCalculability() { this.prms.Z1.calculability = ParamCalculability.EQUATION; this.prms.Z2.calculability = ParamCalculability.FREE;
211212213214215216217218219220221222223224225226227228229230231232233234235236237
this.prms.Q.calculability = ParamCalculability.DICHO; } /** * Remove Calculability of DH for not updating Z2 during calculation * @param child Cloison newly added to the PAB */ protected adjustChildParameters(child: Cloisons) { child.prms.DH.calculability = ParamCalculability.NONE; } private calcCloisonZ1(cl: ParallelStructure, Z: number): number { // Initialisations for current cloison cl.prms.Z2.v = Z; // Calculation of upstream water elevation cl.Calc("Z1", Z + 0.1); // Fall on this wall cl.result.extraResults.DH = cl.result.vCalc - cl.prms.Z2.v; // Return Update elevation for next pool return cl.result.vCalc; } }