diff --git a/src/pipe_flow/pl_lechaptcalmon_params.ts b/src/pipe_flow/pl_lechaptcalmon_params.ts index 9bd1f4c4eff6b63843b52dc228917f16fc7570cf..cfcde837957a7102969bb62db8e7a05fcab78380 100644 --- a/src/pipe_flow/pl_lechaptcalmon_params.ts +++ b/src/pipe_flow/pl_lechaptcalmon_params.ts @@ -1,4 +1,4 @@ -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); diff --git a/src/pipe_flow/pressureloss.ts b/src/pipe_flow/pressureloss.ts index 4dc7fa7c94e95e11e7cd263b1081ead19909ba63..e1c8d9435d3e0cab391d612fc8e2a731591d3819 100644 --- a/src/pipe_flow/pressureloss.ts +++ b/src/pipe_flow/pressureloss.ts @@ -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 diff --git a/src/session.ts b/src/session.ts index 0496e9ad0741d764b2a5f62a2eded5514c70e2f1..efe2e15ae254c2e94ea39a109e339fddca7f5a38 100644 --- a/src/session.ts +++ b/src/session.ts @@ -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