Commit 33b05127 authored by Dorchies David's avatar Dorchies David
Browse files

fix: tests on broad triangular weir structure

- add getBoundedValue fonction du ParamDomain for getting correct initial value for tests

Fix #211
parent 2c2899c3
......@@ -101,7 +101,7 @@ function testStructureLoopPrm(
});
} else {
it(`should return prm.currentValue`, () => {
checkResult(st.CalcSerie(prm.singleValue + 100), prm.currentValue);
checkResult(st.CalcSerie(prm.domain.getBoundedValue(prm.singleValue + 100)), prm.currentValue);
});
}
}
......
import { StructureTriangularWeirBroad } from "../../src/structure/structure_triangular_weir_broad";
import { CreateStructure } from "../../src/structure/factory_structure";
import { LoiDebit } from "../../src/index";
import { LoiDebit } from "../../src/structure/structure_props";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { testStructure } from "./functions";
describe("Class StructureTriangularWeirBroad: ", () => {
it("Q free flow should be similar to Q limit submergence", () => {
......@@ -17,4 +17,9 @@ describe("Class StructureTriangularWeirBroad: ", () => {
st.prms.Z2.singleValue = st.prms.Z1.singleValue - 0.001;
expect(st.CalcSerie().vCalc).toBeCloseTo(0, 1E-3);
})
describe("Free flow:", () => {
const st = CreateStructure(LoiDebit.TriangularWeirBroad);
st.prms.Q.singleValue = st.CalcSerie().vCalc; // Initialisation of Q with exact answer
testStructure(st, StructureFlowMode.WEIR, StructureFlowRegime.FREE)
})
});
\ No newline at end of file
......@@ -105,6 +105,14 @@ export class ParamDomain {
}
}
/**
* Return a value bounded by the definition domain
* @param v the value to be bounded
*/
public getBoundedValue(v: number): number {
return Math.min(Math.max(v, this.minValue), this.maxValue);
}
private checkValue(val: number, min: number, max: number) {
switch (val) {
case ParamDomainValue.INTERVAL:
......
......@@ -24,7 +24,7 @@ export class StructureTriangularWeirBroad extends StructureTriangularWeirFree {
const r = super.CalcQ();
if (r.values.ENUM_StructureFlowRegime !== StructureFlowRegime.FREE) {
if (this.prms.h1.v > 0 && r.values.ENUM_StructureFlowRegime !== StructureFlowRegime.FREE) {
r.vCalc = r.vCalc * Math.sin(3.962902 * Math.pow((1 - this.prms.h2.v / this.prms.h1.v), 0.574979))
}
......
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