Commit dc8fddce authored by Dorchies David's avatar Dorchies David
Browse files

Ajout de l'équation d'ouvrage CEM88D (ne passe pas les tests)

Showing with 124 additions and 1 deletion
+124 -1
...@@ -18,7 +18,6 @@ class StructureTest extends Structure { ...@@ -18,7 +18,6 @@ class StructureTest extends Structure {
constructor(prms: StructureTestParams, dbg: boolean = false) { constructor(prms: StructureTestParams, dbg: boolean = false) {
super(prms, dbg); super(prms, dbg);
this.setParametersCalculability();
} }
Equation(sVarCalc: string): Result { Equation(sVarCalc: string): Result {
......
/// <reference path="../../node_modules/@types/jasmine/index.d.ts" />
import { StructureCem88d, RectangularStructureParams } from "../../src/structure/structure_cem88d";
import { Result } from "../../src/base";
import { precDigits } from "../nubtest";
let structPrm: RectangularStructureParams = new RectangularStructureParams(1, undefined, 1, 2, 0.6, 0);
let structTest: StructureCem88d = new StructureCem88d(structPrm, false);
let resultTesth1FnW: number[] = [Infinity, 3.603062, 1.560872, 1.323331, 1.154102, 1.073632, 1.047438, 1.035118, 1.027086, 1.021649, 1.021305];
describe('Class StructureCem88d: ', () => {
describe('Calcul h1 avec W croissant: ', () => {
for(let iW = 0; iW <= 10; iW++ ) {
structTest.prms.W.v = iW / 10 ;
it('h1(W='+structTest.prms.W.v+') should be '+resultTesth1FnW[iW], () => {
console.log('h1(W='+structTest.prms.W.v+') should be '+resultTesth1FnW[iW]);
expect(structTest.Calc('h1').vCalc).toBeCloseTo(resultTesth1FnW[iW],precDigits);
});
}
});
});
/**
* @file structure/rectangular_structure.ts Equation for weir and orifice (high sill elevation) from Cemagref 1988
*/
import { ComputeNodeType, ParamDefinition, ParamDomainValue, ParamCalculability, ParamsEquation } from "../param";
import { StructureParams, Structure } from "./structure";
export class RectangularStructureParams extends StructureParams {
/** Width of the gate or length of the sill (m) */
L: ParamDefinition;
/** Discharge coefficient */
Cd: ParamDefinition
constructor(rQ: number, rh1: number, rh2: number, rL: number, rCd: number, rW: number = Infinity) {
super(rQ, rh1, rh2, rW);
this.L = new ParamDefinition(ComputeNodeType.CondDistri, 'L', ParamDomainValue.POS, rL);
this.addParamDefinition(this.L);
this.Cd = new ParamDefinition(ComputeNodeType.CondDistri, 'Cd', ParamDomainValue.POS, rCd);
this.addParamDefinition(this.Cd);
}
}
export abstract class RectangularStructure extends Structure {
constructor(prms: RectangularStructureParams, dbg: boolean = false) {
super(prms, dbg);
}
/**
* paramètres castés au bon type
*/
get prms(): RectangularStructureParams {
return <RectangularStructureParams>this._prms;
}
/**
* paramétrage de la calculabilité des paramètres
*/
protected setParametersCalculability() {
super.setParametersCalculability();
this.prms.L.calculability = ParamCalculability.DICHO;
this.prms.Cd.calculability = ParamCalculability.DICHO;
}
}
...@@ -27,9 +27,13 @@ export abstract class StructureParams extends ParamsEquation { ...@@ -27,9 +27,13 @@ export abstract class StructureParams extends ParamsEquation {
constructor(rQ: number, rh1: number, rh2: number, rW: number = Infinity ) { constructor(rQ: number, rh1: number, rh2: number, rW: number = Infinity ) {
super(); super();
this.Q = new ParamDefinition(ComputeNodeType.CondDistri, 'Q', ParamDomainValue.POS_NULL, rQ); this.Q = new ParamDefinition(ComputeNodeType.CondDistri, 'Q', ParamDomainValue.POS_NULL, rQ);
this.addParamDefinition(this.Q);
this.h1 = new ParamDefinition(ComputeNodeType.CondDistri, 'h1', ParamDomainValue.POS_NULL, rh1); this.h1 = new ParamDefinition(ComputeNodeType.CondDistri, 'h1', ParamDomainValue.POS_NULL, rh1);
this.addParamDefinition(this.h1);
this.h2 = new ParamDefinition(ComputeNodeType.CondDistri, 'h2', ParamDomainValue.POS_NULL, rh2); this.h2 = new ParamDefinition(ComputeNodeType.CondDistri, 'h2', ParamDomainValue.POS_NULL, rh2);
this.addParamDefinition(this.h2);
this.W = new ParamDefinition(ComputeNodeType.CondDistri, 'W', ParamDomainValue.POS_NULL, rW); this.W = new ParamDefinition(ComputeNodeType.CondDistri, 'W', ParamDomainValue.POS_NULL, rW);
this.addParamDefinition(this.W);
} }
} }
...@@ -62,6 +66,10 @@ export enum StructureFlowRegime { ...@@ -62,6 +66,10 @@ export enum StructureFlowRegime {
* classe de calcul sur la conduite distributrice * classe de calcul sur la conduite distributrice
*/ */
export abstract class Structure extends Nub { export abstract class Structure extends Nub {
/** Constante utile : Racine de 2g */
protected static readonly R2G: number = Math.sqrt(2*9.81);
constructor(prms: StructureParams, dbg: boolean = false) { constructor(prms: StructureParams, dbg: boolean = false) {
super(prms, dbg); super(prms, dbg);
} }
...@@ -138,6 +146,8 @@ export abstract class Structure extends Nub { ...@@ -138,6 +146,8 @@ export abstract class Structure extends Nub {
default : default :
return new Result(0); // Est-ce toujours vrai ? Nécessitera peut-être d'étendre la méthode return new Result(0); // Est-ce toujours vrai ? Nécessitera peut-être d'étendre la méthode
} }
} else if(this.prms.W.v == 0 && sVarCalc == "h1") {
return new Result(Infinity); // Si la vanne est fermée la cote amont est infinie
} }
// Gestion de l'inversion de débit : on inverse l'amont et l'aval pour le calcul // Gestion de l'inversion de débit : on inverse l'amont et l'aval pour le calcul
...@@ -153,4 +163,11 @@ export abstract class Structure extends Nub { ...@@ -153,4 +163,11 @@ export abstract class Structure extends Nub {
} }
/**
* Test générique si VarCalc="Q" pour l'utilisation de Equation
*/
CheckEquation(sVarCalc: string) {
if(sVarCalc!="Q") throw 'Structure.Equation() : invalid parameter name ' + sVarCalc;
}
} }
\ No newline at end of file
/**
* @file structure/structure_cem88d.ts Equation for weir and orifice (high sill elevation) from Cemagref 1988
*/
import { RectangularStructureParams, RectangularStructure } from "./rectangular_structure";
import { StructureFlowMode, StructureFlowRegime, Structure } from "./structure"
import { Result } from "../base"
export { RectangularStructureParams };
export class StructureCem88d extends RectangularStructure {
Equation(sVarCalc: string): Result {
this.CheckEquation(sVarCalc);
let v : number;
let cd : number = this.prms.Cd.v * this.prms.L.v * Structure.R2G;
let b1 : number = Math.sqrt(this.prms.h1.v);
let b2 : number = Math.sqrt(this.prms.h2.v);
let cd1 : number = cd * 2.5981;
switch(this.getFlowMode()) {
case StructureFlowMode.WEIR:
switch(this.getFlowRegime()) {
case StructureFlowRegime.FREE:
v = cd * this.prms.h1.v * b1;
case StructureFlowRegime.SUBMERGED:
v = cd1 * this.prms.h1.v * b2;
}
case StructureFlowMode.ORIFICE:
let b3 : number = this.prms.h1.v - this.prms.W.v;
switch(this.getFlowRegime()) {
case StructureFlowRegime.FREE:
v = cd * (this.prms.h1.v * b1 -b3);
case StructureFlowRegime.PARTIAL:
v = cd1 * b2 * this.prms.h2.v - cd * b3;
case StructureFlowRegime.SUBMERGED:
v = cd1 * b2 * this.prms.W.v;
}
}
return new Result(v);
}
}
Supports Markdown
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