Commit 090ef9e0 authored by Dorchies David's avatar Dorchies David
Browse files

nghyd#44 gestion propre des ENUM dans les extraResult

parent 4e6145c3
......@@ -85,19 +85,20 @@ describe("Class MacroRugo: ", () => {
});
it(`Calc("Q", 0.1).extraResults.P should be around 759.240352`, () => {
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.P, 759.240352, 0.03);
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.PV, 759.240352, 0.03);
});
it(`Calc("Q", 0.1).extraResults.FlowType should be MacroRugoFlowType.EMERGENT`, () => {
expect(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.FlowType).toBe(MacroRugoFlowType.EMERGENT);
expect(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.ENUM_MacroRugoFlowType)
.toBe(MacroRugoFlowType.EMERGENT);
});
it(`Calc("Q", 0.1).extraResults.Q2 should be around 0.868672`, () => {
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.Q2, 0.868672, 0.03);
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.Q_GuideTech, 0.868672, 0.03);
});
it(`Calc("Q", 0.1).extraResults.V2 should be around 1.991299`, () => {
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.V2, 1.991299, 0.03);
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.V_GuideTech, 1.991299, 0.03);
});
const nub = macroRugoInstanceEmergent();
......
......@@ -33,12 +33,12 @@ export function itCalcQ(
});
if (mode !== undefined) {
it("Q(Z1=" + Z1 + ",W=" + W + ") Mode should be " + mode, () => {
expect(res.extraResults.Mode).toBe(mode);
expect(res.extraResults.ENUM_StructureFlowMode).toBe(mode);
});
}
if (regime !== undefined) {
it("Q(Z1=" + Z1 + ",W=" + W + ") Regime should be " + regime, () => {
expect(res.extraResults.Regime).toBe(regime);
expect(res.extraResults.ENUM_StructureFlowRegime).toBe(regime);
});
}
}
......
......@@ -67,12 +67,12 @@ function itParallelStructure(sVarCalc: string, rVcalc: number, Q?: number) {
});
it(`ExtraResult[ouvrage[${i}].Q_Mode] should be 0`, () => {
expect(
pstruct.Calc(sVarCalc).resultElement.extraResults[`ouvrage[${i}].Q_Mode`]
pstruct.Calc(sVarCalc).resultElement.extraResults[`ouvrage[${i}].Q_ENUM_StructureFlowMode`]
).toEqual(0);
});
it(`ExtraResult[ouvrage[${i}].Q_Regime] should be 0`, () => {
expect(
pstruct.Calc(sVarCalc).resultElement.extraResults[`ouvrage[${i}].Q_Regime`]
pstruct.Calc(sVarCalc).resultElement.extraResults[`ouvrage[${i}].Q_ENUM_StructureFlowRegime`]
).toEqual(0);
});
}
......
......@@ -46,7 +46,7 @@ describe("Class Structure: ", () => {
});
describe("Calc()", () => {
const flagsNull = { Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL };
const flagsNull = { ENUM_StructureFlowMode: StructureFlowMode.NULL, ENUM_StructureFlowRegime: StructureFlowRegime.NULL };
it("Z1=Z2 => Q=0", () => {
structTest.prms.Z2.v = structTest.prms.Z1.v;
checkResult(structTest.Calc("Q"), 0);
......
......@@ -17,15 +17,15 @@ const structTest: StructureTriangularTruncWeirFree = new StructureTriangularTrun
describe("Class StructureTriangularTruncWeirFree: ", () => {
describe("Calcul Q a surface libre avec h1 croissant: ", () => {
const h1: number[] =
const Z1: number[] =
[100.1, 100.2, 100.3, 100.4, 100.5, 100.6, 100.7, 100.8, 100.9, 101, 101.1, 101.5, 101.8, 102];
const Q: number[] =
[0., 0.004, 0.024, 0.067, 0.138, 0.240, 0.379, 0.558, 0.778, 1.045, 1.356, 2.914, 4.346, 5.407];
const mode: StructureFlowMode = StructureFlowMode.WEIR;
const regime: StructureFlowRegime = StructureFlowRegime.FREE;
itCalcQ(structTest, h1[0], Infinity, Q[0], StructureFlowMode.NULL, StructureFlowRegime.NULL);
itCalcQ(structTest, Z1[0], Infinity, Q[0], StructureFlowMode.NULL, StructureFlowRegime.NULL);
for (let i = 1; i < Q.length; i++) {
itCalcQ(structTest, h1[i], Infinity, Q[i], mode, regime);
itCalcQ(structTest, Z1[i], Infinity, Q[i], mode, regime);
}
});
});
......@@ -49,20 +49,20 @@ describe("référence d'un paramètre à un autre : ", () => {
createEnv();
prm4.Q.defineReference(nub1, "ouvrage[0].Q_Mode");
prm4.Q.defineReference(nub1, "ouvrage[0].Q_ENUM_StructureFlowMode");
nub1.CalcSerie(0.001, 0.1, "Q");
nub2.CalcSerie(0.001, 0.1, "Q");
/*
nub1.result.resultElements[0].extraResults = {
"ouvrage[0].Q" : 6.264183905346331
"ouvrage[0].Q_Mode" : 0
"ouvrage[0].Q_Regime" : 0
"ouvrage[0].Q_ENUM_StructureFlowMode" : 0
"ouvrage[0].Q_ENUM_StructureFlowRegime" : 0
}
nub2.result.resultElements[0].extraResults = {
"ouvrage[0].Q" : 2.4110855093366834
"ouvrage[0].Q_Mode" : 0
"ouvrage[0].Q_Regime" : 0
"ouvrage[0].Q_ENUM_StructureFlowMode" : 0
"ouvrage[0].Q_ENUM_StructureFlowRegime" : 0
}
*/
......@@ -83,13 +83,13 @@ describe("référence d'un paramètre à un autre : ", () => {
/*
nub1.result.resultElements[0].extraResults = {
"ouvrage[0].Q" : 6.264183905346331
"ouvrage[0].Q_Mode" : 0
"ouvrage[0].Q_Regime" : 0
"ouvrage[0].Q_ENUM_StructureFlowMode" : 0
"ouvrage[0].Q_ENUM_StructureFlowRegime" : 0
}
nub2.result.resultElements[0].extraResults = {
"ouvrage[0].Q" : 2.4110855093366834
"ouvrage[0].Q_Mode" : 0
"ouvrage[0].Q_Regime" : 0
"ouvrage[0].Q_ENUM_StructureFlowMode" : 0
"ouvrage[0].Q_ENUM_StructureFlowRegime" : 0
}
*/
......
import { Nub } from "../nub";
import { ParamCalculability } from "../param/param-definition";
import { ParamValueMode } from "../param/param-value-mode";
import { Result } from "../util/result";
import { MacrorugoParams } from "./macrorugo_params";
import { ParamValueMode } from "../param/param-value-mode";
export { MacrorugoParams };
......@@ -75,11 +75,11 @@ export class MacroRugo extends Nub {
r.extraResults.PV = 1000 * MacroRugo.g * this.V(this.prms.Q) / this.prms.B.v * this.prms.If.v;
// Type d'écoulement
if (this.prms.Y.v / this.prms.PBH.v < 1) {
r.extraResults.FlowType = MacroRugoFlowType.EMERGENT;
r.extraResults.ENUM_MacroRugoFlowType = MacroRugoFlowType.EMERGENT;
} else if (this.prms.Y.v / this.prms.PBH.v < MacroRugo.limitSubmerg) {
r.extraResults.FlowType = MacroRugoFlowType.QUASI_EMERGENT;
r.extraResults.ENUM_MacroRugoFlowType = MacroRugoFlowType.QUASI_EMERGENT;
} else {
r.extraResults.FlowType = MacroRugoFlowType.IMMERGE;
r.extraResults.ENUM_MacroRugoFlowType = MacroRugoFlowType.IMMERGE;
}
// Vitesse et débit du guide technique
let cQ: [number, number, number, number];
......
......@@ -110,7 +110,7 @@ export abstract class Structure extends Nub {
this.prms.update_h1h2();
// Gestion du débit nul
const flagsNull = { Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL };
const flagsNull = { ENUM_StructureFlowMode: StructureFlowMode.NULL, ENUM_StructureFlowRegime: StructureFlowRegime.NULL };
if (sVarCalc === "Q") {
if (this.prms.h1.v <= 0 || this.prms.Z1.v === this.prms.Z2.v || this.prms.W.v <= 0) {
return new Result(0, flagsNull);
......@@ -166,8 +166,8 @@ export abstract class Structure extends Nub {
protected getResultData() {
return {
Mode: this.getFlowMode(),
Regime: this.getFlowRegime(),
ENUM_StructureFlowMode: this.getFlowMode(),
ENUM_StructureFlowRegime: this.getFlowRegime(),
};
}
......
......@@ -31,9 +31,9 @@ export class StructureCem88d extends RectangularStructure {
const b2: number = Math.sqrt(this.prms.h1.v - this.prms.h2.v);
const cd1: number = cd * 2.5981; // cd * 3*sqrt(3)/2
this.debug("StructureCem88d.Equation b1=" + b1 + " b2=" + b2 + " cd1=" + cd1);
switch (data.Mode) {
switch (data.ENUM_StructureFlowMode) {
case StructureFlowMode.WEIR:
switch (data.Regime) {
switch (data.ENUM_StructureFlowRegime) {
case StructureFlowRegime.FREE:
v = cd * this.prms.h1.v * b1;
break;
......@@ -45,7 +45,7 @@ export class StructureCem88d extends RectangularStructure {
break;
case StructureFlowMode.ORIFICE:
const b3: number = Math.pow(this.prms.h1.v - this.prms.W.v, 1.5);
switch (data.Regime) {
switch (data.ENUM_StructureFlowRegime) {
case StructureFlowRegime.FREE:
v = cd * (this.prms.h1.v * b1 - b3);
break;
......
......@@ -21,13 +21,13 @@ export class StructureCem88v extends RectangularStructure {
let v: number;
const mu0: number = 2 / 3 * this.prms.Cd.v;
let KF: number;
if (data.Regime !== StructureFlowRegime.FREE) {
if (data.ENUM_StructureFlowRegime !== StructureFlowRegime.FREE) {
KF = this.getKF(Math.sqrt(1 - this.prms.h2.v / this.prms.h1.v), this.getAlfa(this.prms.h2.v));
}
switch (data.Mode) {
switch (data.ENUM_StructureFlowMode) {
case StructureFlowMode.WEIR:
const muf: number = mu0 - 0.08;
switch (data.Regime) {
switch (data.ENUM_StructureFlowRegime) {
case StructureFlowRegime.FREE:
v = muf * this.prms.L.v * Structure.R2G * Math.pow(this.prms.h1.v, 1.5);
break;
......@@ -40,12 +40,12 @@ export class StructureCem88v extends RectangularStructure {
case StructureFlowMode.ORIFICE:
const mu: number = mu0 - 0.08 / (this.prms.h1.v / this.prms.W.v);
const mu1: number = mu0 - 0.08 / (this.prms.h1.v / this.prms.W.v - 1);
if (data.Regime === StructureFlowRegime.FREE) {
if (data.ENUM_StructureFlowRegime === StructureFlowRegime.FREE) {
v = this.prms.L.v * Structure.R2G
* (mu * Math.pow(this.prms.h1.v, 1.5)
- mu1 * Math.pow(this.prms.h1.v - this.prms.W.v, 1.5));
} else {
if (data.Regime === StructureFlowRegime.PARTIAL) {
if (data.ENUM_StructureFlowRegime === StructureFlowRegime.PARTIAL) {
v = this.prms.L.v * Structure.R2G * (
KF * mu * Math.pow(this.prms.h1.v, 1.5)
- mu1 * Math.pow(this.prms.h1.v - this.prms.W.v, 1.5)
......
......@@ -26,9 +26,9 @@ export class StructureCunge80 extends RectangularStructure {
const data = this.getResultData();
let v: number;
switch (data.Regime) {
switch (data.ENUM_StructureFlowRegime) {
case StructureFlowRegime.FREE:
if (data.Mode === StructureFlowMode.WEIR) {
if (data.ENUM_StructureFlowMode === StructureFlowMode.WEIR) {
const R32: number = 3 * Math.sqrt(3) / 2;
v = this.prms.Cd.v * this.prms.L.v * Structure.R2G / R32 * Math.pow(this.prms.h1.v, 1.5);
this.debug("StructureCunge80.Equation WEIR FREE Q=" + v);
......@@ -39,7 +39,7 @@ export class StructureCunge80 extends RectangularStructure {
}
break;
case StructureFlowRegime.SUBMERGED:
if (data.Mode === StructureFlowMode.WEIR) {
if (data.ENUM_StructureFlowMode === StructureFlowMode.WEIR) {
v = this.prms.Cd.v * this.prms.L.v * Structure.R2G * this.prms.h2.v
* Math.sqrt(this.prms.h1.v - this.prms.h2.v);
this.debug("StructureCunge80.Equation WEIR SUBMERGED Q=" + v);
......
......@@ -45,7 +45,7 @@ export class StructureKivi extends Structure {
let Q = cd * this.prms.L.v * Structure.R2G * Math.pow(this.prms.h1.v, 1.5);
if (res.extraResults.Regime === StructureFlowRegime.SUBMERGED) {
if (res.extraResults.ENUM_StructureFlowRegime === StructureFlowRegime.SUBMERGED) {
Q = Villemonte(this.prms.h1.v, this.prms.h2.v, 1.5) * Q;
}
......
......@@ -2,7 +2,7 @@
*
* @param h1 hauteur d'eau amont au dessus de la crête du seuil
* @param h2 hauteur d'eau aval au dessus de la crête du seuil
* @param n n est l’exposant dans les relations d’écoulement dénoyé :
* @param n n est l'exposant dans les relations d'écoulement dénoyé :
* déversoir proportionnel : n=1 déversoir rectangulaire : n=1,5
* déversoir parabolique : n=2 déversoir triangulaire : n=2,5
*/
......
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