jalhyd
Version:
JaLHyd, a Javascript Library for Hydraulics
243 lines • 9.35 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SectionParametree = 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");
/**
* Nub sur les sections paramétrées
*/
class SectionParametree extends internal_modules_5.SectionNub {
constructor(s, dbg = false) {
super(new internal_modules_6.SectionParams(), dbg);
this.setCalculatorType(internal_modules_1.CalculatorType.SectionParametree);
this.setSection(s);
this.initSectionVars();
// no calculated parameter
this._defaultCalculatedParam = undefined;
}
setSection(s) {
super.setSection(s);
this.setParametersCalculability(); // to override acSection's tuning
}
getFirstAnalyticalParameter() {
const res = super.getFirstAnalyticalParameter();
if (res) {
return res;
}
// tslint:disable-next-line:forin
for (const k in this._sectionVars) {
const p = this._sectionVars[k];
if (p.isAnalytical) {
return p;
}
}
return undefined;
}
Equation(sVarCalc) {
let r;
switch (sVarCalc) {
case "Hs":
case "Hsc":
case "B":
case "P":
case "S":
case "R":
case "V":
case "Fr":
case "Yc":
case "Yn":
case "Ycor":
case "Ycon":
case "J":
case "Imp":
case "Tau0":
case "I-J":
r = this.section.CalcSection(sVarCalc, this.getParameter("Y").v);
break;
default:
throw new Error(`SectionParam.Equation() : calcul sur ${sVarCalc} non implémenté`);
}
return r;
}
/**
* Aucune variable à calculer plus que les autres, on stocke toutes les
* valeurs des variables à calcul dans les résultats complémentaires
*/
Calc() {
// tirant d'eau original (doit être fourni à acSection.Calc() sous peine d'être modifié
// par les appels successifs car c'est en même temps un paramètre et une variable temporaire)
const Y = this.getParameter("Y").v;
if (!this.result) {
this.initNewResultElement();
}
// charge spécifique
this.addExtraResultFromVar("Hs", Y);
// charge critique
this.addExtraResultFromVar("Hsc", Y);
// largeur au miroir
this.addExtraResultFromVar("B", Y);
// périmètre hydraulique
this.addExtraResultFromVar("P", Y);
// surface hydraulique
this.addExtraResultFromVar("S", Y);
// rayon hydraulique
this.addExtraResultFromVar("R", Y);
// vitesse moyenne
this.addExtraResultFromVar("V", Y);
// nombre de Froude
this.addExtraResultFromVar("Fr", Y);
// tirant d'eau critique
this.addExtraResultFromVar("Yc", Y);
// tirant d'eau normal
this.addExtraResultFromVar("Yn", Y);
// tirant d'eau correspondant
this.addExtraResultFromVar("Ycor", Y);
// tirant d'eau conjugué
this.addExtraResultFromVar("Ycon", Y);
// perte de charge
this.addExtraResultFromVar("J", Y);
// Variation linéaire de l'énergie spécifique
this.addExtraResultFromVar("I-J", Y);
// impulsion hydraulique
this.addExtraResultFromVar("Imp", Y);
// contrainte de cisaillement / force tractrice
this.addExtraResultFromVar("Tau0", Y);
// Est-ce que ça déborde ?
if (this.section.prms.Y.v > this.section.prms.YB.v) {
this.result.resultElement.log.add(new internal_modules_4.Message(internal_modules_4.MessageCode.WARNING_SECTION_OVERFLOW));
}
return this.result;
}
// there is no calculated param
findCalculatedParameter() {
return undefined;
}
// calculated param is always "Y"
doCalc(computedSymbol, rInit) {
return this.Calc();
}
// tslint:disable-next-line:no-empty
setParametersCalculability() {
if (this.section) {
this.section.prms.Ks.calculability = internal_modules_2.ParamCalculability.FREE;
this.section.prms.Q.calculability = internal_modules_2.ParamCalculability.FREE;
this.section.prms.If.calculability = internal_modules_2.ParamCalculability.FREE;
this.section.prms.YB.calculability = internal_modules_2.ParamCalculability.FREE;
this.section.prms.Y.calculability = internal_modules_2.ParamCalculability.FREE;
this.section.prms.LargeurBerge.calculability = internal_modules_2.ParamCalculability.FREE;
// parameters depending on section type
const D = this.section.getParameter("D");
if (D) {
D.calculability = internal_modules_2.ParamCalculability.FREE;
}
const k = this.section.getParameter("k");
if (k) {
k.calculability = internal_modules_2.ParamCalculability.FREE;
}
const fruit = this.section.getParameter("Fruit");
if (fruit) {
fruit.calculability = internal_modules_2.ParamCalculability.FREE;
}
const largeurFond = this.section.getParameter("LargeurFond");
if (largeurFond) {
largeurFond.calculability = internal_modules_2.ParamCalculability.FREE;
}
}
}
// tslint:disable-next-line:no-empty
adjustChildParameters() { }
exposeResults() {
this._resultsFamilies = {
B: internal_modules_2.ParamFamily.WIDTHS,
Yc: internal_modules_2.ParamFamily.HEIGHTS,
Yn: internal_modules_2.ParamFamily.HEIGHTS,
Ycor: internal_modules_2.ParamFamily.HEIGHTS,
Ycon: internal_modules_2.ParamFamily.HEIGHTS
};
}
initSectionVars() {
this.initSectionVar("Hs");
this.initSectionVar("Hsc");
this.initSectionVar("B");
this.initSectionVar("P");
this.initSectionVar("S");
this.initSectionVar("R");
this.initSectionVar("V");
this.initSectionVar("Fr");
this.initSectionVar("Yc");
this.initSectionVar("Yn");
this.initSectionVar("Ycor");
this.initSectionVar("Ycon");
this.initSectionVar("J");
this.initSectionVar("Imp");
this.initSectionVar("Tau0");
this.initSectionVar("I-J");
}
initSectionVar(symbol) {
this._sectionVars[symbol] = this.createSectionVar(symbol);
}
createSectionVar(symbol) {
let dom;
let unit;
switch (symbol) {
case "Hs":
case "Hsc":
case "B":
case "P":
case "R":
case "Yc":
case "Yn":
case "Ycor":
case "Ycon":
case "J":
case "Imp":
dom = new internal_modules_3.ParamDomain(internal_modules_3.ParamDomainValue.POS_NULL);
unit = "m";
break;
case "Tau0": // force tractrice
dom = new internal_modules_3.ParamDomain(internal_modules_3.ParamDomainValue.POS_NULL);
unit = "Pa";
break;
case "V": // vitesse moyenne
dom = new internal_modules_3.ParamDomain(internal_modules_3.ParamDomainValue.POS_NULL);
unit = "m/s";
break;
case "S": // surface
dom = new internal_modules_3.ParamDomain(internal_modules_3.ParamDomainValue.POS_NULL);
unit = "m²";
break;
case "Fr": // Froude
dom = new internal_modules_3.ParamDomain(internal_modules_3.ParamDomainValue.POS_NULL);
break;
case "I-J": // var. lin. énergie spécifique
unit = "m/m";
dom = new internal_modules_3.ParamDomain(internal_modules_3.ParamDomainValue.ANY);
break;
default:
throw new Error(`SectionParametree.createSectionVar() : symbole ${symbol} non pris en charge`);
}
const pe = new internal_modules_6.SectionParams(this);
const res = new internal_modules_2.ParamDefinition(pe, symbol, dom, unit);
res.calculability = internal_modules_2.ParamCalculability.EQUATION;
return res;
}
/**
* Calculates varCalc from Y, and sets the result as an
* extraResult of the given ResultElement
*/
addExtraResultFromVar(varCalc, Y) {
const r = this.section.CalcSection(varCalc, Y);
if (r.ok) {
this.result.resultElement.addExtraResult(varCalc, r.vCalc);
}
else {
this.result.resultElement.log.addLog(r.log);
}
}
}
exports.SectionParametree = SectionParametree;
//# sourceMappingURL=section_parametree.js.map