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

#33 All extraresults of PAB formation example are OK

Showing with 112 additions and 49 deletions
+112 -49
......@@ -49,34 +49,37 @@ function createModelCloisonTest(): Cloisons {
return modelCloisons;
}
// Création de la cloison aval
const downWall = new ParallelStructure(new ParallelStructureParams(0, 0, 0));
const kiviPrms = new StructureKiviParams(
0, // Q
73.95, // ZDV
0, // Z1
0, // Z2
0.6, // L
0.4, // Cd pour un seuil rectangulaire
0,
73.435
);
downWall.addChild(new StructureKivi(kiviPrms));
function createPabTest(): Pab {
// Création de la cloison aval
const downWall = new ParallelStructure(new ParallelStructureParams(0, 0, 0));
const kiviPrms = new StructureKiviParams(
0, // Q
73.95, // ZDV
0, // Z1
0, // Z2
0.6, // L
0.4, // Cd pour un seuil rectangulaire
0,
73.435
);
downWall.addChild(new StructureKivi(kiviPrms));
// Création de la passe
const pab: Pab = new Pab(
new PabParams(
0.773,
78.27,
74.86
),
downWall,
dbg
);
// Création de la passe
const p: Pab = new Pab(
new PabParams(
0.773,
78.27,
74.86
),
downWall,
dbg
);
// Ajout des cloisons
pab.addCloisonsFromModel(createModelCloisonTest(), 15);
pab.downWall = downWall;
// Ajout des cloisons
p.addCloisonsFromModel(createModelCloisonTest(), 15);
p.downWall = downWall;
return p;
}
function TestGeometry(b: Cloisons, ZRMB: number, ZRAM: number, ZDV: number) {
it(`ZRMB should be equal to ${ZRMB}`, () => {
......@@ -90,8 +93,50 @@ function TestGeometry(b: Cloisons, ZRMB: number, ZRAM: number, ZDV: number) {
});
}
function checkPabResults(p: Pab, vCalc: number) {
p.CalcSerie();
// Résultat du calcul principal (Z1 ou Q)
expect(p.result.vCalc).toBeCloseTo(vCalc, 2);
// Résultat Ligne d'eau (Cote de l'eau, P/V, Tmoy dans les 14 bassins)
const tRef = [
[78.270, 150.032, 1.500, 0.230],
[78.040, 149.932, 1.501, 0.230],
[77.811, 149.932, 1.501, 0.230],
[77.581, 149.932, 1.501, 0.230],
[77.351, 149.181, 1.502, 0.229],
[77.122, 149.081, 1.503, 0.229],
[76.893, 148.982, 1.504, 0.229],
[76.664, 148.883, 1.505, 0.229],
[76.435, 148.036, 1.507, 0.228],
[76.207, 147.840, 1.509, 0.228],
[75.979, 146.900, 1.512, 0.227],
[75.752, 145.867, 1.516, 0.226],
[75.526, 144.744, 1.521, 0.225],
[75.301, 143.534, 1.527, 0.224]
];
// Cote de l'eau dernier bassin à l'amont de la cloison aval
expect(p.downWall.result.vCalc).toBeCloseTo(75.077, 2);
expect(p.downWall.result.extraResults.DH).toBeCloseTo(0.217, 2);
for (let i = 0; i < 14; i++) {
// Cote de l'eau à l'amont de la cloison amont du bassin
expect(p.children[i].result.vCalc).toBeCloseTo(tRef[i][0], 2);
// Puissance volumique dissipée
expect(p.children[i].result.extraResults.PV).toBeCloseTo(tRef[i][1], 0);
// Tirant d'eau moyen
expect(p.children[i].result.extraResults.YMOY).toBeCloseTo(tRef[i][2], 2);
// Chute
expect(p.children[i].result.extraResults.DH).toBeCloseTo(tRef[i][3], 2);
// Débit
expect(p.children[i].result.extraResults.Q).toBeCloseTo(0.773, 2);
}
}
// Tests
let pab: Pab = createPabTest();
describe("Class Pab: ", () => {
beforeEach( () => {
pab = createPabTest();
});
describe("Exemple Formation 2018-09 p.14", () => {
let ZRMB = 76.54;
let ZDV = 76.67;
......@@ -104,15 +149,16 @@ describe("Class Pab: ", () => {
ZDV);
});
i++;
ZRMB -= pab.children[0].prms.DH.currentValue;
ZDV -= pab.children[0].prms.DH.currentValue;
ZRMB -= 0.23;
ZDV -= 0.23;
}
it("CalcSerie(Z1) should return 78.27", () => {
pab.calculatedParam = pab.prms.Z1;
expect(pab.CalcSerie().vCalc).toBeCloseTo(78.27, 2);
checkPabResults(pab, 78.27);
});
it("Calc(Q) should return 0.773", () => {
expect(pab.Calc("Q").vCalc).toBeCloseTo(0.773, 2);
pab.calculatedParam = pab.prms.Q;
checkPabResults(pab, 0.773);
});
});
});
......@@ -76,14 +76,15 @@ export class Cloisons extends ParallelStructure {
public adjustChildParameters(child: Nub) {
const prms = child.prms as StructureParams;
if (prms.ZDV.visible) {
if (this.prms.DH.calculability !== ParamCalculability.NONE && prms.ZDV.visible) {
// Dans le contexte hors PAB (DH.calculability !== ParamCalculability.NONE)
// Pour les seuils (i.e. Structures avec cote de radier de seuil)
// on remplace ZDV par h1 la charge sur le seuil
prms.h1.visible = true;
prms.ZDV.visible = false;
}
if (child.prms instanceof StructureKiviParams) {
// hide ZRAM for KIVI, in Cloisons context only
// hide ZRAM for KIVI, in Cloisons and PAB context only
child.prms.ZRAM.visible = false;
}
}
......@@ -101,20 +102,23 @@ export class Cloisons extends ParallelStructure {
}
private updatePrms() {
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.ZRMB.v = this.prms.Z1.v - this.prms.PB.v - this.prms.DH.v;
this.prms.ZRAM.v = this.prms.ZRMB.v + this.prms.DH.v / 2;
for (const structure of this.structures) {
const prms = structure.prms;
if (prms.h1.visible) {
// MAJ de ZDV des seuils à partir de la charge
prms.ZDV.v = this.prms.Z1.v - prms.h1.v;
if (this.prms.DH.calculability !== ParamCalculability.NONE) {
// if NONE => PAB context. it doesn't need update of elevations
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;
}
if (structure.prms instanceof StructureKiviParams) {
structure.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.ZRAM.v = this.prms.ZRMB.v + this.prms.DH.v / 2;
for (const structure of this.structures) {
const prms = structure.prms;
if (prms.h1.visible) {
// MAJ de ZDV des seuils à partir de la charge
prms.ZDV.v = this.prms.Z1.v - prms.h1.v;
}
if (structure.prms instanceof StructureKiviParams) {
structure.prms.ZRAM.v = this.prms.Z1.v - this.prms.PB.v;
}
}
}
}
......
......@@ -119,7 +119,12 @@ export class Pab extends Nub {
const cl: Cloisons = this.children[i];
// Calculation of upstream water elevation
cl.prms.PB.v = Z - cl.prms.ZRMB.v;
Z = this.calcCloisonZ1(cl, Z);
// Add extraresults: mean depth in pool and discharge
cl.result.extraResults.YMOY = cl.prms.PB.v;
cl.result.extraResults.Q = cl.prms.Q.v;
if (this.debug) {
console.log("Bassin n°" + i);
let s: string = "";
......@@ -188,10 +193,18 @@ export class Pab extends Nub {
*/
protected setParametersCalculability() {
this.prms.Z1.calculability = ParamCalculability.EQUATION;
this.prms.Z2.calculability = ParamCalculability.DICHO;
this.prms.Z2.calculability = ParamCalculability.FREE;
this.prms.Q.calculability = ParamCalculability.DICHO;
}
/**
* Remove Calculability of DH for not updating Z2 during calculation
* @param child Cloison newly added to the PAB
*/
protected adjustChildParameters(child: Cloisons) {
child.prms.DH.calculability = ParamCalculability.NONE;
}
private calcCloisonZ1(cl: ParallelStructure, Z: number): number {
// Initialisations for current cloison
cl.prms.Z2.v = Z;
......@@ -199,10 +212,10 @@ export class Pab extends Nub {
// Calculation of upstream water elevation
cl.Calc("Z1", Z + 0.1);
// TODO: Add extraresults: discharge, apron elevation upstream the wall, apron elevation at half basin
cl.result.extraResults.YMOY = cl.prms.Z2.v - cl.result.extraResults.ZRMB;
// Fall on this wall
cl.result.extraResults.DH = cl.result.vCalc - cl.prms.Z2.v;
// Update elevation and discharge for next basin
// Return Update elevation for next pool
return cl.result.vCalc;
}
}
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