UNPKG

jalhyd

Version:

JaLHyd, a Javascript Library for Hydraulics

126 lines 4.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PressureLoss = void 0; const internal_modules_1 = require("../internal_modules"); const internal_modules_2 = require("../internal_modules"); class PressureLoss extends internal_modules_1.Nub { constructor(prms, law, dbg = false) { super(prms, dbg); this.setCalculatorType(internal_modules_2.CalculatorType.PressureLoss); this.calculatedParam = prms.J; this.setLaw(law); } /** * paramètres castés au bon type */ get prms() { return this._prms; } get child() { return this._children[0]; } getParameter(name) { if (typeof name !== "string") { // dirty hack because calculated param descriptor for section params is an object { uid: , symbol: } name = name.symbol; } return super.getParameter(name); // includes child parameters } /** * Set/replaces the current section */ setLaw(pll) { if (pll) { // prevent index out of bounds at first time if (this._children.length === 0) { this._children[0] = undefined; } this.replaceChild(0, pll); this._props.removeProp("pressureLossType"); // because this property belongs to child pressure loss law and is set as long as law is not defined this._props.removeProp("material"); // because this property belongs to child Lechapt-Calmon law and is set as long as law is not defined /** * Y linkability managed in child classes through 'visible' flag * @see Bief,CourbeRemous */ } } /** * paramétrage de la calculabilité des paramètres */ setParametersCalculability() { this.prms.Q.calculability = internal_modules_1.ParamCalculability.DICHO; this.prms.D.calculability = internal_modules_1.ParamCalculability.DICHO; this.prms.J.calculability = internal_modules_1.ParamCalculability.EQUATION; this.prms.Lg.calculability = internal_modules_1.ParamCalculability.DICHO; this.prms.Kloc.calculability = internal_modules_1.ParamCalculability.DICHO; } Calc(sVarCalc, rInit) { if (typeof sVarCalc !== "string") { // sVarCalc may be a calculated parameter descriptor (cf. Nub.calculatedParamDescriptor) if (sVarCalc.uid !== this.uid && sVarCalc.uid !== this.child.uid) { throw new Error("invalid nub"); } sVarCalc = sVarCalc.symbol; } const r = super.Calc(sVarCalc, rInit); const V2 = Math.pow(r.values.V, 2); const Jlin = this.child.result.values.Jlin; r.values.Klin = 19.62 * Jlin / V2; r.values.fD = this.prms.J.V / this.prms.Lg.V / V2 * 19.62 * this.prms.D.V; this.child.finalChecks(r); return r; } Equation(sVarCalc) { if (sVarCalc !== "J") { throw new Error("PressureLoss.Equation() : invalid variable name " + sVarCalc); } if (this._result === undefined) { this.initNewResultElement(); } const r = this._result; // vitesse r.values.V = this.prms.Q.v / (Math.PI * Math.pow(this.prms.D.v / 2, 2)); // perte de charge linéaire propre à chaque module const rc = this.child.Equation("Jlin"); if (!rc.ok) { r.addLog(rc.log); return r; } // perte de charge totale (J) r.vCalc = rc.values.Jlin + this.prms.Kloc.v / 19.62 * Math.pow(r.values.V, 2); return r; } get result() { return this._result; // redéfini (à l'identique) car on a redéfini le setter (et un setter seul fait que le getter n'est pas hérité) } set result(r) { throw new Error("PressureLoss.set result() called!"); } static resultsUnits() { return PressureLoss._resultsUnits; } // interface IProperties getPropValue(key) { if (this.childHasProperty(key)) { return this.child.getPropValue(key); } return this._props.getPropValue(key); } setPropValue(key, val, sender) { if (this.childHasProperty(key)) { return this.child.setPropValue(key, val, sender); } return this._props.setPropValue(key, val, sender); } } exports.PressureLoss = PressureLoss; /** * { symbol => string } map that defines units for extra results */ PressureLoss._resultsUnits = { Q: "m³/s", D: "m", J: "m/m", Lg: "m" }; //# sourceMappingURL=pressureloss.js.map