Commit fc68250b authored by Grand Francois's avatar Grand Francois
Browse files

tests unitaires régime uniforme/section circulaire

Showing with 132 additions and 13 deletions
+132 -13
...@@ -20,11 +20,14 @@ build-dir : ...@@ -20,11 +20,14 @@ build-dir :
buildspec : buildspec :
npm run buildspec npm run buildspec
jasmine : buildspec jasmine : buildspec cls
npm run jasmine npm run jasmine
karma : karma :
npm run karma npm run karma
cls :
printf "\033c"
clean : clean :
rm -rf $(BUILD_DIR) rm -rf $(BUILD_DIR)
...@@ -10,16 +10,13 @@ describe('Class Nub: ', () => { ...@@ -10,16 +10,13 @@ describe('Class Nub: ', () => {
// }); // });
describe('Calc(): ', () => { describe('Calc(): ', () => {
it('should return a result.vCalc equal to 3', () => { it('should return a result.vCalc equal to 3', () => {
let res = new Result(3); expect(nub.Calc("C").vCalc).toBeCloseTo(3, precDigits);
expect(nub.Calc("C").vCalc).toBeCloseTo(res.vCalc, precDigits);
}); });
it('should return a result.vCalc equal to 1', () => { it('should return a result.vCalc equal to 1', () => {
let res = new Result(1); expect(nub.Calc("A").vCalc).toBeCloseTo(1, precDigits);
expect(nub.Calc("A").vCalc).toBeCloseTo(res.vCalc, precDigits);
}); });
it('should return a result.vCalc equal to 2', () => { it('should return a result.vCalc equal to 2', () => {
let res = new Result(2); precDigits expect(nub.Calc("B").vCalc).toBeCloseTo(2, precDigits);
expect(nub.Calc("B").vCalc).toBeCloseTo(res.vCalc, precDigits);
}); });
}); });
}); });
...@@ -2,8 +2,8 @@ import { Result, IParamsEquation } from "../src/base"; ...@@ -2,8 +2,8 @@ import { Result, IParamsEquation } from "../src/base";
import { Nub } from "../src/nub"; import { Nub } from "../src/nub";
export class NubTest extends Nub { export class NubTest extends Nub {
constructor(v: IParamsEquation) { constructor(v: IParamsEquation, dbg: boolean = false) {
super(v); super(v, dbg);
this.sVarsEq = ["C"]; this.sVarsEq = ["C"];
} }
Equation(): Result { Equation(): Result {
...@@ -23,4 +23,4 @@ export let precDigits = 3; ...@@ -23,4 +23,4 @@ export let precDigits = 3;
/** /**
* précision de calcul (max de abs(v-v')) * précision de calcul (max de abs(v-v'))
*/ */
export let precDist = Math.pow(10, -precDigits); export let precDist: number = Math.pow(10, -precDigits);
/// <reference path="../node_modules/@types/jasmine/index.d.ts" />
import { Result } from "../src/base";
import { RegimeUniforme } from "../src/regime_uniforme";
import { cSnCirc } from "../src/section/section_circulaire";
import { cParamsCanal } from "../src/section/section_type";
import { precDigits, precDist } from "./nubtest";
describe('Class RegimeUniforme / section circulaire : ', () => {
// beforeAll(() => {
// });
describe('Calc(): ', () => {
it('Diamètre should be 6', () => {
let paramCnl = new cParamsCanal(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
);
let sect = new cSnCirc(undefined, paramCnl,
0 // diamètre
);
// tirant d'eau
sect.v.Y = 0.6613;
let ru = new RegimeUniforme(sect);
// expect(ru.Calc("D", 0, 0.001).vCalc).toBeCloseTo(6, 2);
expect(ru.Calc("D").vCalc).toBeCloseTo(6, 2);
});
it('Ks should be 40', () => {
let paramCnl = new cParamsCanal(0, // 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
);
let sect = new cSnCirc(undefined, paramCnl,
6 // diamètre
);
// tirant d'eau
sect.v.Y = 0.6613;
let ru = new RegimeUniforme(sect);
expect(ru.Calc("Ks").vCalc).toBeCloseTo(40, 2);
});
it('If should be 0.001', () => {
let paramCnl = new cParamsCanal(40, // Ks=Strickler
1.2, // Q=Débit
0, // If=pente du fond
precDist, // précision
1 // YB= hauteur de berge
// YCL=Condition limite en cote à l'amont ou à l'aval
);
let sect = new cSnCirc(undefined, paramCnl,
6 // diamètre
);
// tirant d'eau
sect.v.Y = 0.6613;
let ru = new RegimeUniforme(sect);
expect(ru.Calc("If").vCalc).toBeCloseTo(0.001, precDigits);
});
it('Q should be 1.2', () => {
let paramCnl = new cParamsCanal(40, // Ks=Strickler
0, // 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
);
let sect = new cSnCirc(undefined, paramCnl,
6 // diamètre
);
// tirant d'eau
sect.v.Y = 0.6613;
let ru = new RegimeUniforme(sect);
expect(ru.Calc("Q").vCalc).toBeCloseTo(1.2, precDigits);
});
it('Y should be 0.6613', () => {
let paramCnl = new cParamsCanal(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
);
let sect = new cSnCirc(undefined, paramCnl,
6 // diamètre
);
// tirant d'eau
sect.v.Y = 0;
let ru = new RegimeUniforme(sect);
expect(ru.Calc("Y").vCalc).toBeCloseTo(0.6613, precDigits);
});
});
});
...@@ -29,6 +29,10 @@ export abstract class Nub extends Debug { ...@@ -29,6 +29,10 @@ export abstract class Nub extends Debug {
* @param rPrec précision de calcul * @param rPrec précision de calcul
*/ */
Calc(sVarCalc: string, rInit: number = 0, rPrec: number = 0.001): Result { Calc(sVarCalc: string, rInit: number = 0, rPrec: number = 0.001): Result {
this.debug("nub : sVarCalc=" + sVarCalc);
this.debug("nub : rInit=" + rInit);
this.debug("nub : rPrec=" + rPrec);
for (let sVarEq of this._varsEq) { for (let sVarEq of this._varsEq) {
if (sVarCalc == sVarEq) { if (sVarCalc == sVarEq) {
return this.Equation(sVarCalc); return this.Equation(sVarCalc);
......
...@@ -10,8 +10,6 @@ export class RegimeUniforme extends Nub { ...@@ -10,8 +10,6 @@ export class RegimeUniforme extends Nub {
constructor(s: acSection, dbg: boolean = false) { constructor(s: acSection, dbg: boolean = false) {
super(s.v, dbg); super(s.v, dbg);
this.debug('constructeur RU');
this.Sn = s; this.Sn = s;
this.AddVarEq("Q"); this.AddVarEq("Q");
...@@ -29,7 +27,7 @@ export class RegimeUniforme extends Nub { ...@@ -29,7 +27,7 @@ export class RegimeUniforme extends Nub {
//this.oLog.Add('h_normale_pente_neg_nul',true); //this.oLog.Add('h_normale_pente_neg_nul',true);
} else { } else {
Qn = this.Sn.oP.v.Ks * Math.pow(this.Sn.Calc('R', this.Sn.v.Y), 2 / 3) * this.Sn.Calc('S', this.Sn.v.Y) * Math.sqrt(this.Sn.oP.v.If); Qn = this.Sn.oP.v.Ks * Math.pow(this.Sn.Calc('R', this.Sn.v.Y), 2 / 3) * this.Sn.Calc('S', this.Sn.v.Y) * Math.sqrt(this.Sn.oP.v.If);
this.debug("RU : Qn=" + Qn); //this.debug("RU : Qn=" + Qn);
} }
return Qn; return Qn;
} }
......
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