Failed to fetch fork details. Try again later.
-
Delaigue Olivier authored87487b78
Forked from
HYCAR-Hydro / airGR
Source project has a limited visibility.
import { ChildNub } from "../child_nub";
import { CalculatorType } from "../compute-node";
import { ParamCalculability, ParamDefinition, ParamFamily } from "../param/param-definition";
import { Props } from "../props";
import { Message, MessageCode } from "../util/message";
import { Result } from "../util/result";
import { StructureParams } from "./structure_params";
import { LoiDebit } from "./structure_props";
/**
* Flow mode: weir or orifice flow
*/
export enum StructureFlowMode {
/** Weir flow */
WEIR,
/** Orifice flow */
ORIFICE,
/** Zéro flow */
NULL
}
/**
* Flow regime: free flow, partially submerged or submerged
*/
export enum StructureFlowRegime {
/** Free flow (unsubmerged) */
FREE,
/** Partially submerged flow */
PARTIAL,
/** Submerged flow */
SUBMERGED,
/** Zéro flow */
NULL
}
/** Type de jet : Sans objet (orifice), plongeant, de surface */
export enum StructureJetType {
/** Plongeant */
PLONGEANT,
/** De surface */
SURFACE,
/** Sans objet (orifice) */
SO
}
/**
* classe de calcul sur la conduite distributrice
*/
export abstract class Structure extends ChildNub {
/**
* Test générique si VarCalc="Q" pour l'utilisation de Equation
*/
public static CheckEquation(sVarCalc: string) {
if (sVarCalc !== "Q") { throw new Error("Structure.Equation() : invalid parameter name " + sVarCalc); }
}
/** Constante utile : Racine de 2g */
protected static readonly R2G: number = Math.sqrt(2 * 9.81);
/** Peut-on calculer ZDV ? */
protected _isZDVcalculable: boolean;
protected _loiDebit: LoiDebit;
constructor(prms: StructureParams, dbg: boolean = false) {
super(prms, dbg);
this._calcType = CalculatorType.Structure;
this._isZDVcalculable = true;
// Q is always the only calculated variable; setting another parameter
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
// of a Structure to CALC mode makes it the calculated variable of the
// *parent* ParallelStructures
this.calculatedParam = this.prms.Q;
}
/** Returns Props object (observable set of key-values) associated to this Nub */
public get properties(): Props {
// completes props with calcType and loiDebit if not already set
this._props.setPropValue("calcType", this.calcType);
if (this._props.getPropValue("loiDebit") === undefined) {
this._props.setPropValue("loiDebit", this._loiDebit);
}
return this._props;
}
// setter is not inherited from Nub if getter is redefined :/
public set properties(props: Props) {
super.setProperties(props);
}
public get isZDVcalculable(): boolean {
return this._isZDVcalculable;
}
/**
* paramètres castés au bon type
*/
public get prms(): StructureParams {
return this._prms as StructureParams;
}
public get W(): number {
if (this.prms.W.visible) {
return this.prms.W.v;
} else {
return Infinity;
}
}
public get loiDebit(): LoiDebit {
return this._loiDebit;
}
/**
* Returns the nth visible parameter (used in nghyd/PabTable)
*/
public getNthVisibleParam(n: number): ParamDefinition {
let i = 0;
for (const p of this.parameterIterator) {
if (p.visible) {
if (n === i) {
return p;
}
i++;
}
}
return undefined;
}
/**
* Calcul d'une équation quelle que soit l'inconnue à calculer.
* Gestion du débit nul et de l'inversion de débit
* @param sVarCalc nom de la variable à calculer
* @param rInit valeur initiale de la variable à calculer dans le cas de la dichotomie
*/
public Calc(sVarCalc: string, rInit?: number): Result {
// Gestion de l'exception de calcul de W sur les seuils
if (rInit === undefined) {
rInit = this.getParameter(sVarCalc).v;
}