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); + }); + }); });