An error occurred while loading the file. Please try again.
-
Mathias Chouet authoredbf645fbb
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";
export { PabParams };
export class Pab extends Nub {
/**
* 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;
}
/**
* paramètres castés au bon type
*/
get prms(): PabParams {
return this._prms as PabParams;
}
/**
* enfants castés au bon type
*/
get children(): PabCloisons[] {
return this._children as PabCloisons[];
}
/**
* Calcul analytique
* @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
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;
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
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
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;
}
r.vCalc = Z;
return r;
}
/**
* Once session is loaded, run a second pass on all PabCloisons to
* reinit their target if needed
*/
public fixPAB(obj: any) {
if (obj.children && Array.isArray(obj.children)) {
for (const c of obj.children) {
if (c.props.calcType === CalculatorType.PabCloisons) { // who knows ?
const childUid = c.uid;
const targetCloisonsUid = c.props.modeleCloisons;
// find child PabCloisons to relink
const pabCloisons = (this.getChild(childUid) as PabCloisons);
if (pabCloisons) {
pabCloisons.setModel(targetCloisonsUid);
} // else cannot find target
}
}
}
}
/**
* paramétrage de la calculabilité des paramètres
*/
protected setParametersCalculability() {
this.prms.Z1.calculability = ParamCalculability.EQUATION;
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;
}
}