Commit 8ed86d49 authored by Mathias Chouet's avatar Mathias Chouet 🍝
Browse files

Fix nghyd#392

parent 703a295e
import { Session } from "../../src/index";
import { Pab } from "../../src/pab/pab";
describe("Class Pab", () => {
describe("NgHyd #392", () => {
it("result.sourceNub should not be undefined", () => {
Session.getInstance().clear();
Session.getInstance().unserialise(`{"header":{"source":"jalhyd","format_version":"1.3","created":"2020-04-23T07:32:02.229Z"},"settings":{"precision":1e-7,"maxIterations":100,"displayPrecision":3},"documentation":"","session":[{"uid":"bDFwYj","props":{"calcType":"Pab"},"meta":{"title":"PAB"},"children":[{"uid":"d2N6dm","props":{"calcType":"Cloisons"},"children":[{"uid":"MDV5cj","props":{"calcType":"Structure","loiDebit":"WeirSubmergedLarinier"},"children":[],"parameters":[{"symbol":"ZDV","mode":"SINGLE","value":101},{"symbol":"L","mode":"SINGLE","value":0.2},{"symbol":"CdWSL","mode":"SINGLE","value":0.75}]}],"parameters":[{"symbol":"LB","mode":"SINGLE","value":10},{"symbol":"BB","mode":"SINGLE","value":1},{"symbol":"ZRMB","mode":"SINGLE","value":0},{"symbol":"ZRAM","mode":"SINGLE","value":0},{"symbol":"QA","mode":"SINGLE","value":0}]}],"parameters":[{"symbol":"Q","mode":"CALCUL","value":1.5},{"symbol":"Z1","mode":"SINGLE","value":102},{"symbol":"Z2","mode":"SINGLE","value":100}],"downWall":{"uid":"MnU0az","props":{"calcType":"CloisonAval"},"children":[{"uid":"cTg4Mn","props":{"calcType":"Structure","loiDebit":"OrificeSubmerged"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":0.1},{"symbol":"CdO","mode":"SINGLE","value":0.7}]}],"parameters":[{"symbol":"ZRAM","mode":"SINGLE","value":0}]}}]}`);
const pab = Session.getInstance().findNubByUid("bDFwYj") as Pab;
// pab.prms.Z2.singleValue = 99;
const res = pab.CalcSerie();
expect(res).toBeDefined();
expect(res.ok).toBe(true);
expect(res.sourceNub).toBeDefined();
});
});
});
......@@ -94,7 +94,7 @@ export class Jet extends Nub {
h = (this.prms.ZJ.v - this.prms.ZW.v);
const sqrtArg = Math.pow(this.prms.V0.v * Math.sin(this.alpha), 2) + 2 * g * h;
if (sqrtArg < 0) {
return new Result(new Message(MessageCode.ERROR_JET_SUBMERGED_NO_SOLUTION));
return new Result(new Message(MessageCode.ERROR_JET_SUBMERGED_NO_SOLUTION), this);
}
v = this.prms.V0.v / g * Math.cos(this.alpha)
* (
......
......@@ -166,7 +166,7 @@ export class Pab extends Nub {
let Z: number = this.prms.Z2.v;
Z = this.calcCloisonZ1(this.downWall, Z);
if (!this.downWall.result.ok) {
return new Result(new Message(MessageCode.ERROR_PAB_CALC_Z1_CLOISON));
return new Result(new Message(MessageCode.ERROR_PAB_CALC_Z1_CLOISON), this);
}
this.downWall.result.resultElement.values.Q = this.downWall.prms.Q.v;
this.downWall.result.resultElement.values.x = l;
......@@ -182,7 +182,7 @@ export class Pab extends Nub {
cl.prms.PB.v = Z - cl.prms.ZRMB.v;
Z = this.calcCloisonZ1(cl, Z);
if (!cl.result.ok) {
return new Result(new Message(MessageCode.ERROR_PAB_CALC_Z1_CLOISON));
return new Result(new Message(MessageCode.ERROR_PAB_CALC_Z1_CLOISON), this);
}
// Add extraresults: mean depth in pool and discharge
cl.result.resultElement.values.YMOY = cl.prms.PB.v;
......
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