Commit f50d3f45 authored by Dorchies David's avatar Dorchies David
Browse files

Closes #100 Debug calcul DH

Showing with 34 additions and 39 deletions
+34 -39
...@@ -29,44 +29,34 @@ function getEmptyCloisonsTest(): Cloisons { ...@@ -29,44 +29,34 @@ function getEmptyCloisonsTest(): Cloisons {
function getCloisonsTest(): Cloisons { function getCloisonsTest(): Cloisons {
const cloisons: Cloisons = getEmptyCloisonsTest(); const cloisons: Cloisons = getEmptyCloisonsTest();
cloisons.addChild(CreateStructure(LoiDebit.CloisonsWeirSubmergedLarinier));
const fente: StructureWeirSubmergedLarinier = new StructureWeirSubmergedLarinier( cloisons.calculatedParam = cloisons.prms.Q;
new RectangularStructureParams( cloisons.structures[0].prms.h1.singleValue = 1;
0,
101,
102,
101.5,
0.2,
0.65
)
);
cloisons.addChild(fente);
return cloisons; return cloisons;
} }
describe("Class Cloisons: ", () => { describe("Class Cloisons: ", () => {
beforeAll( () => {
const c2: Cloisons = new Cloisons(
new CloisonsParams(
0, // Débit total (m3/s)
102, // Cote de l'eau amont (m)
10, // Longueur des bassins (m)
1, // Largeur des bassins (m)
1, // Profondeur moyenne (m)
0.5 // Hauteur de chute (m)
),
false // debug
);
});
describe("Calc(Q) Fente noyée (Larinier 1992)", () => { describe("Calc(Q) Fente noyée (Larinier 1992)", () => {
let c: Cloisons;
beforeEach( () => {
c = getCloisonsTest();
});
it("vCalc should return 0.407", () => { it("vCalc should return 0.407", () => {
expect(getCloisonsTest().Calc("Q").vCalc).toBeCloseTo(0.407, 3); expect(c.CalcSerie().vCalc).toBeCloseTo(0.407, 3);
}); });
it("extraResults.PV should return 199.7", () => { it("extraResults.PV should return 199.7", () => {
expect(getCloisonsTest().Calc("Q").extraResults.PV).toBeCloseTo(199.7, 1); expect(c.CalcSerie().extraResults.PV).toBeCloseTo(199.7, 1);
});
it("ZRMB should be 100.5", () => {
c.CalcSerie();
expect(c.prms.ZRMB.v).toBeCloseTo(100.5, 3);
});
it("Calc(DH) should return 0.5", () => {
c.calculatedParam = c.prms.Q;
c.prms.Q.singleValue = c.CalcSerie().vCalc;
c.calculatedParam = c.prms.DH;
c.calculatedParam.singleValue = 100;
expect(c.CalcSerie().vCalc).toBeCloseTo(0.5, 3);
}); });
}); });
...@@ -74,14 +64,6 @@ describe("Class Cloisons: ", () => { ...@@ -74,14 +64,6 @@ describe("Class Cloisons: ", () => {
testParallelStructures(CreateParalleleStructureTest(getEmptyCloisonsTest())); testParallelStructures(CreateParalleleStructureTest(getEmptyCloisonsTest()));
}); });
describe("Calcul de ZRMB", () => {
it("ZRMB should be 100.5", () => {
const c3 = CreateParalleleStructureTest(getEmptyCloisonsTest()).ps as Cloisons;
c3.Calc("Q");
expect(c3.prms.ZRMB.v).toBeCloseTo(100.5, 3);
});
});
describe("Exemple Formation Cassiopée 2018-09", () => { describe("Exemple Formation Cassiopée 2018-09", () => {
it("Calc(Z1) Exemple Formation Cassiopée 2018-09", () => { it("Calc(Z1) Exemple Formation Cassiopée 2018-09", () => {
// Modèle de cloison // Modèle de cloison
......
...@@ -41,10 +41,15 @@ export class Cloisons extends ParallelStructure { ...@@ -41,10 +41,15 @@ export class Cloisons extends ParallelStructure {
let sVC: string = sVarCalc; let sVC: string = sVarCalc;
if (sVarCalc === "DH") { if (sVarCalc === "DH") {
sVC = "Z2"; sVC = "Z2";
rInit = this.prms.Z1.v - this.prms.DH.v;
} }
this.updatePrms(); this.updatePrms();
const r: Result = super.Calc(sVC, rInit); const r: Result = super.Calc(sVC, rInit);
if (!r.ok) { // Error during calculation
return r;
}
// Transformation Z2 => DH // Transformation Z2 => DH
if (sVarCalc === "DH") { if (sVarCalc === "DH") {
r.vCalc = this.prms.Z1.v - r.vCalc; r.vCalc = this.prms.Z1.v - r.vCalc;
...@@ -96,7 +101,10 @@ export class Cloisons extends ParallelStructure { ...@@ -96,7 +101,10 @@ export class Cloisons extends ParallelStructure {
} }
private updatePrms() { private updatePrms() {
this.prms.Z2.v = this.prms.Z1.v - this.prms.DH.v; if (this.calculatedParam !== this.prms.DH) {
// Z2 is the variable to find if DH is the calculated param
this.prms.Z2.v = this.prms.Z1.v - this.prms.DH.v;
}
this.prms.ZRAM.v = this.prms.Z1.v - this.prms.PB.v; this.prms.ZRAM.v = this.prms.Z1.v - this.prms.PB.v;
this.prms.ZRMB.v = this.prms.Z1.v - this.prms.PB.v - this.prms.DH.v; this.prms.ZRMB.v = this.prms.Z1.v - this.prms.PB.v - this.prms.DH.v;
for (const structure of this.structures) { for (const structure of this.structures) {
......
...@@ -87,6 +87,11 @@ export function CreateStructure(loiDebit: LoiDebit, parentNub?: ParallelStructur ...@@ -87,6 +87,11 @@ export function CreateStructure(loiDebit: LoiDebit, parentNub?: ParallelStructur
case LoiDebit.WeirSubmergedLarinier: case LoiDebit.WeirSubmergedLarinier:
case LoiDebit.CloisonsWeirSubmergedLarinier: case LoiDebit.CloisonsWeirSubmergedLarinier:
ret = new StructureWeirSubmergedLarinier(rectStructPrms, dbg); ret = new StructureWeirSubmergedLarinier(rectStructPrms, dbg);
const prms = ret.prms as RectangularStructureParams;
prms.L.singleValue = 0.2;
prms.Cd.singleValue = 0.65;
prms.ZDV.singleValue = 101;
prms.h1.singleValue = 1;
break; break;
case LoiDebit.KIVI: case LoiDebit.KIVI:
......
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