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

refactor: pressure loss: move common computations to pressure loss law class

refs #334
parent 896bbe0b
No related branches found
No related tags found
No related merge requests found
......@@ -91,6 +91,10 @@ export class PL_LechaptCalmon extends PressureLossLaw implements Observer {
this.properties.setPropValue("material", m);
}
protected calc_Jlin(): number {
return this.prms.L.v * Math.pow(this.prms.Q.v, this.prms.M.v) / Math.pow(this.prms.D.v, this.prms.N.v) * (this.prms.Lg.v / 1000);
}
/**
* paramètres castés au bon type
*/
......@@ -106,26 +110,6 @@ export class PL_LechaptCalmon extends PressureLossLaw implements Observer {
return r;
}
public Equation(sVarCalc: string): Result {
if (sVarCalc !== "J") {
throw new Error("LechaptCalmon.Equation() : invalid variable name " + sVarCalc);
}
const r: Result = new Result(0, this);
r.values.V = this.prms.Q.v / (Math.PI * Math.pow(this.prms.D.v / 2, 2));
if (r.values.V < 0.4 || r.values.V > 2) {
r.resultElement.log.add(new Message(MessageCode.WARNING_LECHAPT_CALMON_SPEED_OUTSIDE_04_2));
}
r.values.Jl = this.prms.L.v * Math.pow(this.prms.Q.v, this.prms.M.v)
/ Math.pow(this.prms.D.v, this.prms.N.v) * (this.prms.Lg.v / 1000);
r.vCalc = r.values.Jl + this.prms.Kloc.v / 19.62 * Math.pow(r.values.V, 2);
return r;
}
// interface Observer
public update(sender: any, data: any) {
......
import { Nub } from "../internal_modules";
import { Nub, PressureLossLawParams } from "../internal_modules";
import { Result } from "../internal_modules";
import { Message, MessageCode } from "../internal_modules";
/**
* Loi de perte de charge
......@@ -17,4 +19,34 @@ export abstract class PressureLossLaw extends Nub {
public get pressureLossType(): PressureLossType {
return this._pressureLossType;
}
/**
* paramètres castés au bon type
*/
get prms(): PressureLossLawParams {
return this._prms as PressureLossLawParams;
}
/**
* calcul de la perte de charge linéaire spécifique à chaque mdule de perte de charge
*/
protected abstract calc_Jlin(): number;
public Equation(sVarCalc: string): Result {
if (sVarCalc !== "J") {
throw new Error("LechaptCalmon.Equation() : invalid variable name " + sVarCalc);
}
const r: Result = new Result(0, this);
r.values.V = this.prms.Q.v / (Math.PI * Math.pow(this.prms.D.v / 2, 2));
if (r.values.V < 0.4 || r.values.V > 2) {
r.resultElement.log.add(new Message(MessageCode.WARNING_LECHAPT_CALMON_SPEED_OUTSIDE_04_2));
}
r.values.Jl = this.calc_Jlin();
r.vCalc = r.values.Jl + this.prms.Kloc.v / 19.62 * Math.pow(r.values.V, 2);
return r;
}
}
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