jalhyd
Version:
JaLHyd, a Javascript Library for Hydraulics
135 lines • 5.59 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloisonAval = 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");
class CloisonAval extends internal_modules_3.ParallelStructure {
constructor(prms, dbg = false) {
super(prms, dbg);
this.setCalculatorType(internal_modules_1.CalculatorType.CloisonAval);
this._intlType = "Cloison";
}
/**
* Return index structure of vanne levante
*/
get indexVanneLevante() {
for (let i = 0; i < this.structures.length; i++) {
if (internal_modules_4.loiAdmissiblesCloisonAval.VanneLevante.includes(this.structures[i].getPropValue("loiDebit"))) {
return i;
}
}
return null;
}
get prms() {
return this._prms;
}
/**
* Returns admissible LoiDebit grouped by StructureType
* Only one vanne levante is allowed on a CloisonAval
*/
getLoisAdmissibles() {
return internal_modules_4.loiAdmissiblesCloisonAval;
}
/**
* Calcul de la cote amont de la cloison
* @param sVarCalc Nom du paramètre à calculer : seul Z1 est admis
* @param rInit Valeur initiale
*/
Calc(sVarCalc, rInit) {
if (sVarCalc !== "Z1") {
throw new Error("CloisonAval sVarCalc should be Z1");
}
if (!this.checkVanneLevante()) {
this.currentResultElement.addMessage(new internal_modules_5.Message(internal_modules_5.MessageCode.ERROR_CLOISON_AVAL_UN_OUVRAGE_REGULE));
return this.result;
}
let m;
if (this.hasVanneLevante()) {
const s = this.structures[this.indexVanneLevante];
this.prms.Z1.v = this.prms.Z2.v + s.getParameter("DH").v;
this.currentResultElement = this.CalcStructPrm(this.indexVanneLevante, "ZDV");
if (this.result.ok) {
s.prms.ZDV.v = this.result.vCalc;
}
// Check if calculated ZDV is between minZDV and maxZDV
if (this.result.vCalc < s.prms.minZDV.v) {
m = new internal_modules_5.Message(internal_modules_5.MessageCode.WARNING_VANLEV_ZDV_INF_MIN);
s.prms.ZDV.v = s.prms.minZDV.v;
}
else if (this.result.vCalc > s.prms.maxZDV.v) {
m = new internal_modules_5.Message(internal_modules_5.MessageCode.WARNING_VANLEV_ZDV_SUP_MAX);
s.prms.ZDV.v = s.prms.maxZDV.v;
}
}
if (!this.hasVanneLevante() || this.result.ok) {
// Calculation of Z1 with the new ZDV in case of existing vanne levante
this.currentResultElement = super.Calc("Z1", rInit);
if (this.result.ok) {
this.getParameter(sVarCalc).v = this.result.vCalc;
// Recalcul du débit total pour récupérer les résultats des ouvrages dans les résultats complémentaires
const resQtot = this.CalcQ();
for (const extraResKey in resQtot.extraResults) {
if (resQtot.resultElement.values.hasOwnProperty(extraResKey)) {
this.result.resultElement.addExtraResult(extraResKey, resQtot.resultElement.values[extraResKey]);
}
}
if (this.hasVanneLevante()) {
this.result.resultElement.values.ZDV = this.structures[this.indexVanneLevante].prms.ZDV.v;
if (m !== undefined) {
this.result.resultElement.addMessage(m);
}
}
}
}
// Ajout de la charge amont/aval et de l'ennoiement pour tous les ouvrages sauf les orifices
let prms;
for (const st of this.structures) {
if (!st.isOrifice) {
if (prms === undefined) {
prms = this.getParamValuesAfterCalc(sVarCalc, this.result);
}
const h1 = st.prms.h1.v;
const h2 = st.prms.h2.v;
st.result.resultElement.addExtraResult("H1", h1);
st.result.resultElement.addExtraResult("H2", h2);
st.result.resultElement.addExtraResult("SUBMERGENCE", internal_modules_1.Structure.computeSubmergencePercentage(h1, h2));
}
}
return this.result;
}
/**
* return false if there is more than one vanne levante in the cloison
*/
checkVanneLevante() {
let n = 0;
for (const st of this.structures) {
if (internal_modules_4.loiAdmissiblesCloisonAval.VanneLevante.includes(st.getPropValue("loiDebit"))) {
n += 1;
}
}
return n < 2;
}
/**
* Is there at least one Vanne Levante in the Cloison ?
*/
hasVanneLevante() {
return !(this.indexVanneLevante === null);
}
/**
* paramétrage de la calculabilité des paramètres
*/
setParametersCalculability() {
this.prms.Q.calculability = internal_modules_2.ParamCalculability.EQUATION;
this.prms.Z1.calculability = internal_modules_2.ParamCalculability.DICHO;
}
exposeResults() {
this._resultsFamilies = {
ZDV: undefined
};
}
}
exports.CloisonAval = CloisonAval;
//# sourceMappingURL=cloison_aval.js.map