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

Merge branch '279-prebarrage-distribution-des-debits-erronee-sur-exemple-simple' into 'master'

Resolve "PreBarrage: Distribution des débits erronée sur exemple simple"

Closes #280 and #279

See merge request cassiopee/jalhyd!93
parents 91f31349 380595f1
......@@ -328,7 +328,7 @@ describe("Class PreBarrage:", () => {
Session.getInstance().unserialise(sess);
const pb = Session.getInstance().findNubByUid("YjJhMX") as PreBarrage;
const res = pb.CalcSerie();
expect(res.ok).toBe(false);
expect(res.ok).toBe(true);
expect(res.resultElements.length).toBe(5);
});
});
......@@ -656,6 +656,7 @@ describe("Class PreBarrage:", () => {
it("downstream water elevation > upstream water elevation", () => {
const pb = createPreBarrageTest();
pb.prms.Z2.singleValue = pb.prms.Z1.singleValue + 1;
pb.prms.Q.setCalculated();
const res = pb.CalcSerie();
expect(res.ok).toBe(false);
expect(res.resultElement.log.messages.length).toBe(1);
......
import { PreBarrage, Session } from "../../src/index";
import { checkResultConsistency } from "../test_func";
let sessionJson: string;
describe("PreBarrage", () => {
beforeEach(()=> {
sessionJson = `{"header":{"source":"jalhyd","format_version":"1.3","created":"2020-10-01T06:43:50.495Z"},"settings":{"precision":1e-7,"maxIterations":100,"displayPrecision":3},"documentation":"","session":[{"uid":"cG9yaG","props":{"calcType":"PreBarrage"},"meta":{"title":"Prébarrages"},"children":[{"uid":"c29nYW","props":{"calcType":"PbBassin"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":13.8},{"symbol":"ZF","mode":"SINGLE","value":95}]},{"uid":"ajB2cn","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":"c29nYW"},"children":[{"uid":"dGtvMW","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":"a2t5eG","props":{"calcType":"PbCloison","upstreamBasin":"c29nYW","downstreamBasin":""},"children":[{"uid":"enJhZT","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":"ODUxdn","props":{"calcType":"PbCloison","upstreamBasin":"","downstreamBasin":""},"children":[{"uid":"YWFqdm","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}]}]}`;
});
describe("jalhyd#279", () => {
it("Discharge in first bassin should be greater than 0.4", () => {
// tslint:disable-next-line:max-line-length
Session.getInstance().unserialise(sessionJson);
const nub = Session.getInstance().findNubByUid("cG9yaG") as PreBarrage;
// nub.DBG = true;
nub.CalcSerie();
expect(nub.bassins[0].result.values.Q).toBeGreaterThan(0.4);
});
});
describe("jalhyd#280", () => {
it("With Z2 > Z1, calculation should succeed", () => {
// tslint:disable-next-line:max-line-length
Session.getInstance().unserialise(sessionJson);
const nub = Session.getInstance().findNubByUid("cG9yaG") as PreBarrage;
// nub.DBG = true;
nub.prms.Z2.setValue(102);
nub.CalcSerie();
expect(nub.result.ok).toBeTrue();
});
});
});
......@@ -453,7 +453,7 @@ export class PreBarrage extends Nub {
// B. messages generating cases: calculation goes on
const res = new Result(new ResultElement(), this);
// downstream water elevation > upstream water elevation ?
if (this.prms.Z2.v > this.prms.Z1.v) {
if (this.calculatedParam === this.prms.Q && this.prms.Z2.v > this.prms.Z1.v) {
res.resultElement.log.add(new Message(MessageCode.ERROR_PREBARRAGE_Z2_SUP_Z1));
}
// for each basin: is apron elevation > upstream water elevation ?
......@@ -533,7 +533,7 @@ export class PreBarrage extends Nub {
// Calculation of repartition regarding actual water elevations
let QT2: number = 0;
for (const c of cloisons) {
c.prms.Q.initValue = c.prms.Q.v;
c.prms.Q.initValue = Math.max(0, c.prms.Q.v);
c.Calc("Q");
// Relax! On ne prend pas toute la modification proposée !
if(c.prms.Q.v > 0) {
......
Markdown is supported
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