UNPKG

jalhyd

Version:

JaLHyd, a Javascript Library for Hydraulics

145 lines 5.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConcentrationBlocs = 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"); class ConcentrationBlocs extends internal_modules_3.Nub { constructor(prms, dbg = false) { super(prms, dbg); this.setCalculatorType(internal_modules_2.CalculatorType.ConcentrationBlocs); this._defaultCalculatedParam = prms.C; this.resetDefaultCalculatedParam(); } get prms() { return this._prms; } /** * L / N = ax = D / sqrt(C) */ Equation(sVarCalc) { let rounded = false; if (sVarCalc !== "N" && !Number.isInteger(this.prms.N.v)) { this.prms.N.v = Math.round(this.prms.N.v); rounded = true; } let v; let ax; // pattern size let R; // rest let NB; let axB; let cB; let NH; let axH; let cH; switch (sVarCalc) { case "C": ax = this.prms.L.v / this.prms.N.v; v = Math.pow(this.prms.D.v / ax, 2); break; case "N": ax = this.prms.D.v / Math.sqrt(this.prms.C.v); const divAndMod = (0, internal_modules_1.floatDivAndMod)(this.prms.L.v, ax); v = divAndMod.q; R = divAndMod.r; // parfois la largeur résiduelle peut être à peine en dessous de la largeur de motif (modulo foireux) if ((0, internal_modules_1.isEqual)(R, ax, 1e-2)) { R -= ax; v++; } // harmonisation ? if (!(0, internal_modules_1.isEqual)(R, 0, 1e-2)) { // vers le bas if (v > 0) { NB = v; axB = this.prms.L.v / NB; cB = Math.pow(this.prms.D.v / axB, 2); } // vers le haut NH = v + 1; axH = this.prms.L.v / NH; cH = Math.pow(this.prms.D.v / axH, 2); } break; case "L": ax = this.prms.D.v / Math.sqrt(this.prms.C.v); v = ax * this.prms.N.v; break; case "D": ax = this.prms.L.v / this.prms.N.v; v = ax * Math.sqrt(this.prms.C.v); break; default: throw new Error("ConcentrationBlocs.Equation() : invalid variable name " + sVarCalc); } const r = new internal_modules_6.Result(v, this); // extra results r.resultElement.values.ax = ax; if (R !== undefined) { r.resultElement.values.R = R; } if (NB !== undefined) { r.resultElement.values.NB = NB; } if (axB !== undefined) { r.resultElement.values.AXB = axB; } if (cB !== undefined) { r.resultElement.values.CB = cB; } if (NH !== undefined) { r.resultElement.values.NH = NH; } if (axH !== undefined) { r.resultElement.values.AXH = axH; } if (cH !== undefined) { r.resultElement.values.CH = cH; } if (rounded) { const m = new internal_modules_5.Message(internal_modules_5.MessageCode.WARNING_VALUE_ROUNDED_TO_INTEGER); m.extraVar.symbol = "N"; m.extraVar.rounded = this.prms.N.v; r.resultElement.log.add(m); } return r; } /** * paramétrage de la calculabilité des paramètres */ setParametersCalculability() { this.prms.C.calculability = internal_modules_4.ParamCalculability.EQUATION; this.prms.N.calculability = internal_modules_4.ParamCalculability.EQUATION; this.prms.L.calculability = internal_modules_4.ParamCalculability.EQUATION; this.prms.D.calculability = internal_modules_4.ParamCalculability.EQUATION; } static resultsUnits() { return ConcentrationBlocs._resultsUnits; } exposeResults() { this._resultsFamilies = { ax: undefined, R: undefined, NB: undefined, AXB: undefined, CB: undefined, NH: undefined, AXH: undefined, CH: undefined }; } } exports.ConcentrationBlocs = ConcentrationBlocs; /** * { symbol => string } map that defines units for extra results */ ConcentrationBlocs._resultsUnits = { ax: "m", R: "m", AXB: "m", AXH: "m" }; //# sourceMappingURL=concentration_blocs.js.map