Commit ae47d255 authored by Grand Francois's avatar Grand Francois
Browse files

#46 ajout d'une classe StructureProperties pour gérer les valeurs de StructureType et LoiDebit

Showing with 77 additions and 41 deletions
+77 -41
......@@ -10,7 +10,8 @@ import { ConduiteDistribParams, ConduiteDistrib } from "../../src/cond_distri";
import { ParallelStructureParams } from "../../src/structure/parallel_structure_params";
import { ParallelStructure } from "../../src/structure/parallel_structure";
import { Structure } from "../../src/structure/structure";
import { CreateStructure, StructureType, LoiDebit } from "../../src/structure/factory_structure";
import { CreateStructure } from "../../src/structure/factory_structure";
import { StructureType, LoiDebit } from "../../src/structure/structure_props";
import { IParamDefinitionIterator } from "../../src/param/params-equation";
function checkParams(pdi: IParamDefinitionIterator, symbols: string[], values: number[]) {
......
......@@ -7,7 +7,8 @@
// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine";
import { ParamCalculability } from "../../src/param/param-definition";
import { CreateStructure, loiAdmissibles, LoiDebit, StructureType } from "../../src/structure/factory_structure";
import { CreateStructure } from "../../src/structure/factory_structure";
import { LoiDebit, StructureType, loiAdmissibles } from "../../src/structure/structure_props";
import { ParallelStructure } from "../../src/structure/parallel_structure";
import { ParallelStructureParams } from "../../src/structure/parallel_structure_params";
import { Structure } from "../../src/structure/structure";
......
......@@ -7,7 +7,8 @@
// import { describe, expect, it, xdescribe, xit } from "../mock_jasmine";
import { StructureFlowMode, StructureFlowRegime, MessageCode } from "../../src";
import { CreateStructure, LoiDebit, StructureType } from "../../src/structure/factory_structure";
import { CreateStructure } from "../../src/structure/factory_structure";
import { LoiDebit, StructureType } from "../../src/structure/structure_props";
import { StructureKivi } from "../../src/structure/structure_kivi";
import { StructureKiviParams } from "../../src/structure/structure_kivi_params";
import { testStructure } from "./structure_test";
......
......@@ -36,4 +36,5 @@ export * from "./structure/parallel_structure_params";
export * from "./structure/structure";
export * from "./structure/structure_params";
export * from "./structure/factory_structure";
export * from "./structure/structure_props";
export * from "./jalhyd_object";
......@@ -14,7 +14,8 @@ import { RegimeUniforme } from "./regime_uniforme";
import { CourbeRemousParams, MethodeResolution, CourbeRemous } from "./remous";
import { PabDimensionParams, PabDimension } from "./pab/pab_dimension";
import { PabPuissance, PabPuissanceParams } from "./pab/pab_puissance";
import { CreateStructure, StructureType, LoiDebit } from "./structure/factory_structure";
import { CreateStructure } from "./structure/factory_structure";
import { StructureType, LoiDebit } from "./structure/structure_props";
import { Structure } from "./structure/structure";
import { ParallelStructure } from "./structure/parallel_structure";
import { ParallelStructureParams } from "./structure/parallel_structure_params";
......
......@@ -8,40 +8,7 @@ import { StructureKiviParams } from "./structure_kivi_params";
import { StructureOrificeFree } from "./structure_orifice_free";
import { StructureOrificeSubmerged } from "./structure_orifice_submerged";
import { StructureWeirFree } from "./structure_weir_free";
export enum StructureType {
SeuilRectangulaire, VanneRectangulaire
// VanneCirculaire,
// VanneTrapezoidale, SeuilTrapezoidal
}
export enum LoiDebit {
// loi de débit Déversoir / Orifice Cemagref 1988
Cem88d,
// loi de débit Déversoir / Vanne de fond Cemagref 1988
Cem88v,
// loi de débit Cunge 1980
Cunge80,
// loi de débit pour vanne dénoyée
OrificeFree,
// loi de débit pour vanne noyée
OrificeSubmerged,
// loi de débit pour seuil dénoyé
WeirFree,
// Loi Kindsvater-Carter et Villemonte
KIVI
}
export const loiAdmissibles: { [key: string]: LoiDebit[] } = {
SeuilRectangulaire: [
LoiDebit.Cem88d, LoiDebit.Cem88v, LoiDebit.Cunge80, LoiDebit.WeirFree,
LoiDebit.KIVI
],
VanneRectangulaire: [
LoiDebit.Cem88d, LoiDebit.Cem88v, LoiDebit.Cunge80, LoiDebit.OrificeFree,
LoiDebit.OrificeSubmerged
]
};
import { StructureType, LoiDebit, StructureProperties } from "./structure_props";
export function CreateStructure(structureType: StructureType, loiDebit: LoiDebit, dbg: boolean = false): Structure {
const rectStructPrms: RectangularStructureParams = new RectangularStructureParams(
......@@ -57,14 +24,14 @@ export function CreateStructure(structureType: StructureType, loiDebit: LoiDebit
case StructureType.VanneRectangulaire:
rectStructPrms.W.v = 0.5;
rectStructPrms.Cd.v = 0.6; // Cd pour une vanne rectangulaire
if (!(loiAdmissibles.VanneRectangulaire.includes(loiDebit))) {
if (!(StructureProperties.isCompatibleValues(StructureType.VanneRectangulaire, loiDebit))) {
throw new Error(
`la loi de débit ${LoiDebit[loiDebit]} n'est pas admissible pour les vannes rectangulaires`
);
}
break;
case StructureType.SeuilRectangulaire:
if (!loiAdmissibles.SeuilRectangulaire.includes(loiDebit)) {
if (!(StructureProperties.isCompatibleValues(StructureType.SeuilRectangulaire, loiDebit))) {
throw new Error(
`la loi de débit ${LoiDebit[loiDebit]} n'est pas admissible pour les seuils rectangulaires`
);
......@@ -96,6 +63,7 @@ export function CreateStructure(structureType: StructureType, loiDebit: LoiDebit
case LoiDebit.WeirFree:
return new StructureWeirFree(rectStructPrms, dbg);
case LoiDebit.KIVI:
const structKiviPrm: StructureKiviParams = new StructureKiviParams(
8.516, // Q
......@@ -107,8 +75,8 @@ export function CreateStructure(structureType: StructureType, loiDebit: LoiDebit
0.001, // béta
100); // ZRAM : cote Radier Amont
return new StructureKivi(structKiviPrm, dbg);
default:
throw new Error(`type de LoiDebit ${LoiDebit[loiDebit]} non pris en charge`);
}
}
export enum StructureType {
SeuilRectangulaire, VanneRectangulaire
// VanneCirculaire,
// VanneTrapezoidale, SeuilTrapezoidal
}
export enum LoiDebit {
// loi de débit Déversoir / Orifice Cemagref 1988
Cem88d,
// loi de débit Déversoir / Vanne de fond Cemagref 1988
Cem88v,
// loi de débit Cunge 1980
Cunge80,
// loi de débit pour vanne dénoyée
OrificeFree,
// loi de débit pour vanne noyée
OrificeSubmerged,
// loi de débit pour seuil dénoyé
WeirFree,
// Loi Kindsvater-Carter et Villemonte
KIVI
}
export const loiAdmissibles: { [key: string]: LoiDebit[] } = {
SeuilRectangulaire: [
LoiDebit.Cem88d, LoiDebit.Cem88v, LoiDebit.Cunge80, LoiDebit.WeirFree,
LoiDebit.KIVI
],
VanneRectangulaire: [
LoiDebit.Cem88d, LoiDebit.Cem88v, LoiDebit.Cunge80, LoiDebit.OrificeFree,
LoiDebit.OrificeSubmerged
]
};
export class StructureProperties {
/**
* @return true si les valeurs de StructureType et LoiDebit sont compatibles
*/
public static isCompatibleValues(struct: StructureType, loi: LoiDebit): boolean {
return loiAdmissibles[StructureType[struct]].includes(loi);
}
/**
* @return la 1ère valeur de StructureType compatible avec la loi de débit
*/
public static findCompatibleStructure(loi: LoiDebit): StructureType {
for (const st in loiAdmissibles) {
const lds: LoiDebit[] = loiAdmissibles[st];
for (const ld of lds)
if (ld === loi)
return (<any>StructureType)[st];
}
return undefined;
}
/**
* @return la 1ère valeur de LoiDebit compatible avec le type de structure
*/
public static findCompatibleLoiDebit(struct: StructureType): LoiDebit {
const sst: string = StructureType[struct];
return loiAdmissibles[sst][0];
}
}
\ No newline at end of file
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