Skip to content
Snippets Groups Projects
Commit 96b4c64e authored by François Grand's avatar François Grand
Browse files

Session: add pressure loss nub creation

refs #334
parent be882e93
No related branches found
No related tags found
No related merge requests found
import { ParamDefinition, ParamFamily } from "../param/param-definition";
import { ParamDefinition } from "../param/param-definition";
import { ParamDomain, ParamDomainValue } from "../param/param-domain";
import { PressureLossParams } from "./pressureloss_params";
......@@ -16,8 +16,7 @@ export class PL_LechaptCalmonParams extends PressureLossParams {
/** Paramètre de rugosité N */
private _N: ParamDefinition;
constructor(rQ: number, rD: number, rJ: number, rLg: number, rL: number, rM: number, rN: number, rKs: number,
nullParams: boolean = false) {
constructor(rQ: number, rD: number, rJ: number, rLg: number, rKs: number, rL: number, rM: number, rN: number, nullParams: boolean = false) {
super(rQ, rD, rJ, rLg, rKs, nullParams);
this._L = new ParamDefinition(this, "L", new ParamDomain(ParamDomainValue.INTERVAL, 0.8, 2), undefined, rL,
undefined, false, nullParams);
......
......@@ -3,12 +3,23 @@ import { Observer } from "../util/observer";
import { Result } from "../util/result";
import { CalculatorType } from "../compute-node";
import { PressureLossParams } from "./pressureloss_params";
import { PressureLossLaw } from "../pipe_flow/pressureloss_law";
import { ParamCalculability } from "../param/param-definition";
import { Message, MessageCode } from "../util/message";
export class PressureLoss extends Nub implements Observer {
constructor(prms: PressureLossParams, dbg: boolean = false) {
super(prms, dbg);
constructor(law: PressureLossLaw, dbg: boolean = false) {
super(undefined, dbg);
this.setCalculatorType(CalculatorType.PressureLoss);
this.addChild(law);
}
/**
* paramètres castés au bon type
*/
get prms(): PressureLossParams {
return this._prms as PressureLossParams;
}
/**
......@@ -18,7 +29,7 @@ export class PressureLoss extends Nub implements Observer {
}
public Equation(sVarCalc: string): Result {
return undefined;
return this._children[0].Equation(sVarCalc);
}
// interface Observer
......
......@@ -87,6 +87,9 @@ import { PbCloison } from "./prebarrage/pb_cloison";
import { PbBassin } from "./prebarrage/pb_bassin";
import { PbBassinParams } from "./prebarrage/pb_bassin_params";
import { ParamValueMode } from "./param/param-value-mode";
import { PressureLoss } from "./pipe_flow/pressureloss";
import { PressureLossParams } from "./pipe_flow/pressureloss_params";
import { PressureLossLaw, PressureLossType } from "./pipe_flow/pressureloss_law";
export class Session {
......@@ -393,21 +396,6 @@ export class Session {
nub = new ConduiteDistrib(prms, dbg);
break;
case CalculatorType.LechaptCalmon:
prms = new PL_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
0, // Ks Perte de charge singulière
nullParams
);
nub = new PL_LechaptCalmon(prms, dbg);
break;
case CalculatorType.SectionParametree:
nub = new SectionParametree(undefined, dbg);
break;
......@@ -800,6 +788,12 @@ export class Session {
nub = new PbCloison(undefined, undefined, undefined, nullParams);
break;
case CalculatorType.PressureLoss:
const lossType: PressureLossType = params.getPropValue("pressureLossType");
const pl = this.createPressureLossLaw(lossType, dbg, nullParams);
nub = new PressureLoss(pl, dbg);
break;
default:
throw new Error(
`Session.createNub() : type de module '${CalculatorType[calcType]}' non pris en charge`
......@@ -991,6 +985,31 @@ export class Session {
}
}
/**
* Crée un Nub de type perte de charge
*/
private createPressureLossLaw(plt: PressureLossType, dbg: boolean = false, nullParams: boolean = false): PressureLossLaw {
switch (plt) {
case PressureLossType.LechaptCalmon:
const prms = new PL_LechaptCalmonParams(
3, // débit
1.2, // diamètre
0.6, /// perte de charge
100, // longueur du toyo
0, // Ks Perte de charge singulière
1.863, // paramètre L du matériau
2, // paramètre M du matériau
5.33, // paramètre N du matériau
nullParams
);
return new PL_LechaptCalmon(prms, dbg);
default:
throw new Error(`type de perte de charge ${PressureLossType[plt]} non pris en charge`);
}
}
/**
* Creates a Nub from an object representation and adds it to the current session; returns
* a pointer to the Nub and its JSON metadata
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment