diff --git a/spec/macrorugo/macrorugo.spec.ts b/spec/macrorugo/macrorugo.spec.ts index 74cb6b1c82e1d9d77ce30c687eddb0451d11af32..5d79f246075e53ebcf56635144282218d16adfd3 100644 --- a/spec/macrorugo/macrorugo.spec.ts +++ b/spec/macrorugo/macrorugo.spec.ts @@ -1,4 +1,4 @@ -import { ParamCalculability, ParamValueMode, Session } from "../../src/index"; +import { MessageCode, ParamCalculability, ParamValueMode, Session } from "../../src/index"; import { MacroRugo, MacroRugoFlowType } from "../../src/macrorugo/macrorugo"; import { MacrorugoParams } from "../../src/macrorugo/macrorugo_params"; import { checkResult } from "../test_func"; @@ -242,4 +242,50 @@ describe("Class MacroRugo: ", () => { } }); }); + + describe("ramp width tolerance should be 1cm", () => { + it("", () => { + const prms = new MacrorugoParams( + 12.5, // ZF1 + 6, // L + 2.2, // B + 0.05, // If + 0.1, // Q + 0.6, // h + 0.01, // Ks + 0.13, // C + 0.4, // D + 0.6, // k + 1 // Cd0 + ); + const mr = new MacroRugo(prms); + mr.calculatedParam = mr.prms.Q; + + // ramp not wide enough : warning on tolerance (min width=1.109 m) + + prms.B.singleValue = 1.099; + let res = mr.CalcSerie(); + expect(res.log.messages.length).toEqual(1); + expect(res.log.messages[0].code).toEqual(MessageCode.WARNING_RAMP_WIDTH_LOWER_THAN_PATTERN_WIDTH); + + // ramp just wide enough for one block pattern : no warning (min width=1.109 m) + + prms.B.singleValue = 1.1; + res = mr.CalcSerie(); + expect(res.log.messages.length).toEqual(0); + + // ramp wide enough : warning on tolerance (B=2.2, closest rounded value=2.219, B-rounded > 0.01) + + prms.B.singleValue = 2.2; + res = mr.CalcSerie(); + expect(res.log.messages.length).toEqual(1); + expect(res.log.messages[0].code).toEqual(MessageCode.WARNING_RAMP_WIDTH_NOT_MULTIPLE_OF_HALF_PATTERN_WIDTH); + + // ramp wide enough : no warning (B=2.21, closest rounded value=2.219, B-rounded < 0.01) + + prms.B.singleValue = 2.21; + res = mr.CalcSerie(); + expect(res.log.messages.length).toEqual(0); + }); + }); }); diff --git a/spec/macrorugo/macrorugo_compound.spec.ts b/spec/macrorugo/macrorugo_compound.spec.ts index be2e09c8f6dd3b811316aea450de0453f1ee7f86..bc81d33cb2f1ac6490ff32059c8b53939629c890 100644 --- a/spec/macrorugo/macrorugo_compound.spec.ts +++ b/spec/macrorugo/macrorugo_compound.spec.ts @@ -1,5 +1,6 @@ import { CalculatorType } from "../../src/compute-node"; import { Session } from "../../src/index"; +import { MacrorugoCompoundParams, MessageCode } from "../../src/internal_modules"; import { MacroRugo } from "../../src/macrorugo/macrorugo"; import { MacrorugoCompound } from "../../src/macrorugo/macrorugo_compound"; import { MacrorugoParams } from "../../src/macrorugo/macrorugo_params"; @@ -47,7 +48,7 @@ describe("MacroRugoCompound: ", () => { const mr = getMacroRugoRef(); mr.prms.L.singleValue = mrc.children[0].prms.L.v; mr.CalcSerie(); - compareTwoResults(mrc.children[0].result, mr.result, 3, [ "ZF2" ]); + compareTwoResults(mrc.children[0].result, mr.result, 3, ["ZF2"]); }); it("variating Z1, children Y should not always be 0.6", () => { const mrc = Session.getInstance().createNub( @@ -58,7 +59,7 @@ describe("MacroRugoCompound: ", () => { mrc.prms.Z1.setValues(10, 15, 5); mrc.CalcSerie(); const childYs = mrc.children[0].prms.Y.getInferredValuesList(); - expect(childYs).toEqual([ 0, 2.5 ]); + expect(childYs).toEqual([0, 2.5]); }); }); describe("Default inclined but flat apron", () => { @@ -134,8 +135,72 @@ describe("MacroRugoCompound: ", () => { }); it(`Apron #${i} should return same result as Macrorugo`, () => { const mr = getMacroRugoRef(i); - compareTwoResults(mrc2.children[i].result, mr.result, 3, [ "ZF2" ]); + compareTwoResults(mrc2.children[i].result, mr.result, 3, ["ZF2"]); }); } }); + + describe("Ramp width tolerance", () => { + it("tolerance should be 1cm", () => { + const MRCprms = new MacrorugoCompoundParams( + 13.1, // Z1 + 12.5, // ZRL + 12.5, // ZRR + 60, // B + 3, // DH + 0.05, // If + 0.01, // RF (Ks) + 0.13, // C (concentration de bloc) + 0.4, // D (diamètre de bloc) + 0.4, // H (hauteur de bloc) + 1 // Cd0 + ); + const mrc = new MacrorugoCompound(MRCprms); + + const MRprms = new MacrorugoParams( // B 1 + 12.5, // ZF1 + 6, // L + 1, // B + 0.05, // If + 1.57, // Q + 0.6, // Y + 0.01, // Ks + 0.13, // C + 0.4, // D + 0.4, // H + 1 // Cd0 + ); + mrc.addChild(new MacroRugo(MRprms)); + + // ramp not wide enough : warning on tolerance (min width=1.109 m) + + MRprms.B.singleValue = 1.099; + mrc.CalcSerie(); + let res = mrc.children[0].result; // warnings are in the child nub + expect(res.log.messages.length).toEqual(1); + expect(res.log.messages[0].code).toEqual(MessageCode.WARNING_RAMP_WIDTH_LOWER_THAN_PATTERN_WIDTH); + + // ramp just wide enough for one block pattern : no warning (min width=1.109 m) + + MRprms.B.singleValue = 1.1; + mrc.CalcSerie(); + res = mrc.children[0].result; + expect(res.log.messages.length).toEqual(0); + + // ramp wide enough : warning on tolerance (B=2.2, closest rounded value=2.219, B-rounded > 0.01) + + MRprms.B.singleValue = 2.2; + mrc.CalcSerie(); + res = mrc.children[0].result; + expect(res.log.messages.length).toEqual(1); + expect(res.log.messages[0].code).toEqual(MessageCode.WARNING_RAMP_WIDTH_NOT_MULTIPLE_OF_HALF_PATTERN_WIDTH); + + // ramp wide enough : no warning (B=2.21, closest rounded value=2.219, B-rounded < 0.01) + + MRprms.B.singleValue = 2.21; + mrc.CalcSerie(); + res = mrc.children[0].result; + expect(res.log.messages.length).toEqual(0); + }); + }); }); diff --git a/src/macrorugo/macrorugo.ts b/src/macrorugo/macrorugo.ts index db2cd017f3a232dcb056c4d2e430443870552730..1015d3ad1620dfd57b20a5c508a47e933ecdf703 100644 --- a/src/macrorugo/macrorugo.ts +++ b/src/macrorugo/macrorugo.ts @@ -105,11 +105,12 @@ export class MacroRugo extends FishPass { ) ) { const ax: number = this.prms.PBD.v / Math.sqrt(this.prms.C.v); - if (this.prms.B.v < ax - 0.001) { // B < ax, with a little tolerance + const tol = 0.01; // tolérance avant avertissement (1 cm) + if (this.prms.B.v < ax - tol) { // B < ax, with a little tolerance const m = new Message(MessageCode.WARNING_RAMP_WIDTH_LOWER_THAN_PATTERN_WIDTH); m.extraVar.pattern = ax; r.resultElement.log.add(m); - } else if (this.prms.B.v % (ax / 2) > 0.001 && this.prms.B.v % (ax / 2) < ax / 2 - 0.001) { + } else if (this.prms.B.v % (ax / 2) > tol && this.prms.B.v % (ax / 2) < ax / 2 - tol) { const m = new Message(MessageCode.WARNING_RAMP_WIDTH_NOT_MULTIPLE_OF_HALF_PATTERN_WIDTH); m.extraVar.halfPattern = ax / 2; m.extraVar.lower = Math.floor(this.prms.B.v / ax * 2) * (ax / 2); diff --git a/src/macrorugo/macrorugo_compound.ts b/src/macrorugo/macrorugo_compound.ts index 7744680b562b074a761868af23e028458c7b00b2..a9cdad1e5f0787e65183403294c63cc5708bd77f 100644 --- a/src/macrorugo/macrorugo_compound.ts +++ b/src/macrorugo/macrorugo_compound.ts @@ -99,11 +99,12 @@ export class MacrorugoCompound extends MacroRugo implements Observer { this.result.resultElement.values.LIncl = (this.prms.ZRL.v - this.prms.ZRR.v) / this.prms.BR.v; // La largeur de la rampe inclinée est-elle adéquate par rapport à la largeur de motif ax ? const ax: number = this.prms.PBD.v / Math.sqrt(this.prms.C.v); - if (this.prms.BR.v - ax < -0.001) { // BR < ax, with a little tolerance + const tol = 0.01; // tolérance avant avertissement (1 cm) + if (this.prms.BR.v - ax < -tol) { // BR < ax, with a little tolerance const m = new Message(MessageCode.WARNING_RAMP_WIDTH_LOWER_THAN_PATTERN_WIDTH); m.extraVar.pattern = ax; this._result.resultElement.log.add(m); - } else if (this.prms.BR.v % (ax / 2) > 0.001 && this.prms.BR.v % (ax / 2) < ax / 2 - 0.001) { + } else if (this.prms.BR.v % (ax / 2) > tol && this.prms.BR.v % (ax / 2) < ax / 2 - tol) { const m = new Message(MessageCode.WARNING_RAMP_WIDTH_NOT_MULTIPLE_OF_HALF_PATTERN_WIDTH); m.extraVar.halfPattern = ax / 2; m.extraVar.lower = Math.floor(this.prms.BR.v / ax * 2) * (ax / 2);