From cae41e81adc1d1d5c9a79a5d018063d0f6544469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr> Date: Mon, 5 Sep 2022 16:48:20 +0200 Subject: [PATCH] feat: backwater curve: generate error when discretisation step is greater than reach length refs #565 refs cassiopee/jalhyd#316 --- e2e/remous.e2e-spec.ts | 23 +++++++++++++++++++++++ e2e/session/session-remous-dx-bief.json | 1 + jalhyd_branch | 2 +- src/locale/messages.en.json | 1 + src/locale/messages.fr.json | 1 + 5 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 e2e/session/session-remous-dx-bief.json diff --git a/e2e/remous.e2e-spec.ts b/e2e/remous.e2e-spec.ts index f79ad021f..78e1668ba 100644 --- a/e2e/remous.e2e-spec.ts +++ b/e2e/remous.e2e-spec.ts @@ -3,6 +3,7 @@ import { CalculatorPage } from "./calculator.po"; import { browser } from "protractor"; import { Navbar } from "./navbar.po"; import { PreferencesPage } from "./preferences.po"; +import { SideNav } from "./sidenav.po"; /** * Remous @@ -12,12 +13,14 @@ describe("ngHyd − remous", () => { let calcPage: CalculatorPage; let navBar: Navbar; let prefPage: PreferencesPage; + let sidenav: SideNav; beforeEach(async () => { listPage = new ListPage(); prefPage = new PreferencesPage(); calcPage = new CalculatorPage(); navBar = new Navbar(); + sidenav = new SideNav(); // disable evil option "empty fields on module creation" await prefPage.navigateTo(); await prefPage.disableEvilEmptyFields(); @@ -70,4 +73,24 @@ describe("ngHyd − remous", () => { const hasResults = await calcPage.hasResults(); expect(hasResults).toBe(true); }); + + it("Check that calculation with dx >= reach length fails", async () => { + // load backwater curve session file with Dx>=Long + await navBar.clickMenuButton(); + await browser.sleep(200); + await sidenav.clickLoadSessionButton(); + await browser.sleep(200); + await sidenav.loadSessionFile("./session/session-remous-dx-bief.json"); + await browser.sleep(500); + + // Calculate, the calculation should fail + await calcPage.getCalculateButton().click(); + await browser.sleep(500); + + // check error message in log + expect(await calcPage.nbLogEntries()).toBe(1); + + // check there is no result + expect(await calcPage.presentAndVisible("var-results")).toBe(false); + }); }); diff --git a/e2e/session/session-remous-dx-bief.json b/e2e/session/session-remous-dx-bief.json new file mode 100644 index 000000000..cd0a72183 --- /dev/null +++ b/e2e/session/session-remous-dx-bief.json @@ -0,0 +1 @@ +{"header":{"source":"jalhyd","format_version":"1.3","created":"2022-06-30T14:31:54.872Z"},"settings":{"precision":1e-7,"maxIterations":100},"documentation":"","session":[{"uid":"amozNT","props":{"calcType":"CourbeRemous","methodeResolution":"RungeKutta4"},"children":[{"uid":"ZzIyZm","props":{"calcType":"Section","nodeType":"SectionRectangle"},"children":[],"parameters":[{"symbol":"Ks","mode":"SINGLE","value":157544.77102709157},{"symbol":"Q","mode":"SINGLE","value":983277.9803235843},{"symbol":"YB","mode":"SINGLE","value":984997.3273467234},{"symbol":"LargeurBerge","mode":"SINGLE","value":756267.5581282576}]}],"parameters":[{"symbol":"Long","mode":"SINGLE","value":639697.7975510269},{"symbol":"Dx","mode":"SINGLE","value":680775.9048205647},{"symbol":"Z1","mode":"SINGLE","value":662459.5272556832},{"symbol":"Z2","mode":"SINGLE","value":142093.39302660408},{"symbol":"ZF1","mode":"SINGLE","value":150635.28017481393},{"symbol":"ZF2","mode":"SINGLE","value":-375069.6377087354}]}]} \ No newline at end of file diff --git a/jalhyd_branch b/jalhyd_branch index d64531f13..094bda298 100644 --- a/jalhyd_branch +++ b/jalhyd_branch @@ -1 +1 @@ -devel +316-courbe-de-remous-et-bief-remonter-une-erreur-quand-le-pas-de-discretisation-est-superieur-la diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 5fb1a5f88..a1a25b700 100755 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -66,6 +66,7 @@ "WARNING_REMOUS_PAS_CALCUL_DEPUIS_AVAL": "Downstream boundary condition < Critical elevation: no possible calculation from downstream", "ERROR_REMOUS_PAS_CALCUL": "No possible calculation, neither from upstream nor from downstream", "ERROR_REMOUS_PENTE_FORTE": "The water line slope is too steep at abscissa %x% m (the discretisation step should be reduced)", + "ERROR_REMOUS_PAS_SUPERIEUR_BIEF": "Discretisation step should be less than or equal to the reach length", "ERROR_RU_CIRC_LEVEL_TOO_HIGH": "Uniform flow cannot be calculated with a pipe under load", "ERROR_NEWTON_NON_CONVERGENCE": "Non-convergence (Newton's method)", "ERROR_SECTION_NON_CONVERGENCE_NEWTON_HCONJUG": "Non-convergence of the calculation of the combined depth (Newton's method)", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 5f937e2c3..928503bff 100755 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -66,6 +66,7 @@ "WARNING_REMOUS_PAS_CALCUL_DEPUIS_AVAL": "Condition limite aval < Hauteur critique : pas de calcul possible depuis l'aval", "ERROR_REMOUS_PAS_CALCUL": "Aucun calcul possible ni depuis l'amont ni depuis l'aval", "ERROR_REMOUS_PENTE_FORTE": "La pente de la ligne d'eau est trop forte à l'abscisse %x% m (il faudrait réduire le pas de discrétisation)", + "ERROR_REMOUS_PAS_SUPERIEUR_BIEF": "Le pas de discrétisation doit être inférieur ou égal à la longueur du bief", "ERROR_RU_CIRC_LEVEL_TOO_HIGH": "Le régime uniforme ne peut pas être calculé avec une conduite en charge", "ERROR_NEWTON_NON_CONVERGENCE": "Non convergence (Méthode de Newton)", "ERROR_SECTION_NON_CONVERGENCE_NEWTON_HCONJUG": "Non convergence du calcul de la hauteur conjuguée (Méthode de Newton)", -- GitLab