Commit 5c7194db authored by Dorchies David's avatar Dorchies David
Browse files

Merge branch '165-ajout-de-la-loi-d-ouvrage-de-deversoir-noye' into 'master'

Resolve "Ajout de la loi d'ouvrage de déversoir noyé"

Closes #165

See merge request cassiopee/jalhyd!48
parents e869cb71 27347745
......@@ -39,7 +39,7 @@ describe("iterator : ", () => {
pst.addChild(st);
const symbs = [
"Q", "Z1", "Z2", "CdWR", "CdGR", "CdWSL", "h1", "h2", "L", "Q", "W", "Z1", "Z2", "ZDV"
"Q", "Z1", "Z2", "CdWR", "CdGR", "CdWSL", "CdWS", "h1", "h2", "L", "Q", "W", "Z1", "Z2", "ZDV"
];
const vals = [1, 2, 3];
checkParams(pst.parameterIterator, symbs, vals);
......
......@@ -5,6 +5,8 @@ import { SessionSettings } from "../../src/session_settings";
import { CreateStructure } from "../../src/structure/factory_structure";
import { ParallelStructure } from "../../src/structure/parallel_structure";
import { ParallelStructureParams } from "../../src/structure/parallel_structure_params";
import { RectangularStructure } from "../../src/structure/rectangular_structure";
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureKivi } from "../../src/structure/structure_kivi";
import { StructureKiviParams } from "../../src/structure/structure_kivi_params";
import { LoiDebit } from "../../src/structure/structure_props";
......@@ -218,3 +220,31 @@ describe("Class ParallelStructure: ", () => {
});
});
});
describe("switching between LoiDebit should load a new default Cd", () => {
it("test 1", () => {
const ps = new ParallelStructure(new ParallelStructureParams(1, 102, 100));
const s = CreateStructure(LoiDebit.WeirSubmergedLarinier, ps);
expect((s.prms as RectangularStructureParams).CdWSL.singleValue).toBe(0.65);
ps.addChild(s);
expect((ps.getChildren()[0] as RectangularStructure).prms.CdWSL.singleValue).toBe(0.65);
const s2 = CreateStructure(LoiDebit.WeirSubmerged, ps);
expect((s2.prms as RectangularStructureParams).CdWS.singleValue).toBe(0.9);
ps.replaceChildInplace(s, s2);
expect((ps.getChildren()[0] as RectangularStructure).prms.CdWS.singleValue).toBe(0.9);
});
it("test 2", () => {
const ps = new ParallelStructure(new ParallelStructureParams(1, 102, 100));
const s = CreateStructure(LoiDebit.WeirSubmerged, ps);
expect((s.prms as RectangularStructureParams).CdWS.singleValue).toBe(0.9);
ps.addChild(s);
expect((ps.getChildren()[0] as RectangularStructure).prms.CdWS.singleValue).toBe(0.9);
const s2 = CreateStructure(LoiDebit.WeirSubmergedLarinier, ps);
expect((s2.prms as RectangularStructureParams).CdWSL.singleValue).toBe(0.65);
ps.replaceChildInplace(s, s2);
expect((ps.getChildren()[0] as RectangularStructure).prms.CdWSL.singleValue).toBe(0.65);
});
});
import { RectangularStructureParams } from "../../src/structure/rectangular_structure_params";
import { StructureFlowMode, StructureFlowRegime } from "../../src/structure/structure";
import { StructureWeirSubmerged } from "../../src/structure/structure_weir_submerged";
import { MessageCode } from "../../src/util/message";
import { itCalcQ } from "../structure/functions";
import { precDigits } from "../test_config";
function getStructTest(): StructureWeirSubmerged {
return new StructureWeirSubmerged(new RectangularStructureParams(0, 101, 102, 101.5, 0.2, 0.9), false);
}
describe("Class StructureWeirSubmerged: ", () => {
describe("Calc(Q): ", () => {
const Z1: number[] = [102];
const Q: number[] = [0.282];
const mode: StructureFlowMode = StructureFlowMode.WEIR;
const regime: StructureFlowRegime = StructureFlowRegime.SUBMERGED;
for (let i = 0; i < Q.length; i++) {
itCalcQ(getStructTest(), Z1[i], Infinity, Q[i], mode, regime);
}
});
describe("Calc(Z1): ", () => {
it("Z1(Q=0.780) should be 75.234", () => {
const testZ1 = new StructureWeirSubmerged(
new RectangularStructureParams(0.780, 73.665, 75.301, 75.077, 0.35, 0.9),
false);
testZ1.prms.Z1.v = 100; // Test with initial condition far from solution
expect(testZ1.Calc("Z1").vCalc).toBeCloseTo(75.234, precDigits);
});
});
describe("Calcul avec h2/h1 < 0.8 (=0.5) : ", () => {
it("le log devrait contenir 1 message", () => {
const structTest = getStructTest();
structTest.prms.Z1.singleValue = 110;
structTest.prms.Z2.singleValue = 105;
structTest.prms.ZDV.singleValue = 100;
const res = structTest.CalcSerie().resultElement;
expect(res.log.messages.length).toBe(1);
expect(
res.log.messages[0].code
).toBe(MessageCode.WARNING_WEIR_SUBMERSION_LOWER_THAN_08);
});
});
});
......@@ -1138,7 +1138,11 @@ export abstract class Nub extends ComputeNode implements IObservable {
// store old parameters state
if (keepParametersState && hasOldChild) {
for (const p of this._children[index].parameterIterator) {
parametersState[p.symbol] = p.objectRepresentation([]);
// if p is also present and visible in new Nub
const cp = child.getParameter(p.symbol);
if (cp !== undefined && cp.visible && p.visible) {
parametersState[p.symbol] = p.objectRepresentation([]);
}
}
}
......
......@@ -28,6 +28,7 @@ import { StructureWeirCem88d } from "./structure_weir_cem88d";
import { StructureWeirCem88v } from "./structure_weir_cem88v";
import { StructureWeirCunge80 } from "./structure_weir_cunge80";
import { StructureWeirFree } from "./structure_weir_free";
import { StructureWeirSubmerged } from "./structure_weir_submerged";
import { StructureWeirSubmergedLarinier } from "./structure_weir_submerged_larinier";
import { StructureWeirVillemonte } from "./structure_weir_villemonte";
......@@ -105,6 +106,11 @@ export function CreateStructure(loiDebit: LoiDebit, parentNub?: ParallelStructur
ret = new StructureWeirSubmergedLarinier(rectStructPrms, dbg);
break;
case LoiDebit.WeirSubmerged:
rectStructPrms.CdWS.singleValue = 0.9;
ret = new StructureWeirSubmerged(rectStructPrms, dbg);
break;
case LoiDebit.KIVI:
const structKiviPrm: StructureKiviParams = new StructureKiviParams(
8.516, // Q
......
......@@ -11,6 +11,7 @@ export abstract class RectangularStructure extends Structure {
super(prms, dbg);
this.prms.CdGR.visible = false;
this.prms.CdWR.visible = false;
this.prms.CdWS.visible = false;
this.prms.CdWSL.visible = false;
}
......
......@@ -19,6 +19,8 @@ export class RectangularStructureParams extends StructureParams {
public CdWR: ParamDefinition;
// tslint:disable-next-line:variable-name
public CdWSL: ParamDefinition;
// tslint:disable-next-line:variable-name
public CdWS: ParamDefinition;
/**
* Constructeur d'une structure rectangulaire
......@@ -41,5 +43,7 @@ export class RectangularStructureParams extends StructureParams {
this.addParamDefinition(this.CdWR);
this.CdWSL = new ParamDefinition(this, "CdWSL", domainCd, undefined, rCd);
this.addParamDefinition(this.CdWSL);
this.CdWS = new ParamDefinition(this, "CdWS", domainCd, undefined, rCd);
this.addParamDefinition(this.CdWS);
}
}
......@@ -35,6 +35,8 @@ export enum LoiDebit {
TriangularTruncWeirFree,
// Loi de débit fente noyée (Larinier 1992)
WeirSubmergedLarinier,
// Loi de débit fente noyée (Rajaratnam & Muralidhar 1969)
WeirSubmerged,
// Loi de débit orifice noyé
OrificeSubmerged,
// Loi de débit orifice dénoyé
......@@ -54,7 +56,7 @@ export const loiAdmissiblesOuvrages: { [key: string]: LoiDebit[] } = {
LoiDebit.OrificeSubmerged, LoiDebit.OrificeFree
],
SeuilRectangulaire: [
LoiDebit.WeirCem88d, LoiDebit.WeirCem88v, LoiDebit.WeirSubmergedLarinier,
LoiDebit.WeirCem88d, LoiDebit.WeirCem88v, LoiDebit.WeirSubmerged, LoiDebit.WeirSubmergedLarinier,
LoiDebit.WeirVillemonte, LoiDebit.WeirFree, LoiDebit.KIVI, LoiDebit.WeirCunge80
],
SeuilTriangulaire: [
......
import { Message, MessageCode, ParamCalculability } from "../index";
import { Result } from "../util/result";
import { RectangularStructure } from "./rectangular_structure";
import { RectangularStructureParams } from "./rectangular_structure_params";
import { Structure, StructureFlowMode, StructureFlowRegime } from "./structure";
import { LoiDebit } from "./structure_props";
/**
* Equation de la fente noyée
* d'après Rajaratnam, N., et D. Muralidhar.
* « Flow below deeply submerged rectangular weirs ».
* Journal of Hydraulic Research 7, nᵒ 3 (1969): 355–374.
*/
export class StructureWeirSubmerged extends RectangularStructure {
constructor(prms: RectangularStructureParams, dbg: boolean = false) {
super(prms, dbg);
this._loiDebit = LoiDebit.WeirSubmerged;
this.prms.CdWS.visible = true;
}
public Calc(sVarCalc: string, rInit?: number): Result {
this.currentResult = super.Calc(sVarCalc, rInit);
const h2h1ratio = this.prms.h2.v / this.prms.h1.v;
if (h2h1ratio < 0.8) {
this._result.resultElement.addMessage(new Message(
MessageCode.WARNING_WEIR_SUBMERSION_LOWER_THAN_08,
{ h1: this.prms.h1.v, h2: this.prms.h2.v }
));
}
return this._result;
}
/**
* Calcul analytique Q
* @param sVarCalc Variable à calculer (doit être "Q")
*/
public CalcQ(): Result {
const data = this.getResultData();
const v = this.prms.CdWS.v * this.prms.L.v * Structure.R2G
* this.prms.h2.v * Math.sqrt(this.prms.h1.v - this.prms.h2.v);
return new Result(v, this, data);
}
protected getFlowRegime() {
return StructureFlowRegime.SUBMERGED;
}
protected getFlowMode() {
return StructureFlowMode.WEIR;
}
/**
* paramétrage de la calculabilité des paramètres
*/
protected setParametersCalculability() {
super.setParametersCalculability();
this.prms.L.calculability = ParamCalculability.DICHO;
this.prms.CdWS.calculability = ParamCalculability.DICHO;
}
}
......@@ -352,6 +352,11 @@ export enum MessageCode {
*/
WARNING_SLOT_SUBMERSION_NOT_BETWEEN_07_AND_09,
/**
* La formule du seuil noyé n'est pas conseillé pour un ennoiement inférieur à 0.8
*/
WARNING_WEIR_SUBMERSION_LOWER_THAN_08,
/**
* Vanne levante : ZDV > ZDV max
*/
......
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