Commit f0dcb283 authored by Mathias Chouet's avatar Mathias Chouet 🍝
Browse files

Merge branch '32-ajout-de-l-outil-prebarrage' into 'devel'

Resolve "Ajout de l'outil "Prébarrage""

See merge request cassiopee/jalhyd!65
parents 3b43433c fccbcfbe
......@@ -110,15 +110,15 @@
"dev": true
},
"@types/jasmine": {
"version": "3.5.13",
"resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.5.13.tgz",
"integrity": "sha512-bVSrTEWdCNH2RHN+E0QlEr4pGPMRA6puKOmL/X13ZeZmUS0q12ZR1rkB9PVvJSX0zi/OXrMDNvUai+PC380+rQ==",
"version": "3.5.14",
"resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.5.14.tgz",
"integrity": "sha512-Fkgk536sHPqcOtd+Ow+WiUNuk0TSo/BntKkF8wSvcd6M2FvPjeXcUE6Oz/bwDZiUZEaXLslAgw00Q94Pnx6T4w==",
"dev": true
},
"@types/node": {
"version": "14.6.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.0.tgz",
"integrity": "sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA==",
"version": "14.6.4",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.6.4.tgz",
"integrity": "sha512-Wk7nG1JSaMfMpoMJDKUsWYugliB2Vy55pdjLpmLixeyMi7HizW2I/9QoxsPCkXl3dO+ZOVqPumKaDUv5zJu2uQ==",
"dev": true
},
"ansi-regex": {
......@@ -715,6 +715,29 @@
"is-glob": "^4.0.0",
"merge2": "^1.2.3",
"micromatch": "^3.1.10"
},
"dependencies": {
"glob-parent": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz",
"integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=",
"dev": true,
"requires": {
"is-glob": "^3.1.0",
"path-dirname": "^1.0.0"
},
"dependencies": {
"is-glob": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz",
"integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=",
"dev": true,
"requires": {
"is-extglob": "^2.1.0"
}
}
}
}
}
},
"fill-range": {
......@@ -833,27 +856,6 @@
"path-is-absolute": "^1.0.0"
}
},
"glob-parent": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz",
"integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=",
"dev": true,
"requires": {
"is-glob": "^3.1.0",
"path-dirname": "^1.0.0"
},
"dependencies": {
"is-glob": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz",
"integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=",
"dev": true,
"requires": {
"is-extglob": "^2.1.0"
}
}
}
},
"glob-to-regexp": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz",
......@@ -935,9 +937,9 @@
}
},
"highlight.js": {
"version": "10.1.2",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.1.2.tgz",
"integrity": "sha512-Q39v/Mn5mfBlMff9r+zzA+gWxRsCRKwEMvYTiisLr/XUiFI/4puWt0Ojdko3R3JCNWGdOWaA5g/Yxqa23kC5AA==",
"version": "10.2.0",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.2.0.tgz",
"integrity": "sha512-OryzPiqqNCfO/wtFo619W+nPYALM6u7iCQkum4bqRmmlcTikOkmlL06i009QelynBPAlNByTQU6cBB2cOBQtCw==",
"dev": true
},
"hosted-git-info": {
......@@ -2456,42 +2458,51 @@
}
},
"typedoc": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.18.0.tgz",
"integrity": "sha512-UgDQwapCGQCCdYhEQzQ+kGutmcedklilgUGf62Vw6RdI29u6FcfAXFQfRTiJEbf16aK3YnkB20ctQK1JusCRbA==",
"version": "0.19.1",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.19.1.tgz",
"integrity": "sha512-EqZpRJQUnkwHA1yBhaDExEXUZIiWKddkrDXhRcfUzpnu6pizxNmVTw5IZ3mu682Noa4zQCniE0YNjaAwHQodrA==",
"dev": true,
"requires": {
"fs-extra": "^9.0.1",
"handlebars": "^4.7.6",
"highlight.js": "^10.0.0",
"lodash": "^4.17.15",
"lunr": "^2.3.8",
"lodash": "^4.17.20",
"lunr": "^2.3.9",
"marked": "^1.1.1",
"minimatch": "^3.0.0",
"progress": "^2.0.3",
"semver": "^7.3.2",
"shelljs": "^0.8.4",
"typedoc-default-themes": "^0.10.2"
"typedoc-default-themes": "^0.11.1"
},
"dependencies": {
"semver": {
"version": "7.3.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz",
"integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==",
"dev": true
}
}
},
"typedoc-default-themes": {
"version": "0.10.2",
"resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.10.2.tgz",
"integrity": "sha512-zo09yRj+xwLFE3hyhJeVHWRSPuKEIAsFK5r2u47KL/HBKqpwdUSanoaz5L34IKiSATFrjG5ywmIu98hPVMfxZg==",
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.11.1.tgz",
"integrity": "sha512-1yl8pbhjrLywqGJx9TfT+wzP+ntudPYjgJdpCj+s5ed2etBkqZPOCBMKwpaN9o6pdoFQF195PggqWTLVEkaRQQ==",
"dev": true,
"requires": {
"lunr": "^2.3.8"
"lunr": "^2.3.9"
}
},
"typescript": {
"version": "3.7.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz",
"integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==",
"version": "3.9.7",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz",
"integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==",
"dev": true
},
"uglify-js": {
"version": "3.10.2",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.10.2.tgz",
"integrity": "sha512-GXCYNwqoo0MbLARghYjxVBxDCnU0tLqN7IPLdHHbibCb1NI5zBkU2EPcy/GaVxc0BtTjqyGXJCINe6JMR2Dpow==",
"version": "3.10.4",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.10.4.tgz",
"integrity": "sha512-kBFT3U4Dcj4/pJ52vfjCSfyLyvG9VYYuGYPmrPvAxRw/i7xHiT4VvCev+uiEMcEEiu6UNB6KgWmGtSUYIWScbw==",
"dev": true,
"optional": true
},
......@@ -2638,9 +2649,9 @@
"dev": true
},
"yargs": {
"version": "15.4.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",
"integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",
"version": "15.3.1",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-15.3.1.tgz",
"integrity": "sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==",
"dev": true,
"requires": {
"cliui": "^6.0.0",
......@@ -2653,7 +2664,7 @@
"string-width": "^4.2.0",
"which-module": "^2.0.0",
"y18n": "^4.0.0",
"yargs-parser": "^18.1.2"
"yargs-parser": "^18.1.1"
}
},
"yargs-parser": {
......
......@@ -41,8 +41,8 @@
"base-64": "^0.1.0"
},
"devDependencies": {
"@types/jasmine": "^3.5.13",
"@types/node": "^14.6.0",
"@types/jasmine": "^3.5.14",
"@types/node": "^14.6.4",
"buffer": "^5.6.0",
"find": "^0.3.0",
"jasmine": "^3.6.1",
......@@ -54,8 +54,8 @@
"rimraf": "^3.0.2",
"ts-node": "^8.10.2",
"tslint": "^6.1.3",
"typedoc": "^0.18.0",
"typescript": "~3.7.5"
"typedoc": "^0.19.1",
"typescript": "^3.9.7"
},
"scripts": {
"preprocess": "node scripts/preprocessors.js",
......
......@@ -42,7 +42,10 @@ const nubsNotTested: CalculatorType[] = [
CalculatorType.Solveur,
CalculatorType.YAXN,
CalculatorType.Verificateur,
CalculatorType.Espece
CalculatorType.Espece,
CalculatorType.PbBassin,
CalculatorType.PbCloison,
CalculatorType.PreBarrage // TODO: Add special treatments for creating fuzzy PreBarrage
];
const nubsWithStructures: CalculatorType[] = [
......
......@@ -106,8 +106,7 @@ describe("Class ParSimulation −", () => {
// regime: ParFlowRegime.FREE
message: MessageCode.WARNING_PAR_NOT_SUBMERGED
},
{
Z1: 14, // (dans Cv3, "calcul" est "off", sous-entendant que le calcul a raté ? Mais il y a tout de même des valeurs…)
{ Z1: 14, // (dans Cv3, "calcul" est "off", sous-entendant que le calcul a raté ? Mais il y a tout de même des valeurs…)
/* vCalc: 0.549,
h: 0.937,
ha: 4.64,
......
This diff is collapsed.
......@@ -33,6 +33,14 @@ import { RectangularStructure } from "../../src/structure/rectangular_structure"
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { LoiDebit } from "../../src/structure/structure_props";
import { StructureWeirSubmergedLarinier, } from "../../src/structure/structure_weir_submerged_larinier";
import { PreBarrage } from "../../src/prebarrage/pre_barrage";
import { PbCloison } from "../../src/prebarrage/pb_cloison";
import { PreBarrageParams } from "../../src/prebarrage/pre_barrage_params";
import { PbBassin } from "../../src/prebarrage/pb_bassin";
import { PbBassinParams } from "../../src/prebarrage/pb_bassin_params";
import { TriangularStructureParams } from "../../src/structure/structure_triangular_weir_params";
import { StructureOrificeFreeParams } from "../../src/structure/structure_orifice_free_params";
import { TriangularTruncStructureParams } from "../../src/structure/structure_triangular_trunc_weir_params";
import { StructureJetType } from "../../src/structure/structure";
import { CloisonsAvalParams } from "../../src/pab/cloison_aval_params";
......@@ -48,6 +56,7 @@ import { sessionSolveurLast } from "./session.solveur.last";
import { sessionSpaghetti } from "./session.spaghetti";
import { sessionVerificateurLast } from "./session.verificateur.last";
import { sessionVerificateurFirst } from "./session.verificateur.first";
import { Structure } from "../../src/structure/structure";
let dever: Dever;
let cloisons: Cloisons;
......@@ -442,6 +451,166 @@ describe("sessions containing Solveur - ", () => {
expect(sp4.symbol).toBe("Z1");
expect(sp4.parentNub.uid).toBe("NjRvcG");
});
});
describe("PreBarrage - ", () => {
it("serialise", () => {
const pb = new PreBarrage(new PreBarrageParams(1, 100, 90));
pb.addChild(new PbCloison(undefined, undefined)); // amont-aval
const b1 = new PbBassin(new PbBassinParams(0.1, 42));
pb.addChild(b1);
pb.addChild(new PbCloison(undefined, b1)); // amont-B1
const b2 = new PbBassin(new PbBassinParams(0.15, 38));
const c2 = new PbCloison(undefined, b2); // amont-B2
const s1: Structure = CreateStructure(LoiDebit.WeirCunge80);
s1.prms.ZDV.singleValue = 95.30;
s1.getParameter("L").singleValue = 0.4;
s1.getParameter("CdGR").singleValue = 1.04;
c2.addChild(s1);
pb.addChild(c2);
pb.addChild(b2);
pb.addChild(new PbCloison(b1, b2)); // B1-B2
pb.addChild(new PbCloison(b2, undefined)); // B2-aval
Session.getInstance().clear();
Session.getInstance().registerNub(pb);
const json = Session.getInstance().serialise();
expect(json).toContain(`"props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":""}`);
// check that no parameter is in CALC mode in children
const calcCount = (json.match(/"mode":"CALCUL"/g) || []).length;
expect(calcCount).toBe(1);
});
it("unserialise", () => {
Session.getInstance().clear();
const json = `{ "header": { "source": "jalhyd", "format_version": "1.3", "created": "2020-06-29T07:58:18.237Z" }, "settings": { "precision": 1e-7, "maxIterations": 100, "displayPrecision": 3 }, "documentation": "", "session": [ { "uid": "bG5oYW", "props": { "calcType": "PreBarrage" }, "meta": { "title": "Prébarrages" }, "children": [ { "uid": "a3c1eH", "props": { "calcType": "PbCloison", "upstreamBasin": "", "downstreamBasin": "" }, "children": [ { "uid": "bHdvOW", "props": { "calcType": "Structure", "structureType": "SeuilRectangulaire", "loiDebit": "WeirSubmergedLarinier" }, "children": [], "parameters": [ { "symbol": "ZDV", "mode": "SINGLE", "value": 101.11 }, { "symbol": "L", "mode": "SINGLE", "value": 0.211 }, { "symbol": "CdWSL", "mode": "SINGLE", "value": 0.7511 } ] } ], "parameters": [ { "symbol": "Q", "mode": "SINGLE" }, { "symbol": "Z1", "mode": "SINGLE", "value": 0 }, { "symbol": "Z2", "mode": "SINGLE", "value": 0 } ] }, { "uid": "M3AxbT", "props": { "calcType": "PbBassin" }, "children": [], "parameters": [ { "symbol": "S", "mode": "SINGLE", "value": 0.111 }, { "symbol": "ZF", "mode": "SINGLE", "value": 42.11 } ] }, { "uid": "bjRzNG", "props": { "calcType": "PbCloison", "upstreamBasin": "", "downstreamBasin": "M3AxbT" }, "children": [ { "uid": "MGYycm", "props": { "calcType": "Structure", "structureType": "SeuilTriangulaire", "loiDebit": "TriangularWeirBroad" }, "children": [], "parameters": [ { "symbol": "ZDV", "mode": "SINGLE", "value": 101.22 }, { "symbol": "alpha2", "mode": "SINGLE", "value": 45.22 }, { "symbol": "CdT", "mode": "SINGLE", "value": 1.3622 } ] } ], "parameters": [ { "symbol": "Q", "mode": "SINGLE" }, { "symbol": "Z1", "mode": "SINGLE", "value": 0 }, { "symbol": "Z2", "mode": "SINGLE", "value": 0 } ] }, { "uid": "OTg1en", "props": { "calcType": "PbCloison", "upstreamBasin": "", "downstreamBasin": "d2kxcD" }, "children": [ { "uid": "Ym1qZH", "props": { "calcType": "Structure", "structureType": "Orifice", "loiDebit": "OrificeFree" }, "children": [], "parameters": [ { "symbol": "S", "mode": "SINGLE", "value": 0.133 }, { "symbol": "CdO", "mode": "SINGLE", "value": 0.733 }, { "symbol": "Zco", "mode": "SINGLE", "value": 101.33 } ] } ], "parameters": [ { "symbol": "Q", "mode": "SINGLE" }, { "symbol": "Z1", "mode": "SINGLE", "value": 0 }, { "symbol": "Z2", "mode": "SINGLE", "value": 0 } ] }, { "uid": "d2kxcD", "props": { "calcType": "PbBassin" }, "children": [], "parameters": [ { "symbol": "S", "mode": "SINGLE", "value": 0.1522 }, { "symbol": "ZF", "mode": "SINGLE", "value": 38.22 } ] }, { "uid": "Z3J2cD", "props": { "calcType": "PbCloison", "upstreamBasin": "M3AxbT", "downstreamBasin": "d2kxcD" }, "children": [ { "uid": "aHpubT", "props": { "calcType": "Structure", "structureType": "VanneRectangulaire", "loiDebit": "RectangularOrificeSubmerged" }, "children": [], "parameters": [ { "symbol": "ZDV", "mode": "SINGLE", "value": 101.44 }, { "symbol": "W", "mode": "SINGLE", "value": 0.544 }, { "symbol": "L", "mode": "SINGLE", "value": 0.244 }, { "symbol": "CdGR", "mode": "SINGLE", "value": 0.644 } ] } ], "parameters": [ { "symbol": "Q", "mode": "SINGLE" }, { "symbol": "Z1", "mode": "SINGLE", "value": 0 }, { "symbol": "Z2", "mode": "SINGLE", "value": 0 } ] }, { "uid": "anQ0Zn", "props": { "calcType": "PbCloison", "upstreamBasin": "d2kxcD", "downstreamBasin": "" }, "children": [ { "uid": "ZzJtan", "props": { "calcType": "Structure", "structureType": "VanneRectangulaire", "loiDebit": "GateCunge80" }, "children": [], "parameters": [ { "symbol": "ZDV", "mode": "SINGLE", "value": 101.55 }, { "symbol": "W", "mode": "SINGLE", "value": 0.555 }, { "symbol": "L", "mode": "SINGLE", "value": 0.255 }, { "symbol": "CdCunge", "mode": "SINGLE", "value": 1.55 } ] } ], "parameters": [ { "symbol": "Q", "mode": "SINGLE" }, { "symbol": "Z1", "mode": "SINGLE", "value": 0 }, { "symbol": "Z2", "mode": "SINGLE", "value": 0 } ] } ], "parameters": [ { "symbol": "Q", "mode": "SINGLE", "value": 1.0101 }, { "symbol": "Z1", "mode": "CALCUL" }, { "symbol": "Z2", "mode": "SINGLE", "value": 90.0101 } ] } ] }`;
const res = Session.getInstance().unserialise(json);
expect(res.hasErrors).toBe(false);
const pb = Session.getInstance().findNubByUid("bG5oYW") as PreBarrage;
expect(pb).toBeDefined();
expect(pb.children.length).toBe(7); // 2 basins, 5 walls
expect(pb.bassins.length).toBe(2);
// paramètres de la rivière
expect(pb.prms.Q.singleValue).toBe(1.0101);
expect(pb.prms.Z2.singleValue).toBe(90.0101);
expect(pb.prms.Z1.valueMode).toBe(ParamValueMode.CALCUL);
expect(pb.calculatedParam.symbol).toBe("Z1");
const b1: PbBassin = pb.findChild("M3AxbT") as PbBassin;
expect(b1.prms.S.singleValue).toBe(0.111);
expect(b1.prms.ZF.singleValue).toBe(42.11);
const b2: PbBassin = pb.findChild("d2kxcD") as PbBassin;
expect(b2.prms.S.singleValue).toBe(0.1522);
expect(b2.prms.ZF.singleValue).toBe(38.22);
const c1: PbCloison = pb.findChild("a3c1eH") as PbCloison; // amont-aval
expect(c1.bassinAmont).toBeUndefined();
expect(c1.bassinAval).toBeUndefined();
expect(c1.structures.length).toBe(1);
expect(c1.structures[0].properties.getPropValue("loiDebit")).toBe(LoiDebit.WeirSubmergedLarinier);
const s1 = c1.structures[0].prms as RectangularStructureParams;
expect(s1.ZDV.singleValue).toBe(101.11);
expect(s1.L.singleValue).toBe(0.211);
expect(s1.CdWSL.singleValue).toBe(0.7511);
const c2: PbCloison = pb.findChild("bjRzNG") as PbCloison; // amont-B1
expect(c2.bassinAmont).toBeUndefined();
expect(c2.bassinAval.uid).toBe("M3AxbT");
expect(c2.structures.length).toBe(1);
expect(c2.structures[0].properties.getPropValue("loiDebit")).toBe(LoiDebit.TriangularWeirBroad);
const s2 = c2.structures[0].prms as TriangularStructureParams;
expect(s2.ZDV.singleValue).toBe(101.22);
expect(s2.CdT.singleValue).toBe(1.3622);
expect(s2.alpha2.singleValue).toBe(45.22);
const c3: PbCloison = pb.findChild("OTg1en") as PbCloison; // amont-B2
expect(c3.bassinAmont).toBeUndefined();
expect(c3.bassinAval.uid).toBe("d2kxcD");
expect(c3.structures.length).toBe(1);
expect(c3.structures[0].properties.getPropValue("loiDebit")).toBe(LoiDebit.OrificeFree);
const s3 = c3.structures[0].prms as StructureOrificeFreeParams;
expect(s3.S.singleValue).toBe(0.133);
expect(s3.CdO.singleValue).toBe(0.733);
expect(s3.Zco.singleValue).toBe(101.33);
const c4: PbCloison = pb.findChild("Z3J2cD") as PbCloison; // B1-B2
expect(c4.bassinAmont.uid).toBe("M3AxbT");
expect(c4.bassinAval.uid).toBe("d2kxcD");
expect(c4.structures.length).toBe(1);
expect(c4.structures[0].properties.getPropValue("loiDebit")).toBe(LoiDebit.RectangularOrificeSubmerged);
const s4 = c4.structures[0].prms as RectangularStructureParams;
expect(s4.ZDV.singleValue).toBe(101.44);
expect(s4.L.singleValue).toBe(0.244);
expect(s4.W.singleValue).toBe(0.544);
expect(s4.CdGR.singleValue).toBe(0.644);
const c5: PbCloison = pb.findChild("anQ0Zn") as PbCloison; // B2-aval
expect(c5.bassinAmont.uid).toBe("d2kxcD");
expect(c5.bassinAval).toBeUndefined();
expect(c5.structures.length).toBe(1);
expect(c5.structures[0].properties.getPropValue("loiDebit")).toBe(LoiDebit.GateCunge80);
const s5 = c5.structures[0].prms as RectangularStructureParams;
expect(s5.ZDV.singleValue).toBe(101.55);
expect(s5.L.singleValue).toBe(0.255);
expect(s5.W.singleValue).toBe(0.555);
expect(s5.CdCunge.singleValue).toBe(1.55);
// calculate
const resPb = pb.CalcSerie();
expect(resPb).toBeDefined();
});
it("unserialise multiple times", () => {
Session.getInstance().clear();
const json = `{"header":{"source":"jalhyd","format_version":"1.3","created":"2020-07-03T11:58:35.049Z"},"settings":{"precision":1e-7,"maxIterations":100,"displayPrecision":3},"documentation":"","session":[{"uid":"YmZ6eW","props":{"calcType":"PreBarrage"},"meta":{"title":"Prébarrages"},"children":[{"uid":"ZW8yaX","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":13.8},{"symbol":"ZF","mode":"SINGLE","value":95}]},{"uid":"bXkwZW","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"ZW8yaX"},"children":[{"uid":"cmw3eH","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.3},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]},{"uid":"OHV2cH","props":{"calcType":"PbCloison","upstreamBasin":"ZW8yaX","downstreamBasin":""},"children":[{"uid":"OGM3bm","props":{"calcType":"Structure","loiDebit":"WeirCunge80","structureType":"SeuilRectangulaire"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":95.3},{"symbol":"L","mode":"SINGLE","value":0.4},{"symbol":"CdCunge","mode":"SINGLE","value":1}]}],"parameters":[]}],"parameters":[{"symbol":"Q","mode":"SINGLE","value":1},{"symbol":"Z1","mode":"CALCUL"},{"symbol":"Z2","mode":"SINGLE","value":100}]}]}`;
// unserialise
const res = Session.getInstance().unserialise(json);
expect(res.hasErrors).toBe(false);
expect(Session.getInstance().getAllNubs().length).toBe(1);
const pb = Session.getInstance().findNubByUid("YmZ6eW") as PreBarrage;
expect(pb).toBeDefined();
expect(pb.children.length).toBe(3); // 1 basins, 2 walls
expect(pb.bassins.length).toBe(1);
const c1: PbCloison = pb.findChild("bXkwZW") as PbCloison; // amont-B1
expect(c1.bassinAmont).toBeUndefined();
expect(c1.bassinAval.uid).toBe("ZW8yaX");
const c2: PbCloison = pb.findChild("OHV2cH") as PbCloison; // B1-aval
expect(c2.bassinAmont.uid).toBe("ZW8yaX");
expect(c2.bassinAval).toBeUndefined();
// unserialise the same Nub a second time
const res2 = Session.getInstance().unserialise(json);
expect(res2.hasErrors).toBe(false);
expect(Session.getInstance().getAllNubs().length).toBe(2);
const pb2 = Session.getInstance().getAllNubs()[1] as PreBarrage;
expect(pb2).toBeDefined();
expect(pb2.uid).not.toBe("YmZ6eW");
expect(pb2.children.length).toBe(3); // 1 basins, 2 walls
expect(pb2.bassins.length).toBe(1);
// check that UIDs changed
expect(pb2.uid).not.toBe(pb.uid);
expect(pb2.bassins[0].uid).not.toBe(pb.bassins[0].uid);
const c12: PbCloison = pb2.getChildren()[1] as PbCloison; // amont-B1
expect(c12.bassinAmont).toBeUndefined();
expect(c12.bassinAval.uid).toBe(pb2.bassins[0].uid);
const c22: PbCloison = pb2.getChildren()[2] as PbCloison; // B1-aval
expect(c22.bassinAmont.uid).toBe(pb2.bassins[0].uid);
expect(c22.bassinAval).toBeUndefined();
});
});
describe("sessions containing Verificateur - ", () => {
......
......@@ -25,10 +25,12 @@ function createPab(): Pab {
const pab = Session.getInstance().createSessionNub(
new Props({ calcType: CalculatorType.Pab })
) as Pab;
pab.children.push(Session.getInstance().createNub(
const cl = Session.getInstance().createNub(
new Props({ calcType: CalculatorType.Cloisons })
) as Cloisons);
pab.children[0].structures[0] = CreateStructure(LoiDebit.WeirSubmergedLarinier);
) as Cloisons;
cl.parent = pab;
pab.children.push(cl);
pab.children[0].structures[0] = CreateStructure(LoiDebit.WeirSubmergedLarinier, cl);
const dw = Session.getInstance().createNub(
new Props({ calcType: CalculatorType.CloisonAval })
) as CloisonAval;
......@@ -235,6 +237,7 @@ describe("vérificateur de franchissement −", () => {
pab.children[4].structures[0] = new StructureWeirVillemonte( // Échancrure (Villemonte 1957)
pab.children[4].structures[0].prms as RectangularStructureParams
);
pab.children[4].structures[0].parent = pab.children[4];
pab.children[4].structures[0].getParameter("L").singleValue = 0.35;
pab.prms.Z2.singleValue = 30.4; // évite une chute trop importante à la cloison 5
// vérificateur
......
......@@ -38,6 +38,9 @@ export enum CalculatorType {
ConcentrationBlocs,
Par, // Passe à ralentisseurs, calage
ParSimulation, // Passe à ralentisseurs, simulation
PreBarrage, // Pré-barrage
PbCloison, // Cloison de pré-barrage
PbBassin, // Bassin de pré-barrage
Espece, // Critères de vérification pour une espèce de poissons
Verificateur // Vérificateur de contraintes sur une passe pour une ou plusieurs espèces
}
......
......@@ -150,13 +150,17 @@ export class Dichotomie extends Debug {
* @param dom domaine de définition de la variable
*/
private isIncreasingFunction(x: number, dom: Interval): boolean {
const epsilon = 1e-8;
const bounds = new Interval(x - epsilon, x + epsilon);
bounds.setInterval(bounds.intersect(dom)); // au cas où l'on sorte du domaine de la variable de la fonction
const y1 = this.CalculX(bounds.min);
const y2 = this.CalculX(bounds.max);
return y2 > y1;
let epsilon = 1e-8;
for(let i=0; i < 20; i++) {
const bounds = new Interval(x - epsilon, x + epsilon);
bounds.setInterval(bounds.intersect(dom)); // au cas où l'on sorte du domaine de la variable de la fonction
const y1 = this.CalculX(bounds.min);
const y2 = this.CalculX(bounds.max);
if(Math.abs(y2 - y1) > 1E-6) return y2 > y1;
epsilon *= 10;
}
return true;
}
/**
......
......@@ -93,3 +93,8 @@ export * from "./verification/verificateur_params";
export * from "./verification/fish_species";
export * from "./verification/diving-jet-support";
export * from "./fish_pass";
export * from "./prebarrage/pre_barrage";
export * from "./prebarrage/pre_barrage_params";
export * from "./prebarrage/pb_cloison";
export * from "./prebarrage/pb_bassin";
export * from "./prebarrage/pb_bassin_params";
......@@ -77,7 +77,7 @@ export class MacrorugoParams extends ParamsEquation {
this._Ks = new ParamDefinition(this, "Ks", new ParamDomain(ParamDomainValue.INTERVAL, 0, 1), "m", rRF);
this.addParamDefinition(this._Ks);
this._C = new ParamDefinition(this, "C", new ParamDomain(ParamDomainValue.INTERVAL, 0, 1), "-", rCB);
this._C = new ParamDefinition(this, "C", new ParamDomain(ParamDomainValue.INTERVAL, 0, 1), "", rCB);
this.addParamDefinition(this._C);
this._PBD = new ParamDefinition(this, "PBD", new ParamDomain(ParamDomainValue.INTERVAL, 0, 2), "m", rPBD);
......
......@@ -461,6 +461,28 @@ export abstract class Nub extends ComputeNode implements IObservable {
};
}
/**
* Returns a list of parameters that are fixed, either because their valueMode
* is SINGLE, or because their valueMode is LINK and the reference is
* defined and fixed. Does not take calculated parameters into account.
*/
public findFixedParams(): ParamDefinition[] {
const fixed: ParamDefinition[] = [];
for (const p of this.parameterIterator) {
if (
p.valueMode === ParamValueMode.SINGLE
|| (
p.valueMode === ParamValueMode.LINK
&& p.isReferenceDefined()
&& ! p.referencedValue.hasMultipleValues()
)
) {
fixed.push(p);
}
}
return fixed;
}
/**
* Returns a list of parameters that are variating, either because their valueMode
* is LISTE or MINMAX, or because their valueMode is LINK and the reference is
......@@ -493,7 +515,6 @@ export abstract class Nub extends ComputeNode implements IObservable {
* Effectue une série de calculs sur un paramètre; déclenche le calcul en chaîne
* des modules en amont si nécessaire
* @param rInit solution approximative du paramètre
* @param sDonnee éventuel symbole / paire symbole-uid du paramètre à calculer
*/
public CalcSerie(rInit?: number): Result {
// prepare calculation
......@@ -1033,8 +1054,8 @@ export abstract class Nub extends ComputeNode implements IObservable {
// is this a Solveur
if (this instanceof Solveur) {
return (
(this.searchedParameter !== undefined && this.searchedParameter.nubUid === uid)
|| (this.nubToCalculate !== undefined && this.nubToCalculate.uid === uid)
(this.searchedParameter?.nubUid === uid)
|| (this.nubToCalculate?.uid === uid)
);
} else if (this instanceof Verificateur) {
return (
......@@ -1159,16 +1180,17 @@ export abstract class Nub extends ComputeNode implements IObservable {
* @returns the calculated parameter found, if any - used by child Nub to notify
* its parent of the calculated parameter to set
*/
public loadObjectRepresentation(obj: any): { p: ParamDefinition, hasErrors: boolean } {
public loadObjectRepresentation(obj: any): { p: ParamDefinition, hasErrors: boolean, changedUids: { [key: string]: string } } {
// return value
const ret: { p: ParamDefinition, hasErrors: boolean } = {
const ret: { p: ParamDefinition, hasErrors: boolean, changedUids: { [key: string]: string } } = {
p: undefined,
hasErrors: false
hasErrors: false,
changedUids: {}
};
// set parameter modes and values
if (obj.parameters && Array.isArray(obj.parameters)) {
// 1st pass: find calculated param
// (if calculated param is not the default one, and default one is processes
// (if calculated param is not the default one, and default one is processed
// before new one, prevents changing the former's mode from setting the 1st
// param of the Nub to calculated, resetting the mode that had been loaded)
for (const p of obj.parameters) {
......@@ -1198,6 +1220,8 @@ export abstract class Nub extends ComputeNode implements IObservable {
// try to keep the original ID
if (! Session.getInstance().uidAlreadyUsed(s.uid)) {
subNub.setUid(s.uid);
} else {
ret.changedUids[s.uid] = subNub.uid;
}
const childRet = subNub.loadObjectRepresentation(s);
// add Structure to parent
......@@ -1296,7 +1320,7 @@ export abstract class Nub extends ComputeNode implements IObservable {
for (const p of this._children[index].parameterIterator) {
// if p is also present and visible in new Nub
const cp = child.getParameter(p.symbol);
if (cp !== undefined && cp.visible && p.visible) {
if (cp?.visible && p.visible) {
parametersState[p.symbol] = p.objectRepresentation([]);