Newer
Older
import { CalculatorType, ComputeNodeType } from "./compute-node";
import { Nub } from "./nub";
// Calculettes
import { ConduiteDistrib, ConduiteDistribParams } from "./cond_distri";
import { LechaptCalmon, LechaptCalmonParams } from "./lechaptcalmon";
Dorchies David
committed
import { MacroRugo, MacrorugoParams } from "./macrorugo/macrorugo";
import { PabDimension, PabDimensionParams } from "./pab/pab_dimension";
import { PabPuissance, PabPuissanceParams } from "./pab/pab_puissance";
import { RegimeUniforme } from "./regime_uniforme";
import { CourbeRemous, CourbeRemousParams, MethodeResolution } from "./remous";
import { SectionParametree } from "./section/section_nub";
import { Cloisons, CloisonsParams } from "./structure/cloisons";
import { Dever, DeverParams } from "./structure/dever";
import { ParallelStructure, ParallelStructureParams } from "./structure/parallel_structure";
// Classes relatives aux sections
import { cSnCirc, ParamsSectionCirc } from "./section/section_circulaire";
import { cSnPuiss, ParamsSectionPuiss } from "./section/section_puissance";
import { cSnRectang, ParamsSectionRectang } from "./section/section_rectang";
import { cSnTrapez, ParamsSectionTrapez } from "./section/section_trapez";
import { acSection } from "./section/section_type";
// Classes relatives aux structures

Grand Francois
committed
import { CreateStructure } from "./structure/factory_structure";
import { Structure } from "./structure/structure";
import { LoiDebit, StructureType } from "./structure/structure_props";
if (Session._instance === undefined) {
Session._instance = new Session();
/** instance pour le pattern singleton */
private static _instance: Session;
private defaultPrecision: number = 0.001;

Grand Francois
committed

Grand Francois
committed
/**

Grand Francois
committed
*/
public createSessionNub(p: Props, dbg: boolean = false): Nub {

Grand Francois
committed
return res;
}

Grand Francois
committed
/**
* remplace un Nub par un nouveau dans la session
* @param sn Nub à remplacer
* @param params propriété du nouveau Nub

Grand Francois
committed
*/
public replaceNub(sn: Nub, params: Props): Nub {

Grand Francois
committed
let i = 0;
// move structure inside parent
if (sn instanceof Structure) {
const struct = sn as Structure;
if (struct.parent) {
struct.parent.replaceStructureInplace(struct, newNub as Structure);
} else {
throw new Error("Structure nub had no parent");
}
}

Grand Francois
committed
return newNub;
}
i++;
}
// pas trouvé
return undefined;
}
/**
* Removes a Nub from the session
* @param sn the Nub to remove
*/
public deleteNub(sn: Nub) {
throw new Error(`Session.deleteNub() : le Nub (uid ${sn.uid}) à supprimer n'a pas été trouvé`);
private newNubWithProps(p: Props, dbg: boolean = false): Nub {
const nub = this.createNub(p, dbg);
* Crée un Nub à partir d'une description (Props)
* @param params paramètres supplémentaires spécifiques
* - calcType: type de Nub
* - nodeType: sous type de Nub
private createNub(params: Props, dbg: boolean = false): Nub {

Grand Francois
committed
const calcType: CalculatorType = params.getPropValue("calcType");
const nodeType: ComputeNodeType = params.getPropValue("nodeType");
switch (calcType) {
case CalculatorType.ConduiteDistributrice:
Dorchies David
committed
{
prms = new ConduiteDistribParams(3, // débit Q
1.2, // diamètre D
0.6, // perte de charge J
100, // Longueur de la conduite Lg
1e-6, // Viscosité dynamique Nu
);
nub = new ConduiteDistrib(prms, dbg);
break;
}
Dorchies David
committed
{
prms = new LechaptCalmonParams(3, // débit
1.2, // diamètre
0.6, /// perte de charge
100, // longueur du toyo
1.863, // paramètre L du matériau
2, // paramètre M du matériau
5.33// paramètre N du matériau
);
nub = new LechaptCalmon(prms, dbg);
break;
}
case CalculatorType.SectionParametree:
Dorchies David
committed
{
nub = new SectionParametree(this.createSection(nodeType, dbg), dbg);
break;
Dorchies David
committed
}
Dorchies David
committed
{
const sect: acSection = this.createSection(nodeType, dbg);
const ru = new RegimeUniforme(sect, dbg);
Dorchies David
committed
}
Dorchies David
committed
{
const sectCR: acSection = this.createSection(nodeType, dbg);
prms = new CourbeRemousParams(sectCR, 0.15, // Yamont = tirant amont
0.4, // Yaval = tirant aval
100, // Long= Longueur du bief
5, // Dx=Pas d'espace
MethodeResolution.EulerExplicite
);
nub = new CourbeRemous(prms, dbg);
break;
}
Dorchies David
committed
{
prms = new PabDimensionParams(
2, // Longueur L
1, // Largeur W
0.5, // Tirant d'eau Y
2 // Volume V
);
nub = new PabDimension(prms, dbg);
break;
}
Dorchies David
committed
{
prms = new PabPuissanceParams(
0.3, // Chute entre bassins DH (m)
0.1, // Débit Q (m3/s)
0.5, // Volume V (m3)
588.6 // Puissance dissipée PV (W/m3)
);
nub = new PabPuissance(prms, dbg);
break;
}
Dorchies David
committed
{

Grand Francois
committed
const structType: StructureType = params.getPropValue("structureType");
const loiDebit: LoiDebit = params.getPropValue("loiDebit");
nub = CreateStructure(structType, loiDebit);
break;
Dorchies David
committed
}
case CalculatorType.ParallelStructure:
Dorchies David
committed
{
prms = new ParallelStructureParams(0.5, // Q
102, // Z1
101.5 // Z2
);
nub = new ParallelStructure(prms, dbg);
break;
}
Dorchies David
committed
{
const deverPrms = new DeverParams(0.5, // Q
102, // Z1
10, // BR : largeur du cours d'eau
99 // ZR : cote du lit du cours d'eau
);
nub = new Dever(deverPrms, dbg);
break;
}
Dorchies David
committed
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
{
nub = new Cloisons(
new CloisonsParams(
0, // Débit total (m3/s)
102, // Cote de l'eau amont (m)
10, // Longueur des bassins (m)
1, // Largeur des bassins (m)
1, // Profondeur moyenne (m)
0.5 // Hauteur de chute (m)
), dbg
);
break;
}
case CalculatorType.MacroRugo:
{
nub = new MacroRugo(
new MacrorugoParams(
12.5, // ZF1
6, // L
1, // B
0.05, // If
1.57, // Q
0.6, // h
0.01, // Ks
0.05, // C
0.5, // D
0.8, // k
1.5 // Cd0
)
);
Dorchies David
committed
}
Dorchies David
committed
{
`Session.createNub() : calculatrice '${CalculatorType[calcType]}' / noeud de calcul '${ComputeNodeType[nodeType]}' non pris en charge`
Dorchies David
committed
}
// propagate properties
nub.properties = params;
return nub;
/**
* Crée un Nub de type Section
* @param nt ComputeNodeType
* @param dbg activer débogage
*/
private createSection(nt: ComputeNodeType, dbg: boolean = false): acSection {
switch (nt) {
case ComputeNodeType.None: // pour les paramètres communs, n'importe quelle section convient
case ComputeNodeType.SectionTrapeze:
{
const prms = new ParamsSectionTrapez(2.5, // largeur de fond
0.56, // fruit
0.8, // tirant d'eau
40, // Ks=Strickler
1.2, // Q=Débit
0.001, // If=pente du fond
}
case ComputeNodeType.SectionRectangle:
{
const prms = new ParamsSectionRectang(0.8, // tirant d'eau
2.5, // largeur de fond
40, // Ks=Strickler
1.2, // Q=Débit
0.001, // If=pente du fond
}
case ComputeNodeType.SectionCercle:
{
const prms = new ParamsSectionCirc(2, // diamètre
0.8, // tirant d'eau
40, // Ks=Strickler
1.2, // Q=Débit
0.001, // If=pente du fond
}
case ComputeNodeType.SectionPuissance:
{
const prms = new ParamsSectionPuiss(0.5, // coefficient
0.8, // tirant d'eau
4, // largeur de berge
40, // Ks=Strickler
1.2, // Q=Débit
0.001, // If=pente du fond
}
default:
throw new Error(`type de section ${ComputeNodeType[nt]} non pris en charge`);
}
}