UNPKG

jalhyd

Version:

JaLHyd, a Javascript Library for Hydraulics

134 lines 4.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParTypeAbstract = void 0; const internal_modules_1 = require("../internal_modules"); const internal_modules_2 = require("../internal_modules"); class ParTypeAbstract { constructor(prms) { this.prms = prms; } CalcZM() { return this.CalcZR1() + this.maxHa; } ; CalcZR1() { return this.CalcZRFromZD(this.ZD1); } addExtraResults(res, includeZmAndZr1 = true) { // hauteur d'eau dans la passe res.resultElement.values.h = this.CalcH(); // débit adimensionnel res.resultElement.values.qStar = this.CalcQStar(); // vitesse débitante res.resultElement.values.V = this.CalcVDeb(); // espacement entre les ralentisseurs res.resultElement.values.P = this.P; // if Z1 is set if (this.prms.Z1.v !== undefined && includeZmAndZr1) { // cote d'arase minimale des murs latéraux à l'amont res.resultElement.values.ZM = this.CalcZM(); // cote de radier à l'amont de la passe res.resultElement.values.ZR1 = this.CalcZR1(); } } CalcVDeb() { const aw = this.CalcAw(); // .V uses calculated value if any return this.prms.Q.V / aw; } get ZD1() { // when in ParSimulation if (this.prms instanceof internal_modules_2.ParSimulationParams) { // if ZD1 is given and not calculated, use it if (this.prms.ZD1.V !== undefined) { return this.prms.ZD1.V; } else { // else get the standard value return this.CalcZDFromZR(this.prms.ZR1.V); } } else { return this.prms.Z1.v - this.prms.ha.V; // returns undefined if Z1 (optional in Calage) is not set } } get ha() { // when in ParSimulation, do not trigger a calc loop if Z1 and ZD1 are given if (this.prms instanceof internal_modules_2.ParSimulationParams && this.prms.Z1.valueMode !== internal_modules_1.ParamValueMode.CALCUL) { return this.prms.Z1.V - this.ZD1; } else if (this.prms.ha.V !== undefined) { // when ha is a given parameter, use it return this.prms.ha.V; } else { // else calculate ha from abacuses return this.CalcHa(); } } /** returns the given input P if any, or the standard P calculated by CalcP() */ get P() { if (this.prms.P.v !== undefined) { return this.prms.P.v; } else { return this.CalcP(); } } /** minimum value of ha according to abacuses */ get minHa() { return this.CalcHa(this.minQstar); } /** maximum value of ha according to abacuses */ get maxHa() { return this.CalcHa(this.maxQstar); } /** Calculate the raw length of the pass based on water elevations */ CalcLw() { return (this.prms.Z1.V - this.prms.Z2.v) * (Math.sqrt(1 + this.prms.S.v * this.prms.S.v) / this.prms.S.v); } /** Calculate the net length of the pass based on number of baffles */ CalcLs() { return Math.ceil((this.CalcLw() - 0.001) / this.P) * this.P; } /** Calculate horizontal projection of pass length */ CalcLh() { return this.CalcLs() / Math.sqrt(1 + this.prms.S.v * this.prms.S.v); } // return y part of CalcQFromHa doCalcQYFromHa(x) { return (Math.sqrt(Math.pow(this.c1ha, 2) - 4 * this.c2ha * (this.c0ha - x)) - this.c1ha) / (2 * this.c2ha); } /** * get c0, c1 or c2 coefficient for h or ha, for the current pass type * @param hOrHa "h" or "ha" :) * @param ci "c0", "c1" or "c2" */ getCoeff(hOrHa, ci) { const a = this.coef[hOrHa][ci][0]; const b = this.coef[hOrHa][ci][1]; const c = this.coef[hOrHa][ci][2]; return a * Math.pow(this.prms.S.v, 2) + b * this.prms.S.v + c; } get c0h() { return this.getCoeff("h", "c0"); } get c1h() { return this.getCoeff("h", "c1"); } get c2h() { return this.getCoeff("h", "c2"); } get c0ha() { return this.getCoeff("ha", "c0"); } get c1ha() { return this.getCoeff("ha", "c1"); } get c2ha() { return this.getCoeff("ha", "c2"); } } exports.ParTypeAbstract = ParTypeAbstract; //# sourceMappingURL=par_type.js.map