An error occurred while loading the file. Please try again.
-
Dorchies David authoreddbae67af
/**
* IMPORTANT !
* Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine")
* Pour exécuter ce code dans le débugger.
* Faire de même avec le fichier test_func.ts
*/
// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine";
import { ParamCalculability, ParamValueMode } from "../../src";
import { MacroRugo, MacroRugoFlowType, MacrorugoParams } from "../../src/macrorugo/macrorugo";
import { Result } from "../../src/util/result";
import { checkResult, checkPercent } from "../test_func";
function macroRugoInstanceEmergent(): MacroRugo {
return new MacroRugo(
new MacrorugoParams(
12.5, // ZF1
6, // L
1, // B
0.05, // If
1.57, // Q
0.6, // h
0.01, // Ks
0.05, // C
0.5, // D
0.8, // k
1.5 // Cd0
)
);
}
function macroRugoInstanceSubmerged(): MacroRugo {
const nub: MacroRugo = macroRugoInstanceEmergent();
nub.prms.Y.v = 0.8;
nub.prms.PBH.v = 0.6;
nub.prms.Q.v = 4.737;
return nub;
}
function testMacroRugo(nubFactory: () => MacroRugo, varTest: string, valRef: number) {
describe("Calc(): ", () => {
it(`${varTest} should be ${valRef}`, () => {
const nub = nubFactory();
nub.prms.Q.v = nub.Calc("Q").vCalc;
const p = nub.getParameter(varTest);
p.v = undefined;
p.valueMode = ParamValueMode.CALCUL;
checkResult(nub.Calc(varTest, 0.1), valRef);
});
});
}
describe("Class MacroRugo: ", () => {
describe("Emerged conditions", () => {
it(`resolveU0(2.58) should be around 0`, () => {
const nubit = macroRugoInstanceEmergent();
// tslint:disable-next-line:no-string-literal
expect(nubit["resolveU0"](2.58)).toBeCloseTo(0, 1);
});
it(`resolveQ(1.547827) should be around 0`, () => {
const nubit = macroRugoInstanceEmergent();
// tslint:disable-next-line:no-string-literal
expect(nubit["resolveQ"](1.547827)).toBeCloseTo(0, 1);
});
it(`Calc("Q") should be around 1.548`, () => {
checkResult(macroRugoInstanceEmergent().Calc("Q", 0.1), 1.548, 1);
});
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
it(`Calc("Q", 0.1).extraResults.ZF2 should be around 12.2`, () => {
expect(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.ZF2).toBeCloseTo(12.2, 3);
});
it(`Calc("Q", 0.1).extraResults.Vdeb should be around 2.579818`, () => {
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.Vdeb, 2.579818, 0.03);
});
it(`Calc("Q", 0.1).extraResults.V should be around 2.694279`, () => {
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.V, 2.694279, 0.03);
});
it(`Calc("Q", 0.1).extraResults.Fr should be around 1.369611`, () => {
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.Fr, 1.369611, 0.03);
});
it(`Calc("Q", 0.1).extraResults.P should be around 759.240352`, () => {
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.P, 759.240352, 0.03);
});
it(`Calc("Q", 0.1).extraResults.FlowType should be MacroRugoFlowType.EMERGENT`, () => {
expect(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.FlowType).toBe(MacroRugoFlowType.EMERGENT);
});
it(`Calc("Q", 0.1).extraResults.Q2 should be around 0.868672`, () => {
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.Q2, 0.868672, 0.03);
});
it(`Calc("Q", 0.1).extraResults.V2 should be around 1.991299`, () => {
checkPercent(macroRugoInstanceEmergent().Calc("Q", 0.1).extraResults.V2, 1.991299, 0.03);
});
const nub = macroRugoInstanceEmergent();
for (const prm of nub.prms) {
if ([ParamCalculability.DICHO, ParamCalculability.EQUATION].includes(prm.calculability)) {
testMacroRugo(macroRugoInstanceEmergent, prm.symbol, prm.v);
}
}
});
describe("Submerged conditions", () => {
it(`resolveQ(4.737) should be around 0`, () => {
const nubit = macroRugoInstanceSubmerged();
// tslint:disable-next-line:no-string-literal
expect(nubit["resolveQ"](4.737)).toBeCloseTo(0, 1);
});
});
});