Commit 6f99124c authored by Grand Francois's avatar Grand Francois
Browse files

correction bugs dans les tests

Showing with 69 additions and 50 deletions
+69 -50
......@@ -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 {
......
......@@ -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);
......
......@@ -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);
});
......
......@@ -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
......
......@@ -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', () => {
......
......@@ -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);
});
......
......@@ -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);
});
......
......@@ -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";
}
}
......
......@@ -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
}
/**
......
......@@ -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];
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment