Commit ed9d2230 authored by Dorchies David's avatar Dorchies David
Browse files

refactor: split structure triangular weir classes

For splitting discharge law from submergence law.

Refs #211
parent 03f8cf9e
import { ParamCalculability } from "../param/param-definition";
import { Result } from "../util/result";
import { Structure, StructureFlowMode, StructureFlowRegime } from "./structure";
import { StructureFlowMode, StructureFlowRegime } from "./structure";
import { LoiDebit } from "./structure_props";
import { TriangularStructureParams } from "./structure_triangular_weir_params";
import { Villemonte } from "./villemonte";
import { StructureTriangularWeirFree } from "./structure_triangular_weir_free";
/**
* Equation classique seuil triangulaire + Ennoiement Villemonte
*/
export class StructureTriangularWeir extends Structure {
export class StructureTriangularWeir extends StructureTriangularWeirFree {
constructor(prms: TriangularStructureParams, dbg: boolean = false) {
super(prms, dbg);
this._loiDebit = LoiDebit.TriangularWeirFree;
}
/**
* paramètres castés au bon type
*/
get prms(): TriangularStructureParams {
return this._prms as TriangularStructureParams;
this._loiDebit = LoiDebit.TriangularWeirFree; // First name of the law for backward compatibility
}
/**
......@@ -27,16 +21,14 @@ export class StructureTriangularWeir extends Structure {
* @param sVarCalc Variable à calculer (doit être "Q")
*/
public CalcQ(): Result {
const data = this.getResultData();
let Q = this.prms.CdT.v * this.getTanFromDegrees(this.prms.alpha2.v)
* Math.pow(this.prms.h1.v, 2.5);
const r = super.CalcQ();
if (data.ENUM_StructureFlowRegime !== StructureFlowRegime.FREE) {
Q = Villemonte(this.prms.h1.v, this.prms.h2.v, 2.5) * Q;
if (r.values.ENUM_StructureFlowRegime !== StructureFlowRegime.FREE) {
r.vCalc = Villemonte(this.prms.h1.v, this.prms.h2.v, 2.5) * r.vCalc;
}
return new Result(Q, this, data);
return r;
}
protected getFlowRegime() {
......@@ -51,25 +43,4 @@ export class StructureTriangularWeir extends Structure {
return StructureFlowRegime.SUBMERGED;
}
}
protected getFlowMode() {
return StructureFlowMode.WEIR;
}
/**
* Compute Tangent with angle in degrees
* @param degrees Angle (degrees)
*/
protected getTanFromDegrees(degrees: number) {
return Math.tan(degrees * Math.PI / 180);
}
/**
* paramétrage de la calculabilité des paramètres
*/
protected setParametersCalculability() {
super.setParametersCalculability();
this.prms.alpha2.calculability = ParamCalculability.DICHO;
this.prms.CdT.calculability = ParamCalculability.DICHO;
}
}
import { ParamCalculability } from "../param/param-definition";
import { Result } from "../util/result";
import { Structure, StructureFlowMode } from "./structure";
import { TriangularStructureParams } from "./structure_triangular_weir_params";
/**
* Equation classique seuil triangulaire + Ennoiement Villemonte
*/
export class StructureTriangularWeirFree extends Structure {
constructor(prms: TriangularStructureParams, dbg: boolean = false) {
super(prms, dbg);
}
/**
* paramètres castés au bon type
*/
get prms(): TriangularStructureParams {
return this._prms as TriangularStructureParams;
}
/**
* Calcul analytique Q = f(Cd, L, h1, h2, W)
* @param sVarCalc Variable à calculer (doit être "Q")
*/
public CalcQ(): Result {
const data = this.getResultData();
const Q = this.prms.CdT.v * this.getTanFromDegrees(this.prms.alpha2.v)
* Math.pow(this.prms.h1.v, 2.5);
return new Result(Q, this, data);
}
protected getFlowMode() {
return StructureFlowMode.WEIR;
}
/**
* Compute Tangent with angle in degrees
* @param degrees Angle (degrees)
*/
protected getTanFromDegrees(degrees: number) {
return Math.tan(degrees * Math.PI / 180);
}
/**
* paramétrage de la calculabilité des paramètres
*/
protected setParametersCalculability() {
super.setParametersCalculability();
this.prms.alpha2.calculability = ParamCalculability.DICHO;
this.prms.CdT.calculability = ParamCalculability.DICHO;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment