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

feat(macrorugo): warning pour concentration hors 8-20%

Refs #284
parent 11e9bdaa
import { CalculatorType } from "../../src/compute-node";
import { MacrorugoCompound, MessageCode } from "../../src/index";
import { MRCInclination } from "../../src/macrorugo/mrc-inclination";
import { Props } from "../../src/props";
import { Session } from "../../src/session";
let nub: MacrorugoCompound;
describe("MacroRugoCompound: ", () => {
beforeEach(() => {
nub = Session.getInstance().createNub(
new Props({ calcType: CalculatorType.MacroRugoCompound })
) as MacrorugoCompound;
nub.properties.setPropValue("inclinedApron", MRCInclination.INCLINED);
});
describe("jalhyd #284 warnings about block concentration − ", () => {
it("case 1: no warnings", () => {
nub.prms.BR.singleValue = 3.328;
const res = nub.CalcSerie();
expect(res.log.messages.length).toBe(0);
// children should not have any width-related warning
for (const c of nub.children) {
for (const re of c.result.resultElements) {
for (const m of re.log.messages) {
expect(m.code).not.toBe(MessageCode.WARNING_MACRORUGO_CONCENTRATION_OUT_OF_BOUNDS);
}
}
}
});
it("case 2: block concentration is out of bounds", () => {
nub.prms.BR.singleValue = 3.024;
nub.prms.C.singleValue = 0.07;
const res = nub.CalcSerie();
expect(res.log.messages.length).toBe(1);
expect(res.log.messages[0].code).toBe(MessageCode.WARNING_MACRORUGO_CONCENTRATION_OUT_OF_BOUNDS);
// children should not have any width-related warning
for (const c of nub.children) {
for (const re of c.result.resultElements) {
for (const m of re.log.messages) {
expect(m.code).not.toBe(MessageCode.WARNING_MACRORUGO_CONCENTRATION_OUT_OF_BOUNDS);
}
}
}
});
});
});
import { CalculatorType } from "../../src/compute-node";
import { MessageCode } from "../../src/index";
import { MacroRugo } from "../../src/macrorugo/macrorugo";
import { Props } from "../../src/props";
import { Session } from "../../src/session";
let nub: MacroRugo;
describe("Class MacroRugo: ", () => {
describe("jalhyd #284 warnings about block concentration - ", () => {
it("case 1: no warnings", () => {
nub = Session.getInstance().createNub(new Props({ calcType: CalculatorType.MacroRugo })) as MacroRugo;
nub.prms.B.singleValue = 1.109;
const res = nub.CalcSerie();
expect(res.log.messages.length).toBe(0);
});
it("case 2: concentration out of bounds", () => {
nub = Session.getInstance().createNub(new Props({ calcType: CalculatorType.MacroRugo })) as MacroRugo;
nub.prms.C.singleValue = 0.07;
nub.prms.B.singleValue = 3.024;
const res = nub.CalcSerie();
expect(res.log.messages.length).toBe(1);
expect(res.log.messages[0].code).toBe(MessageCode.WARNING_MACRORUGO_CONCENTRATION_OUT_OF_BOUNDS);
});
});
});
......@@ -90,6 +90,15 @@ export class MacroRugo extends FishPass {
}
}
// La concentration est-elle dans les valeurs admissibles 8-20% (#284)
if (this.parent === undefined) {
if(this.prms.C.V < 0.08 || this.prms.C.V > 0.2) {
r.resultElement.log.add(
new Message(MessageCode.WARNING_MACRORUGO_CONCENTRATION_OUT_OF_BOUNDS)
);
}
}
// Ajout des résultats complémentaires
// Cote de fond aval
r.resultElement.values.ZF2 = this.prms.ZF1.v - this.prms.If.v * this.prms.L.v;
......
......@@ -112,6 +112,12 @@ export class MacrorugoCompound extends MacroRugo implements Observer {
this._result.resultElement.log.add(m);
}
}
// Check block concentration bounds
if(this.prms.C.v < 0.08 || this.prms.C.v > 0.2) {
this._result.resultElement.log.add(
new Message(MessageCode.WARNING_MACRORUGO_CONCENTRATION_OUT_OF_BOUNDS)
);
}
return this._result;
}
......
......@@ -563,6 +563,9 @@ export enum MessageCode {
/** Macrorugo : la largeur de la rampe devrait être un multiple de la demie-largeur d'un motif de plot */
WARNING_RAMP_WIDTH_NOT_MULTIPLE_OF_HALF_PATTERN_WIDTH,
//** MacroRugo : concentration des blocs hors 8-20% */
WARNING_MACRORUGO_CONCENTRATION_OUT_OF_BOUNDS,
/** section : le tirant d'eau dépasse la hauteur de berge */
WARNING_SECTION_OVERFLOW,
......
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