Commit 895fdbe3 authored by Dorchies David's avatar Dorchies David
Browse files

Merge branch '156-lois-d-ouvrages-orifice-denoye' into 'master'

Resolve "Lois d'ouvrages: orifice dénoyé"

Closes #156 and #163

See merge request cassiopee/jalhyd!46
parents 8f49a054 202caa00
stable - 2019-10-29
===================
new features
------------
* New module "Solver"
* New discharge equation "Orifice Free"
*
bug fixes
---------
* PAB: elevations issue on Cloisons
* Chained calculation: stop calculation if one step fails
* Remous: sometimes an abscissa is missing
stable - 2019-10-14
===================
......
{
"name": "jalhyd",
"version": "4.6.0",
"version": "4.6.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "jalhyd",
"version": "4.6.0",
"version": "4.6.2",
"author": "DD",
"license": "ISC",
"description": "JaLHyd, a Javascript Library for Hydraulics",
......
......@@ -153,8 +153,8 @@ export function testParallelStructures(o: { ps: ParallelStructure, ld: number[]
.getPropValue("loiDebit") === LoiDebit.GateCem88v
&& o.ps.calculatedParam.symbol === "ZDV")
) {
o.ps.calculatedParam.singleValue =
Math.min(
// altering value to force looking for the solution
o.ps.calculatedParam.singleValue = Math.min(
o.ps.calculatedParam.currentValue + 1000,
o.ps.calculatedParam.domain.maxValue
);
......
import { ParallelStructure, ParallelStructureParams, Session } from "../../src/index";
import { StructureOrificeFree } from "../../src/structure/structure_orifice_free";
import { StructureOrificeFreeParams } from "../../src/structure/structure_orifice_free_params";
describe("ParallelStructures, jalhyd#163, calculated variables present in the results − ", () => {
it("when Z1 is high enough and Zco calc succeeds, 10 variables should be present", () => {
// tslint:disable-next-line:max-line-length
const sess = `{"header":{"source":"jalhyd","format_version":"1.3","created":"2019-10-29T14:06:53.775Z"},"settings":{"precision":0.0001,"maxIterations":100,"displayPrecision":3},"documentation":"","session":[{"uid":"c292bn","props":{"calcType":"ParallelStructure"},"meta":{"title":"Ouvrages 1"},"children":[{"uid":"bGxmYT","props":{"calcType":"Structure","structureType":"Orifice","loiDebit":"OrificeFree"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":0.1},{"symbol":"CdO","mode":"SINGLE","value":0.7},{"symbol":"Zco","mode":"CALCUL"}]}],"parameters":[{"symbol":"Q","mode":"SINGLE","value":0.5},{"symbol":"Z1","mode":"SINGLE","value":105},{"symbol":"Z2","mode":"SINGLE","value":100}]}]}`;
Session.getInstance().clear();
Session.getInstance().unserialise(sess);
const nub = Session.getInstance().findNubByUid("c292bn");
nub.CalcSerie();
const vN = nub.result.resultElement.values;
const vS = nub.getChildren()[0].result.resultElement.values;
const vSK = Object.keys(vS);
vSK.sort();
const vNK = Object.keys(vN);
vNK.sort();
expect(vNK.length).toBe(1);
expect(vNK).toEqual([ "Zco" ]);
expect(vSK.length).toBe(5);
expect(vSK).toEqual(
[ "ENUM_StructureFlowMode", "ENUM_StructureFlowRegime", "ENUM_StructureJetType", "Q", "Zco" ]
);
});
it("when Z1 is too low and Zco calc fails, 10 variables should be present", () => {
// tslint:disable-next-line:max-line-length
const sess = `{"header":{"source":"jalhyd","format_version":"1.3","created":"2019-10-29T14:06:53.775Z"},"settings":{"precision":0.0001,"maxIterations":100,"displayPrecision":3},"documentation":"","session":[{"uid":"c292bn","props":{"calcType":"ParallelStructure"},"meta":{"title":"Ouvrages 1"},"children":[{"uid":"bGxmYT","props":{"calcType":"Structure","structureType":"Orifice","loiDebit":"OrificeFree"},"children":[],"parameters":[{"symbol":"S","mode":"SINGLE","value":0.1},{"symbol":"CdO","mode":"SINGLE","value":0.7},{"symbol":"Zco","mode":"CALCUL"}]}],"parameters":[{"symbol":"Q","mode":"SINGLE","value":0.5},{"symbol":"Z1","mode":"SINGLE","value":90},{"symbol":"Z2","mode":"SINGLE","value":100}]}]}`;
Session.getInstance().clear();
Session.getInstance().unserialise(sess);
const nub = Session.getInstance().findNubByUid("c292bn");
nub.CalcSerie();
const vN = nub.result.resultElement.values;
const vS = nub.getChildren()[0].result.resultElement.values;
const vSK = Object.keys(vS);
vSK.sort();
const vNK = Object.keys(vN);
vNK.sort();
expect(vNK.length).toBe(1);
expect(vNK).toEqual([ "Zco" ]);
expect(vSK.length).toBe(5);
expect(vSK).toEqual(
[ "ENUM_StructureFlowMode", "ENUM_StructureFlowRegime", "ENUM_StructureJetType", "Q", "Zco" ]
);
});
});
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureFlowMode, StructureFlowRegime, StructureJetType } from "../../src/structure/structure";
import { checkResult } from "../test_func";
import { CreateStructTest, StructureTest } from "./structure_test";
......@@ -43,7 +43,8 @@ describe("Class Structure: ", () => {
describe("Calc()", () => {
const flagsNull = {
ENUM_StructureFlowMode: StructureFlowMode.NULL,
ENUM_StructureFlowRegime: StructureFlowRegime.NULL
ENUM_StructureFlowRegime: StructureFlowRegime.NULL,
ENUM_StructureJetType: StructureJetType.SO
};
it("Z1=Z2 => Q=0", () => {
structTest.prms.Z2.v = structTest.prms.Z1.v;
......
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureOrificeFree } from "../../src/structure/structure_orifice_free";
import { StructureOrificeFreeParams } from "../../src/structure/structure_orifice_free_params";
import { itCalcQ } from "../structure/functions";
const prms: StructureOrificeFreeParams = new StructureOrificeFreeParams(0, 102, 101.5, 0.7, 0.1, 101);
const test: StructureOrificeFree = new StructureOrificeFree(prms, false);
describe("Class StructureOrificeFree: ", () => {
describe("Calc(Q): ", () => {
const h1: number[] = [102];
const Q: number[] = [0.310];
const mode: StructureFlowMode = StructureFlowMode.ORIFICE;
const regime: StructureFlowRegime = StructureFlowRegime.FREE;
for (let i = 0; i < Q.length; i++) {
itCalcQ(test, h1[i], Infinity, Q[i], mode, regime);
}
});
});
......@@ -11,6 +11,8 @@ import { StructureGateCem88v } from "./structure_gate_cem88v";
import { StructureGateCunge80 } from "./structure_gate_cunge80";
import { StructureKivi } from "./structure_kivi";
import { StructureKiviParams } from "./structure_kivi_params";
import { StructureOrificeFree } from "./structure_orifice_free";
import { StructureOrificeFreeParams } from "./structure_orifice_free_params";
import { StructureOrificeSubmerged } from "./structure_orifice_submerged";
import { StructureOrificeSubmergedParams } from "./structure_orifice_submerged_params";
import { StructureRectangularOrificeFree } from "./structure_rectangular_orifice_free";
......@@ -157,6 +159,20 @@ export function CreateStructure(loiDebit: LoiDebit, parentNub?: ParallelStructur
);
break;
case LoiDebit.OrificeFree:
ret = new StructureOrificeFree(
new StructureOrificeFreeParams(
0, // Q
102, // Z1
101.5, // Z2
0.7, // Cd
0.1, // S
101 // Zco
),
dbg
);
break;
case LoiDebit.WeirVillemonte:
ret = new StructureWeirVillemonte(rectStructPrms, dbg);
break;
......
......@@ -127,14 +127,13 @@ export class ParallelStructure extends Nub {
// Pour les caractéristiques des ouvrages
const structureIndex = this.getIndexForChild(sVarCalc.uid);
const r = this.CalcStructPrm(structureIndex, sVarCalc.symbol, rInit);
if (r.ok) {
this.result.symbol = r.symbol;
this.result.vCalc = r.vCalc;
// merge logs
this.result.log.addLog(r.log);
} else {
this.currentResult = r;
}
// whether r is .ok() or not, just copy vCalc and logs to avoid
// this._result being polluted by structure.flagsNull
this.result.symbol = r.symbol;
this.result.vCalc = r.vCalc;
// merge logs
this.result.log.addLog(r.log);
this.result.globalLog.addLog(r.globalLog);
}
return this.result;
......
......@@ -210,8 +210,11 @@ export abstract class Structure extends Nub {
this.prms.update_h1h2();
// Gestion du débit nul
const flagsNull = { ENUM_StructureFlowMode: StructureFlowMode.NULL,
ENUM_StructureFlowRegime: StructureFlowRegime.NULL };
const flagsNull = {
ENUM_StructureFlowMode: StructureFlowMode.NULL,
ENUM_StructureFlowRegime: StructureFlowRegime.NULL,
ENUM_StructureJetType: StructureJetType.SO
};
if (sVarCalc === "Q") {
if (this.prms.h1.v <= 0 || Math.abs(this.prms.h1.v - this.prms.h2.v) < 1E-20 || this.W <= 1E-20) {
return new Result(0, this, flagsNull);
......
import { ParamCalculability } from "../param/param-definition";
import { Structure, StructureFlowMode, StructureFlowRegime } from "../structure/structure";
import { Message, MessageCode } from "../util/message";
import { Result } from "../util/result";
import { StructureOrificeFreeParams } from "./structure_orifice_free_params";
import { LoiDebit } from "./structure_props";
/**
* Equation classique orifice dénoyé
*/
export class StructureOrificeFree extends Structure {
constructor(prms: StructureOrificeFreeParams, dbg: boolean = false) {
super(prms, dbg);
this._loiDebit = LoiDebit.OrificeFree;
this._isZDVcalculable = false;
}
/**
* paramètres castés au bon type
*/
get prms(): StructureOrificeFreeParams {
return this._prms as StructureOrificeFreeParams;
}
public Calc(sVarCalc: string, rInit?: number): Result {
this.currentResult = super.Calc(sVarCalc, rInit);
if (this._loiDebit === LoiDebit.OrificeFree && this.prms.Z2.v > this.prms.Zco.v) {
this._result.resultElement.addMessage(new Message(
MessageCode.WARNING_ORIFICE_FREE_DOWNSTREAM_ELEVATION_POSSIBLE_SUBMERSION,
{
Z2: this.prms.Z2.v,
Zco: this.prms.Zco.v
}
));
}
return this._result;
}
/**
* Calcul du débit avec l'équation classique d'un orifice dénoyé
*/
public CalcQ(): Result {
const data = this.getResultData();
const v = this.prms.CdO.v * this.prms.S.v * Structure.R2G * Math.sqrt(Math.max(0, this.prms.h1.v));
return new Result(v, this, data);
}
public calcA(): number {
return this.prms.S.v;
}
protected getFlowRegime() {
return StructureFlowRegime.FREE;
}
protected getFlowMode() {
return StructureFlowMode.ORIFICE;
}
protected setParametersCalculability() {
super.setParametersCalculability();
this.prms.S.calculability = ParamCalculability.DICHO;
this.prms.CdO.calculability = ParamCalculability.DICHO;
this.prms.Zco.calculability = ParamCalculability.DICHO;
this.prms.ZDV.visible = false;
}
}
import { ParamDefinition } from "../param/param-definition";
import { ParamDomain, ParamDomainValue } from "../param/param-domain";
import { StructureParams } from "../structure/structure_params";
export class StructureOrificeFreeParams extends StructureParams {
/** Area of the orifice (m2) */
public S: ParamDefinition;
/** Discharge coefficient */
// tslint:disable-next-line:variable-name
public CdO: ParamDefinition; // @TODO rename ?
/** Elevation of orifice center */
// tslint:disable-next-line:variable-name
public Zco: ParamDefinition;
/**
* Constructeur d'une structure rectangulaire
* @param rQ Débit (m3/s)
* @param rZ1 Cote de l'eau amont (m)
* @param rZ2 Cote de l'eau aval (m)
* @param rCd Coefficient de débit (-)
* @param rS Surface de l'orifice (m2)
* @param rZco Cote du centre de l'orifice (m)
*/
constructor(rQ: number, rZ1: number, rZ2: number, rCd: number, rS: number, rZco: number) {
super(rQ, 100, rZ1, rZ2);
this.S = new ParamDefinition(this, "S", ParamDomainValue.POS_NULL, "", rS);
this.addParamDefinition(this.S);
this.CdO = new ParamDefinition(this, "CdO", new ParamDomain(ParamDomainValue.INTERVAL, 0, 10), undefined, rCd);
this.addParamDefinition(this.CdO);
this.Zco = new ParamDefinition(this, "Zco", new ParamDomain(ParamDomainValue.ANY), "m", rZco);
this.addParamDefinition(this.Zco);
// hide params
this.ZDV.visible = false;
}
/** Mise à jour de h1 */
public update_h1h2() {
this.h1.v = this.Z1.v - this.Zco.v;
}
}
......@@ -37,6 +37,8 @@ export enum LoiDebit {
WeirSubmergedLarinier,
// Loi de débit orifice noyé
OrificeSubmerged,
// Loi de débit orifice dénoyé
OrificeFree,
// Loi de seuil noyée Villemonte
WeirVillemonte,
// Vanne levante Larinier
......@@ -49,7 +51,7 @@ export enum LoiDebit {
export const loiAdmissiblesOuvrages: { [key: string]: LoiDebit[] } = {
Orifice: [
LoiDebit.OrificeSubmerged
LoiDebit.OrificeSubmerged, LoiDebit.OrificeFree
],
SeuilRectangulaire: [
LoiDebit.WeirCem88d, LoiDebit.WeirCem88v, LoiDebit.WeirSubmergedLarinier,
......
......@@ -311,6 +311,11 @@ export enum MessageCode {
*/
WARNING_DOWNSTREAM_ELEVATION_POSSIBLE_SUBMERSION,
/**
* La cote de l'eau aval est plus élevée que la cote du centre de l'orifice (ennoiement possible)
*/
WARNING_ORIFICE_FREE_DOWNSTREAM_ELEVATION_POSSIBLE_SUBMERSION,
/**
* Grille orientée, préconisation pour le guidage des poissons : α ≤ 45°
*/
......
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