Skip to content
Snippets Groups Projects
Commit 52b71238 authored by Dorchies David's avatar Dorchies David Committed by mathias.chouet
Browse files

#35 Add macrorugoCompound first test and factory

parent 9dd9dd7c
No related branches found
No related tags found
No related merge requests found
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);
});
});
});
...@@ -11,6 +11,7 @@ export class MacrorugoCompound extends MacroRugo { ...@@ -11,6 +11,7 @@ export class MacrorugoCompound extends MacroRugo {
get children(): MacroRugo[] { get children(): MacroRugo[] {
return this._children as MacroRugo[]; return this._children as MacroRugo[];
} }
constructor(prms: MacrorugoParams, dbg: boolean = false) { constructor(prms: MacrorugoParams, dbg: boolean = false) {
super(prms, dbg); super(prms, dbg);
this._calcType = CalculatorType.MacroRugoCompound; this._calcType = CalculatorType.MacroRugoCompound;
......
...@@ -12,10 +12,9 @@ export class MacrorugoCompoundParams extends MacrorugoParams { ...@@ -12,10 +12,9 @@ export class MacrorugoCompoundParams extends MacrorugoParams {
/** /**
* *
* @param rZF1 Cote de fond amont (m) * @param rZF1 Cote de fond amont (m)
* @param rL Longueur (m) * @param rDH Longueur (m)
* @param rB Largeur (m) * @param rB Largeur (m)
* @param rIf Pente (m/m) * @param rIf Pente (m/m)
* @param rQ Débit (m3/s)
* @param rY Tirant d'eau (m) * @param rY Tirant d'eau (m)
* @param rRF Rugosité de fond (m) * @param rRF Rugosité de fond (m)
* @param rCB Concentration de blocs (m) * @param rCB Concentration de blocs (m)
...@@ -25,24 +24,27 @@ export class MacrorugoCompoundParams extends MacrorugoParams { ...@@ -25,24 +24,27 @@ export class MacrorugoCompoundParams extends MacrorugoParams {
*/ */
constructor( constructor(
rZ1: number, rZ1: number,
rL: number, rDH: number,
rIf: number, rIf: number,
rQ: number,
rRF: number, rRF: number,
rCB: number, rCB: number,
rPBD: number, rPBD: number,
rPBH: number, rPBH: number,
rCd0: 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._Z1 = new ParamDefinition(this, "ZF1", ParamDomainValue.POS, "m", rZ1, ParamFamily.ELEVATIONS);
this.addParamDefinition(this._Z1); 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 // Width, water depth, and Bottom elevation are defined in Macrorugo children
this.prms.B.visible = false; this.prms.B.visible = false;
this.prms.ZF1.visible = false; this.prms.ZF1.visible = false;
this.prms.Y.visible = false; this.prms.Y.visible = false;
this.prms.Q.visible = false;
} }
public get Z1(): ParamDefinition { public get Z1(): ParamDefinition {
......
...@@ -36,6 +36,8 @@ import { Dever, DeverParams } from "./structure/dever"; ...@@ -36,6 +36,8 @@ import { Dever, DeverParams } from "./structure/dever";
import { CreateStructure } from "./structure/factory_structure"; import { CreateStructure } from "./structure/factory_structure";
import { ParallelStructure, ParallelStructureParams } from "./structure/parallel_structure"; import { ParallelStructure, ParallelStructureParams } from "./structure/parallel_structure";
import { LoiDebit, StructureType } from "./structure/structure_props"; import { LoiDebit, StructureType } from "./structure/structure_props";
import { MacrorugoCompound } from "./macrorugo/macrorugo_compound";
import { MacrorugoCompoundParams } from "./macrorugo/macrorugo_compound_params";
export class Session { export class Session {
...@@ -427,6 +429,21 @@ export class Session { ...@@ -427,6 +429,21 @@ export class Session {
break; 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: { default: {
throw new Error( throw new Error(
`Session.createNub() : type de module '${CalculatorType[calcType]}' non pris en charge` `Session.createNub() : type de module '${CalculatorType[calcType]}' non pris en charge`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment