Commit 7b6e5403 authored by Mathias Chouet's avatar Mathias Chouet :spaghetti:
Browse files

refactor nubs

merged cParamsCanal and ParamsSection
Structures are now only defined by their LoiDebit (no more StructureType)
Session : fixed serialization of lately registered Nubs
Sections are now defined by a CalculatorType and a NodeType
fixed bug in findFirstSingleParameter
added tests for session serialisation
Showing with 560 additions and 265 deletions
+560 -265
...@@ -12,7 +12,7 @@ import { CreateStructure } from "../../src/structure/factory_structure"; ...@@ -12,7 +12,7 @@ import { CreateStructure } from "../../src/structure/factory_structure";
import { ParallelStructure } from "../../src/structure/parallel_structure"; import { ParallelStructure } from "../../src/structure/parallel_structure";
import { ParallelStructureParams } from "../../src/structure/parallel_structure_params"; import { ParallelStructureParams } from "../../src/structure/parallel_structure_params";
import { Structure } from "../../src/structure/structure"; import { Structure } from "../../src/structure/structure";
import { LoiDebit, StructureType } from "../../src/structure/structure_props"; import { LoiDebit } from "../../src/structure/structure_props";
function checkParams(pdi: IParamDefinitionIterator, symbols: string[], values: number[]) { function checkParams(pdi: IParamDefinitionIterator, symbols: string[], values: number[]) {
let n = 0; let n = 0;
...@@ -45,8 +45,8 @@ describe("iterator : ", () => { ...@@ -45,8 +45,8 @@ describe("iterator : ", () => {
const psp: ParallelStructureParams = new ParallelStructureParams(1, 2, 3); const psp: ParallelStructureParams = new ParallelStructureParams(1, 2, 3);
const pst = new ParallelStructure(psp); const pst = new ParallelStructure(psp);
const st: Structure = CreateStructure(StructureType.SeuilRectangulaire, LoiDebit.WeirCem88d, pst); const st: Structure = CreateStructure(LoiDebit.WeirCem88d, pst);
pst.addStructure(st); pst.addChild(st);
// le 2e "Pr" est celui de la structure // le 2e "Pr" est celui de la structure
const symbs = ["Pr", "Q", "Z1", "Z2", "Pr", "Cd", "h1", "h2", "L", "Q", "W", "Z1", "Z2", "ZDV"]; const symbs = ["Pr", "Q", "Z1", "Z2", "Pr", "Cd", "h1", "h2", "L", "Q", "W", "Z1", "Z2", "ZDV"];
......
...@@ -152,6 +152,14 @@ class Expect { ...@@ -152,6 +152,14 @@ class Expect {
} }
} }
public toContain(expected: any) {
const res = Array.isArray(this.actual) && this.actual.includes(expected);
if (!res) {
console.error("Expected " + this.actual + " to contain " + expected);
}
return res;
}
public toThrow(expected?: any) { public toThrow(expected?: any) {
let exception: Error; let exception: Error;
if (typeof this.actual !== "function") { if (typeof this.actual !== "function") {
......
...@@ -2,10 +2,11 @@ import { cSnTrapez, LinkedValue, Nub, ParallelStructure, ParallelStructureParams ...@@ -2,10 +2,11 @@ import { cSnTrapez, LinkedValue, Nub, ParallelStructure, ParallelStructureParams
ParamsSectionTrapez, ParamValueMode, SectionParametree, Session } from "../../src/index"; ParamsSectionTrapez, ParamValueMode, SectionParametree, Session } from "../../src/index";
import { RegimeUniforme } from "../../src/regime_uniforme"; import { RegimeUniforme } from "../../src/regime_uniforme";
import { cSnCirc, ParamsSectionCirc } from "../../src/section/section_circulaire"; import { cSnCirc, ParamsSectionCirc } from "../../src/section/section_circulaire";
import { Cloisons, CloisonsParams } from "../../src/structure/cloisons"; import { Cloisons } from "../../src/structure/cloisons";
import { CloisonsParams } from "../../src/structure/cloisons_params";
import { Dever, DeverParams } from "../../src/structure/dever"; import { Dever, DeverParams } from "../../src/structure/dever";
import { CreateStructure } from "../../src/structure/factory_structure"; import { CreateStructure } from "../../src/structure/factory_structure";
import { LoiDebit, StructureType } from "../../src/structure/structure_props"; import { LoiDebit } from "../../src/structure/structure_props";
/** /**
* IMPORTANT ! * IMPORTANT !
...@@ -38,22 +39,20 @@ function createEnv() { ...@@ -38,22 +39,20 @@ function createEnv() {
paramSect.Pr.v = 0.01; paramSect.Pr.v = 0.01;
const sect = new cSnCirc(paramSect); const sect = new cSnCirc(paramSect);
nub1 = new RegimeUniforme(sect); nub1 = new RegimeUniforme(sect);
prm1 = nub1.prms as ParamsSectionCirc; prm1 = nub1.section.prms as ParamsSectionCirc;
// Nub 2 : Lois d'ouvrages // Nub 2 : Lois d'ouvrages
prm2 = new ParallelStructureParams(0.5, 102, 101.5); prm2 = new ParallelStructureParams(0.5, 102, 101.5);
prm2.Pr.v = 0.01; prm2.Pr.v = 0.01;
nub2 = new ParallelStructure(prm2); nub2 = new ParallelStructure(prm2);
nub2.addStructure( nub2.addChild(
CreateStructure( CreateStructure(
StructureType.VanneRectangulaire,
LoiDebit.Cunge80, LoiDebit.Cunge80,
nub2 nub2
) )
); );
nub2.addStructure( nub2.addChild(
CreateStructure( CreateStructure(
StructureType.SeuilTriangulaire,
LoiDebit.TriangularWeirFree, LoiDebit.TriangularWeirFree,
nub2 nub2
) )
...@@ -62,16 +61,14 @@ function createEnv() { ...@@ -62,16 +61,14 @@ function createEnv() {
// Nub 3 : Passe à Bassin : Cloisons // Nub 3 : Passe à Bassin : Cloisons
prm3 = new CloisonsParams(1.5, 102, 10, 1, 1, 0.5); prm3 = new CloisonsParams(1.5, 102, 10, 1, 1, 0.5);
nub3 = new Cloisons(prm3); nub3 = new Cloisons(prm3);
nub3.addStructure( nub3.addChild(
CreateStructure( CreateStructure(
StructureType.Orifice,
LoiDebit.OrificeSubmerged, LoiDebit.OrificeSubmerged,
nub3 nub3
) )
); );
nub3.addStructure( nub3.addChild(
CreateStructure( CreateStructure(
StructureType.SeuilRectangulaire,
LoiDebit.KIVI, LoiDebit.KIVI,
nub3 nub3
) )
...@@ -81,17 +78,15 @@ function createEnv() { ...@@ -81,17 +78,15 @@ function createEnv() {
prm4 = new DeverParams(0.5, 102, 10, 99); prm4 = new DeverParams(0.5, 102, 10, 99);
prm4.Pr.v = 0.01; prm4.Pr.v = 0.01;
nub4 = new Dever(prm4); nub4 = new Dever(prm4);
nub4.addStructure( nub4.addChild(
CreateStructure( CreateStructure(
StructureType.SeuilRectangulaire,
LoiDebit.WeirFree, LoiDebit.WeirFree,
nub4, nub4,
false false
) )
); );
nub4.addStructure( nub4.addChild(
CreateStructure( CreateStructure(
StructureType.SeuilTriangulaireTrunc,
LoiDebit.TriangularTruncWeirFree, LoiDebit.TriangularTruncWeirFree,
nub4, nub4,
false false
...@@ -102,17 +97,15 @@ function createEnv() { ...@@ -102,17 +97,15 @@ function createEnv() {
prm5 = new DeverParams(0.5, 102, 10, 99); prm5 = new DeverParams(0.5, 102, 10, 99);
prm5.Pr.v = 0.01; prm5.Pr.v = 0.01;
nub5 = new Dever(prm5); nub5 = new Dever(prm5);
nub5.addStructure( nub5.addChild(
CreateStructure( CreateStructure(
StructureType.SeuilRectangulaire,
LoiDebit.WeirFree, LoiDebit.WeirFree,
nub5, nub5,
false false
) )
); );
nub5.addStructure( nub5.addChild(
CreateStructure( CreateStructure(
StructureType.SeuilTriangulaireTrunc,
LoiDebit.TriangularTruncWeirFree, LoiDebit.TriangularTruncWeirFree,
nub5, nub5,
false false
...@@ -245,6 +238,9 @@ describe("cohérence des modes de paramètres : ", () => { ...@@ -245,6 +238,9 @@ describe("cohérence des modes de paramètres : ", () => {
it("varier un paramètre d'une Section Paramétrée", () => { it("varier un paramètre d'une Section Paramétrée", () => {
createEnv(); createEnv();
prm6.YB.setValues(0.5, 2, 0.075); prm6.YB.setValues(0.5, 2, 0.075);
/* for (const p of nub6.parameterIterator) {
console.log(">>> param 2", p.symbol, ParamValueMode[p.valueMode]);
} */
nub6.CalcSerie(1, "Yf"); nub6.CalcSerie(1, "Yf");
}); });
...@@ -276,7 +272,7 @@ describe("cohérence des modes de paramètres : ", () => { ...@@ -276,7 +272,7 @@ describe("cohérence des modes de paramètres : ", () => {
// link other Nubs Q to nub1.Q // link other Nubs Q to nub1.Q
for (const n of [ nub2, nub3, nub4 ]) { for (const n of [ nub2, nub3, nub4 ]) {
n.prms.Q.defineReference(nub1, "Q"); n.prms.Q.defineReference(nub1.section, "Q");
// set every parameter to MINMAX / LISTE mode // set every parameter to MINMAX / LISTE mode
let i = 0; let i = 0;
for (const p of n.parameterIterator) { for (const p of n.parameterIterator) {
...@@ -299,11 +295,11 @@ describe("cohérence des modes de paramètres : ", () => { ...@@ -299,11 +295,11 @@ describe("cohérence des modes de paramètres : ", () => {
prm1.Q.setValues(0.6, 2.4, 0.09); prm1.Q.setValues(0.6, 2.4, 0.09);
// link nub6.Q to nub1.Q // link nub6.Q to nub1.Q
prm6.Q.defineReference(nub1, "Q"); prm6.Q.defineReference(nub1.section, "Q");
// link other Nubs Q to nub6.Q // link other Nubs Q to nub6.Q
for (const n of [ nub2, nub3, nub4 ]) { for (const n of [ nub2, nub3, nub4 ]) {
n.prms.Q.defineReference(nub6, "Q"); n.prms.Q.defineReference(nub6.section, "Q");
// set every parameter to MINMAX / LISTE mode // set every parameter to MINMAX / LISTE mode
let i = 0; let i = 0;
for (const p of n.parameterIterator) { for (const p of n.parameterIterator) {
...@@ -328,7 +324,7 @@ describe("cohérence des modes de paramètres : ", () => { ...@@ -328,7 +324,7 @@ describe("cohérence des modes de paramètres : ", () => {
// link other Nubs Q to nub1.Q // link other Nubs Q to nub1.Q
for (const n of [ nub2, nub3, nub4 ]) { for (const n of [ nub2, nub3, nub4 ]) {
n.prms.Q.defineReference(nub1, "Q"); n.prms.Q.defineReference(nub1.section, "Q");
// set every parameter to MINMAX / LISTE mode // set every parameter to MINMAX / LISTE mode
let i = 0; let i = 0;
for (const p of n.parameterIterator) { for (const p of n.parameterIterator) {
...@@ -352,11 +348,11 @@ describe("cohérence des modes de paramètres : ", () => { ...@@ -352,11 +348,11 @@ describe("cohérence des modes de paramètres : ", () => {
prm1.Q.setCalculated(); prm1.Q.setCalculated();
// link nub6.Q to nub5.CvQT // link nub6.Q to nub5.CvQT
prm6.Q.defineReference(nub1, "Q"); prm6.Q.defineReference(nub1.section, "Q");
// link other Nubs Q to nub6.Q // link other Nubs Q to nub6.Q
for (const n of [ nub2, nub3, nub4 ]) { for (const n of [ nub2, nub3, nub4 ]) {
n.prms.Q.defineReference(nub6, "Q"); n.prms.Q.defineReference(nub6.section, "Q");
// set every parameter to MINMAX / LISTE mode // set every parameter to MINMAX / LISTE mode
let i = 0; let i = 0;
for (const p of n.parameterIterator) { for (const p of n.parameterIterator) {
...@@ -409,7 +405,7 @@ describe("cohérence des modes de paramètres : ", () => { ...@@ -409,7 +405,7 @@ describe("cohérence des modes de paramètres : ", () => {
// link other Nubs Q to nub6.Q // link other Nubs Q to nub6.Q
for (const n of [ nub2, nub3, nub4 ]) { for (const n of [ nub2, nub3, nub4 ]) {
n.prms.Q.defineReference(nub6, "Q"); n.prms.Q.defineReference(nub6.section, "Q");
// set every parameter to MINMAX / LISTE mode // set every parameter to MINMAX / LISTE mode
let i = 0; let i = 0;
for (const p of n.parameterIterator) { for (const p of n.parameterIterator) {
......
...@@ -39,89 +39,89 @@ describe("Section paramétrée circulaire : ", () => { ...@@ -39,89 +39,89 @@ describe("Section paramétrée circulaire : ", () => {
describe("fluvial / pas de débordement :", () => { describe("fluvial / pas de débordement :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 0.853", () => { it("Hs should equal to 0.853", () => {
checkResult(sect.Calc("Hs"), 0.853); checkResult(sect.CalcSection("Hs"), 0.853);
}); });
// charge critique // charge critique
it("Hsc should equal to 0.694", () => { it("Hsc should equal to 0.694", () => {
checkResult(sect.Calc("Hsc"), 0.694); checkResult(sect.CalcSection("Hsc"), 0.694);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 1.959", () => { it("B should equal to 1.959", () => {
checkResult(sect.Calc("B"), 1.959); checkResult(sect.CalcSection("B"), 1.959);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 2.738", () => { it("P should equal to 2.738", () => {
checkResult(sect.Calc("P"), 2.738); checkResult(sect.CalcSection("P"), 2.738);
}); });
// surface mouillée // surface mouillée
it("S should equal to 1.173", () => { it("S should equal to 1.173", () => {
checkResult(sect.Calc("S"), 1.173); checkResult(sect.CalcSection("S"), 1.173);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 0.428", () => { it("R should equal to 0.428", () => {
checkResult(sect.Calc("R"), 0.428); checkResult(sect.CalcSection("R"), 0.428);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 1.023", () => { it("V should equal to 1.023", () => {
checkResult(sect.Calc("V"), 1.023); checkResult(sect.CalcSection("V"), 1.023);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 0.422", () => { it("Fr should equal to 0.422", () => {
checkResult(sect.Calc("Fr"), 0.422); checkResult(sect.CalcSection("Fr"), 0.422);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 0.512", () => { it("Yc should equal to 0.512", () => {
checkResult(sect.Calc("Yc"), 0.512); checkResult(sect.CalcSection("Yc"), 0.512);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 0.976", () => { it("Yn should equal to 0.976", () => {
checkResult(sect.Calc("Yn"), 0.976); checkResult(sect.CalcSection("Yn"), 0.976);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 0.8", () => { it("Yf should equal to 0.8", () => {
checkResult(sect.Calc("Yf"), 0.8); checkResult(sect.CalcSection("Yf"), 0.8);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.361", () => { it("Yt should equal to 0.361", () => {
checkResult(sect.Calc("Yt"), 0.361); checkResult(sect.CalcSection("Yt"), 0.361);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 0.307", () => { it("Yco should equal to 0.307", () => {
checkResult(sect.Calc("Yco"), 0.307); checkResult(sect.CalcSection("Yco"), 0.307);
}); });
// perte de charge // perte de charge
it("J should equal to 0.002", () => { it("J should equal to 0.002", () => {
// sect = createSection(0.00001); // sect = createSection(0.00001);
checkResult(sect.Calc("J"), 0.002); checkResult(sect.CalcSection("J"), 0.002);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to -0.00102", () => { it("I-J should equal to -0.00102", () => {
sect = createSection(0.00001); sect = createSection(0.00001);
checkResult(sect.Calc("I-J"), -0.00102); checkResult(sect.CalcSection("I-J"), -0.00102);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 5076.304", () => { it("Imp should equal to 5076.304", () => {
checkResult(sect.Calc("Imp"), 5076.304); checkResult(sect.CalcSection("Imp"), 5076.304);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 8.505", () => { it("Tau0 should equal to 8.505", () => {
checkResult(sect.Calc("Tau0"), 8.505); checkResult(sect.CalcSection("Tau0"), 8.505);
}); });
}); });
}); });
...@@ -134,89 +134,89 @@ describe("Section paramétrée circulaire : ", () => { ...@@ -134,89 +134,89 @@ describe("Section paramétrée circulaire : ", () => {
describe("fluvial / débordement :", () => { describe("fluvial / débordement :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 2.006", () => { it("Hs should equal to 2.006", () => {
checkResult(sect.Calc("Hs"), 2.006); checkResult(sect.CalcSection("Hs"), 2.006);
}); });
// charge critique // charge critique
it("Hsc should equal to 0.694", () => { it("Hsc should equal to 0.694", () => {
checkResult(sect.Calc("Hsc"), 0.694); checkResult(sect.CalcSection("Hsc"), 0.694);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 2", () => { it("B should equal to 2", () => {
checkResult(sect.Calc("B"), 2); checkResult(sect.CalcSection("B"), 2);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 5.142", () => { it("P should equal to 5.142", () => {
checkResult(sect.Calc("P"), 5.142); checkResult(sect.CalcSection("P"), 5.142);
}); });
// surface mouillée // surface mouillée
it("S should equal to 3.571", () => { it("S should equal to 3.571", () => {
checkResult(sect.Calc("S"), 3.571); checkResult(sect.CalcSection("S"), 3.571);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 0.694", () => { it("R should equal to 0.694", () => {
checkResult(sect.Calc("R"), 0.694); checkResult(sect.CalcSection("R"), 0.694);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 0.336", () => { it("V should equal to 0.336", () => {
checkResult(sect.Calc("V"), 0.336); checkResult(sect.CalcSection("V"), 0.336);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 0.08", () => { it("Fr should equal to 0.08", () => {
checkResult(sect.Calc("Fr"), 0.08); checkResult(sect.CalcSection("Fr"), 0.08);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 0.512", () => { it("Yc should equal to 0.512", () => {
checkResult(sect.Calc("Yc"), 0.512); checkResult(sect.CalcSection("Yc"), 0.512);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 0.976", () => { it("Yn should equal to 0.976", () => {
checkResult(sect.Calc("Yn"), 0.976); checkResult(sect.CalcSection("Yn"), 0.976);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 2", () => { it("Yf should equal to 2", () => {
checkResult(sect.Calc("Yf"), 2); checkResult(sect.CalcSection("Yf"), 2);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.232", () => { it("Yt should equal to 0.232", () => {
checkResult(sect.Calc("Yt"), 0.232); checkResult(sect.CalcSection("Yt"), 0.232);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 0.24", () => { it("Yco should equal to 0.24", () => {
checkResult(sect.Calc("Yco"), 0.24); checkResult(sect.CalcSection("Yco"), 0.24);
}); });
// perte de charge // perte de charge
it("J should equal to 0.0001", () => { it("J should equal to 0.0001", () => {
sect = createSectionDebordement(0.00001); sect = createSectionDebordement(0.00001);
checkResult(sect.Calc("J"), 0.0001); checkResult(sect.CalcSection("J"), 0.0001);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to 0.001", () => { it("I-J should equal to 0.001", () => {
sect = createSectionDebordement(0.00001); sect = createSectionDebordement(0.00001);
checkResult(sect.Calc("I-J"), 0.001); checkResult(sect.CalcSection("I-J"), 0.001);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 6943.271", () => { it("Imp should equal to 6943.271", () => {
checkResult(sect.Calc("Imp"), 6943.271); checkResult(sect.CalcSection("Imp"), 6943.271);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 0.782", () => { it("Tau0 should equal to 0.782", () => {
checkResult(sect.Calc("Tau0"), 0.782); checkResult(sect.CalcSection("Tau0"), 0.782);
}); });
}); });
}); });
...@@ -26,89 +26,89 @@ describe("Section paramétrée circulaire : ", () => { ...@@ -26,89 +26,89 @@ describe("Section paramétrée circulaire : ", () => {
describe("torrentiel :", () => { describe("torrentiel :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 4.501", () => { it("Hs should equal to 4.501", () => {
checkResult(sect.Calc("Hs"), 4.501); checkResult(sect.CalcSection("Hs"), 4.501);
}); });
// charge critique // charge critique
it("Hsc should equal to 2.263", () => { it("Hsc should equal to 2.263", () => {
checkResult(sect.Calc("Hsc"), 2.263); checkResult(sect.CalcSection("Hsc"), 2.263);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 1.960", () => { it("B should equal to 1.960", () => {
checkResult(sect.Calc("B"), 1.960); checkResult(sect.CalcSection("B"), 1.960);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 2.739", () => { it("P should equal to 2.739", () => {
checkResult(sect.Calc("P"), 2.739); checkResult(sect.CalcSection("P"), 2.739);
}); });
// surface mouillée // surface mouillée
it("S should equal to 1.173", () => { it("S should equal to 1.173", () => {
checkResult(sect.Calc("S"), 1.173); checkResult(sect.CalcSection("S"), 1.173);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 0.428", () => { it("R should equal to 0.428", () => {
checkResult(sect.Calc("R"), 0.428); checkResult(sect.CalcSection("R"), 0.428);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 8.522", () => { it("V should equal to 8.522", () => {
checkResult(sect.Calc("V"), 8.522); checkResult(sect.CalcSection("V"), 8.522);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 3.516", () => { it("Fr should equal to 3.516", () => {
checkResult(sect.Calc("Fr"), 3.516); checkResult(sect.CalcSection("Fr"), 3.516);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 1.581", () => { it("Yc should equal to 1.581", () => {
checkResult(sect.Calc("Yc"), 1.581); checkResult(sect.CalcSection("Yc"), 1.581);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 4.624", () => { it("Yn should equal to 4.624", () => {
checkResult(sect.Calc("Yn"), 4.624); checkResult(sect.CalcSection("Yn"), 4.624);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 4.43", () => { it("Yf should equal to 4.43", () => {
checkResult(sect.Calc("Yf"), 4.43); checkResult(sect.CalcSection("Yf"), 4.43);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.8", () => { it("Yt should equal to 0.8", () => {
checkResult(sect.Calc("Yt"), 0.8); checkResult(sect.CalcSection("Yt"), 0.8);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 0.8", () => { it("Yco should equal to 0.8", () => {
checkResult(sect.Calc("Yco"), 0.8); checkResult(sect.CalcSection("Yco"), 0.8);
}); });
// perte de charge // perte de charge
it("J should equal to 0.141", () => { it("J should equal to 0.141", () => {
// sect = createSection(0.00001); // sect = createSection(0.00001);
checkResult(sect.Calc("J"), 0.141); checkResult(sect.CalcSection("J"), 0.141);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to -0.14", () => { it("I-J should equal to -0.14", () => {
// sect = createSection(0.00001); // sect = createSection(0.00001);
checkResult(sect.Calc("I-J"), -0.14); checkResult(sect.CalcSection("I-J"), -0.14);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 89065.861", () => { it("Imp should equal to 89065.861", () => {
checkResult(sect.Calc("Imp"), 89065.861); checkResult(sect.CalcSection("Imp"), 89065.861);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 590.605", () => { it("Tau0 should equal to 590.605", () => {
checkResult(sect.Calc("Tau0"), 590.605); checkResult(sect.CalcSection("Tau0"), 590.605);
}); });
}); });
}); });
...@@ -41,89 +41,89 @@ describe("Section paramétrée puissance :", () => { ...@@ -41,89 +41,89 @@ describe("Section paramétrée puissance :", () => {
describe("fluvial / pas de débordement :", () => { describe("fluvial / pas de débordement :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 0.82", () => { it("Hs should equal to 0.82", () => {
checkResult(sect.Calc("Hs"), 0.82); checkResult(sect.CalcSection("Hs"), 0.82);
}); });
// charge critique // charge critique
it("Hsc should equal to 0.559", () => { it("Hsc should equal to 0.559", () => {
checkResult(sect.Calc("Hsc"), 0.559); checkResult(sect.CalcSection("Hsc"), 0.559);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 3.578", () => { it("B should equal to 3.578", () => {
checkResult(sect.Calc("B"), 3.578); checkResult(sect.CalcSection("B"), 3.578);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 4.223", () => { it("P should equal to 4.223", () => {
checkResult(sect.Calc("P"), 4.223); checkResult(sect.CalcSection("P"), 4.223);
}); });
// surface mouillée // surface mouillée
it("S should equal to 1.908", () => { it("S should equal to 1.908", () => {
checkResult(sect.Calc("S"), 1.908); checkResult(sect.CalcSection("S"), 1.908);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 0.452", () => { it("R should equal to 0.452", () => {
checkResult(sect.Calc("R"), 0.452); checkResult(sect.CalcSection("R"), 0.452);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 0.629", () => { it("V should equal to 0.629", () => {
checkResult(sect.Calc("V"), 0.629); checkResult(sect.CalcSection("V"), 0.629);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 0.275", () => { it("Fr should equal to 0.275", () => {
checkResult(sect.Calc("Fr"), 0.275); checkResult(sect.CalcSection("Fr"), 0.275);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 0.419", () => { it("Yc should equal to 0.419", () => {
checkResult(sect.Calc("Yc"), 0.419); checkResult(sect.CalcSection("Yc"), 0.419);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 0.742", () => { it("Yn should equal to 0.742", () => {
checkResult(sect.Calc("Yn"), 0.742); checkResult(sect.CalcSection("Yn"), 0.742);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 0.8", () => { it("Yf should equal to 0.8", () => {
checkResult(sect.Calc("Yf"), 0.8); checkResult(sect.CalcSection("Yf"), 0.8);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.265", () => { it("Yt should equal to 0.265", () => {
checkResult(sect.Calc("Yt"), 0.265); checkResult(sect.CalcSection("Yt"), 0.265);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 0.189", () => { it("Yco should equal to 0.189", () => {
checkResult(sect.Calc("Yco"), 0.189); checkResult(sect.CalcSection("Yco"), 0.189);
}); });
// perte de charge // perte de charge
it("J should equal to 0.0007", () => { it("J should equal to 0.0007", () => {
sect = createSection(0.00001); sect = createSection(0.00001);
checkResult(sect.Calc("J"), 0.0007); checkResult(sect.CalcSection("J"), 0.0007);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to 0.000335", () => { it("I-J should equal to 0.000335", () => {
sect = createSection(0.000001); sect = createSection(0.000001);
checkResult(sect.Calc("I-J"), 0.000335); checkResult(sect.CalcSection("I-J"), 0.000335);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 6744.616", () => { it("Imp should equal to 6744.616", () => {
checkResult(sect.Calc("Imp"), 6744.616); checkResult(sect.CalcSection("Imp"), 6744.616);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 3.16", () => { it("Tau0 should equal to 3.16", () => {
checkResult(sect.Calc("Tau0"), 3.16); checkResult(sect.CalcSection("Tau0"), 3.16);
}); });
}); });
}); });
...@@ -136,89 +136,89 @@ describe("Section paramétrée puissance :", () => { ...@@ -136,89 +136,89 @@ describe("Section paramétrée puissance :", () => {
describe("fluvial / débordement :", () => { describe("fluvial / débordement :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 2.001", () => { it("Hs should equal to 2.001", () => {
checkResult(sect.Calc("Hs"), 2.001); checkResult(sect.CalcSection("Hs"), 2.001);
}); });
// charge critique // charge critique
it("Hsc should equal to 0.559", () => { it("Hsc should equal to 0.559", () => {
checkResult(sect.Calc("Hsc"), 0.559); checkResult(sect.CalcSection("Hsc"), 0.559);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 4", () => { it("B should equal to 4", () => {
checkResult(sect.Calc("B"), 4); checkResult(sect.CalcSection("B"), 4);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 6.098", () => { it("P should equal to 6.098", () => {
checkResult(sect.Calc("P"), 6.098); checkResult(sect.CalcSection("P"), 6.098);
}); });
// surface mouillée // surface mouillée
it("S should equal to 7.542", () => { it("S should equal to 7.542", () => {
checkResult(sect.Calc("S"), 7.542); checkResult(sect.CalcSection("S"), 7.542);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 1.237", () => { it("R should equal to 1.237", () => {
checkResult(sect.Calc("R"), 1.237); checkResult(sect.CalcSection("R"), 1.237);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 0.159", () => { it("V should equal to 0.159", () => {
checkResult(sect.Calc("V"), 0.159); checkResult(sect.CalcSection("V"), 0.159);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 0.037", () => { it("Fr should equal to 0.037", () => {
checkResult(sect.Calc("Fr"), 0.037); checkResult(sect.CalcSection("Fr"), 0.037);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 0.419", () => { it("Yc should equal to 0.419", () => {
checkResult(sect.Calc("Yc"), 0.419); checkResult(sect.CalcSection("Yc"), 0.419);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 0.742", () => { it("Yn should equal to 0.742", () => {
checkResult(sect.Calc("Yn"), 0.742); checkResult(sect.CalcSection("Yn"), 0.742);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 2", () => { it("Yf should equal to 2", () => {
checkResult(sect.Calc("Yf"), 2); checkResult(sect.CalcSection("Yf"), 2);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.178", () => { it("Yt should equal to 0.178", () => {
checkResult(sect.Calc("Yt"), 0.178); checkResult(sect.CalcSection("Yt"), 0.178);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 0.044", () => { it("Yco should equal to 0.044", () => {
checkResult(sect.Calc("Yco"), 0.044); checkResult(sect.CalcSection("Yco"), 0.044);
}); });
// perte de charge // perte de charge
it("J should equal to 0.00059", () => { it("J should equal to 0.00059", () => {
sect = createSection(0.00001); sect = createSection(0.00001);
checkResult(sect.Calc("J"), 0.00059); checkResult(sect.CalcSection("J"), 0.00059);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to 0.00041", () => { it("I-J should equal to 0.00041", () => {
sect = createSection(0.00001); sect = createSection(0.00001);
checkResult(sect.Calc("I-J"), 0.00041); checkResult(sect.CalcSection("I-J"), 0.00041);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 59384.242", () => { it("Imp should equal to 59384.242", () => {
checkResult(sect.Calc("Imp"), 59384.242); checkResult(sect.CalcSection("Imp"), 59384.242);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 0.145", () => { it("Tau0 should equal to 0.145", () => {
checkResult(sect.Calc("Tau0"), 0.145); checkResult(sect.CalcSection("Tau0"), 0.145);
}); });
}); });
}); });
...@@ -27,89 +27,89 @@ describe("Section paramétrée puissance :", () => { ...@@ -27,89 +27,89 @@ describe("Section paramétrée puissance :", () => {
describe("torrentiel / pas de débordement :", () => { describe("torrentiel / pas de débordement :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 2.2", () => { it("Hs should equal to 2.2", () => {
checkResult(sect.Calc("Hs"), 2.2); checkResult(sect.CalcSection("Hs"), 2.2);
}); });
// charge critique // charge critique
it("Hsc should equal to 1.616", () => { it("Hsc should equal to 1.616", () => {
checkResult(sect.Calc("Hsc"), 1.616); checkResult(sect.CalcSection("Hsc"), 1.616);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 3.578", () => { it("B should equal to 3.578", () => {
checkResult(sect.Calc("B"), 3.578); checkResult(sect.CalcSection("B"), 3.578);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 4.223", () => { it("P should equal to 4.223", () => {
checkResult(sect.Calc("P"), 4.223); checkResult(sect.CalcSection("P"), 4.223);
}); });
// surface mouillée // surface mouillée
it("S should equal to 1.908", () => { it("S should equal to 1.908", () => {
checkResult(sect.Calc("S"), 1.908); checkResult(sect.CalcSection("S"), 1.908);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 0.452", () => { it("R should equal to 0.452", () => {
checkResult(sect.Calc("R"), 0.452); checkResult(sect.CalcSection("R"), 0.452);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 5.241", () => { it("V should equal to 5.241", () => {
checkResult(sect.Calc("V"), 5.241); checkResult(sect.CalcSection("V"), 5.241);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 2.291", () => { it("Fr should equal to 2.291", () => {
checkResult(sect.Calc("Fr"), 2.291); checkResult(sect.CalcSection("Fr"), 2.291);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 1.186", () => { it("Yc should equal to 1.186", () => {
checkResult(sect.Calc("Yc"), 1.186); checkResult(sect.CalcSection("Yc"), 1.186);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 1.916", () => { it("Yn should equal to 1.916", () => {
checkResult(sect.Calc("Yn"), 1.916); checkResult(sect.CalcSection("Yn"), 1.916);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 2.126", () => { it("Yf should equal to 2.126", () => {
checkResult(sect.Calc("Yf"), 2.126); checkResult(sect.CalcSection("Yf"), 2.126);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.8", () => { it("Yt should equal to 0.8", () => {
checkResult(sect.Calc("Yt"), 0.8); checkResult(sect.CalcSection("Yt"), 0.8);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 1.746", () => { it("Yco should equal to 1.746", () => {
checkResult(sect.Calc("Yco"), 1.746); checkResult(sect.CalcSection("Yco"), 1.746);
}); });
// perte de charge // perte de charge
it("J should equal to 0.05", () => { it("J should equal to 0.05", () => {
// sect = createSection(0.00001); // sect = createSection(0.00001);
checkResult(sect.Calc("J"), 0.05); checkResult(sect.CalcSection("J"), 0.05);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to -0.049", () => { it("I-J should equal to -0.049", () => {
// sect = createSection(0.00001); // sect = createSection(0.00001);
checkResult(sect.Calc("I-J"), -0.049); checkResult(sect.CalcSection("I-J"), -0.049);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 58397.786", () => { it("Imp should equal to 58397.786", () => {
checkResult(sect.Calc("Imp"), 58397.786); checkResult(sect.CalcSection("Imp"), 58397.786);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 219.455", () => { it("Tau0 should equal to 219.455", () => {
checkResult(sect.Calc("Tau0"), 219.455); checkResult(sect.CalcSection("Tau0"), 219.455);
}); });
}); });
}); });
...@@ -23,13 +23,13 @@ describe("Section paramétrée rectangulaire : ", () => { ...@@ -23,13 +23,13 @@ describe("Section paramétrée rectangulaire : ", () => {
describe("non convergence de la méthode de Newton :", () => { describe("non convergence de la méthode de Newton :", () => {
it("hauteur critique", () => { it("hauteur critique", () => {
const r: Result = sect.Calc("Yc"); const r: Result = sect.CalcSection("Yc");
expect(r.log.messages.length).toEqual(1); expect(r.log.messages.length).toEqual(1);
expect(r.log.messages[0].code).toEqual(MessageCode.ERROR_SECTION_NON_CONVERGENCE_NEWTON_HCRITIQUE); expect(r.log.messages[0].code).toEqual(MessageCode.ERROR_SECTION_NON_CONVERGENCE_NEWTON_HCRITIQUE);
}); });
it("hauteur normale", () => { it("hauteur normale", () => {
const r: Result = sect.Calc("Yn"); const r: Result = sect.CalcSection("Yn");
// expect(r.log.messages.length).toEqual(2); // expect(r.log.messages.length).toEqual(2);
expect(r.ok).toBeFalsy("le calcul devrait avoir échoué"); expect(r.ok).toBeFalsy("le calcul devrait avoir échoué");
expect(r.log.messages.length).toEqual(1); expect(r.log.messages.length).toEqual(1);
...@@ -39,20 +39,20 @@ describe("Section paramétrée rectangulaire : ", () => { ...@@ -39,20 +39,20 @@ describe("Section paramétrée rectangulaire : ", () => {
it("hauteur normale, pente nulle", () => { it("hauteur normale, pente nulle", () => {
sect.prms.If.v = 0; sect.prms.If.v = 0;
const r: Result = sect.Calc("Yn"); const r: Result = sect.CalcSection("Yn");
expect(r.log.messages.length).toEqual(1); expect(r.log.messages.length).toEqual(1);
expect(r.log.messages[0].code).toEqual(MessageCode.ERROR_SECTION_PENTE_NEG_NULLE_HNORMALE_INF); expect(r.log.messages[0].code).toEqual(MessageCode.ERROR_SECTION_PENTE_NEG_NULLE_HNORMALE_INF);
}); });
it("hauteur normale, pente négative", () => { it("hauteur normale, pente négative", () => {
sect.prms.If.v = -0.001; sect.prms.If.v = -0.001;
const r: Result = sect.Calc("Yn"); const r: Result = sect.CalcSection("Yn");
expect(r.log.messages.length).toEqual(1); expect(r.log.messages.length).toEqual(1);
expect(r.log.messages[0].code).toEqual(MessageCode.ERROR_SECTION_PENTE_NEG_NULLE_HNORMALE_INF); expect(r.log.messages[0].code).toEqual(MessageCode.ERROR_SECTION_PENTE_NEG_NULLE_HNORMALE_INF);
}); });
it("hauteur fluviale, Y < Yc", () => { it("hauteur fluviale, Y < Yc", () => {
const r: Result = sect.Calc("Yf"); const r: Result = sect.CalcSection("Yf");
// expect(r.log.messages.length).toEqual(3); // expect(r.log.messages.length).toEqual(3);
expect(r.ok).toBeFalsy("le calcul devrait avoir échoué"); expect(r.ok).toBeFalsy("le calcul devrait avoir échoué");
expect(r.log.messages.length).toEqual(1); expect(r.log.messages.length).toEqual(1);
...@@ -63,20 +63,20 @@ describe("Section paramétrée rectangulaire : ", () => { ...@@ -63,20 +63,20 @@ describe("Section paramétrée rectangulaire : ", () => {
it("hauteur fluviale, Y > Yc", () => { it("hauteur fluviale, Y > Yc", () => {
sect.prms.Y.v = 2; sect.prms.Y.v = 2;
const r: Result = sect.Calc("Yf"); const r: Result = sect.CalcSection("Yf");
expect(r.log.messages.length).toEqual(1); expect(r.log.messages.length).toEqual(1);
expect(r.log.messages[0].code).toEqual(MessageCode.ERROR_SECTION_NON_CONVERGENCE_NEWTON_HCRITIQUE); expect(r.log.messages[0].code).toEqual(MessageCode.ERROR_SECTION_NON_CONVERGENCE_NEWTON_HCRITIQUE);
}); });
it("hauteur torrentielle, Y < Yc", () => { it("hauteur torrentielle, Y < Yc", () => {
const r: Result = sect.Calc("Yt"); const r: Result = sect.CalcSection("Yt");
expect(r.log.messages.length).toEqual(1); expect(r.log.messages.length).toEqual(1);
expect(r.log.messages[0].code).toEqual(MessageCode.ERROR_SECTION_NON_CONVERGENCE_NEWTON_HCRITIQUE); expect(r.log.messages[0].code).toEqual(MessageCode.ERROR_SECTION_NON_CONVERGENCE_NEWTON_HCRITIQUE);
}); });
it("hauteur torrentielle, Y > Yc", () => { it("hauteur torrentielle, Y > Yc", () => {
sect.prms.Y.v = 2; sect.prms.Y.v = 2;
const r: Result = sect.Calc("Yt"); const r: Result = sect.CalcSection("Yt");
// expect(r.log.messages.length).toEqual(2); // expect(r.log.messages.length).toEqual(2);
expect(r.ok).toBeFalsy("le calcul devrait avoir échoué"); expect(r.ok).toBeFalsy("le calcul devrait avoir échoué");
expect(r.log.messages.length).toEqual(1); expect(r.log.messages.length).toEqual(1);
...@@ -86,7 +86,7 @@ describe("Section paramétrée rectangulaire : ", () => { ...@@ -86,7 +86,7 @@ describe("Section paramétrée rectangulaire : ", () => {
it("hauteur conjuguée, Froude < 1", () => { it("hauteur conjuguée, Froude < 1", () => {
sect.prms.Y.v = 2; sect.prms.Y.v = 2;
const r: Result = sect.Calc("Yco"); const r: Result = sect.CalcSection("Yco");
// console.log(r.log.toString()); // console.log(r.log.toString());
// expect(r.log.messages.length).toEqual(3); // expect(r.log.messages.length).toEqual(3);
expect(r.ok).toBeFalsy("le calcul devrait avoir échoué"); expect(r.ok).toBeFalsy("le calcul devrait avoir échoué");
...@@ -97,7 +97,7 @@ describe("Section paramétrée rectangulaire : ", () => { ...@@ -97,7 +97,7 @@ describe("Section paramétrée rectangulaire : ", () => {
}); });
it("hauteur conjuguée, Froude > 1", () => { it("hauteur conjuguée, Froude > 1", () => {
const r: Result = sect.Calc("Yco"); const r: Result = sect.CalcSection("Yco");
// expect(r.log.messages.length).toEqual(4); // expect(r.log.messages.length).toEqual(4);
expect(r.ok).toBeFalsy("le calcul devrait avoir échoué"); expect(r.ok).toBeFalsy("le calcul devrait avoir échoué");
expect(r.log.messages.length).toEqual(1); expect(r.log.messages.length).toEqual(1);
......
...@@ -39,89 +39,89 @@ describe("Section paramétrée rectangulaire : ", () => { ...@@ -39,89 +39,89 @@ describe("Section paramétrée rectangulaire : ", () => {
describe("fluvial / pas de débordement :", () => { describe("fluvial / pas de débordement :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 0.818", () => { it("Hs should equal to 0.818", () => {
checkResult(sect.Calc("Hs"), 0.818); checkResult(sect.CalcSection("Hs"), 0.818);
}); });
// charge critique // charge critique
it("Hsc should equal to 0.43", () => { it("Hsc should equal to 0.43", () => {
checkResult(sect.Calc("Hsc"), 0.43); checkResult(sect.CalcSection("Hsc"), 0.43);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 2.5", () => { it("B should equal to 2.5", () => {
checkResult(sect.Calc("B"), 2.5); checkResult(sect.CalcSection("B"), 2.5);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 4.1", () => { it("P should equal to 4.1", () => {
checkResult(sect.Calc("P"), 4.1); checkResult(sect.CalcSection("P"), 4.1);
}); });
// surface mouillée // surface mouillée
it("S should equal to 2", () => { it("S should equal to 2", () => {
checkResult(sect.Calc("S"), 2); checkResult(sect.CalcSection("S"), 2);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 0.488", () => { it("R should equal to 0.488", () => {
checkResult(sect.Calc("R"), 0.488); checkResult(sect.CalcSection("R"), 0.488);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 0.6", () => { it("V should equal to 0.6", () => {
checkResult(sect.Calc("V"), 0.6); checkResult(sect.CalcSection("V"), 0.6);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 0.214", () => { it("Fr should equal to 0.214", () => {
checkResult(sect.Calc("Fr"), 0.214); checkResult(sect.CalcSection("Fr"), 0.214);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 0.286", () => { it("Yc should equal to 0.286", () => {
checkResult(sect.Calc("Yc"), 0.286); checkResult(sect.CalcSection("Yc"), 0.286);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 0.663", () => { it("Yn should equal to 0.663", () => {
checkResult(sect.Calc("Yn"), 0.663); checkResult(sect.CalcSection("Yn"), 0.663);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 0.8", () => { it("Yf should equal to 0.8", () => {
checkResult(sect.Calc("Yf"), 0.8); checkResult(sect.CalcSection("Yf"), 0.8);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.131", () => { it("Yt should equal to 0.131", () => {
checkResult(sect.Calc("Yt"), 0.131); checkResult(sect.CalcSection("Yt"), 0.131);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 0.068", () => { it("Yco should equal to 0.068", () => {
checkResult(sect.Calc("Yco"), 0.068); checkResult(sect.CalcSection("Yco"), 0.068);
}); });
// perte de charge // perte de charge
it("J should equal to 0.00059", () => { it("J should equal to 0.00059", () => {
sect = createSection(0.00001); sect = createSection(0.00001);
checkResult(sect.Calc("J"), 0.00059); checkResult(sect.CalcSection("J"), 0.00059);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to 0.00041", () => { it("I-J should equal to 0.00041", () => {
sect = createSection(0.00001); sect = createSection(0.00001);
checkResult(sect.Calc("I-J"), 0.00041); checkResult(sect.CalcSection("I-J"), 0.00041);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 8568", () => { it("Imp should equal to 8568", () => {
checkResult(sect.Calc("Imp"), 8568); checkResult(sect.CalcSection("Imp"), 8568);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 2.804", () => { it("Tau0 should equal to 2.804", () => {
checkResult(sect.Calc("Tau0"), 2.804); checkResult(sect.CalcSection("Tau0"), 2.804);
}); });
}); });
}); });
...@@ -134,89 +134,89 @@ describe("Section paramétrée rectangulaire : ", () => { ...@@ -134,89 +134,89 @@ describe("Section paramétrée rectangulaire : ", () => {
describe("fluvial / débordement :", () => { describe("fluvial / débordement :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 2.003", () => { it("Hs should equal to 2.003", () => {
checkResult(sect.Calc("Hs"), 2.003); checkResult(sect.CalcSection("Hs"), 2.003);
}); });
// charge critique // charge critique
it("Hsc should equal to 0.43", () => { it("Hsc should equal to 0.43", () => {
checkResult(sect.Calc("Hsc"), 0.43); checkResult(sect.CalcSection("Hsc"), 0.43);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 2.5", () => { it("B should equal to 2.5", () => {
checkResult(sect.Calc("B"), 2.5); checkResult(sect.CalcSection("B"), 2.5);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 6.5", () => { it("P should equal to 6.5", () => {
checkResult(sect.Calc("P"), 6.5); checkResult(sect.CalcSection("P"), 6.5);
}); });
// surface mouillée // surface mouillée
it("S should equal to 5", () => { it("S should equal to 5", () => {
checkResult(sect.Calc("S"), 5); checkResult(sect.CalcSection("S"), 5);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 0.769", () => { it("R should equal to 0.769", () => {
checkResult(sect.Calc("R"), 0.769); checkResult(sect.CalcSection("R"), 0.769);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 0.24", () => { it("V should equal to 0.24", () => {
checkResult(sect.Calc("V"), 0.24); checkResult(sect.CalcSection("V"), 0.24);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 0.0542", () => { it("Fr should equal to 0.0542", () => {
checkResult(sect.Calc("Fr"), 0.0542); checkResult(sect.CalcSection("Fr"), 0.0542);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 0.286", () => { it("Yc should equal to 0.286", () => {
checkResult(sect.Calc("Yc"), 0.286); checkResult(sect.CalcSection("Yc"), 0.286);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 0.663", () => { it("Yn should equal to 0.663", () => {
checkResult(sect.Calc("Yn"), 0.663); checkResult(sect.CalcSection("Yn"), 0.663);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 2", () => { it("Yf should equal to 2", () => {
checkResult(sect.Calc("Yf"), 2); checkResult(sect.CalcSection("Yf"), 2);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.078", () => { it("Yt should equal to 0.078", () => {
checkResult(sect.Calc("Yt"), 0.078); checkResult(sect.CalcSection("Yt"), 0.078);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 0.012", () => { it("Yco should equal to 0.012", () => {
checkResult(sect.Calc("Yco"), 0.012); checkResult(sect.CalcSection("Yco"), 0.012);
}); });
// perte de charge // perte de charge
it("J should equal to 0.00059", () => { it("J should equal to 0.00059", () => {
sect = createSection(0.00001); sect = createSection(0.00001);
checkResult(sect.Calc("J"), 0.00059); checkResult(sect.CalcSection("J"), 0.00059);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to 0.0009", () => { it("I-J should equal to 0.0009", () => {
sect = createSection(0.00001); sect = createSection(0.00001);
checkResult(sect.Calc("I-J"), 0.0009); checkResult(sect.CalcSection("I-J"), 0.0009);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 49338", () => { it("Imp should equal to 49338", () => {
checkResult(sect.Calc("Imp"), 49338); checkResult(sect.CalcSection("Imp"), 49338);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 0.385", () => { it("Tau0 should equal to 0.385", () => {
checkResult(sect.Calc("Tau0"), 0.385); checkResult(sect.CalcSection("Tau0"), 0.385);
}); });
}); });
}); });
...@@ -22,89 +22,89 @@ describe("Section paramétrée rectangulaire : ", () => { ...@@ -22,89 +22,89 @@ describe("Section paramétrée rectangulaire : ", () => {
describe("torrentiel :", () => { describe("torrentiel :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 2.074", () => { it("Hs should equal to 2.074", () => {
checkResult(sect.Calc("Hs"), 2.074); checkResult(sect.CalcSection("Hs"), 2.074);
}); });
// charge critique // charge critique
it("Hsc should equal to 1.766", () => { it("Hsc should equal to 1.766", () => {
checkResult(sect.Calc("Hsc"), 1.766); checkResult(sect.CalcSection("Hsc"), 1.766);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 2.5", () => { it("B should equal to 2.5", () => {
checkResult(sect.Calc("B"), 2.5); checkResult(sect.CalcSection("B"), 2.5);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 4.1", () => { it("P should equal to 4.1", () => {
checkResult(sect.Calc("P"), 4.1); checkResult(sect.CalcSection("P"), 4.1);
}); });
// surface mouillée // surface mouillée
it("S should equal to 2", () => { it("S should equal to 2", () => {
checkResult(sect.Calc("S"), 2); checkResult(sect.CalcSection("S"), 2);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 0.488", () => { it("R should equal to 0.488", () => {
checkResult(sect.Calc("R"), 0.488); checkResult(sect.CalcSection("R"), 0.488);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 5", () => { it("V should equal to 5", () => {
checkResult(sect.Calc("V"), 5); checkResult(sect.CalcSection("V"), 5);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 1.785", () => { it("Fr should equal to 1.785", () => {
checkResult(sect.Calc("Fr"), 1.785); checkResult(sect.CalcSection("Fr"), 1.785);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 1.177", () => { it("Yc should equal to 1.177", () => {
checkResult(sect.Calc("Yc"), 1.177); checkResult(sect.CalcSection("Yc"), 1.177);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 3.364", () => { it("Yn should equal to 3.364", () => {
checkResult(sect.Calc("Yn"), 3.364); checkResult(sect.CalcSection("Yn"), 3.364);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 1.831", () => { it("Yf should equal to 1.831", () => {
checkResult(sect.Calc("Yf"), 1.831); checkResult(sect.CalcSection("Yf"), 1.831);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.8", () => { it("Yt should equal to 0.8", () => {
checkResult(sect.Calc("Yt"), 0.8); checkResult(sect.CalcSection("Yt"), 0.8);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 1.659", () => { it("Yco should equal to 1.659", () => {
checkResult(sect.Calc("Yco"), 1.659); checkResult(sect.CalcSection("Yco"), 1.659);
}); });
// perte de charge // perte de charge
it("J should equal to 0.041", () => { it("J should equal to 0.041", () => {
// paramCnl.v.Prec = 0.00001; // paramCnl.v.Prec = 0.00001;
checkResult(sect.Calc("J"), 0.041); checkResult(sect.CalcSection("J"), 0.041);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to -0.04", () => { it("I-J should equal to -0.04", () => {
// paramCnl.v.Prec = 0.00001; // paramCnl.v.Prec = 0.00001;
checkResult(sect.Calc("I-J"), -0.04); checkResult(sect.CalcSection("I-J"), -0.04);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 57848", () => { it("Imp should equal to 57848", () => {
checkResult(sect.Calc("Imp"), 57848); checkResult(sect.CalcSection("Imp"), 57848);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 194.718", () => { it("Tau0 should equal to 194.718", () => {
checkResult(sect.Calc("Tau0"), 194.718); checkResult(sect.CalcSection("Tau0"), 194.718);
}); });
}); });
}); });
...@@ -41,88 +41,88 @@ describe("Section paramétrée trapèze : ", () => { ...@@ -41,88 +41,88 @@ describe("Section paramétrée trapèze : ", () => {
describe("fluvial / pas de débordement :", () => { describe("fluvial / pas de débordement :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 0.813", () => { it("Hs should equal to 0.813", () => {
checkResult(sect.Calc("Hs"), 0.813); checkResult(sect.CalcSection("Hs"), 0.813);
}); });
// charge critique // charge critique
it("Hsc should equal to 0.413", () => { it("Hsc should equal to 0.413", () => {
checkResult(sect.Calc("Hsc"), 0.413); checkResult(sect.CalcSection("Hsc"), 0.413);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 3.396", () => { it("B should equal to 3.396", () => {
checkResult(sect.Calc("B"), 3.396); checkResult(sect.CalcSection("B"), 3.396);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 4.334", () => { it("P should equal to 4.334", () => {
checkResult(sect.Calc("P"), 4.334); checkResult(sect.CalcSection("P"), 4.334);
}); });
// surface mouillée // surface mouillée
it("S should equal to 2.358", () => { it("S should equal to 2.358", () => {
checkResult(sect.Calc("S"), 2.358); checkResult(sect.CalcSection("S"), 2.358);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 0.544", () => { it("R should equal to 0.544", () => {
checkResult(sect.Calc("R"), 0.544); checkResult(sect.CalcSection("R"), 0.544);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 0.509", () => { it("V should equal to 0.509", () => {
checkResult(sect.Calc("V"), 0.509); checkResult(sect.CalcSection("V"), 0.509);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 0.195", () => { it("Fr should equal to 0.195", () => {
checkResult(sect.Calc("Fr"), 0.195); checkResult(sect.CalcSection("Fr"), 0.195);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 0.28", () => { it("Yc should equal to 0.28", () => {
checkResult(sect.Calc("Yc"), 0.28); checkResult(sect.CalcSection("Yc"), 0.28);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 0.587", () => { it("Yn should equal to 0.587", () => {
checkResult(sect.Calc("Yn"), 0.587); checkResult(sect.CalcSection("Yn"), 0.587);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 0.8", () => { it("Yf should equal to 0.8", () => {
checkResult(sect.Calc("Yf"), 0.8); checkResult(sect.CalcSection("Yf"), 0.8);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.127", () => { it("Yt should equal to 0.127", () => {
checkResult(sect.Calc("Yt"), 0.127); checkResult(sect.CalcSection("Yt"), 0.127);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 0.061", () => { it("Yco should equal to 0.061", () => {
checkResult(sect.Calc("Yco"), 0.061); checkResult(sect.CalcSection("Yco"), 0.061);
}); });
// perte de charge // perte de charge
it("J should equal to 0.00036", () => { it("J should equal to 0.00036", () => {
const sect2 = createSection(0.00001); const sect2 = createSection(0.00001);
checkResult(sect2.Calc("J"), 0.00036); checkResult(sect2.CalcSection("J"), 0.00036);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to 0.001", () => { it("I-J should equal to 0.001", () => {
checkResult(sect.Calc("I-J"), 0.001); checkResult(sect.CalcSection("I-J"), 0.001);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 9396.158", () => { it("Imp should equal to 9396.158", () => {
checkResult(sect.Calc("Imp"), 9396.158); checkResult(sect.CalcSection("Imp"), 9396.158);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 1.944", () => { it("Tau0 should equal to 1.944", () => {
checkResult(sect.Calc("Tau0"), 1.944); checkResult(sect.CalcSection("Tau0"), 1.944);
}); });
}); });
}); });
...@@ -135,88 +135,88 @@ describe("Section paramétrée trapèze : ", () => { ...@@ -135,88 +135,88 @@ describe("Section paramétrée trapèze : ", () => {
describe("fluvial / débordement :", () => { describe("fluvial / débordement :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 2.002", () => { it("Hs should equal to 2.002", () => {
checkResult(sect.Calc("Hs"), 2.002); checkResult(sect.CalcSection("Hs"), 2.002);
}); });
// charge critique // charge critique
it("Hsc should equal to 0.413", () => { it("Hsc should equal to 0.413", () => {
checkResult(sect.Calc("Hsc"), 0.413); checkResult(sect.CalcSection("Hsc"), 0.413);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 3.62", () => { it("B should equal to 3.62", () => {
checkResult(sect.Calc("B"), 3.62); checkResult(sect.CalcSection("B"), 3.62);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 6.792", () => { it("P should equal to 6.792", () => {
checkResult(sect.Calc("P"), 6.792); checkResult(sect.CalcSection("P"), 6.792);
}); });
// surface mouillée // surface mouillée
it("S should equal to 6.68", () => { it("S should equal to 6.68", () => {
checkResult(sect.Calc("S"), 6.68); checkResult(sect.CalcSection("S"), 6.68);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 0.983", () => { it("R should equal to 0.983", () => {
checkResult(sect.Calc("R"), 0.983); checkResult(sect.CalcSection("R"), 0.983);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 0.18", () => { it("V should equal to 0.18", () => {
checkResult(sect.Calc("V"), 0.18); checkResult(sect.CalcSection("V"), 0.18);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 0.042", () => { it("Fr should equal to 0.042", () => {
checkResult(sect.Calc("Fr"), 0.042); checkResult(sect.CalcSection("Fr"), 0.042);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 0.28", () => { it("Yc should equal to 0.28", () => {
checkResult(sect.Calc("Yc"), 0.28); checkResult(sect.CalcSection("Yc"), 0.28);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 0.587", () => { it("Yn should equal to 0.587", () => {
checkResult(sect.Calc("Yn"), 0.587); checkResult(sect.CalcSection("Yn"), 0.587);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 2", () => { it("Yf should equal to 2", () => {
checkResult(sect.Calc("Yf"), 2); checkResult(sect.CalcSection("Yf"), 2);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.077", () => { it("Yt should equal to 0.077", () => {
checkResult(sect.Calc("Yt"), 0.077); checkResult(sect.CalcSection("Yt"), 0.077);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 0.009", () => { it("Yco should equal to 0.009", () => {
checkResult(sect.Calc("Yco"), 0.009); checkResult(sect.CalcSection("Yco"), 0.009);
}); });
// perte de charge // perte de charge
it("J should equal to 0.00002", () => { it("J should equal to 0.00002", () => {
const sect2 = createSection(0.00001); const sect2 = createSection(0.00001);
checkResult(sect2.Calc("J"), 0.00002); checkResult(sect2.CalcSection("J"), 0.00002);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to 0.001", () => { it("I-J should equal to 0.001", () => {
checkResult(sect.Calc("I-J"), 0.001); checkResult(sect.CalcSection("I-J"), 0.001);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 63915.169", () => { it("Imp should equal to 63915.169", () => {
checkResult(sect.Calc("Imp"), 63915.169); checkResult(sect.CalcSection("Imp"), 63915.169);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 0.199", () => { it("Tau0 should equal to 0.199", () => {
checkResult(sect.Calc("Tau0"), 0.199); checkResult(sect.CalcSection("Tau0"), 0.199);
}); });
}); });
}); });
...@@ -23,88 +23,88 @@ describe("Section paramétrée trapèze :", () => { ...@@ -23,88 +23,88 @@ describe("Section paramétrée trapèze :", () => {
describe("torrentiel :", () => { describe("torrentiel :", () => {
// charge spécifique // charge spécifique
it("Hs should equal to 1.716", () => { it("Hs should equal to 1.716", () => {
checkResult(sect.Calc("Hs"), 1.716); checkResult(sect.CalcSection("Hs"), 1.716);
}); });
// charge critique // charge critique
it("Hsc should equal to 1.534", () => { it("Hsc should equal to 1.534", () => {
checkResult(sect.Calc("Hsc"), 1.534); checkResult(sect.CalcSection("Hsc"), 1.534);
}); });
// largeur au miroir // largeur au miroir
it("B should equal to 3.396", () => { it("B should equal to 3.396", () => {
checkResult(sect.Calc("B"), 3.396); checkResult(sect.CalcSection("B"), 3.396);
}); });
// périmètre mouillé // périmètre mouillé
it("P should equal to 4.334", () => { it("P should equal to 4.334", () => {
checkResult(sect.Calc("P"), 4.334); checkResult(sect.CalcSection("P"), 4.334);
}); });
// surface mouillée // surface mouillée
it("S should equal to 2.358", () => { it("S should equal to 2.358", () => {
checkResult(sect.Calc("S"), 2.358); checkResult(sect.CalcSection("S"), 2.358);
}); });
// rayon hydraulique // rayon hydraulique
it("R should equal to 0.544", () => { it("R should equal to 0.544", () => {
checkResult(sect.Calc("R"), 0.544); checkResult(sect.CalcSection("R"), 0.544);
}); });
// vitesse moyenne // vitesse moyenne
it("V should equal to 4.24", () => { it("V should equal to 4.24", () => {
checkResult(sect.Calc("V"), 4.24); checkResult(sect.CalcSection("V"), 4.24);
}); });
// nombre de Froude // nombre de Froude
it("Fr should equal to 1.625", () => { it("Fr should equal to 1.625", () => {
checkResult(sect.Calc("Fr"), 1.625); checkResult(sect.CalcSection("Fr"), 1.625);
}); });
// tirant d'eau critique // tirant d'eau critique
it("Yc should equal to 1.074", () => { it("Yc should equal to 1.074", () => {
checkResult(sect.Calc("Yc"), 1.074); checkResult(sect.CalcSection("Yc"), 1.074);
}); });
// tirant d'eau normal // tirant d'eau normal
it("Yn should equal to 2.275", () => { it("Yn should equal to 2.275", () => {
checkResult(sect.Calc("Yn"), 2.275); checkResult(sect.CalcSection("Yn"), 2.275);
}); });
// tirant d'eau fluvial // tirant d'eau fluvial
it("Yf should equal to 1.502", () => { it("Yf should equal to 1.502", () => {
checkResult(sect.Calc("Yf"), 1.502); checkResult(sect.CalcSection("Yf"), 1.502);
}); });
// tirant d'eau torrentiel // tirant d'eau torrentiel
it("Yt should equal to 0.8", () => { it("Yt should equal to 0.8", () => {
checkResult(sect.Calc("Yt"), 0.8); checkResult(sect.CalcSection("Yt"), 0.8);
}); });
// tirant d'eau conjugué // tirant d'eau conjugué
it("Yco should equal to 1.398", () => { it("Yco should equal to 1.398", () => {
checkResult(sect.Calc("Yco"), 1.398); checkResult(sect.CalcSection("Yco"), 1.398);
}); });
// perte de charge // perte de charge
it("J should equal to 0.025", () => { it("J should equal to 0.025", () => {
// paramCnl.v.Prec = 0.00001; // paramCnl.v.Prec = 0.00001;
checkResult(sect.Calc("J"), 0.025); checkResult(sect.CalcSection("J"), 0.025);
}); });
// Variation linéaire de l'énergie spécifique // Variation linéaire de l'énergie spécifique
it("I-J should equal to -0.024", () => { it("I-J should equal to -0.024", () => {
checkResult(sect.Calc("I-J"), -0.024); checkResult(sect.CalcSection("I-J"), -0.024);
}); });
// impulsion hydraulique // impulsion hydraulique
it("Imp should equal to 51187.203", () => { it("Imp should equal to 51187.203", () => {
checkResult(sect.Calc("Imp"), 51187.203); checkResult(sect.CalcSection("Imp"), 51187.203);
}); });
// force tractrice (contrainte de cisaillement) // force tractrice (contrainte de cisaillement)
it("Tau0 should equal to 135.020", () => { it("Tau0 should equal to 135.020", () => {
checkResult(sect.Calc("Tau0"), 135.020); checkResult(sect.CalcSection("Tau0"), 135.020);
}); });
}); });
}); });
import { ParamValueMode, SectionParametree, Session } from "../../src";
import { ConduiteDistrib, ConduiteDistribParams } from "../../src/cond_distri";
import { CourbeRemous, CourbeRemousParams, MethodeResolution } from "../../src/remous";
import { cSnCirc, ParamsSectionCirc } from "../../src/section/section_circulaire";
import { cSnTrapez, ParamsSectionTrapez } from "../../src/section/section_trapez";
import { Cloisons } from "../../src/structure/cloisons";
import { CloisonsParams } from "../../src/structure/cloisons_params";
import { Dever, DeverParams } from "../../src/structure/dever";
import { CreateStructure } from "../../src/structure/factory_structure";
import { LoiDebit } from "../../src/structure/structure_props";
import {
RectangularStructureParams,
StructureWeirSubmergedLarinier
} from "../../src/structure/structure_weir_submerged_larinier";
/**
* 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";
function createEnv() {
// create complex session
const dever: Dever = new Dever(
new DeverParams(
0, // rQ Débit total (m3/s)
102, // rZ1 Cote de l'eau amont (m)
2, // rBR Largeur du cours d'eau amont (m)
100 // rZR Cote du lit du cours d'eau amont (m)
),
false // debug
);
dever.addChild(CreateStructure(LoiDebit.TriangularTruncWeirFree, dever, false));
const cloisons: 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
);
const fente: StructureWeirSubmergedLarinier = new StructureWeirSubmergedLarinier(
new RectangularStructureParams(
0,
101,
102,
101.5,
0.2,
0.65
)
);
cloisons.addChild(fente);
const prmsCD = new ConduiteDistribParams(undefined, // débit Q
1.2, // diamètre D
0.6, // perte de charge J
100, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
const conduite = new ConduiteDistrib(prmsCD);
const prmsST = new ParamsSectionTrapez(2.5, // largeur de fond
0.56, // fruit
undefined, // tirant d'eau
40, // Ks=Strickler
2, // Q=Débit
0.001, // If=pente du fond
1, // YB= hauteur de berge
);
const sect = new cSnTrapez(prmsST);
const prem = new CourbeRemousParams(0.15, // Yamont = tirant amont
0.803, // Yaval = tirant aval
5, // Long= Longueur du bief
5, // Dx=Pas d'espace
);
const rem = new CourbeRemous(sect, prem, MethodeResolution.Trapezes);
const paramSection = new ParamsSectionCirc(2, // diamètre
0.8, // tirant d'eau
40, // Ks=Strickler
10, // Q=Débit
0.001, // If=pente du fond
1, // YB= hauteur de berge
);
const section = new cSnCirc(paramSection);
const sp = new SectionParametree(section);
Session.getInstance().clear();
Session.getInstance().registerNub(dever);
Session.getInstance().registerNub(cloisons);
Session.getInstance().registerNub(conduite);
Session.getInstance().registerNub(rem);
Session.getInstance().registerNub(sp);
}
describe("serialising / deserialising session - ", () => {
it ("serialized file should contain 5 Nubs", () => {
createEnv();
const session = Session.getInstance().serialise();
const js = JSON.parse(session);
expect(Object.keys(js)).toContain("session");
expect(js.session.length).toBe(5);
});
it ("reloading serialized file should give 5 Nubs", () => {
createEnv();
const session = Session.getInstance().serialise();
Session.getInstance().clear();
expect(Session.getInstance().getNumberOfNubs()).toBe(0);
Session.getInstance().unserialise(session);
expect(Session.getInstance().getNumberOfNubs()).toBe(5);
});
it("when saving a SectionParametree, the edited values should be present in the file", () => {
// d
const paramSection = new ParamsSectionCirc(
2, // diamètre
0.8, // tirant d'eau
40, // Ks=Strickler
10, // Q=Débit
0.001, // If=pente du fond
1, // YB= hauteur de berge
);
const section = new cSnCirc(paramSection);
const sp = new SectionParametree(section);
sp.section.prms.Ks.v = 42;
const serialised = sp.serialise();
expect(serialised).toContain('{"symbol":"Ks","mode":"SINGLE","value":42}');
});
it ("loaded serialized RegimeUniforme should be calculable", () => {
const fs = require("fs");
Session.getInstance().clear();
const session = fs.readFileSync(__dirname + "/../../../spec/session/session-RU.json", { encoding: "utf8" });
Session.getInstance().unserialise(session);
expect(Session.getInstance().getNumberOfNubs()).toBe(1);
const RU = Session.getInstance().findNubByUid("YTEwZG");
expect(RU).toBeDefined();
const calculatedParam = RU.calculatedParam;
expect(calculatedParam.symbol).toBe("Q");
let nbCalc = 0;
for (const p of RU.parameterIterator) {
if (p.valueMode === ParamValueMode.CALCUL) {
nbCalc++;
}
}
expect(nbCalc).toBe(1);
RU.CalcSerie();
expect(RU.result).toBeDefined();
});
it ("loaded serialized Ouvrages should be calculable", () => {
const fs = require("fs");
Session.getInstance().clear();
const session = fs.readFileSync(__dirname + "/../../../spec/session/session-OUV.json", { encoding: "utf8" });
Session.getInstance().unserialise(session);
expect(Session.getInstance().getNumberOfNubs()).toBe(1);
const OUV = Session.getInstance().findNubByUid("NGVzdz");
expect(OUV).toBeDefined();
const calculatedParam = OUV.calculatedParam;
expect(calculatedParam.symbol).toBe("L");
let nbCalc = 0;
for (const p of OUV.parameterIterator) {
if (p.valueMode === ParamValueMode.CALCUL) {
nbCalc++;
}
}
expect(nbCalc).toBe(1);
OUV.CalcSerie();
expect(OUV.result).toBeDefined();
expect(OUV.result.vCalc).toBeCloseTo(1.031);
});
});
{
"session": [
{
"uid": "NGVzdz",
"props": {
"calcType": 8,
"nodeType": 0
},
"meta": {
"title": "Ouvrages"
},
"children": [
{
"uid": "Z2F4dz",
"props": {
"calcType": 7,
"nodeType": 5,
"structureType": 1,
"loiDebit": 1
},
"children": [],
"parameters": [
{
"symbol": "ZDV",
"mode": "SINGLE",
"value": 100
},
{
"symbol": "W",
"mode": "SINGLE",
"value": 0.5
},
{
"symbol": "L",
"mode": "SINGLE",
"value": 2
},
{
"symbol": "Cd",
"mode": "SINGLE",
"value": 0.6
}
]
},
{
"uid": "ZDR4cX",
"props": {
"calcType": 7,
"nodeType": 5,
"structureType": 1,
"loiDebit": 1
},
"children": [],
"parameters": [
{
"symbol": "ZDV",
"mode": "SINGLE",
"value": 100
},
{
"symbol": "W",
"mode": "SINGLE",
"value": 0.5
},
{
"symbol": "L",
"mode": "CALCUL"
},
{
"symbol": "Cd",
"mode": "SINGLE",
"value": 0.6
}
]
}
],
"parameters": [
{
"symbol": "Pr",
"mode": "SINGLE",
"value": 0.0001
},
{
"symbol": "Q",
"mode": "SINGLE",
"value": 3.5
},
{
"symbol": "Z1",
"mode": "SINGLE",
"value": 102
},
{
"symbol": "Z2",
"mode": "SINGLE",
"value": 101.5
}
]
}
]
}
\ No newline at end of file
{"session":[{"uid":"YTEwZG","props":{"calcType":3,"nodeType":2},"meta":{"title":"R. uniforme"},"children":[{"uid":"NDcxN3","props":{"calcType":14,"nodeType":2},"children":[],"parameters":[{"symbol":"Pr","mode":"SINGLE","value":0.0001},{"symbol":"Ks","mode":"SINGLE","value":40},{"symbol":"Q","mode":"CALCUL"},{"symbol":"If","mode":"SINGLE","value":0.001},{"symbol":"YB","mode":"SINGLE","value":1},{"symbol":"Y","mode":"SINGLE","value":0.89},{"symbol":"LargeurBerge","mode":"SINGLE","value":2.5}]}],"parameters":[{"symbol":"Pr","mode":"SINGLE","value":0.0001}]}]}
\ No newline at end of file
...@@ -6,10 +6,11 @@ ...@@ -6,10 +6,11 @@
*/ */
// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine"; // import { describe, expect, it, xdescribe, xit } from "../mock_jasmine";
import { Cloisons, CloisonsParams } from "../../src/structure/cloisons"; import { Cloisons } from "../../src/structure/cloisons";
import { CloisonsParams } from "../../src/structure/cloisons_params";
import { CreateStructure } from "../../src/structure/factory_structure"; import { CreateStructure } from "../../src/structure/factory_structure";
import { StructureKiviParams } from "../../src/structure/structure_kivi"; import { StructureKiviParams } from "../../src/structure/structure_kivi";
import { LoiDebit, StructureType } from "../../src/structure/structure_props"; import { LoiDebit } from "../../src/structure/structure_props";
// tslint:disable-next-line:max-line-length // tslint:disable-next-line:max-line-length
import { RectangularStructureParams, StructureWeirSubmergedLarinier } from "../../src/structure/structure_weir_submerged_larinier"; import { RectangularStructureParams, StructureWeirSubmergedLarinier } from "../../src/structure/structure_weir_submerged_larinier";
import { testParallelStructures } from "./functions"; import { testParallelStructures } from "./functions";
...@@ -37,7 +38,7 @@ const fente: StructureWeirSubmergedLarinier = new StructureWeirSubmergedLarinier ...@@ -37,7 +38,7 @@ const fente: StructureWeirSubmergedLarinier = new StructureWeirSubmergedLarinier
) )
); );
cloisons.addStructure(fente); cloisons.addChild(fente);
describe("Class Cloisons: ", () => { describe("Class Cloisons: ", () => {
describe("Calc(Q) Fente noyée (Larinier 1992)", () => { describe("Calc(Q) Fente noyée (Larinier 1992)", () => {
...@@ -62,23 +63,18 @@ describe("Class Cloisons: ", () => { ...@@ -62,23 +63,18 @@ describe("Class Cloisons: ", () => {
); );
// Ajout d'une structure de chaque type dans Cloisons // Ajout d'une structure de chaque type dans Cloisons
const iStTypes: StructureType[] = [
StructureType.Orifice,
StructureType.SeuilRectangulaire,
StructureType.SeuilRectangulaire
];
const iLoiDebits: LoiDebit[] = [ const iLoiDebits: LoiDebit[] = [
LoiDebit.OrificeSubmerged, LoiDebit.OrificeSubmerged,
LoiDebit.WeirSubmergedLarinier, LoiDebit.WeirSubmergedLarinier,
LoiDebit.KIVI LoiDebit.KIVI
]; ];
for (let i = 0; i < 3; i++ ) { for (let i = 0; i < 3; i++ ) {
c2.addStructure(CreateStructure(iStTypes[i], iLoiDebits[i], c2, false)); c2.addChild(CreateStructure(iLoiDebits[i], c2, false));
} }
const prmsKivi: StructureKiviParams = c2.structures[2].prms as StructureKiviParams; const prmsKivi: StructureKiviParams = c2.structures[2].prms as StructureKiviParams;
prmsKivi.ZRAM.v = 0; prmsKivi.ZRAM.v = 0;
testParallelStructures(c2, iStTypes, iLoiDebits); testParallelStructures(c2, iLoiDebits);
describe("Calcul de ZRAM de l'équation KIVI", () => { describe("Calcul de ZRAM de l'équation KIVI", () => {
it("ZRAM should be 101", () => { it("ZRAM should be 101", () => {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import { Dever, DeverParams } from "../../src/structure/dever"; import { Dever, DeverParams } from "../../src/structure/dever";
import { CreateStructure } from "../../src/structure/factory_structure"; import { CreateStructure } from "../../src/structure/factory_structure";
import { LoiDebit, StructureType } from "../../src/structure/structure_props"; import { LoiDebit } from "../../src/structure/structure_props";
const dever: Dever = new Dever( const dever: Dever = new Dever(
new DeverParams( new DeverParams(
...@@ -20,8 +20,7 @@ const dever: Dever = new Dever( ...@@ -20,8 +20,7 @@ const dever: Dever = new Dever(
false // debug false // debug
); );
dever.addStructure(CreateStructure(StructureType.SeuilTriangulaireTrunc, dever.addChild(CreateStructure(LoiDebit.TriangularTruncWeirFree, dever, false));
LoiDebit.TriangularTruncWeirFree, dever, false));
describe("Class Dever: ", () => { describe("Class Dever: ", () => {
describe("Calc(Q) Seuil Triangulaire Trunc", () => { describe("Calc(Q) Seuil Triangulaire Trunc", () => {
......
...@@ -9,7 +9,7 @@ import { MessageCode } from "../../src/index"; ...@@ -9,7 +9,7 @@ import { MessageCode } from "../../src/index";
import { ParamCalculability } from "../../src/param/param-definition"; import { ParamCalculability } from "../../src/param/param-definition";
import { ParallelStructure } from "../../src/structure/parallel_structure"; import { ParallelStructure } from "../../src/structure/parallel_structure";
import { Structure, StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure"; import { Structure, StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { LoiDebit, StructureType } from "../../src/structure/structure_props"; import { loiAdmissiblesOuvrages, LoiDebit } from "../../src/structure/structure_props";
import { Result } from "../../src/util/result"; import { Result } from "../../src/util/result";
import { precDigits } from "../test_config"; import { precDigits } from "../test_config";
import { checkResult } from "../test_func"; import { checkResult } from "../test_func";
...@@ -92,12 +92,12 @@ export function testStructure( ...@@ -92,12 +92,12 @@ export function testStructure(
* @param iStTypes Liste ordonnée des types des ouvrages à tester * @param iStTypes Liste ordonnée des types des ouvrages à tester
* @param iLoiDebits Liste ordonnée des lois de débit à tester * @param iLoiDebits Liste ordonnée des lois de débit à tester
*/ */
export function testParallelStructures(oPS: ParallelStructure, iStTypes: number[], iLoiDebits: number[]) { export function testParallelStructures(oPS: ParallelStructure, iLoiDebits: number[]) {
oPS.prms.Q.v = oPS.Calc("Q").vCalc; oPS.prms.Q.v = oPS.Calc("Q").vCalc;
for (let i = 0; i < oPS.structures.length; i++) { for (let i = 0; i < oPS.structures.length; i++) {
const st: Structure = oPS.structures[i]; const st: Structure = oPS.structures[i];
describe(`this.structures[${i}]: ${StructureType[iStTypes[i]]} Structure${LoiDebit[iLoiDebits[i]]}: `, () => { describe(`this.structures[${i}]: Structure${LoiDebit[iLoiDebits[i]]}: `, () => {
// Tests sur les résultats complémentaires // Tests sur les résultats complémentaires
it(`Calc(Q).extraResults[${i}.Q] should return ${oPS.structures[i].Calc("Q").vCalc}`, () => { it(`Calc(Q).extraResults[${i}.Q] should return ${oPS.structures[i].Calc("Q").vCalc}`, () => {
expect( expect(
...@@ -125,7 +125,7 @@ export function testParallelStructures(oPS: ParallelStructure, iStTypes: number[ ...@@ -125,7 +125,7 @@ export function testParallelStructures(oPS: ParallelStructure, iStTypes: number[
).toThrow(new Error("Structure:Calc : Calcul de W impossible sur un seuil")); ).toThrow(new Error("Structure:Calc : Calcul de W impossible sur un seuil"));
}); });
} else if ( } else if (
iStTypes[i] === StructureType.VanneRectangulaire && loiAdmissiblesOuvrages.VanneRectangulaire.includes(iLoiDebits[i]) &&
!oPS.structures[i].isZDVcalculable && !oPS.structures[i].isZDVcalculable &&
prm.symbol === "ZDV" prm.symbol === "ZDV"
) { ) {
......
...@@ -27,8 +27,8 @@ const pstruct: ParallelStructure = new ParallelStructure( ...@@ -27,8 +27,8 @@ const pstruct: ParallelStructure = new ParallelStructure(
* Tests avec deux structures test identiques * Tests avec deux structures test identiques
*/ */
pstruct.addStructure(structTest); pstruct.addChild(structTest);
pstruct.addStructure(structTest); pstruct.addChild(structTest);
describe("Class ParallelStructure: ", () => { describe("Class ParallelStructure: ", () => {
describe("Calc()", () => { describe("Calc()", () => {
...@@ -104,10 +104,10 @@ describe("Class ParallelStructure: ", () => { ...@@ -104,10 +104,10 @@ describe("Class ParallelStructure: ", () => {
const iStTypes: number[] = []; const iStTypes: number[] = [];
for (const s of EnumEx.getValues(StructureType)) { for (const s of EnumEx.getValues(StructureType)) {
for (const la of loiAdmissiblesOuvrages[StructureType[s]]) { for (const la of loiAdmissiblesOuvrages[StructureType[s]]) {
ps2.addStructure(CreateStructure(s, la, ps2, false)); ps2.addChild(CreateStructure(la, ps2, false));
iLoiDebits.push(la); iLoiDebits.push(la);
iStTypes.push(s); iStTypes.push(s);
} }
} }
testParallelStructures(ps2, iStTypes, iLoiDebits); testParallelStructures(ps2, iLoiDebits);
}); });
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* décommenter la ligne suivante (import { expect } from "./mock_jasmine") dans le cas d'une fonction * décommenter la ligne suivante (import { expect } from "./mock_jasmine") dans le cas d'une fonction
* qui utilise la fonction expect() de Jasmine mais qui doit être exécutée en dehors de tests Jasmine * qui utilise la fonction expect() de Jasmine mais qui doit être exécutée en dehors de tests Jasmine
*/ */
// import { expect } from "./mock_jasmine"; import { expect } from "./mock_jasmine";
import { cLog } from "../src/util/log"; import { cLog } from "../src/util/log";
import { Message, MessageCode } from "../src/util/message"; import { Message, MessageCode } from "../src/util/message";
......
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