diff --git a/spec/macrorugo/macrorugo_compound_jalhyd284.spec.ts b/spec/macrorugo/macrorugo_compound_jalhyd284.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c6fe7ef7b09779df031972bb911abda0c58da9e --- /dev/null +++ b/spec/macrorugo/macrorugo_compound_jalhyd284.spec.ts @@ -0,0 +1,47 @@ +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); + } + } + } + }); + }); +}); diff --git a/spec/macrorugo/macrorugo_jalhyd284.spec.ts b/spec/macrorugo/macrorugo_jalhyd284.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..e887a327bae1e53e355e07039ca1b3f8e3bd3052 --- /dev/null +++ b/spec/macrorugo/macrorugo_jalhyd284.spec.ts @@ -0,0 +1,26 @@ +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); + }); + }); +}); diff --git a/src/macrorugo/macrorugo.ts b/src/macrorugo/macrorugo.ts index 242f251f2d9610ba591aefa5e38b2c65e140f373..1bde85f2050be3ba35b1825709c74fe05be7fb22 100644 --- a/src/macrorugo/macrorugo.ts +++ b/src/macrorugo/macrorugo.ts @@ -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; diff --git a/src/macrorugo/macrorugo_compound.ts b/src/macrorugo/macrorugo_compound.ts index 25627f67f9eb987c322d399925f21cb4f6e23705..0d96cef5dba951d1df37558bb73d4cde1570c621 100644 --- a/src/macrorugo/macrorugo_compound.ts +++ b/src/macrorugo/macrorugo_compound.ts @@ -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; } diff --git a/src/util/message.ts b/src/util/message.ts index 9d5fb1f99e96dd1425599c65fbd723e08bdedd91..219d5ca5b36eb2e9a7785aeac2cfcadf5449f87e 100644 --- a/src/util/message.ts +++ b/src/util/message.ts @@ -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,