An error occurred while loading the file. Please try again.
-
Mathias Chouet authoredee2f1a2c
import { CalculatorType } from "./compute-node";
import { ParamCalculability } from "./param/param-definition";
import { SectionNub } from "./section/section_nub";
import { SectionParams } from "./section/section_parametree";
import { acSection } from "./section/section_type";
import { Result } from "./util/result";
export class RegimeUniforme extends SectionNub {
constructor(s: acSection, dbg: boolean = false) {
super(new SectionParams(), dbg);
this._calcType = CalculatorType.RegimeUniforme;
this.setSection(s);
}
/**
* paramètres castés au bon type
*/
get prms(): SectionParams {
return this._prms as SectionParams;
}
public Equation(sVarCalc: string): Result {
this.debug("RU: Equation(" + sVarCalc + ")");
if (typeof sVarCalc !== "string") {
// dirty hack because calculated param descriptor for section params is an object { uid: , symbol: }
sVarCalc = (sVarCalc as any).symbol;
}
switch (sVarCalc) {
case "Y":
return this.section.CalcSection("Yn");
case "Q":
return this.Calc_Qn();
default:
throw new Error("RegimeUniforme.Equation() : invalid variable name " + sVarCalc);
}
}
public setSection(s: acSection) {
super.setSection(s);
// had no analytical parameters before ?
this._defaultCalculatedParam = this.getFirstAnalyticalParameter();
this.resetDefaultCalculatedParam();
}
// tslint:disable-next-line:no-empty
protected setParametersCalculability() {}
protected adjustChildParameters(): void {
this.section.prms.Q.calculability = ParamCalculability.EQUATION;
this.section.prms.Y.calculability = ParamCalculability.EQUATION;
}
/**
* Calcul du débit en régime uniforme.
* @return Débit en régime uniforme
*/
private Calc_Qn(): Result {
if (this.section.prms.If.v <= 0) {
return new Result(0, this);
}
const rR: Result = this.section.CalcSection("R", this.section.prms.Y.v);
if (!rR) {
return rR;
}
717273747576777879808182
const rS: Result = this.section.CalcSection("S", this.section.prms.Y.v);
if (!rS) {
return rS;
}
const v = this.section.prms.Ks.v * Math.pow(rR.vCalc, 2 / 3) * rS.vCalc * Math.sqrt(this.section.prms.If.v);
return new Result(v, this);
}
}