Commit 79f70324 authored by Mathias Chouet's avatar Mathias Chouet 🍝
Browse files

Fix #122 - refactored classes organization

parent bde96c93
import { ParamDefinition, ParamFamily } from "./param/param-definition";
import { ParamDomainValue } from "./param/param-domain";
import { ParamsEquation } from "./param/params-equation";
/**
* paramètres pour la conduite distributrice
*/
export class ConduiteDistribParams extends ParamsEquation {
/** Débit */
public Q: ParamDefinition;
/** Diamètre */
public D: ParamDefinition;
/** Perte de charge */
public J: ParamDefinition;
/** Longueur de la conduite */
// tslint:disable-next-line:variable-name
public Lg: ParamDefinition;
/** Viscosité dynamique nu */
// tslint:disable-next-line:variable-name
public Nu: ParamDefinition;
constructor(rQ: number, rD: number, rJ: number, rLg: number, rNu: number) {
super();
this.Q = new ParamDefinition(this, "Q", ParamDomainValue.POS, "m³/s", rQ, ParamFamily.FLOWS);
this.D = new ParamDefinition(this, "D", ParamDomainValue.POS, "m", rD, ParamFamily.DIAMETERS);
this.J = new ParamDefinition(this, "J", ParamDomainValue.POS, "m", rJ);
this.Lg = new ParamDefinition(this, "Lg", ParamDomainValue.POS, "m", rLg, ParamFamily.LENGTHS);
this.Nu = new ParamDefinition(this, "Nu", ParamDomainValue.POS, "Pa·s", rNu);
this.addParamDefinition(this.Q);
this.addParamDefinition(this.D);
this.addParamDefinition(this.J);
this.addParamDefinition(this.Lg);
this.addParamDefinition(this.Nu);
}
}
......@@ -5,101 +5,7 @@ import { ParamDomain, ParamDomainValue } from "./param/param-domain";
import { Interval } from "./util/interval";
import { Message, MessageCode } from "./util/message";
import { Result } from "./util/result";
class SearchInterval extends Interval {
private _step: number;
private _dicho: Dichotomie;
private _targets: Interval;
constructor(d: Dichotomie, min: number, max: number, s: number) {
super(min, max);
if (s === 0) {
const e = new Message(MessageCode.ERROR_DICHO_NULL_STEP);
throw e;
}
this._step = s;
this._dicho = d;
}
public reverse() {
this._step = -this._step;
}
public growStep(k: number) {
if (k === 0) {
const e = new Message(MessageCode.ERROR_DICHO_INVALID_STEP_GROWTH);
throw e;
}
this._step *= k;
}
get step() {
return this._step;
}
get targets() {
if (this._targets === undefined) {
// @TODO just set _targets to undefined / null ?
this._targets = new Interval(undefined, undefined);
}
return this._targets;
}
/**
* get target value for lower bound
*/
get targetLower() {
this.updateTargets();
// @TODO val1 is not guaranteed to be the lower bound; use .min ?
return this.targets.val1;
}
/**
* get target value for upper bound
*/
get targetUpper() {
this.updateTargets();
// @TODO val2 is not guaranteed to be the upper bound; use .max ?
return this.targets.val2;
}
public next() {
if (this._step > 0) {
this.val1 = this.val2;
this.val2 += this._step;
this.targets.setValues(this.targets.val2, undefined);
} else {
this.val2 = this.val1;
this.val1 += this._step;
this.targets.setValues(undefined, this.targets.val1);
}
}
public hasTargetValue(targ: number) {
this.updateTargets();
return this.targets.intervalHasValue(targ);
}
public toString(): string {
return super.toString() + " step=" + this._step;
}
public updateTargets() {
let t1 = this.targets.val1;
if (t1 === undefined || isNaN(t1)) {
t1 = this._dicho.CalculX(this.val1);
}
let t2 = this.targets.val2;
if (t2 === undefined || isNaN(t2)) {
t2 = this._dicho.CalculX(this.val2);
}
this.targets.setValues(t1, t2);
}
}
import { SearchInterval } from "./util/search_interval";
/**
* calcul par dichotomie
......@@ -107,7 +13,6 @@ class SearchInterval extends Interval {
* on cherche par ex le x2 correspondant, les autres xi étant fixés.
* la méthode Equation() calcule analytiquement y=f(xi)
*/
// tslint:disable-next-line:max-classes-per-file
export class Dichotomie extends Debug {
/**
* définition de la variable de la fonction
......
......@@ -24,7 +24,10 @@ export * from "./util/result";
export * from "./util/resultelement";
export * from "./util/interval";
export * from "./util/observer";
export * from "./util/iterator";
export * from "./util/array_reverse_iterator";
export * from "./util/map_iterator";
export * from "./util/number_array_iterator";
export * from "./util/number_array_reverse_iterator";
export * from "./util/enum";
export * from "./pab/cloisons";
export * from "./structure/parallel_structure";
......
import { CalculatorType } from "./compute-node";
import { LCMaterial } from "./lc-material";
import { LechaptCalmonParams } from "./lechaptcalmon_params";
import { Nub } from "./nub";
import { ParamCalculability, ParamDefinition, ParamFamily } from "./param/param-definition";
import { ParamDomain, ParamDomainValue } from "./param/param-domain";
import { ParamsEquation } from "./param/params-equation";
import { ParamCalculability } from "./param/param-definition";
import { Observer } from "./util/observer";
import { Result } from "./util/result";
/**
* paramètres pour le calcul Lechapt et Calmon
*/
export class LechaptCalmonParams extends ParamsEquation {
/** Débit */
private _Q: ParamDefinition;
/** Diamètre */
private _D: ParamDefinition;
/** Perte de charge */
private _J: ParamDefinition;
/** Longueur de la conduite */
private _Lg: ParamDefinition;
/** Paramètre de rugosité L */
private _L: ParamDefinition;
/** Paramètre de rugosité M */
private _M: ParamDefinition;
/** Paramètre de rugosité N */
private _N: ParamDefinition;
constructor(rQ: number, rD: number, rJ: number, rLg: number, rL: number, rM: number, rN: number) {
super();
this._Q = new ParamDefinition(this, "Q", ParamDomainValue.POS, "m³/s", rQ, ParamFamily.FLOWS);
this._D = new ParamDefinition(
this, "D", new ParamDomain(ParamDomainValue.INTERVAL, 0, 20), "m", rD, ParamFamily.DIAMETERS
);
this._J = new ParamDefinition(this, "J", ParamDomainValue.POS, "m", rJ);
this._Lg = new ParamDefinition(this, "Lg", ParamDomainValue.POS, "m", rLg, ParamFamily.LENGTHS);
this._L = new ParamDefinition(this, "L", new ParamDomain(ParamDomainValue.INTERVAL, 0.8, 2), undefined, rL,
undefined, false);
this._M = new ParamDefinition(this, "M", new ParamDomain(ParamDomainValue.INTERVAL, 1.5, 2.5), undefined, rM,
undefined, false);
this._N = new ParamDefinition(this, "N", new ParamDomain(ParamDomainValue.INTERVAL, 4.5, 5.5), undefined, rN,
undefined, false);
this.addParamDefinition(this._Q);
this.addParamDefinition(this._D);
this.addParamDefinition(this._J);
this.addParamDefinition(this._Lg);
this.addParamDefinition(this._L);
this.addParamDefinition(this._M);
this.addParamDefinition(this._N);
}
get Q() {
return this._Q;
}
get D() {
return this._D;
}
get J() {
return this._J;
}
get Lg() {
return this._Lg;
}
get L() {
return this._L;
}
get M() {
return this._M;
}
get N() {
return this._N;
}
}
/**
* Calcul des pertes de charge dans un tube à partir des tables de Lechapt et Calmon
*/
// tslint:disable-next-line:max-classes-per-file
export class LechaptCalmon extends Nub implements Observer {
private static _materials: Array<{ L: number, M: number, N: number, title: string }> = [
......
import { ParamDefinition, ParamFamily } from "./param/param-definition";
import { ParamDomain, ParamDomainValue } from "./param/param-domain";
import { ParamsEquation } from "./param/params-equation";
/**
* paramètres pour le calcul Lechapt et Calmon
*/
export class LechaptCalmonParams extends ParamsEquation {
/** Débit */
private _Q: ParamDefinition;
/** Diamètre */
private _D: ParamDefinition;
/** Perte de charge */
private _J: ParamDefinition;
/** Longueur de la conduite */
private _Lg: ParamDefinition;
/** Paramètre de rugosité L */
private _L: ParamDefinition;
/** Paramètre de rugosité M */
private _M: ParamDefinition;
/** Paramètre de rugosité N */
private _N: ParamDefinition;
constructor(rQ: number, rD: number, rJ: number, rLg: number, rL: number, rM: number, rN: number) {
super();
this._Q = new ParamDefinition(this, "Q", ParamDomainValue.POS, "m³/s", rQ, ParamFamily.FLOWS);
this._D = new ParamDefinition(
this, "D", new ParamDomain(ParamDomainValue.INTERVAL, 0, 20), "m", rD, ParamFamily.DIAMETERS
);
this._J = new ParamDefinition(this, "J", ParamDomainValue.POS, "m", rJ);
this._Lg = new ParamDefinition(this, "Lg", ParamDomainValue.POS, "m", rLg, ParamFamily.LENGTHS);
this._L = new ParamDefinition(this, "L", new ParamDomain(ParamDomainValue.INTERVAL, 0.8, 2), undefined, rL,
undefined, false);
this._M = new ParamDefinition(this, "M", new ParamDomain(ParamDomainValue.INTERVAL, 1.5, 2.5), undefined, rM,
undefined, false);
this._N = new ParamDefinition(this, "N", new ParamDomain(ParamDomainValue.INTERVAL, 4.5, 5.5), undefined, rN,
undefined, false);
this.addParamDefinition(this._Q);
this.addParamDefinition(this._D);
this.addParamDefinition(this._J);
this.addParamDefinition(this._Lg);
this.addParamDefinition(this._L);
this.addParamDefinition(this._M);
this.addParamDefinition(this._N);
}
get Q() {
return this._Q;
}
get D() {
return this._D;
}
get J() {
return this._J;
}
get Lg() {
return this._Lg;
}
get L() {
return this._L;
}
get M() {
return this._M;
}
get N() {
return this._N;
}
}
......@@ -6,8 +6,6 @@ import { ParamValueMode } from "../param/param-value-mode";
import { Result } from "../util/result";
import { MacrorugoParams } from "./macrorugo_params";
export { MacrorugoParams };
export enum MacroRugoFlowType {
EMERGENT,
QUASI_EMERGENT,
......
import { ParamDefinition, ParamFamily } from "../param/param-definition";
import { ParamDomain, ParamDomainValue } from "../param/param-domain";
import { MacrorugoParams } from "./macrorugo";
import { MacrorugoParams } from "./macrorugo_params";
export class MacrorugoCompoundParams extends MacrorugoParams {
......
import { CalculatorType, ComputeNode } from "./compute-node";
import { Dichotomie } from "./dichotomie";
import { acSection, IParamDefinitionIterator, MacrorugoCompound, Pab, ParamDefinition, ParamsEquation,
ParamsEquationArrayIterator, Session, Structure } from "./index";
import { acSection, MacrorugoCompound, Pab, ParamDefinition, ParamsEquation,
Session, Structure } from "./index";
import { LinkedValue } from "./linked-value";
import { ParamCalculability, ParamFamily } from "./param/param-definition";
import { ParamValueMode } from "./param/param-value-mode";
import { ParamValues } from "./param/param-values";
import { IParamDefinitionIterator } from "./param/param_definition_iterator";
import { ParamsEquationArrayIterator } from "./param/params_equation_array_iterator";
import { Props } from "./props";
import { IObservable, Observable, Observer } from "./util/observer";
import { Result } from "./util/result";
......
import { CalculatorType, ParamsEquation } from "../index";
import { CalculatorType } from "../index";
import { ParamCalculability } from "../param/param-definition";
import { ParallelStructure } from "../structure/parallel_structure";
import { loiAdmissiblesCloisonAval, LoiDebit } from "../structure/structure_props";
import { StructureVanLevLarinier, StructureVanLevVillemonte } from "../structure/structure_vanlev";
import { StructureVanLevLarinier } from "../structure/structure_vanlev_larinier";
import { StructureVanLevVillemonte } from "../structure/structure_vanlev_villemonte";
import { Message, MessageCode } from "../util/message";
import { Result } from "../util/result";
import { CloisonsAvalParams } from "./cloison_aval_params";
export { ParallelStructureParams } from "../structure/parallel_structure_params";
export class CloisonAval extends ParallelStructure {
constructor(prms: CloisonsAvalParams, dbg: boolean = false) {
......
......@@ -2,12 +2,10 @@ import { CalculatorType } from "../compute-node";
import { Nub, Pab, StructureParams } from "../index";
import { ParamCalculability } from "../param/param-definition";
import { ParallelStructure } from "../structure/parallel_structure";
import { StructureKiviParams } from "../structure/structure_kivi";
import { StructureKiviParams } from "../structure/structure_kivi_params";
import { loiAdmissiblesCloisons, LoiDebit } from "../structure/structure_props";
import { Result } from "../util/result";
import { CloisonsParams } from "./cloisons_params";
export { CloisonsParams };
export class Cloisons extends ParallelStructure {
constructor(prms: CloisonsParams, dbg: boolean = false) {
......
......@@ -2,7 +2,9 @@ import { CalculatorType } from "../compute-node";
import { ParamValueMode } from "../index";
import { Nub } from "../nub";
import { ParamCalculability, ParamDefinition } from "../param/param-definition";
import { IParamDefinitionIterator, ParamsEquation, ParamsEquationArrayIterator } from "../param/params-equation";
import { IParamDefinitionIterator } from "../param/param_definition_iterator";
import { ParamsEquation } from "../param/params-equation";
import { ParamsEquationArrayIterator } from "../param/params_equation_array_iterator";
import { Props } from "../props";
import { Session } from "../session";
import { ParallelStructure } from "../structure/parallel_structure";
......@@ -10,13 +12,11 @@ import { StructureTriangularTruncWeirFree } from "../structure/structure_triangu
import { Message, MessageCode } from "../util/message";
import { Result } from "../util/result";
import { ResultElement } from "../util/resultelement";
import { CloisonAval, ParallelStructureParams } from "./cloison_aval";
import { CloisonAval } from "./cloison_aval";
import { CloisonsAvalParams } from "./cloison_aval_params";
import { Cloisons } from "./cloisons";
import { PabParams } from "./pab_params";
export { PabParams };
export class Pab extends Nub {
/**
......
import { CalculatorType } from "../compute-node";
import { Nub } from "../nub";
import { ParamCalculability, ParamDefinition, ParamFamily } from "../param/param-definition";
import { ParamDomainValue } from "../param/param-domain";
import { ParamsEquation } from "../param/params-equation";
import { ParamCalculability } from "../param/param-definition";
import { Message, MessageCode } from "../util/message";
import { Result } from "../util/result";
import { PabChuteParams } from "./pab_chute_params";
export class PabChuteParams extends ParamsEquation {
[key: string]: any; // pour pouvoir faire this['methode']();
/** Cote amont Z1 */
private _Z1: ParamDefinition;
/** Cote aval Z2 */
private _Z2: ParamDefinition;
/** Chute DH */
private _DH: ParamDefinition;
constructor(rZ1: number, rZ2: number, rDH: number) {
super();
this._Z1 = new ParamDefinition(this, "Z1", ParamDomainValue.ANY, "m", rZ1, ParamFamily.ELEVATIONS);
this._Z2 = new ParamDefinition(this, "Z2", ParamDomainValue.ANY, "m", rZ2, ParamFamily.ELEVATIONS);
this._DH = new ParamDefinition(this, "DH", ParamDomainValue.POS_NULL, "m", rDH, ParamFamily.TOTALFALLS);
this.addParamDefinition(this._Z1);
this.addParamDefinition(this._Z2);
this.addParamDefinition(this._DH);
}
get Z1() {
return this._Z1;
}
get Z2() {
return this._Z2;
}
get DH() {
return this._DH;
}
}
// tslint:disable-next-line:max-classes-per-file
export class PabChute extends Nub {
constructor(prms: PabChuteParams, dbg: boolean = false) {
super(prms, dbg);
......
import { ParamDefinition, ParamFamily } from "../param/param-definition";
import { ParamDomainValue } from "../param/param-domain";
import { ParamsEquation } from "../param/params-equation";
export class PabChuteParams extends ParamsEquation {
[key: string]: any; // pour pouvoir faire this['methode']();
/** Cote amont Z1 */
private _Z1: ParamDefinition;
/** Cote aval Z2 */
private _Z2: ParamDefinition;
/** Chute DH */
private _DH: ParamDefinition;
constructor(rZ1: number, rZ2: number, rDH: number) {
super();
this._Z1 = new ParamDefinition(this, "Z1", ParamDomainValue.ANY, "m", rZ1, ParamFamily.ELEVATIONS);
this._Z2 = new ParamDefinition(this, "Z2", ParamDomainValue.ANY, "m", rZ2, ParamFamily.ELEVATIONS);
this._DH = new ParamDefinition(this, "DH", ParamDomainValue.POS_NULL, "m", rDH, ParamFamily.TOTALFALLS);
this.addParamDefinition(this._Z1);
this.addParamDefinition(this._Z2);
this.addParamDefinition(this._DH);
}
get Z1() {
return this._Z1;
}
get Z2() {
return this._Z2;
}
get DH() {
return this._DH;
}
}
import { CalculatorType } from "../compute-node";
import { Nub } from "../nub";
import { ParamCalculability, ParamDefinition, ParamFamily } from "../param/param-definition";
import { ParamDomainValue } from "../param/param-domain";
import { ParamsEquation } from "../param/params-equation";
import { ParamCalculability } from "../param/param-definition";
import { Result } from "../util/result";
import { PabDimensionParams } from "./pab_dimensions_params";
export class PabDimensionParams extends ParamsEquation {
[key: string]: any; // pour pouvoir faire this['methode]();
/** Longueur L */
private _L: ParamDefinition;
/** Largeur W */
private _W: ParamDefinition;
/** Tirant d'eau Y */
private _Y: ParamDefinition;
/** Volume V */
private _V: ParamDefinition;
constructor(rL: number, rW: number, rY: number, rV?: number) {
super();
this._L = new ParamDefinition(this, "L", ParamDomainValue.POS, "m", rL, ParamFamily.LENGTHS);
this._W = new ParamDefinition(this, "W", ParamDomainValue.POS, "m", rW, ParamFamily.WIDTHS);
this._Y = new ParamDefinition(this, "Y", ParamDomainValue.POS, "m", rY, ParamFamily.HEIGHTS);
this._V = new ParamDefinition(this, "V", ParamDomainValue.POS, "", rV, ParamFamily.VOLUMES);
this.addParamDefinition(this._L);
this.addParamDefinition(this._W);
this.addParamDefinition(this._Y);
this.addParamDefinition(this._V);
}
get L() {
return this._L;
}
get W() {
return this._W;
}
get Y() {
return this._Y;
}
get V() {
return this._V;
}
}
// tslint:disable-next-line:max-classes-per-file
export class PabDimension extends Nub {
constructor(prms: PabDimensionParams, dbg: boolean = false) {
super(prms, dbg);
......
import { ParamDefinition, ParamFamily } from "../param/param-definition";
import { ParamDomainValue } from "../param/param-domain";
import { ParamsEquation } from "../param/params-equation";
export class PabDimensionParams extends ParamsEquation {
[key: string]: any; // pour pouvoir faire this['methode]();
/** Longueur L */
private _L: ParamDefinition;
/** Largeur W */