Commit 802f5535 authored by Grand Francois's avatar Grand Francois
Browse files

test: simple/compound MacroRugo: check ramp width tolerance to 1 cm

refs #344
Showing with 115 additions and 4 deletions
+115 -4
import { ParamCalculability, ParamValueMode, Session } from "../../src/index"; import { MessageCode, ParamCalculability, ParamValueMode, Session } from "../../src/index";
import { MacroRugo, MacroRugoFlowType } from "../../src/macrorugo/macrorugo"; import { MacroRugo, MacroRugoFlowType } from "../../src/macrorugo/macrorugo";
import { MacrorugoParams } from "../../src/macrorugo/macrorugo_params"; import { MacrorugoParams } from "../../src/macrorugo/macrorugo_params";
import { checkResult } from "../test_func"; import { checkResult } from "../test_func";
...@@ -242,4 +242,50 @@ describe("Class MacroRugo: ", () => { ...@@ -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);
});
});
}); });
import { CalculatorType } from "../../src/compute-node"; import { CalculatorType } from "../../src/compute-node";
import { Session } from "../../src/index"; import { Session } from "../../src/index";
import { MacrorugoCompoundParams, MessageCode } from "../../src/internal_modules";
import { MacroRugo } from "../../src/macrorugo/macrorugo"; import { MacroRugo } from "../../src/macrorugo/macrorugo";
import { MacrorugoCompound } from "../../src/macrorugo/macrorugo_compound"; import { MacrorugoCompound } from "../../src/macrorugo/macrorugo_compound";
import { MacrorugoParams } from "../../src/macrorugo/macrorugo_params"; import { MacrorugoParams } from "../../src/macrorugo/macrorugo_params";
...@@ -47,7 +48,7 @@ describe("MacroRugoCompound: ", () => { ...@@ -47,7 +48,7 @@ describe("MacroRugoCompound: ", () => {
const mr = getMacroRugoRef(); const mr = getMacroRugoRef();
mr.prms.L.singleValue = mrc.children[0].prms.L.v; mr.prms.L.singleValue = mrc.children[0].prms.L.v;
mr.CalcSerie(); 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", () => { it("variating Z1, children Y should not always be 0.6", () => {
const mrc = Session.getInstance().createNub( const mrc = Session.getInstance().createNub(
...@@ -58,7 +59,7 @@ describe("MacroRugoCompound: ", () => { ...@@ -58,7 +59,7 @@ describe("MacroRugoCompound: ", () => {
mrc.prms.Z1.setValues(10, 15, 5); mrc.prms.Z1.setValues(10, 15, 5);
mrc.CalcSerie(); mrc.CalcSerie();
const childYs = mrc.children[0].prms.Y.getInferredValuesList(); 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", () => { describe("Default inclined but flat apron", () => {
...@@ -134,8 +135,72 @@ describe("MacroRugoCompound: ", () => { ...@@ -134,8 +135,72 @@ describe("MacroRugoCompound: ", () => {
}); });
it(`Apron #${i} should return same result as Macrorugo`, () => { it(`Apron #${i} should return same result as Macrorugo`, () => {
const mr = getMacroRugoRef(i); 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);
});
});
}); });
Supports Markdown
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