jalhyd
Version:
JaLHyd, a Javascript Library for Hydraulics
115 lines • 4.63 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RegimeUniforme = void 0;
const internal_modules_1 = require("../internal_modules");
const internal_modules_2 = require("../internal_modules");
const internal_modules_3 = require("../internal_modules");
const internal_modules_4 = require("../internal_modules");
const internal_modules_5 = require("../internal_modules");
const internal_modules_6 = require("../internal_modules");
const internal_modules_7 = require("../internal_modules");
const internal_modules_8 = require("../internal_modules");
class RegimeUniforme extends internal_modules_5.SectionNub {
constructor(s, dbg = false) {
super(new internal_modules_6.SectionParams(), dbg);
this.setCalculatorType(internal_modules_1.CalculatorType.RegimeUniforme);
this.setSection(s);
}
/**
* paramètres castés au bon type
*/
get prms() {
return this._prms;
}
Equation(sVarCalc) {
this.debug("RU: Equation(" + sVarCalc + ")");
let r;
if (typeof sVarCalc !== "string") {
// dirty hack because calculated param descriptor for section params is an object { uid: , symbol: }
sVarCalc = sVarCalc.symbol;
}
switch (sVarCalc) {
case "Y":
r = this.section.CalcSection("Yn");
break;
case "Q":
r = this.Calc_Qn();
break;
default:
throw new Error("RegimeUniforme.Equation() : invalid variable name " + sVarCalc);
}
return r;
}
/**
* Calcul d'une équation quelle que soit l'inconnue à calculer; déclenche le calcul en
* chaîne des modules en amont si nécessaire
* @param sVarCalc nom de la variable à calculer
* @param rInit valeur initiale de la variable à calculer dans le cas de la dichotomie
*/
Calc(sVarCalc, rInit) {
const r = super.Calc(sVarCalc, rInit);
// Vitesse moyenne
const V = this.section.CalcSection("V", this.section.prms.Y.v);
r.resultElement.values.V = V.vCalc;
// Est-ce que ça déborde ?
if (this.section.prms.Y.v > this.section.prms.YB.v) {
r.resultElement.log.add(new internal_modules_3.Message(internal_modules_3.MessageCode.WARNING_SECTION_OVERFLOW));
}
// Est-ce qu'on est en charge sur une section circulaire ? @see #214
if (this.section instanceof internal_modules_7.cSnCirc
&& this.section.prms.YB.v >= this.section.prms.D.v
&& (0, internal_modules_8.isGreaterThan)(this.section.prms.Y.v, this.section.prms.D.v, 1e-3)) {
this.currentResultElement = new internal_modules_4.Result(new internal_modules_3.Message(internal_modules_3.MessageCode.ERROR_RU_CIRC_LEVEL_TOO_HIGH));
return this.result;
}
return r;
}
setSection(s) {
super.setSection(s);
// had no analytical parameters before ?
this._defaultCalculatedParam = this.getFirstAnalyticalParameter();
this.resetDefaultCalculatedParam();
}
// tslint:disable-next-line:no-empty
setParametersCalculability() { }
adjustChildParameters() {
this.section.prms.Q.calculability = internal_modules_2.ParamCalculability.EQUATION;
this.section.prms.Y.calculability = internal_modules_2.ParamCalculability.EQUATION;
this.section.prms.YB.calculability = internal_modules_2.ParamCalculability.FREE;
}
static resultsUnits() {
return RegimeUniforme._resultsUnits;
}
exposeResults() {
this._resultsFamilies = {
V: internal_modules_2.ParamFamily.SPEEDS
};
}
/**
* Calcul du débit en régime uniforme.
* @return Débit en régime uniforme
*/
Calc_Qn() {
if (this.section.prms.If.v <= 0) {
return new internal_modules_4.Result(0, this);
}
const rR = this.section.CalcSection("R", this.section.prms.Y.v);
if (!rR) {
return rR;
}
const rS = this.section.CalcSection("S", this.section.prms.Y.v);
if (!rS) {
return rS;
}
this.section.prms.Q.v = this.section.prms.Ks.v * Math.pow(rR.vCalc, 2 / 3) * rS.vCalc * Math.sqrt(this.section.prms.If.v);
return new internal_modules_4.Result(this.section.prms.Q.v, this);
}
}
exports.RegimeUniforme = RegimeUniforme;
/**
* { symbol => string } map that defines units for extra results
*/
RegimeUniforme._resultsUnits = {
V: "m/s"
};
//# sourceMappingURL=regime_uniforme.js.map