Skip to content
Snippets Groups Projects
Commit c2d90098 authored by David Dorchies's avatar David Dorchies
Browse files

Fix #116

parent 8a65b70e
No related branches found
No related tags found
No related merge requests found
......@@ -7,27 +7,28 @@ import { checkResult } from "../test_func";
function PabPuissanceTest(varTest: string) {
describe("Calc(): ", () => {
it("V should be 1", () => {
const prms = new PabPuissanceParams(
0.3, // Chute entre bassins DH (m)
0.1, // Débit Q (m3/s)
0.5, // Volume V (m3)
588.6 // Puissance dissipée PV (W/m3)
);
it(`${varTest} should be ${prms[varTest].v}`, () => {
prms = createPabPuisPrms();
const res: number = prms[varTest].v;
const nub = new PabPuissance(prms);
prms[varTest].v = undefined;
checkResult(nub.Calc(varTest, 1e-9), res);
});
});
}
function createPabPuisPrms(): PabPuissanceParams {
return new PabPuissanceParams(
0.3, // Chute entre bassins DH (m)
0.1, // Débit Q (m3/s)
0.5, // Volume V (m3)
588.6 // Puissance dissipée PV (W/m3)
);
}
let prms: PabPuissanceParams = createPabPuisPrms();
describe("Class PabPuissance: ", () => {
// beforeEach(() => {
// });
// beforeAll(() => {
// });
PabPuissanceTest("DH");
......
......@@ -6,10 +6,15 @@
*/
// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine";
import { MessageCode } from "../../src/index";
import { CalculatorType } from "../../src/compute-node";
import { Props } from "../../src/props";
import { Session } from "../../src/session";
import { CreateStructure } from "../../src/structure/factory_structure";
import { ParallelStructure } from "../../src/structure/parallel_structure";
import { ParallelStructureParams } from "../../src/structure/parallel_structure_params";
import { StructureKivi, StructureKiviParams } from "../../src/structure/structure_kivi";
import { LoiDebit } from "../../src/structure/structure_props";
import { MessageCode } from "../../src/util/message";
import { Result } from "../../src/util/result";
import { precDigits } from "../test_config";
import { checkResult } from "../test_func";
......@@ -133,4 +138,18 @@ describe("Class ParallelStructure: ", () => {
expect(ps3.CalcSerie().vCalc).toBeCloseTo(101.57, 2);
});
});
describe("#116 Pas de calcul de Z2 sur loi dénoyée", () => {
it("Calc(Z2) should return an error", () => {
// Create Parallel Structure with default parameters
const ps4 = Session.getInstance().createNub(
new Props({calcType: CalculatorType.ParallelStructure})
) as ParallelStructure;
// Add Free flow weir
ps4.addChild(CreateStructure(LoiDebit.WeirFree));
// Define Z2 to calculate
ps4.calculatedParam = ps4.prms.Z2;
expect(ps4.CalcSerie().ok).toBeFalsy();
});
});
});
......@@ -516,7 +516,7 @@ export class Dichotomie extends Debug {
tolAct = 1e-15 * Math.abs(b) + errorTol / 2;
newStep = (c - b) / 2;
if (Math.abs(newStep) <= tolAct || fb === 0) {
if (Math.abs(newStep) <= tolAct && Math.abs(fb) < 0.1) {
return b; // Acceptable approx. is found
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment