diff --git a/spec/nubtest.ts b/spec/nubtest.ts index d0f0c2f9937060100a4561ec8bf69e09beb80dd9..9b0fc3d6cb37cace172f3c5ff0cea7121e2cb8e1 100644 --- a/spec/nubtest.ts +++ b/spec/nubtest.ts @@ -55,7 +55,7 @@ export class NubTest extends Nub { protected setParametersCalculability() { this.getParameter('A').calculability = ParamCalculability.DICHO; this.getParameter('B').calculability = ParamCalculability.DICHO; - //this.getParameter('C').calculability = ParamCalculability.EQUATION; // TODO + this.getParameter('C').calculability = ParamCalculability.EQUATION; } get prms(): NubTestParams { diff --git a/spec/regime_uniforme_circ.spec.ts b/spec/regime_uniforme_circ.spec.ts index f1d01da151cf9ef963a9369df90ed306e37cf988..57d1987b17c3a406ecfbc13607f67a23fd04b14a 100644 --- a/spec/regime_uniforme_circ.spec.ts +++ b/spec/regime_uniforme_circ.spec.ts @@ -25,13 +25,12 @@ describe('Class RegimeUniforme / section circulaire : ', () => { let ru = new RegimeUniforme(sect); - // expect(ru.Calc("D", 0, 0.001).vCalc).toBeCloseTo(6, 2); - expect(ru.Calc("D").vCalc).toBeCloseTo(6, 2); + expect(ru.Calc("D", 1e-8).vCalc).toBeCloseTo(6, 2); }); it('Ks should be 40', () => { - let paramCnl = new ParamsSectionCirc(6, // diamètre + let paramSection = new ParamsSectionCirc(6, // diamètre 0.6613, // tirant d'eau undefined, // Ks=Strickler 1.2, // Q=Débit @@ -41,15 +40,15 @@ describe('Class RegimeUniforme / section circulaire : ', () => { // YCL=Condition limite en cote à l'amont ou à l'aval ); - let sect = new cSnCirc(undefined, paramCnl); + let sect = new cSnCirc(undefined, paramSection); let ru = new RegimeUniforme(sect); - expect(ru.Calc("Ks").vCalc).toBeCloseTo(40, 2); + expect(ru.Calc("Ks", 1e-8).vCalc).toBeCloseTo(40, 2); }); it('If should be 0.001', () => { - let paramCnl = new ParamsSectionCirc(6, // diamètre + let paramSection = new ParamsSectionCirc(6, // diamètre 0.6613, // tirant d'eau 40, // Ks=Strickler 1.2, // Q=Débit @@ -59,7 +58,7 @@ describe('Class RegimeUniforme / section circulaire : ', () => { // YCL=Condition limite en cote à l'amont ou à l'aval ); - let sect = new cSnCirc(undefined, paramCnl); + let sect = new cSnCirc(undefined, paramSection); let ru = new RegimeUniforme(sect); @@ -67,7 +66,7 @@ describe('Class RegimeUniforme / section circulaire : ', () => { }); it('Q should be 1.2', () => { - let paramCnl = new ParamsSectionCirc(6, // diamètre + let paramSection = new ParamsSectionCirc(6, // diamètre 0.6613, // tirant d'eau 40, // Ks=Strickler undefined, // Q=Débit @@ -77,7 +76,7 @@ describe('Class RegimeUniforme / section circulaire : ', () => { // YCL=Condition limite en cote à l'amont ou à l'aval ); - let sect = new cSnCirc(undefined, paramCnl); + let sect = new cSnCirc(undefined, paramSection); let ru = new RegimeUniforme(sect); @@ -85,7 +84,7 @@ describe('Class RegimeUniforme / section circulaire : ', () => { }); it('Y should be 0.6613', () => { - let paramCnl = new ParamsSectionCirc(6, // diamètre + let paramSection = new ParamsSectionCirc(6, // diamètre undefined, // tirant d'eau 40, // Ks=Strickler 1.2, // Q=Débit @@ -95,7 +94,7 @@ describe('Class RegimeUniforme / section circulaire : ', () => { // YCL=Condition limite en cote à l'amont ou à l'aval ); - let sect = new cSnCirc(undefined, paramCnl); + let sect = new cSnCirc(undefined, paramSection); let ru = new RegimeUniforme(sect); diff --git a/spec/regime_uniforme_puissance.spec.ts b/spec/regime_uniforme_puissance.spec.ts index e19d0db26aad494c7017f140cf2681f61e97f0c4..a210c33d7847248d95c410f873cb0bfe8305795a 100644 --- a/spec/regime_uniforme_puissance.spec.ts +++ b/spec/regime_uniforme_puissance.spec.ts @@ -64,7 +64,7 @@ describe('Class RegimeUniforme / section puissance: ', () => { let ru = new RegimeUniforme(sect, false); - expect(ru.Calc("Ks").vCalc).toBeCloseTo(33.774, 2); + expect(ru.Calc("Ks", 1e-8).vCalc).toBeCloseTo(33.774, 2); }); diff --git a/spec/regime_uniforme_rect.spec.ts b/spec/regime_uniforme_rect.spec.ts index 5472c9ce5546ce5672a8b995cadd6ba3276fafa9..36347bda0032728015c7d401b822991f010d77ed 100644 --- a/spec/regime_uniforme_rect.spec.ts +++ b/spec/regime_uniforme_rect.spec.ts @@ -44,7 +44,7 @@ describe('Class RegimeUniforme / section rectangulaire : ', () => { let sect = new cSnRectang(undefined, prms); let ru = new RegimeUniforme(sect); - expect(ru.Calc("Ks").vCalc).toBeCloseTo(30.618, precDigits); + expect(ru.Calc("Ks", 1e-8).vCalc).toBeCloseTo(30.618, precDigits); }); it('If should be 0.001', () => { @@ -101,8 +101,8 @@ describe('Class RegimeUniforme / section rectangulaire : ', () => { it('Y should be 0.663', () => { let prms = new ParamsSectionRectang(undefined, // tirant d'eau + 2.5, // largeur de fond 40, // Ks=Strickler - 2.5, // largeur de fond 1.2, // Q=Débit 0.001, // If=pente du fond precDist, // précision diff --git a/spec/regime_uniforme_trapeze.spec.ts b/spec/regime_uniforme_trapeze.spec.ts index 2b3a76772459e8d69489a7356d94169566b36842..c49878910bc034fa147b98806ed1945e65b6096c 100644 --- a/spec/regime_uniforme_trapeze.spec.ts +++ b/spec/regime_uniforme_trapeze.spec.ts @@ -62,7 +62,7 @@ describe('Class RegimeUniforme / section trapèze: ', () => { let sect = new cSnTrapez(undefined, prms); let ru = new RegimeUniforme(sect); - expect(ru.Calc("Ks").vCalc).toBeCloseTo(24.14, precDigits); + expect(ru.Calc("Ks", 1e-8).vCalc).toBeCloseTo(24.14, precDigits); }); it('If should be 0.001', () => { diff --git a/spec/section_param_rect_fluvial.spec.ts b/spec/section_param_rect_fluvial.spec.ts index 0371cd946f12db05320517e3f02efcadd6752b3a..488453f098b21a096c4defee783aa5bfa35910c3 100644 --- a/spec/section_param_rect_fluvial.spec.ts +++ b/spec/section_param_rect_fluvial.spec.ts @@ -7,19 +7,23 @@ import { ParamsSectionRectang, cSnRectang } from "../src/section/section_rectang let paramSection: ParamsSectionRectang; let sect: cSnRectang; +function createSection(prec: number): cSnRectang { + paramSection = 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 + prec, // précision + 1 // YB= hauteur de berge + // YCL=Condition limite en cote à l'amont ou à l'aval + ); + + return new cSnRectang(undefined, paramSection); +} + describe('Section paramétrée rectangulaire : ', () => { beforeEach(() => { - paramSection = 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 - precDist, // précision - 1 // YB= hauteur de berge - // YCL=Condition limite en cote à l'amont ou à l'aval - ); - - sect = new cSnRectang(undefined, paramSection); + sect = createSection(precDist); }); describe('fluvial :', () => { @@ -90,13 +94,13 @@ describe('Section paramétrée rectangulaire : ', () => { // perte de charge it('J should equal to 0.00059', () => { - paramSection.Prec.v = 0.00001; + sect = createSection(0.00001); expect(sect.Calc_J()).toBeCloseTo(0.00059, precDigits); }); // Variation linéaire de l'énergie spécifique it('I-J should equal to 0.00041', () => { - paramSection.Prec.v = 0.00001; + sect = createSection(0.00001); expect(sect.Calc("I-J")).toBeCloseTo(0.00041, precDigits); }); diff --git a/spec/section_param_trapez_fluvial.spec.ts b/spec/section_param_trapez_fluvial.spec.ts index 352641e7b410f9549a3c04b03418ba5f6ba3f30f..896fdc87b11c6d5b17f46b3a2104806dd8aacf31 100644 --- a/spec/section_param_trapez_fluvial.spec.ts +++ b/spec/section_param_trapez_fluvial.spec.ts @@ -7,20 +7,24 @@ import { ParamsSectionTrapez, cSnTrapez } from "../src/section/section_trapez"; let paramSection: ParamsSectionTrapez; let sect: cSnTrapez; +function createSection(prec: number): cSnTrapez { + paramSection = 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 + precDist, // précision + 1 // YB= hauteur de berge + // YCL=Condition limite en cote à l'amont ou à l'aval + ); + + return new cSnTrapez(undefined, paramSection); +} + describe('Section paramétrée trapèze : ', () => { beforeEach(() => { - paramSection = new ParamsSectionTrapez(2.5, // largeur de fond - 0.56, // fruit - 0.8, // tirant d'eau - 1.2, // Q=Débit - 40, // Ks=Strickler - 0.001, // If=pente du fond - precDist, // précision - 1 // YB= hauteur de berge - // YCL=Condition limite en cote à l'amont ou à l'aval - ); - - sect = new cSnTrapez(undefined, paramSection); + sect = createSection(precDist); }); describe('fluvial :', () => { @@ -91,7 +95,7 @@ describe('Section paramétrée trapèze : ', () => { // perte de charge it('J should equal to 0.00036', () => { - paramSection.Prec.v = 0.00001; + let sect = createSection(0.00001); expect(sect.Calc_J()).toBeCloseTo(0.00036, precDigits); }); diff --git a/src/param.ts b/src/param.ts index 86e2d429fdfbb6cb2cd655eb72840d52ae39f655..8d8a751ae5b71c6e38934816b023a1a836aa9955 100644 --- a/src/param.ts +++ b/src/param.ts @@ -189,6 +189,10 @@ export class ParamDefinition { this._value = val; } + get uncheckedValue() { + return this._value; + } + private checkValue(v: number) { let sDomain = ParamDomainValue[this._domain.value]; @@ -252,6 +256,12 @@ export class ParamDefinition { this._savedValue = undefined; } */ + + toString(): string { + if (this.isDefined()) + return "" + this._value; + return "undefined"; + } } diff --git a/src/section/section_circulaire.ts b/src/section/section_circulaire.ts index e32b23467c8bef34d7471c32119a9570e78f508f..ee0ddbb888eb74c44a5065020b5f8b933b9dd7e2 100644 --- a/src/section/section_circulaire.ts +++ b/src/section/section_circulaire.ts @@ -77,7 +77,8 @@ export class cSnCirc extends acSection { private isDebordement(): boolean { // return this.prms.Y.v > Math.min(this.prms.YB.v, this.prms.D.v); //return this.valeurYDebordement() > 0; - return this.prms.Y.v >= this.prms.D.v || this.prms.Y.v >= this.prms.YB.v + // return this.prms.Y.v >= this.prms.D.v || this.prms.Y.v >= this.prms.YB.v + return this.prms.Y.v > this.prms.D.v || this.prms.Y.v > this.prms.YB.v } /** diff --git a/src/section/section_type.ts b/src/section/section_type.ts index 95c1b01fc4906c8eda338e32129c02389e849241..e8eb850893b9f74bf41e22a5480fefd4f1de763d 100644 --- a/src/section/section_type.ts +++ b/src/section/section_type.ts @@ -221,8 +221,8 @@ export abstract class acSection extends ComputeNode { */ private Swap(bMem) { if (bMem) { - this.debug('save Y=' + this.prms.Y.v); - this.Y_old = this.prms.Y.v; + this.debug('save Y=' + this.prms.Y.toString()); + this.Y_old = this.prms.Y.uncheckedValue; this.Calc_old = this.arCalc; } else { @@ -241,9 +241,10 @@ export abstract class acSection extends ComputeNode { */ Calc(sDonnee: string, rY: number = undefined): number { this.debug("in Calc(" + sDonnee + ", rY = " + rY + ") old " + sDonnee + "= " + this.arCalc[sDonnee]); - this.debug("this.Y=" + this.prms.Y.v); + this.debug("this.Y=" + this.prms.Y.toString()); - if (rY != undefined && rY != this.prms.Y.v) { + //if (rY != undefined && rY != this.prms.Y.v) { + if (rY != undefined && (!this.prms.Y.isDefined() || rY != this.prms.Y.v)) { this.prms.Y.v = rY; // On efface toutes les données dépendantes de Y pour forcer le calcul this.Reset(false); @@ -276,7 +277,7 @@ export abstract class acSection extends ComputeNode { else this.debug("Calc(" + sDonnee + ") cache= " + this.arCalc[sDonnee]); - this.debug('this.Y=' + this.prms.Y.v); + this.debug('this.Y=' + this.prms.Y.toString()); return this.arCalc[sDonnee]; } @@ -289,7 +290,7 @@ export abstract class acSection extends ComputeNode { */ CalcGeo(sDonnee): number { this.debug("in CalcGeo(" + sDonnee + ') old ' + sDonnee + '=' + this.arCalcGeo[sDonnee]); - this.debug('this.Y=' + this.prms.Y.v); + this.debug('this.Y=' + this.prms.Y.toString()); // if (sDonnee != 'B' && !this.arCalcGeo['B']) { if (sDonnee != 'B' && this.arCalcGeo['B'] == undefined) { @@ -329,7 +330,7 @@ export abstract class acSection extends ComputeNode { else this.debug("CalcGeo(" + sDonnee + ") cache= " + this.arCalcGeo[sDonnee]); - this.debug('this.Y=' + this.prms.Y.v); + this.debug('this.Y=' + this.prms.Y.toString()); return this.arCalcGeo[sDonnee]; }