Commit 9cd7b933 authored by Dorchies David's avatar Dorchies David
Browse files

Merge branch...

Merge branch '31-ajouter-la-cote-de-radier-et-travailler-avec-la-cote-de-l-eau-sur-les-ouvrages' into '36-definition-du-stockage-des-resultats-complementaires'

Resolve "Ajouter la cote de radier et travailler avec la cote de l'eau sur les ouvrages"

See merge request cassiopee/jalhyd!5
Showing with 169 additions and 247 deletions
+169 -247
// tslint:disable:no-console
/**
* Mock fonction describe de Jasmine
* @param sTxt Texte de la suite de test
* @param fFun Fonction de la suite de test
*/
export function describe(sTxt: string, fFun: () => void) {
// tslint:disable-next-line:no-console
console.log(sTxt);
fFun();
}
......@@ -15,7 +15,6 @@ export function describe(sTxt: string, fFun: () => void) {
* @param fFun Fonction de la suite de test
*/
export function xdescribe(sTxt: string, fFun: () => void) {
// tslint:disable-next-line:no-console
console.log(sTxt + " ignored ***");
}
......@@ -25,7 +24,6 @@ export function xdescribe(sTxt: string, fFun: () => void) {
* @param fFun Function à lancer pour la spec
*/
export function it(sTxt: string, fFun: () => void) {
// tslint:disable-next-line:no-console
console.log(sTxt);
fFun();
}
......@@ -52,7 +50,6 @@ class Expect {
const delta = Math.abs(expected - this.actual);
const maxDelta = Math.pow(10, -precision) / 2;
if (Math.round(delta * pow) / pow > maxDelta) {
// tslint:disable-next-line:no-console
console.error("Expected " + this.actual + " to be close to " + expected + "," + precision);
}
return this;
......@@ -64,8 +61,9 @@ class Expect {
*/
public toBe(expected: any) {
const res = this.actual === expected;
if (!res)
if (!res) {
console.error("Error : expected " + this.actual + " to be " + expected);
}
return res;
}
......@@ -75,8 +73,9 @@ class Expect {
*/
public toEqual(expected: any) {
const res = this.actual === expected;
if (!res)
console.error("Error : expected " + this.actual + " to be equal to " + expected);
if (!res) {
console.warn("Warning : test 'to be equal to' not tested");
}
return res;
}
......@@ -85,8 +84,9 @@ class Expect {
* @param message message d'erreur
*/
public toBeTruthy(message: string) {
if (!this.actual)
if (!this.actual) {
console.error(message);
}
}
/**
......@@ -94,8 +94,9 @@ class Expect {
* @param message message d'erreur
*/
public toBeFalsy(message: string) {
if (this.actual)
if (this.actual) {
console.error(message);
}
}
}
......
// tslint:disable-next-line:no-reference
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/**
* IMPORTANT !
* Décommenter temporairement la ligne suivante (import { } from "./mock_jasmine")
* Pour exécuter ce code dans le débugger.
*/
// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { Result } from "../../src/util/result";
import { RectangularStructure } from "../../src/structure/rectangular_structure";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { Result } from "../../src/util/result";
import { precDigits } from "../test_config";
/**
......@@ -23,27 +27,27 @@ export class Describer {
}
export function itCalcQ(
struct: RectangularStructure, h1: number, W: number, Q: number,
struct: RectangularStructure, Z1: number, W: number, Q: number,
mode?: StructureFlowMode, regime?: StructureFlowRegime) {
struct.debug("itCalQ " + Describer.getName(struct) + " h1=" + h1 + " W=" + W + " Q=" + Q);
struct.debug("itCalQ " + Describer.getName(struct) + " Z1=" + Z1 + " W=" + W + " Q=" + Q);
struct.prms.h1.v = h1;
struct.prms.Z1.v = Z1;
struct.prms.W.v = W;
const res: Result = struct.Calc("Q");
struct.debug("struct.Calc(Q)=" + res.vCalc);
it("Q(h1=" + h1 + ",W=" + W + ") should be " + Q, () => {
it("Q(Z1=" + Z1 + ",W=" + W + ") should be " + Q, () => {
struct.debug("struct.Calc(Q)=" + res.vCalc);
expect(res.vCalc).toBeCloseTo(Q, precDigits);
});
if (mode !== undefined) {
it("Q(h1=" + h1 + ",W=" + W + ") Mode should be " + mode, () => {
it("Q(Z1=" + Z1 + ",W=" + W + ") Mode should be " + mode, () => {
expect(res.extraVar.Mode).toBe(mode);
});
}
if (regime !== undefined) {
it("Q(h1=" + h1 + ",W=" + W + ") Regime should be " + regime, () => {
it("Q(Z1=" + Z1 + ",W=" + W + ") Regime should be " + regime, () => {
expect(res.extraVar.Regime).toBe(regime);
});
}
......
// tslint:disable-next-line:no-reference
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/**
* 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 } from "../mock_jasmine";
import { Result } from "../../src/util/result";
import { Structure, StructureFlowMode, StructureFlowRegime, StructureParams } from "../../src/structure/structure";
import { Result } from "../../src/util/result";
import { checkResult } from "../test_func";
class StructureTest extends Structure {
......@@ -15,6 +20,7 @@ class StructureTest extends Structure {
* Test of getFlowMode
*/
public testGetFlowMode() {
this.prms.update_h1h2();
return this.getFlowMode();
}
......@@ -22,24 +28,19 @@ class StructureTest extends Structure {
* Test of getFlowRegime
*/
public testGetFlowRegime() {
this.prms.update_h1h2();
return this.getFlowRegime();
}
public Equation(sVarCalc: string): Result {
let v: number;
switch (sVarCalc) {
case "Q":
v = this.prms.h1.v - this.prms.h2.v;
break;
default:
throw new Error("StructureTest.Equation() : invalid parameter name " + sVarCalc);
}
return new Result(v);
this.prms.update_h1h2();
this.CheckEquation(sVarCalc);
return new Result(this.prms.Z1.v - this.prms.Z2.v);
}
}
const structTestPrm: StructureParams = new StructureParams(1, 30, 15);
const structTestPrm: StructureParams = new StructureParams(1, 0, 30, 15);
const structTest: StructureTest = new StructureTest(structTestPrm, false);
describe("Class Structure: ", () => {
......@@ -60,30 +61,30 @@ describe("Class Structure: ", () => {
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.FREE);
});
it("Flow Regime should be SUBMERGED (WEIR)", () => {
structTest.prms.h2.v = 21;
structTest.prms.Z2.v = 21;
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.SUBMERGED);
});
it("Flow Regime should be PARTIAL (ORIFICE)", () => {
structTest.prms.h2.v = 21;
structTest.prms.Z2.v = 21;
structTest.prms.W.v = 15;
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.PARTIAL);
});
it("Flow Regime should be SUBMERGED (ORIFICE)", () => {
structTest.prms.h2.v = 25;
structTest.prms.Z2.v = 25;
structTest.prms.W.v = 15;
expect(structTest.testGetFlowRegime()).toBe(StructureFlowRegime.SUBMERGED);
});
structTest.prms.h2.v = 15;
structTest.prms.Z2.v = 15;
structTest.prms.W.v = Infinity;
});
describe("Calc()", () => {
const flagsNull = { Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL };
it("h1=h2 => Q=0", () => {
structTest.prms.h2.v = structTest.prms.h1.v;
structTest.prms.Z2.v = structTest.prms.Z1.v;
checkResult(structTest.Calc("Q"), 0);
expect(structTest.Calc("Q").extraVar).toEqual(flagsNull);
structTest.prms.h2.v = 15;
structTest.prms.Z2.v = 15;
});
it("W=0 => Q=0", () => {
structTest.prms.W.v = 0;
......
// tslint:disable-next-line:no-reference
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/**
* 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 rectangular_structure.ts
*/
// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureCem88d } from "../../src/structure/structure_cem88d";
import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureCem88d = new StructureCem88d(structPrm, false);
describe("Class StructureCem88d: ", () => {
......
// tslint:disable-next-line:no-reference
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/**
* 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 rectangular_structure.ts
*/
// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureCem88v } from "../../src/structure/structure_cem88v";
import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureCem88v = new StructureCem88v(structPrm, false);
describe("Class StructureCem88v: ", () => {
......
// tslint:disable-next-line:no-reference
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/**
* 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 rectangular_structure.ts
*/
// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureCunge80 } from "../../src/structure/structure_cunge80";
import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureCunge80 = new StructureCunge80(structPrm, false);
describe("Class StructureCunge80: ", () => {
......
// tslint:disable-next-line:no-reference
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/**
* 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 rectangular_structure.ts
*/
// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureOrificeFree } from "../../src/structure/structure_orifice_free";
import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureOrificeFree = new StructureOrificeFree(structPrm, false);
describe("Class StructureOrificeFree: ", () => {
......
// tslint:disable-next-line:no-reference
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/**
* 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 rectangular_structure.ts
*/
// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureOrificeSubmerged } from "../../src/structure/structure_orifice_submerged";
import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureOrificeSubmerged = new StructureOrificeSubmerged(structPrm, false);
describe("Class StructureOrificeSubmerged: ", () => {
......
// tslint:disable-next-line:no-reference
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
/**
* 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 rectangular_structure.ts
*/
// import { describe, expect, it, xdescribe } from "../mock_jasmine";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureWeirFree } from "../../src/structure/structure_weir_free";
import { Result } from "../../src/util/result";
import { itCalcQ } from "./rectangular_structure";
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 0, 1, 1, 2, 0.6, 0);
const structTest: StructureWeirFree = new StructureWeirFree(structPrm, false);
describe("Class StructureWeirFree: ", () => {
......
import { Result } from "../../src/util/result";
import { RectangularStructure } from "../../src/structure/rectangular_structure";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { expect, it } from "../mock_jasmine";
import { precDigits } from "../test_config";
import { Describer } from "./rectangular_structure";
export function itCalcQ(
struct: RectangularStructure, h1: number, W: number, Q: number,
mode?: StructureFlowMode, regime?: StructureFlowRegime) {
struct.debug("itCalQ " + Describer.getName(struct) + " h1=" + h1 + " W=" + W + " Q=" + Q);
struct.prms.h1.v = h1;
struct.prms.W.v = W;
const res: Result = struct.Calc("Q");
struct.debug("struct.Calc(Q)=" + res.vCalc);
it("Q(h1=" + h1 + ",W=" + W + ") should be " + Q, () => {
struct.debug("struct.Calc(Q)=" + res.vCalc);
expect(res.vCalc).toBeCloseTo(Q, precDigits);
});
if (mode !== undefined) {
it("Q(h1=" + h1 + ",W=" + W + ") Mode should be " + mode, () => {
expect(res.extraVar.Mode).toBe(mode);
});
}
if (regime !== undefined) {
it("Q(h1=" + h1 + ",W=" + W + ") Regime should be " + regime, () => {
expect(res.extraVar.Regime).toBe(regime);
});
}
}
import { RectangularStructureParams, StructureCem88d } from "../../src/structure/structure_cem88d";
import { describe, xdescribe } from "../mock_jasmine";
import { itCalcQ } from "./test_rectangular_structure";
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
const structTest: StructureCem88d = new StructureCem88d(structPrm, true);
describe("Class StructureCem88d: ", () => {
describe("Calcul Q avec W croissant: ", () => {
const W: number[] = [0.000000, 0.100000, 0.200000, 0.300000, 0.400000, 0.500000,
0.600000, 0.700000, 0.800000, 0.900000, 1.000000, 1.100000, 1.200000, 1.300000];
const h1: number = 1.200000;
const Q: number[] = [0.000000, 0.617586, 1.235173, 1.852759, 2.470345, 3.087931, 3.705518,
4.296608, 4.831177, 5.302464, 5.700445, 6.007777, 6.175863, 6.175863];
for (let i = 0; i < Q.length; i++) {
itCalcQ(structTest, h1, W[i], Q[i]);
}
});
describe("Calcul Q en charge avec h1 croissant: ", () => {
const W: number = 0.8;
const h1: number[] = [1.050000, 1.300000, 1.500000];
const Q: number[] = [2.470345, 5.684601, 6.651906];
for (let i = 0; i < Q.length; i++) {
itCalcQ(structTest, h1[i], W, Q[i]);
}
});
describe("Calcul Q a surface libre avec h1 croissant: ", () => {
const W: number = Infinity;
const h1: number[] = [1.100000, 1.500000];
const Q: number[] = [4.366994, 9.764896];
for (let i = 0; i < Q.length; i++) {
itCalcQ(structTest, h1[i], W, Q[i]);
}
});
});
import { RectangularStructureParams, StructureCem88v } from "../../src/structure/structure_cem88v";
import { describe, xdescribe } from "../mock_jasmine";
import { itCalcQ } from "./test_rectangular_structure";
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
const structTest: StructureCem88v = new StructureCem88v(structPrm, true);
describe("Class StructureCem88v: ", () => {
describe("Calcul Q avec W croissant: ", () => {
const W: number[] = [0.000000, 0.100000, 0.200000, 0.300000, 0.400000, 0.500000, 0.600000,
0.700000, 0.800000, 0.900000, 1.000000, 1.100000, 1.200000, 1.300000];
const h1: number = 1.200000;
const Q: number[] = [.000000, 0.328260, 0.641822, 0.823867, 1.117381, 1.720738,
2.225472, 2.575336, 2.873893, 3.113250, 3.280545, 3.349403, 3.149324, 3.149324];
for (let i = 0; i < Q.length; i++) {
itCalcQ(structTest, h1, W[i], Q[i]);
}
});
xdescribe("Calcul Q en charge avec h1 croissant: ", () => {
const W: number = 0.8;
const h1: number[] = [1.05, 1.3, 1.5];
const Q: number[] = [1.365897, 3.623277, 4.214572];
for (let i = 0; i < Q.length; i++) {
itCalcQ(structTest, h1[i], W, Q[i]);
}
});
xdescribe("Calcul Q a surface libre avec h1 croissant: ", () => {
const W: number = Infinity;
const h1: number[] = [1.100000, 1.500000];
const Q: number[] = [2.086781, 5.207945];
for (let i = 0; i < Q.length; i++) {
itCalcQ(structTest, h1[i], W, Q[i]);
}
});
});
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureCunge80 } from "../../src/structure/structure_cunge80";
import { describe, xdescribe } from "../mock_jasmine";
import { itCalcQ } from "./test_rectangular_structure";
const structPrm: RectangularStructureParams = new RectangularStructureParams(1, 1, 1, 2, 0.6, 0);
const structTest: StructureCunge80 = new StructureCunge80(structPrm, true);
describe("Class StructureCunge80: ", () => {
describe("Calcul Q avec W croissant: ", () => {
const W: number[] = [
0.000000, 0.100000, 0.200000, 0.300000, 0.400000, 0.500000, 0.600000,
0.700000, 0.800000, 0.900000, 1.000000, 1.100000, 1.200000, 1.300000];
const h1: number = 1.200000;
const Q: number[] = [0.000000, 0.237709, 0.475418, 0.713127, 0.950836, 1.188545,
1.426254, 1.663963, 1.901673, 2.139382, 2.377091, 2.377091, 2.377091, 2.377091];
for (let i = 0; i < Q.length; i++) {
itCalcQ(structTest, h1, W[i], Q[i]);
}
});
describe("Calcul Q en charge avec h1 croissant: ", () => {
const W: number = 0.8;
const h1: number[] = [1.050000, 1.300000, 1.500000];
const Q: number[] = [0.950836, 2.329064, 3.557704];
const mode: StructureFlowMode[] = [
StructureFlowMode.ORIFICE, StructureFlowMode.ORIFICE, StructureFlowMode.ORIFICE];
const regime: StructureFlowRegime[] = [
StructureFlowRegime.SUBMERGED, StructureFlowRegime.SUBMERGED, StructureFlowRegime.FREE];
for (let i = 0; i < Q.length; i++) {
itCalcQ(structTest, h1[i], W, Q[i], mode[i], regime[i]);
}
});
describe("Calcul Q a surface libre avec h1 croissant: ", () => {
const W: number = Infinity;
const h1: number[] = [1.100000, 1.500000];
const Q: number[] = [1.680857, 3.758510];
const mode: StructureFlowMode[] = [
StructureFlowMode.WEIR, StructureFlowMode.WEIR];
const regime: StructureFlowRegime[] = [
StructureFlowRegime.SUBMERGED, StructureFlowRegime.FREE];
for (let i = 0; i < Q.length; i++) {
itCalcQ(structTest, h1[i], W, Q[i], mode[i], regime[i]);
}
});
});
......@@ -3,13 +3,13 @@
* 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
*/
//import { expect } from "./mock_jasmine"
// import { describe, expect, it, xdescribe } from "./mock_jasmine";
import { cLog } from "../src/util/log";
import { Message, MessageCode } from "../src/util/message";
import { precDist } from "./test_config";
import { Result } from "../src/util/result";
import { precDigits } from "./test_config"
import { precDist } from "./test_config";
import { precDigits } from "./test_config";
/**
* Compare deux valeurs réelles à un epsilon près
......@@ -140,7 +140,7 @@ export function compareLog(logTest: cLog, logValid: cLog) {
// clés des données
for (const j in m1.extraVar) {
for (let j = 0; j < m1.extraVar.length; j++) {
b = m2.extraVar[j] !== undefined;
expect(b).toBeTruthy(
"journal : message n°" + i + ", code " + code1 + " : la donnée " + j + "=" + m1.extraVar[j]
......@@ -148,7 +148,7 @@ export function compareLog(logTest: cLog, logValid: cLog) {
// if (!b) return;
}
for (const j in m2.extraVar) {
for (let j = 0; j < m2.extraVar.length; j++) {
b = m1.extraVar[j] !== undefined;
expect(b).toBeTruthy(
"journal : message n°" + i + ", code " + code1 + " : la donnée " + j + "=" + m2.extraVar[j]
......@@ -158,7 +158,7 @@ export function compareLog(logTest: cLog, logValid: cLog) {
// type des données
for (const j in m1.extraVar) {
for (let j = 0; j < m1.extraVar.length; j++) {
b = typeof m1.extraVar[j] === typeof m2.extraVar[j];
expect(b).toBeTruthy(
"journal : " + i + "ieme message, code " + code1 + " : la donnée " + j + "=" + m1.extraVar[j]
......@@ -169,7 +169,7 @@ export function compareLog(logTest: cLog, logValid: cLog) {
// valeur des données
for (const j in m1.extraVar) {
for (let j = 0; j < m1.extraVar.length; j++) {
const d: any = m1.extraVar[j];
if (typeof d === "number") {
b = equalEpsilon(d, m2.extraVar[j]);
......@@ -184,7 +184,7 @@ export function compareLog(logTest: cLog, logValid: cLog) {
}
}
export function checkResult(val1: Result, val2: number, prec: number = undefined) {
export function checkResult(val1: Result, val2: number, prec?: number) {
expect(val1.ok).toBeTruthy("Result : computation error on Result " + val1.toString());
if (val1.ok) {
/*
......@@ -195,8 +195,9 @@ export function checkResult(val1: Result, val2: number, prec: number = undefined
* valeur attendue 1.301
* valeur calculée 1.3016, arrondie à 1.302, faisant échouer le test
*/
if (prec == undefined)
if (prec === undefined) {
prec = Math.max(0, precDigits - 1);
}
expect(val1.vCalc).toBeCloseTo(val2, prec);
}
......
......@@ -12,8 +12,18 @@ export class RectangularStructureParams extends StructureParams {
/** Discharge coefficient */
public Cd: ParamDefinition;
constructor(rQ: number, rh1: number, rh2: number, rL: number, rCd: number, rW: number = Infinity) {
super(rQ, rh1, rh2, rW);
/**
* Constructeur d'une structure rectangulaire
* @param rQ Débit (m3/s)
* @param rZDV Cote de la crête du déversoir ou du radier de la vanne (m)
* @param rZ1 Cote de l'eau amont (m)
* @param rZ2 Cote de l'eau aval (m)
* @param rL Largeur de la vanne ou du déversoir (m)
* @param rCd Coefficient de débit (-)
* @param rW Ouverture de la vanne (m) (Valeur par défaut +infinity pour les déversoirs)
*/
constructor(rQ: number, rZDV: number, rZ1: number, rZ2: number, rL: number, rCd: number, rW: number = Infinity) {
super(rQ, rZDV, rZ1, rZ2, rW);
this.L = new ParamDefinition(ComputeNodeType.CondDistri, "L", ParamDomainValue.POS, rL);
this.addParamDefinition(this.L);
this.Cd = new ParamDefinition(ComputeNodeType.CondDistri, "Cd", ParamDomainValue.POS, rCd);
......
import { Result } from "../util/result";
import { Nub } from "../nub";
import { ParamCalculability } from "../param";
import { Message } from "../util/message";
import { Result } from "../util/result";
import { StructureParams } from "./structure_params";
......@@ -57,13 +57,6 @@ export abstract class Structure extends Nub {
*/
public abstract Equation(sVarCalc: string): Result;
protected defaultResultData() {
return {
Mode: this.getFlowMode(),
Regime: this.getFlowRegime()
};
}
/**
* Calcul d'une équation quelque soit l'inconnue à calculer.
* Gestion du débit nul et de l'inversion de débit
......@@ -72,8 +65,11 @@ export abstract class Structure extends Nub {
* @param rPrec précision de calcul
*/
public Calc(sVarCalc: string, rInit: number = 0, rPrec: number = 0.001): Result {
const flagsNull = {Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL};
// Mise à jour de h1 et h2
this.prms.update_h1h2();
// Gestion du débit nul
const flagsNull = {Mode: StructureFlowMode.NULL, Regime: StructureFlowRegime.NULL};
if (sVarCalc === "Q") {
if (this.prms.h1.v === this.prms.h2.v || this.prms.W.v <= 0) {
return new Result(0, flagsNull);
......@@ -102,8 +98,15 @@ export abstract class Structure extends Nub {
return res;
}
// Calcul normal hors débit nul et inversion de débit
return super.Calc(sVarCalc, rInit, rPrec);
}
protected defaultResultData() {
return {
Mode: this.getFlowMode(),
Regime: this.getFlowRegime(),
};
}
/**
......@@ -111,8 +114,11 @@ export abstract class Structure extends Nub {
*/
protected setParametersCalculability() {
this.prms.Q.calculability = ParamCalculability.EQUATION;
this.prms.h1.calculability = ParamCalculability.DICHO;
this.prms.h2.calculability = ParamCalculability.DICHO;
this.prms.ZDV.calculability = ParamCalculability.DICHO;
this.prms.Z1.calculability = ParamCalculability.DICHO;
this.prms.Z2.calculability = ParamCalculability.DICHO;
this.prms.h1.calculability = ParamCalculability.FREE;
this.prms.h2.calculability = ParamCalculability.FREE;
this.prms.W.calculability = ParamCalculability.DICHO;
}
......
import { Result } from "../util/result";
import { Nub } from "../nub";
import { ComputeNodeType, ParamDefinition, ParamDomain, ParamDomainValue, ParamsEquation } from "../param";
import { Message } from "../util/message";
import { ComputeNodeType, ParamDefinition, ParamDomainValue, ParamsEquation } from "../param";
/**
* Common parameters of hydraulic structure equations
*/
export class StructureParams extends ParamsEquation {
/** Débit */
/** Débit (m3/s) */
public Q: ParamDefinition;
/** Tirant d'eau amont */
/** Cote de la crête du déversoir ou du radier de la vanne (m) */
public ZDV: ParamDefinition;
/** Cote de l'eau amont (m) */
public Z1: ParamDefinition;
/** Cote de l'eau aval (m) */
public Z2: ParamDefinition;
/** Tirant d'eau amont (m) */
public h1: ParamDefinition;
/** Tirant d'eau aval */
/** Tirant d'eau aval (m) */
public h2: ParamDefinition;
/** Ouverture de la vanne
......@@ -24,19 +31,34 @@ export class StructureParams extends ParamsEquation {
/**
* Paramètres communs à toutes les équations de structure
* @param rQ Débit (m3/s)
* @param rh1 Hauteur amont au dessus de la crête (m)
* @param rh2 Hauteur aval au dessus de la crête (m)
* @param rZDV Cote de la crête du déversoir ou du radier de la vanne (m)
* @param rZ1 Cote de l'eau amont (m)
* @param rZ2 Cote de l'eau aval (m)
* @param rW Ouverture de vanne (m) (infinity pour un seuil)
*/
constructor(rQ: number, rh1: number, rh2: number, rW: number = Infinity ) {
constructor(rQ: number, rZDV: number, rZ1: number, rZ2: number, rW: number = Infinity ) {
super();
this.Q = new ParamDefinition(ComputeNodeType.CondDistri, "Q", ParamDomainValue.POS_NULL, rQ);
this.addParamDefinition(this.Q);
this.h1 = new ParamDefinition(ComputeNodeType.CondDistri, "h1", ParamDomainValue.POS_NULL, rh1);
this.ZDV = new ParamDefinition(ComputeNodeType.CondDistri, "ZDV", ParamDomainValue.POS_NULL, rZDV);
this.addParamDefinition(this.ZDV);
this.Z1 = new ParamDefinition(ComputeNodeType.CondDistri, "Z1", ParamDomainValue.POS_NULL, rZ1);
this.addParamDefinition(this.Z1);
this.Z2 = new ParamDefinition(ComputeNodeType.CondDistri, "Z2", ParamDomainValue.POS_NULL, rZ2);
this.addParamDefinition(this.Z2);
this.h1 = new ParamDefinition(ComputeNodeType.CondDistri, "h1", ParamDomainValue.POS_NULL,
Math.max(0, this.Z1.v - this.ZDV.v));
this.addParamDefinition(this.h1);
this.h2 = new ParamDefinition(ComputeNodeType.CondDistri, "h2", ParamDomainValue.POS_NULL, rh2);
this.h2 = new ParamDefinition(ComputeNodeType.CondDistri, "h2", ParamDomainValue.POS_NULL,
Math.max(0, this.Z2.v - this.ZDV.v));
this.addParamDefinition(this.h2);
this.W = new ParamDefinition(ComputeNodeType.CondDistri, "W", ParamDomainValue.POS_NULL, rW);
this.addParamDefinition(this.W);
}
/** Mise à jour des paramètres h1 et h2 à partir de Z1, Z2 et ZDV */
public update_h1h2() {
this.h1.v = Math.max(0, this.Z1.v - this.ZDV.v);
this.h2.v = Math.max(0, this.Z2.v - this.ZDV.v);
}
}
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