diff --git a/spec/macrorugo/macrorugo_compound.spec.ts b/spec/macrorugo/macrorugo_compound.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..dbae546943c7b110d31bec494328d13d51908883 --- /dev/null +++ b/spec/macrorugo/macrorugo_compound.spec.ts @@ -0,0 +1,18 @@ +import { CalculatorType } from "../../src/compute-node"; +import { MacroRugo } from "../../src/macrorugo/macrorugo"; +import { MacrorugoCompound } from "../../src/macrorugo/macrorugo_compound"; +import { Props } from "../../src/props"; +import { Session } from "../../src/session"; + +describe("MacroRugoCompound", () => { + describe("Default 1 apron", () => { + it("should return same result as Macrorugo", () => { + const mrc = Session.getInstance().createNub( + new Props({ calcType: CalculatorType.MacroRugoCompound }) + ) as MacrorugoCompound; + const mr = Session.getInstance().createNub(new Props({ calcType: CalculatorType.MacroRugo })) as MacroRugo; + mr.prms.Q.setCalculated(); + expect(mrc.CalcSerie().vCalc).toBeCloseTo(mr.CalcSerie().vCalc, 3); + }); + }); +}); diff --git a/src/macrorugo/macrorugo_compound.ts b/src/macrorugo/macrorugo_compound.ts index 97655ed847f199bd4d4ec627782d8bf8fbb843e2..56c369f795b9d22770130a0b4c5b157d1cb7a1be 100644 --- a/src/macrorugo/macrorugo_compound.ts +++ b/src/macrorugo/macrorugo_compound.ts @@ -11,6 +11,7 @@ export class MacrorugoCompound extends MacroRugo { get children(): MacroRugo[] { return this._children as MacroRugo[]; } + constructor(prms: MacrorugoParams, dbg: boolean = false) { super(prms, dbg); this._calcType = CalculatorType.MacroRugoCompound; diff --git a/src/macrorugo/macrorugo_compound_params.ts b/src/macrorugo/macrorugo_compound_params.ts index 5cb96d9122b627cc09d1e5e4ad15f51bdd07cb4e..244e9ce2c89a0e4ff34cbdce0b42f350c822f1f3 100644 --- a/src/macrorugo/macrorugo_compound_params.ts +++ b/src/macrorugo/macrorugo_compound_params.ts @@ -12,10 +12,9 @@ export class MacrorugoCompoundParams extends MacrorugoParams { /** * * @param rZF1 Cote de fond amont (m) - * @param rL Longueur (m) + * @param rDH Longueur (m) * @param rB Largeur (m) * @param rIf Pente (m/m) - * @param rQ Débit (m3/s) * @param rY Tirant d'eau (m) * @param rRF Rugosité de fond (m) * @param rCB Concentration de blocs (m) @@ -25,24 +24,27 @@ export class MacrorugoCompoundParams extends MacrorugoParams { */ constructor( rZ1: number, - rL: number, + rDH: number, rIf: number, - rQ: number, rRF: number, rCB: number, rPBD: number, rPBH: number, rCd0: number ) { - super(0, rL, 0, rIf, rQ, 0, rRF, rCB, rPBD, rPBH, rCd0); + super(0, rDH / rIf, 0, rIf, 0, 0, rRF, rCB, rPBD, rPBH, rCd0); this._Z1 = new ParamDefinition(this, "ZF1", ParamDomainValue.POS, "m", rZ1, ParamFamily.ELEVATIONS); this.addParamDefinition(this._Z1); + this._DH = new ParamDefinition(this, "DH", ParamDomainValue.POS, "m", rDH, ParamFamily.ELEVATIONS); + this.addParamDefinition(this._DH); + // Width, water depth, and Bottom elevation are defined in Macrorugo children this.prms.B.visible = false; this.prms.ZF1.visible = false; this.prms.Y.visible = false; + this.prms.Q.visible = false; } public get Z1(): ParamDefinition { diff --git a/src/session.ts b/src/session.ts index f340f7433a394b694ede5a63758bb90926a30fc4..1398aadd230f00524796065a9bb8108124cb9305 100644 --- a/src/session.ts +++ b/src/session.ts @@ -36,6 +36,8 @@ import { Dever, DeverParams } from "./structure/dever"; import { CreateStructure } from "./structure/factory_structure"; import { ParallelStructure, ParallelStructureParams } from "./structure/parallel_structure"; import { LoiDebit, StructureType } from "./structure/structure_props"; +import { MacrorugoCompound } from "./macrorugo/macrorugo_compound"; +import { MacrorugoCompoundParams } from "./macrorugo/macrorugo_compound_params"; export class Session { @@ -427,6 +429,21 @@ export class Session { break; } + case CalculatorType.MacroRugoCompound: { + nub = new MacrorugoCompound( + new MacrorugoCompoundParams( + 13.1, // Z1 + 3, // DH + 0.05, // If + 0.01, // Ks + 0.05, // C + 0.5, // D + 0.8, // k + 1.5 // Cd0 + ) + ); + } + default: { throw new Error( `Session.createNub() : type de module '${CalculatorType[calcType]}' non pris en charge`