diff --git a/package.json b/package.json index 47299514a7146cbc821c50f35d2cfe70bc3d3f62..be8fc1bc6d6e4c4f0a8bbc6df54a1988d74c80b4 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "dependencies": {}, "devDependencies": { "@types/jasmine": "^2.5.47", + "jasmine": "^2.6.0", "jasmine-core": "^2.5.2", "jasmine-node": "^1.14.5", "karma": "^1.3.0", @@ -28,4 +29,4 @@ "lint": "./node_modules/tslint/bin/tslint", "viz": "tsviz -recursive src/ jalhyd_class_diagram.png" } -} \ No newline at end of file +} diff --git a/spec/base.spec.ts b/spec/base.spec.ts index 0d4d9af8619f12c471676a31906b09b5f45ecd35..e06d92379a8bc8815805aaf6cf408089cc64fd4b 100644 --- a/spec/base.spec.ts +++ b/spec/base.spec.ts @@ -5,9 +5,6 @@ import { nub, precDigits } from "./nubtest"; describe('Class Nub: ', () => { - // beforeEach(() => { - // res.vCalc = 3; - // }); describe('Calc(): ', () => { it('should return a result.vCalc equal to 3', () => { expect(nub.Calc("C").vCalc).toBeCloseTo(3, precDigits); diff --git a/spec/cond_distri.spec.ts b/spec/cond_distri.spec.ts index f0226a176ff04dd1a28fca57c4b0298748b82d23..2282d676a1325817ad3e1ef82941667694acecb1 100644 --- a/spec/cond_distri.spec.ts +++ b/spec/cond_distri.spec.ts @@ -5,8 +5,6 @@ import { ConduiteDistrib, ConduiteDistribParams } from "../src/cond_distri"; describe('Class ConduiteDistrib: ', () => { // beforeEach(() => { - // nub.sVarsEq = ["C"]; - // res.vCalc = 3; // }); // beforeAll(() => { // }); diff --git a/spec/dichotomie.spec.ts b/spec/dichotomie.spec.ts index 003c2724416f92ebaa75de5b9a8b95e8ee9815c4..dd628e738db0befa1a2dccf2831a6e10e4161dea 100644 --- a/spec/dichotomie.spec.ts +++ b/spec/dichotomie.spec.ts @@ -1,6 +1,5 @@ /// <reference path="../node_modules/@types/jasmine/index.d.ts" /> -// import { nub, res } from "./nubtest"; import { nub } from "./nubtest"; import { Dichotomie } from "../src/dichotomie" diff --git a/spec/lechaptcalmon.spec.ts b/spec/lechaptcalmon.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..d269606439cd73f9d2aeaafbef98cabf9f2820d2 --- /dev/null +++ b/spec/lechaptcalmon.spec.ts @@ -0,0 +1,67 @@ +/// <reference path="../node_modules/@types/jasmine/index.d.ts" /> + +import { precDist, nub } from "./nubtest"; +import { LechaptCalmonParams, LechaptCalmon } from "../src/lechaptcalmon" + +let lechapt: LechaptCalmon; +let prms: LechaptCalmonParams; + +describe('Class LechaptCalmon : ', () => { + describe('Calc() : ', () => { + it('Q should be 2.917', () => { + prms = new LechaptCalmonParams(undefined, // débit + 1.2, // diamètre + 0.6, /// perte de charge + 100, // longueur du toyo + 1.863, // paramètre L du matériau + 2, // paramètre M du matériau + 5.33// paramètre N du matériau + ); + lechapt = new LechaptCalmon(prms); + + expect(lechapt.Calc("Q").vCalc).toBeCloseTo(2.917, 3); + }); + + it('D should be 1.213', () => { + prms = new LechaptCalmonParams(3, // débit + undefined, // diamètre + 0.6, /// perte de charge + 100, // longueur du toyo + 1.863, // paramètre L du matériau + 2, // paramètre M du matériau + 5.33// paramètre N du matériau + ); + lechapt = new LechaptCalmon(prms); + + expect(lechapt.Calc("D").vCalc).toBeCloseTo(1.213, 3); + }); + + it('J should be 0.634', () => { + prms = new LechaptCalmonParams(3, // débit + 1.2, // diamètre + undefined, /// perte de charge + 100, // longueur du toyo + 1.863, // paramètre L du matériau + 2, // paramètre M du matériau + 5.33// paramètre N du matériau + ); + lechapt = new LechaptCalmon(prms); + + expect(lechapt.Calc("J").vCalc).toBeCloseTo(0.634, 3); + }); + + it('Lg should be 94.565', () => { + prms = new LechaptCalmonParams(3, // débit + 1.2, // diamètre + 0.6, /// perte de charge + undefined, // longueur du toyo + 1.863, // paramètre L du matériau + 2, // paramètre M du matériau + 5.33// paramètre N du matériau + ); + lechapt = new LechaptCalmon(prms); + + expect(lechapt.Calc("Lg").vCalc).toBeCloseTo(94.565, 3); + }); + }); +}); diff --git a/spec/nubtest.ts b/spec/nubtest.ts index 9b0fc3d6cb37cace172f3c5ff0cea7121e2cb8e1..1bc3bc30ae088cac3676d19af7724a8341d84185 100644 --- a/spec/nubtest.ts +++ b/spec/nubtest.ts @@ -2,27 +2,6 @@ import { Result } from "../src/base"; import { Nub } from "../src/nub"; import { ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability, IParamsEquation } from "../src/param"; - -// export class NubTest extends Nub { -// constructor(dbg: boolean = false) { -// super(dbg); -// } - -// Equation(): Result { -// return new Result(this.prms["A"] + this.prms["B"]); -// } - -// protected createParams(): IParamsEquation { -// let res: IParamsEquation = {}; - -// res['A'] = new ParamDefinition('A', ParamDomain.POS, ParamCalculability.DIRECT, 1); -// res['B'] = new ParamDefinition('B', ParamDomain.POS, ParamCalculability.DICHO, 2); -// res['C'] = new ParamDefinition('C', ParamDomain.POS, ParamCalculability.DICHO, 3); - -// return res; -// } -// } - class NubTestParams implements IParamsEquation { private _A: ParamDefinition; private _B: ParamDefinition; @@ -65,7 +44,6 @@ export class NubTest extends Nub { Equation(): Result { // C = A+B - // return new Result(this.prms["A"] + this.prms["B"]); return new Result(this.prms.A.v + this.prms.B.v); } } diff --git a/spec/regime_uniforme_circ.spec.ts b/spec/regime_uniforme_circ.spec.ts index 57d1987b17c3a406ecfbc13607f67a23fd04b14a..a1c8748cf5e32ce73c646e16f2c658caa45fd0e8 100644 --- a/spec/regime_uniforme_circ.spec.ts +++ b/spec/regime_uniforme_circ.spec.ts @@ -5,11 +5,8 @@ import { RegimeUniforme } from "../src/regime_uniforme"; import { ParamsSectionCirc, cSnCirc } from "../src/section/section_circulaire"; import { precDigits, precDist } from "./nubtest"; -describe('Class RegimeUniforme / section circulaire : ', () => { - // beforeAll(() => { - // }); - - describe('Calc(): ', () => { +describe('Class RegimeUniforme / section circulaire :', () => { + describe('pas de débordement : ', () => { it('Diamètre should be 6', () => { let paramSect = new ParamsSectionCirc(undefined, // diamètre 0.6613, // tirant d'eau @@ -20,9 +17,7 @@ describe('Class RegimeUniforme / section circulaire : ', () => { 1 // YB= hauteur de berge // YCL=Condition limite en cote à l'amont ou à l'aval ); - let sect = new cSnCirc(undefined, paramSect); - let ru = new RegimeUniforme(sect); expect(ru.Calc("D", 1e-8).vCalc).toBeCloseTo(6, 2); @@ -39,7 +34,6 @@ describe('Class RegimeUniforme / section circulaire : ', () => { 1 // YB= hauteur de berge // YCL=Condition limite en cote à l'amont ou à l'aval ); - let sect = new cSnCirc(undefined, paramSection); let ru = new RegimeUniforme(sect); @@ -57,9 +51,7 @@ describe('Class RegimeUniforme / section circulaire : ', () => { 1 // YB= hauteur de berge // YCL=Condition limite en cote à l'amont ou à l'aval ); - let sect = new cSnCirc(undefined, paramSection); - let ru = new RegimeUniforme(sect); expect(ru.Calc("If").vCalc).toBeCloseTo(0.001, precDigits); @@ -75,9 +67,7 @@ describe('Class RegimeUniforme / section circulaire : ', () => { 1 // YB= hauteur de berge // YCL=Condition limite en cote à l'amont ou à l'aval ); - let sect = new cSnCirc(undefined, paramSection); - let ru = new RegimeUniforme(sect); expect(ru.Calc("Q").vCalc).toBeCloseTo(1.2, precDigits); @@ -93,12 +83,94 @@ describe('Class RegimeUniforme / section circulaire : ', () => { 1 // YB= hauteur de berge // YCL=Condition limite en cote à l'amont ou à l'aval ); + let sect = new cSnCirc(undefined, paramSection); + let ru = new RegimeUniforme(sect); + expect(ru.Calc("Y").vCalc).toBeCloseTo(0.6613, precDigits); + }); + }); + + describe('débordement : ', () => { + it('Diamètre should be 2', () => { + let paramSect = new ParamsSectionCirc(undefined, // diamètre + 2, // tirant d'eau + 13.551, // 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, paramSect); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("D", 1e-8).vCalc).toBeCloseTo(2, precDigits); + }); + + + it('Ks should be 13.551', () => { + let paramSection = new ParamsSectionCirc(2, // diamètre + 2, // tirant d'eau + undefined, // 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, paramSection); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("Ks", 1e-8).vCalc).toBeCloseTo(13.551, precDigits); + }); + + it('If should be 0.001', () => { + let paramSection = new ParamsSectionCirc(2, // diamètre + 2, // tirant d'eau + 13.551, // Ks=Strickler + 1.2, // Q=Débit + undefined, // 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, paramSection); let ru = new RegimeUniforme(sect); - expect(ru.Calc("Y").vCalc).toBeCloseTo(0.6613, precDigits); + expect(ru.Calc("If").vCalc).toBeCloseTo(0.001, precDigits); + }); + + it('Q should be 1.2', () => { + let paramSection = new ParamsSectionCirc(2, // diamètre + 2, // tirant d'eau + 13.551, // Ks=Strickler + undefined, // 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, paramSection); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("Q").vCalc).toBeCloseTo(1.2, precDigits); + }); + + it('Y should be 2', () => { + let paramSection = new ParamsSectionCirc(2, // diamètre + undefined, // tirant d'eau + 13.551, // 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, paramSection); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("Y").vCalc).toBeCloseTo(2, precDigits); }); }); }); diff --git a/spec/regime_uniforme_puissance.spec.ts b/spec/regime_uniforme_puissance.spec.ts index a210c33d7847248d95c410f873cb0bfe8305795a..e8d46167c9c693f91435b9abc3c7750676d3a302 100644 --- a/spec/regime_uniforme_puissance.spec.ts +++ b/spec/regime_uniforme_puissance.spec.ts @@ -5,11 +5,8 @@ import { RegimeUniforme } from "../src/regime_uniforme"; import { ParamsSectionPuiss, cSnPuiss } from "../src/section/section_puissance"; import { precDigits, precDist } from "./nubtest"; -describe('Class RegimeUniforme / section puissance: ', () => { - beforeAll(() => { - }); - - describe('Calc(): ', () => { +describe('Class RegimeUniforme / section puissance :', () => { + describe('pas de débordement :', () => { it('k should be 0.635', () => { let prms = new ParamsSectionPuiss(undefined, // coef 0.8, // tirant d'eau @@ -125,4 +122,119 @@ describe('Class RegimeUniforme / section puissance: ', () => { expect(ru.Calc("Y").vCalc).toBeCloseTo(0.742, precDigits); }); }); + + describe('débordement :', () => { + it('k should be 0.635', () => { + let prms = new ParamsSectionPuiss(undefined, // coef + 2, // tirant d'eau + 4, // largeur de berge + 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 cSnPuiss(undefined, prms); + + let ru = new RegimeUniforme(sect, false); + + expect(ru.Calc("k").vCalc).toBeCloseTo(0.635, precDigits); + }); + + it('LargeurBerge should be 0.721', () => { + let prms = new ParamsSectionPuiss(0.5, // coef + 2, // tirant d'eau + undefined, // largeur de berge + 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 cSnPuiss(undefined, prms); + let ru = new RegimeUniforme(sect, false); + + expect(ru.Calc("LargeurBerge").vCalc).toBeCloseTo(0.721, precDigits); + }); + + it('Strickler should be 4.366', () => { + let prms = new ParamsSectionPuiss(0.5, // coef + 2, // tirant d'eau + 4, // largeur de berge + undefined, // 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 cSnPuiss(undefined, prms); + + let ru = new RegimeUniforme(sect, false); + + expect(ru.Calc("Ks", 1e-8).vCalc).toBeCloseTo(4.366, precDigits); + }); + + + it('If should be 0.001', () => { + let prms = new ParamsSectionPuiss(0.5, // coef + 2, // tirant d'eau + 4, // largeur de berge + 4.366, // Ks=Strickler + 1.2, // Q=Débit + undefined, // 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 cSnPuiss(undefined, prms); + + let ru = new RegimeUniforme(sect, false); + + expect(ru.Calc("If").vCalc).toBeCloseTo(0.001, precDigits); + }); + + it('Q should be 10.993', () => { + let prms = new ParamsSectionPuiss(0.5, // coef + 2, // tirant d'eau + 4, // largeur de berge + 40, // Ks=Strickler + undefined, // 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 cSnPuiss(undefined, prms); + + let ru = new RegimeUniforme(sect, false); + + expect(ru.Calc("Q").vCalc).toBeCloseTo(10.993, precDigits); + }); + + it('Y should be 0.742', () => { + let paramCnl = new ParamsSectionPuiss(0.5, // coef + undefined, // tirant d'eau + 4, // largeur de berge + 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 cSnPuiss(undefined, paramCnl); + + let ru = new RegimeUniforme(sect, false); + + expect(ru.Calc("Y").vCalc).toBeCloseTo(0.742, precDigits); + }); + }); }); diff --git a/spec/regime_uniforme_rect.spec.ts b/spec/regime_uniforme_rect.spec.ts index 36347bda0032728015c7d401b822991f010d77ed..a442e6fa6ab4508833c7579c991f2a82507afa1d 100644 --- a/spec/regime_uniforme_rect.spec.ts +++ b/spec/regime_uniforme_rect.spec.ts @@ -5,11 +5,8 @@ import { RegimeUniforme } from "../src/regime_uniforme"; import { ParamsSectionRectang, cSnRectang } from "../src/section/section_rectang"; import { precDigits, precDist } from "./nubtest"; -describe('Class RegimeUniforme / section rectangulaire : ', () => { - // beforeAll(() => { - // }); - - describe('Calc(): ', () => { +xdescribe('Class RegimeUniforme / section rectangulaire :', () => { + describe('pas de débordement : ', () => { /** * test de la largeur de fond (= largeur de berge pour le rectangulaire) */ @@ -117,4 +114,113 @@ describe('Class RegimeUniforme / section rectangulaire : ', () => { expect(ru.Calc("Y").vCalc).toBeCloseTo(0.663, precDigits); }); }); + + describe('débordement : ', () => { + /** + * test de la largeur de fond (= largeur de berge pour le rectangulaire) + */ + it('LargeurBerge should be 2.5', () => { + let prms = new ParamsSectionRectang(2, // tirant d'eau + undefined, // largeur de fond + 40, // Ks=Strickler + 1.568, // 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 cSnRectang(undefined, prms, false); + let ru = new RegimeUniforme(sect, false); + + expect(ru.Calc("LargeurBerge").vCalc).toBeCloseTo(2.5, precDigits); + }); + + it('Strickler should be 30.618', () => { + let prms = new ParamsSectionRectang(2, // tirant d'eau + 2.5, // largeur de fond + undefined, // 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 cSnRectang(undefined, prms); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("Ks", 1e-8).vCalc).toBeCloseTo(30.618, precDigits); + }); + + it('If should be 0.001', () => { + let prms = new ParamsSectionRectang(2, // tirant d'eau + 2.5, // largeur de fond + 40, // Ks=Strickler + 1.568, // Q=Débit + undefined, // 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 cSnRectang(undefined, prms); + let ru = new RegimeUniforme(sect, false); + + // nom variable à calculer, valeur de Ks + expect(ru.Calc("If", 0, precDist).vCalc).toBeCloseTo(0.001, precDigits); + }); + + it('Q should be 1.568', () => { + let prms = new ParamsSectionRectang(2, // tirant d'eau + 2.5, // largeur de fond + 40, // Ks=Strickler + undefined, // 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 cSnRectang(undefined, prms); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("Q").vCalc).toBeCloseTo(1.568, precDigits); + }); + + it('Q should be 0.731', () => { + let prms = new ParamsSectionRectang(2, // tirant d'eau + 3, // largeur de fond + 30, // Ks=Strickler + undefined, // Q=Débit + 0.0001, // If=pente du fond + precDist, // précision + 1.2 // YB=hauteur de berge + // YCL=Condition limite en cote à l'amont ou à l'aval + ); + + let sect = new cSnRectang(undefined, prms); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("Q").vCalc).toBeCloseTo(0.731, precDigits); + }); + + it('Y should be 0.663', () => { + let prms = new ParamsSectionRectang(undefined, // 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 + 0.1 // YB=hauteur de berge + // YCL=Condition limite en cote à l'amont ou à l'aval + ); + + let sect = new cSnRectang(undefined, prms); + let ru = new RegimeUniforme(sect); + + // nom variable à calculer, valeur de Ks + expect(ru.Calc("Y").vCalc).toBeCloseTo(0.663, precDigits); + }); + }); }); diff --git a/spec/regime_uniforme_trapeze.spec.ts b/spec/regime_uniforme_trapeze.spec.ts index c49878910bc034fa147b98806ed1945e65b6096c..c5bca80e249be813d98f28ff875f18a08243c0b5 100644 --- a/spec/regime_uniforme_trapeze.spec.ts +++ b/spec/regime_uniforme_trapeze.spec.ts @@ -5,11 +5,8 @@ import { RegimeUniforme } from "../src/regime_uniforme"; import { ParamsSectionTrapez, cSnTrapez } from "../src/section/section_trapez"; import { precDigits, precDist } from "./nubtest"; -describe('Class RegimeUniforme / section trapèze: ', () => { - beforeAll(() => { - }); - - describe('Calc(): ', () => { +xdescribe('Class RegimeUniforme / section trapèze :', () => { + describe('pas de débordement :', () => { it('LargeurFond should be 2.5', () => { let prms = new ParamsSectionTrapez(undefined, // largeur de fond 0.56, // fruit @@ -119,4 +116,115 @@ describe('Class RegimeUniforme / section trapèze: ', () => { expect(ru.Calc("Y").vCalc).toBeCloseTo(0.587, precDigits); }); }); + + describe('débordement :', () => { + it('LargeurFond should be 2.5', () => { + let prms = new ParamsSectionTrapez(undefined, // largeur de fond + 0.56, // fruit + 2, // tirant d'eau + 40, // Ks=Strickler + 1.988428, // 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 cSnTrapez(undefined, prms); + + let ru = new RegimeUniforme(sect, false); + + expect(ru.Calc("LargeurFond", 0, precDist).vCalc).toBeCloseTo(2.5, precDigits); + }); + + it('Fruit should be 0.56', () => { + let prms = new ParamsSectionTrapez(2.5, // largeur de fond + undefined, // fruit + 2, // 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 + ); + + let sect = new cSnTrapez(undefined, prms); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("Fruit").vCalc).toBeCloseTo(0.56, precDigits); + }); + + it('Ks should be 24.14', () => { + let prms = new ParamsSectionTrapez(2.5, // largeur de fond + 0.56, // fruit + 2, // tirant d'eau + undefined, // 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 cSnTrapez(undefined, prms); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("Ks", 1e-8).vCalc).toBeCloseTo(24.14, precDigits); + }); + + it('If should be 0.001', () => { + let prms = new ParamsSectionTrapez(2.5, // largeur de fond + 0.56, // fruit + 2, // tirant d'eau + 40, // Ks=Strickler + 1.2, // Q=Débit + undefined, // 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 cSnTrapez(undefined, prms); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("If").vCalc).toBeCloseTo(0.001, precDigits); + }); + + it('Q should be 1.2', () => { + let prms = new ParamsSectionTrapez(2.5, // largeur de fond + 0.56, // fruit + 2, // tirant d'eau + 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 cSnTrapez(undefined, prms); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("Q").vCalc).toBeCloseTo(1.2, precDigits); + }); + + it('Y should be 0.587', () => { + let prms = new ParamsSectionTrapez(2.5, // largeur de fond + 0.56, // fruit + undefined, // tirant d'eau + 40, // Ks=Strickler + 1.2, // Q=Débit + 0.001, // If=pente du fond + precDist, // précision + 0.1 // YB= hauteur de berge + // YCL=Condition limite en cote à l'amont ou à l'aval + ); + + let sect = new cSnTrapez(undefined, prms); + let ru = new RegimeUniforme(sect); + + expect(ru.Calc("Y").vCalc).toBeCloseTo(0.587, precDigits); + }); + }); }); diff --git a/spec/section_param_circ_fluvial.spec.ts b/spec/section_param_circ_fluvial.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..e35771877085e0ed81561213526fa78b3f253fdb --- /dev/null +++ b/spec/section_param_circ_fluvial.spec.ts @@ -0,0 +1,227 @@ +/// <reference path="../node_modules/@types/jasmine/index.d.ts" /> + +import { Result } from "../src/base"; +import { nub, precDigits, precDist } from "./nubtest"; +import { ParamsSectionCirc, cSnCirc } from "../src/section/section_circulaire"; + +let paramSection: ParamsSectionCirc; +let sect: cSnCirc; + +function createSection(prec: number): cSnCirc { + paramSection = new ParamsSectionCirc(2, // diamètre + 0.8, // tirant d'eau + 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 cSnCirc(undefined, paramSection); +} + +function createSectionDebordement(prec: number): cSnCirc { + paramSection = new ParamsSectionCirc(2, // diamètre + 2, // tirant d'eau + 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 cSnCirc(undefined, paramSection); +} + +xdescribe('Section paramétrée circulaire : ', () => { + beforeEach(() => { + sect = createSection(precDist); + }); + + describe('fluvial / pas de débordement :', () => { + // charge spécifique + it('Hs should equal to 0.853', () => { + expect(sect.Calc_Hs()).toBeCloseTo(0.853, precDigits); + }); + + // charge critique + it('Hsc should equal to 0.694', () => { + expect(sect.Calc_Hsc()).toBeCloseTo(0.694, precDigits); + }); + + // largeur au miroir + it('B should equal to 1.959', () => { + expect(sect.Calc_B()).toBeCloseTo(1.959, precDigits); + }); + + // périmètre mouillé + it('P should equal to 2.738', () => { + expect(sect.Calc_P()).toBeCloseTo(2.738, precDigits); + }); + + // surface mouillée + it('S should equal to 1.173', () => { + expect(sect.Calc_S()).toBeCloseTo(1.173, precDigits); + }); + + // rayon hydraulique + it('R should equal to 0.428', () => { + expect(sect.Calc_R()).toBeCloseTo(0.428, precDigits); + }); + + // vitesse moyenne + it('V should equal to 1.022', () => { + expect(sect.Calc_V()).toBeCloseTo(1.022, precDigits); + }); + + // nombre de Froude + it('Fr should equal to 0.421', () => { + expect(sect.Calc_Fr()).toBeCloseTo(0.421, precDigits); + }); + + // tirant d'eau critique + it('Yc should equal to 0.512', () => { + expect(sect.Calc_Yc()).toBeCloseTo(0.512, precDigits); + }); + + // tirant d'eau normal + it('Yn should equal to 0.975', () => { + expect(sect.Calc_Yn()).toBeCloseTo(0.975, precDigits); + }); + + // tirant d'eau fluvial + it('Yf should equal to 0.8', () => { + expect(sect.Calc_Yf()).toBeCloseTo(0.8, precDigits); + }); + + // tirant d'eau torrentiel + it('Yt should equal to 0.361', () => { + expect(sect.Calc_Yt()).toBeCloseTo(0.361, precDigits); + }); + + // tirant d'eau conjugué + it('Yco should equal to 0.307', () => { + expect(sect.Calc_Yco()).toBeCloseTo(0.307, precDigits); + }); + + // perte de charge + it('J should equal to 0.002', () => { + //sect = createSection(0.00001); + expect(sect.Calc_J()).toBeCloseTo(0.002, precDigits); + }); + + // Variation linéaire de l'énergie spécifique + it('I-J should equal to -0.00102', () => { + sect = createSection(0.00001); + expect(sect.Calc("I-J")).toBeCloseTo(-0.00102, precDigits); + }); + + // impulsion hydraulique + it('Imp should equal to xx', () => { + expect(sect.Calc_Imp()).toBeCloseTo(-1, precDigits); + }); + + // force tractrice (contrainte de cisaillement) + it('Tau0 should equal to 8.504', () => { + expect(sect.Calc_Tau0()).toBeCloseTo(8.504, precDigits); + }); + }); +}); + + +xdescribe('Section paramétrée circulaire : ', () => { + beforeEach(() => { + sect = createSectionDebordement(precDist); + }); + + describe('fluvial / débordement :', () => { + // charge spécifique + it('Hs should equal to 2.007', () => { + expect(sect.Calc_Hs()).toBeCloseTo(2.007, precDigits); + }); + + // charge critique + it('Hsc should equal to 0.694', () => { + expect(sect.Calc_Hsc()).toBeCloseTo(0.694, precDigits); + }); + + // largeur au miroir + it('B should equal to 0', () => { + expect(sect.Calc_B()).toBeCloseTo(0, precDigits); + }); + + // périmètre mouillé + it('P should equal to 6.283', () => { + expect(sect.Calc_P()).toBeCloseTo(6.283, precDigits); + }); + + // surface mouillée + it('S should equal to 3.141', () => { + expect(sect.Calc_S()).toBeCloseTo(3.141, precDigits); + }); + + // rayon hydraulique + it('R should equal to 0.5', () => { + expect(sect.Calc_R()).toBeCloseTo(0.5, precDigits); + }); + + // vitesse moyenne + it('V should equal to 0.382', () => { + expect(sect.Calc_V()).toBeCloseTo(0.382, precDigits); + }); + + // nombre de Froude + it('Fr should equal to 0', () => { + expect(sect.Calc_Fr()).toBeCloseTo(0, precDigits); + }); + + // tirant d'eau critique + it('Yc should equal to 0.512', () => { + expect(sect.Calc_Yc()).toBeCloseTo(0.512, precDigits); + }); + + // tirant d'eau normal + it('Yn should equal to 0.975', () => { + expect(sect.Calc_Yn()).toBeCloseTo(0.975, precDigits); + }); + + // tirant d'eau fluvial + it('Yf should equal to 1.999', () => { + expect(sect.Calc_Yf()).toBeCloseTo(1.999, precDigits); + }); + + // tirant d'eau torrentiel + it('Yt should equal to 0.232', () => { + expect(sect.Calc_Yt()).toBeCloseTo(0.232, precDigits); + }); + + // tirant d'eau conjugué + it('Yco should equal to 0.084', () => { + expect(sect.Calc_Yco()).toBeCloseTo(0.084, precDigits); + }); + + // perte de charge + it('J should equal to 0.0002', () => { + sect = createSection(0.00001); + expect(sect.Calc_J()).toBeCloseTo(0.0002, precDigits); + }); + + // Variation linéaire de l'énergie spécifique + it('I-J should equal to 0.00077', () => { + sect = createSection(0.00001); + expect(sect.Calc("I-J")).toBeCloseTo(0.00077, precDigits); + }); + + // impulsion hydraulique + it('Imp should equal to xx', () => { + expect(sect.Calc_Imp()).toBeCloseTo(-1, precDigits); + }); + + // force tractrice (contrainte de cisaillement) + it('Tau0 should equal to 1.127', () => { + expect(sect.Calc_Tau0()).toBeCloseTo(1.127, precDigits); + }); + }); +}); diff --git a/spec/section_param_circ_torrentiel.spec.ts b/spec/section_param_circ_torrentiel.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..8e7b838758bb503566098cb9a87bb3989148abf6 --- /dev/null +++ b/spec/section_param_circ_torrentiel.spec.ts @@ -0,0 +1,117 @@ +/// <reference path="../node_modules/@types/jasmine/index.d.ts" /> + +import { Result } from "../src/base"; +import { nub, precDigits, precDist } from "./nubtest"; +import { ParamsSectionCirc, cSnCirc } from "../src/section/section_circulaire"; + +let paramSection: ParamsSectionCirc; +let sect: cSnCirc; + +function createSection(prec: number): cSnCirc { + paramSection = new ParamsSectionCirc(2, // diamètre + 0.8, // tirant d'eau + 40, // Ks=Strickler + 10, // 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 cSnCirc(undefined, paramSection); +} + +xdescribe('Section paramétrée circulaire : ', () => { + beforeEach(() => { + sect = createSection(precDist); + }); + + describe('torrentiel :', () => { + // charge spécifique + it('Hs should equal to 4.501', () => { + expect(sect.Calc_Hs()).toBeCloseTo(4.501, precDigits); + }); + + // charge critique + it('Hsc should equal to 2.296', () => { + expect(sect.Calc_Hsc()).toBeCloseTo(2.296, precDigits); + }); + + // largeur au miroir + it('B should equal to 1.959', () => { + expect(sect.Calc_B()).toBeCloseTo(1.959, precDigits); + }); + + // périmètre mouillé + it('P should equal to 2.738', () => { + expect(sect.Calc_P()).toBeCloseTo(2.738, precDigits); + }); + + // surface mouillée + it('S should equal to 1.173', () => { + expect(sect.Calc_S()).toBeCloseTo(1.173, precDigits); + }); + + // rayon hydraulique + it('R should equal to 0.428', () => { + expect(sect.Calc_R()).toBeCloseTo(0.428, precDigits); + }); + + // vitesse moyenne + it('V should equal to 8.521', () => { + expect(sect.Calc_V()).toBeCloseTo(8.521, precDigits); + }); + + // nombre de Froude + it('Fr should equal to 3.515', () => { + expect(sect.Calc_Fr()).toBeCloseTo(3.515, precDigits); + }); + + // tirant d'eau critique + it('Yc should equal to 1.533', () => { + expect(sect.Calc_Yc()).toBeCloseTo(1.533, precDigits); + }); + + // tirant d'eau normal + it('Yn should equal to xxx', () => { + expect(sect.Calc_Yn()).toBeCloseTo(-1, precDigits); + }); + + // tirant d'eau fluvial + it('Yf should equal to 1.999', () => { + expect(sect.Calc_Yf()).toBeCloseTo(1.999, precDigits); + }); + + // tirant d'eau torrentiel + it('Yt should equal to 0.8', () => { + expect(sect.Calc_Yt()).toBeCloseTo(0.8, precDigits); + }); + + // tirant d'eau conjugué + it('Yco should equal to 99.999', () => { + expect(sect.Calc_Yco()).toBeCloseTo(99.999, precDigits); + }); + + // perte de charge + it('J should equal to 0.14', () => { + //sect = createSection(0.00001); + expect(sect.Calc_J()).toBeCloseTo(0.14, precDigits); + }); + + // Variation linéaire de l'énergie spécifique + it('I-J should equal to -0.139', () => { + //sect = createSection(0.00001); + expect(sect.Calc("I-J")).toBeCloseTo(-0.139, precDigits); + }); + + // impulsion hydraulique + it('Imp should equal to xxx', () => { + expect(sect.Calc_Imp()).toBeCloseTo(-1, precDigits); + }); + + // force tractrice (contrainte de cisaillement) + it('Tau0 should equal to 590.605', () => { + expect(sect.Calc_Tau0()).toBeCloseTo(590.605, precDigits); + }); + }); +}); diff --git a/spec/section_param_puiss_fluvial.spec.ts b/spec/section_param_puiss_fluvial.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..c5b0840159c3377c69f583686c3f35bb0850bcc0 --- /dev/null +++ b/spec/section_param_puiss_fluvial.spec.ts @@ -0,0 +1,229 @@ +/// <reference path="../node_modules/@types/jasmine/index.d.ts" /> + +import { Result } from "../src/base"; +import { nub, precDigits, precDist } from "./nubtest"; +import { ParamsSectionPuiss, cSnPuiss } from "../src/section/section_puissance"; + +let paramSection: ParamsSectionPuiss; +let sect: cSnPuiss; + +function createSection(prec: number): cSnPuiss { + paramSection = new ParamsSectionPuiss(0.5, // coefficient + 0.8, // tirant d'eau + 4, // largeur de berge + 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 cSnPuiss(undefined, paramSection); +} + +function createSectionDebordement(prec: number): cSnPuiss { + paramSection = new ParamsSectionPuiss(0.5, // coefficient + 2, // tirant d'eau + 4, // largeur de berge + 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 cSnPuiss(undefined, paramSection); +} + +xdescribe('Section paramétrée puissance :', () => { + beforeEach(() => { + sect = createSection(precDist); + }); + + describe('fluvial / pas de débordement :', () => { + // charge spécifique + it('Hs should equal to 0.82', () => { + expect(sect.Calc_Hs()).toBeCloseTo(0.82, precDigits); + }); + + // charge critique + it('Hsc should equal to 0.559', () => { + expect(sect.Calc_Hsc()).toBeCloseTo(0.559, precDigits); + }); + + // largeur au miroir + it('B should equal to 3.577', () => { + expect(sect.Calc_B()).toBeCloseTo(3.577, precDigits); + }); + + // périmètre mouillé + it('P should equal to 4.009', () => { + expect(sect.Calc_P()).toBeCloseTo(4.009, precDigits); + }); + + // surface mouillée + it('S should equal to 1.908', () => { + expect(sect.Calc_S()).toBeCloseTo(1.908, precDigits); + }); + + // rayon hydraulique + it('R should equal to 0.476', () => { + expect(sect.Calc_R()).toBeCloseTo(0.476, precDigits); + }); + + // vitesse moyenne + it('V should equal to 0.629', () => { + expect(sect.Calc_V()).toBeCloseTo(0.629, precDigits); + }); + + // nombre de Froude + it('Fr should equal to 0.275', () => { + expect(sect.Calc_Fr()).toBeCloseTo(0.275, precDigits); + }); + + // tirant d'eau critique + it('Yc should equal to 0.419', () => { + expect(sect.Calc_Yc()).toBeCloseTo(0.419, precDigits); + }); + + // tirant d'eau normal + it('Yn should equal to 0.726', () => { + expect(sect.Calc_Yn()).toBeCloseTo(0.726, precDigits); + }); + + // tirant d'eau fluvial + it('Yf should equal to 0.8', () => { + expect(sect.Calc_Yf()).toBeCloseTo(0.8, precDigits); + }); + + // tirant d'eau torrentiel + it('Yt should equal to 0.265', () => { + expect(sect.Calc_Yt()).toBeCloseTo(0.265, precDigits); + }); + + // tirant d'eau conjugué + it('Yco should equal to 0.189', () => { + expect(sect.Calc_Yco()).toBeCloseTo(0.189, precDigits); + }); + + // perte de charge + it('J should equal to 0.0007', () => { + sect = createSection(0.00001); + expect(sect.Calc_J()).toBeCloseTo(0.0007, precDigits); + }); + + // Variation linéaire de l'énergie spécifique + it('I-J should equal to 0.000335', () => { + sect = createSection(0.000001); + expect(sect.Calc("I-J")).toBeCloseTo(0.000335, precDigits); + }); + + // impulsion hydraulique + it('Imp should equal to xx', () => { + expect(sect.Calc_Imp()).toBeCloseTo(-1, precDigits); + }); + + // force tractrice (contrainte de cisaillement) + it('Tau0 should equal to 3.105', () => { + expect(sect.Calc_Tau0()).toBeCloseTo(3.105, precDigits); + }); + }); +}); + + +xdescribe('Section paramétrée puissance :', () => { + beforeEach(() => { + sect = createSectionDebordement(precDist); + }); + + describe('fluvial / débordement :', () => { + // charge spécifique + it('Hs should equal to 0.818', () => { + expect(sect.Calc_Hs()).toBeCloseTo(0.818, precDigits); + }); + + // charge critique + it('Hsc should equal to 0.43', () => { + expect(sect.Calc_Hsc()).toBeCloseTo(0.43, precDigits); + }); + + // largeur au miroir + it('B should equal to 2.5', () => { + expect(sect.Calc_B()).toBeCloseTo(2.5, precDigits); + }); + + // périmètre mouillé + it('P should equal to 4.1', () => { + expect(sect.Calc_P()).toBeCloseTo(4.1, precDigits); + }); + + // surface mouillée + it('S should equal to 2', () => { + expect(sect.Calc_S()).toBeCloseTo(2, precDigits); + }); + + // rayon hydraulique + it('R should equal to 0.488', () => { + expect(sect.Calc_R()).toBeCloseTo(0.488, precDigits); + }); + + // vitesse moyenne + it('V should equal to 0.6', () => { + expect(sect.Calc_V()).toBeCloseTo(0.6, precDigits); + }); + + // nombre de Froude + it('Fr should equal to 0.214', () => { + expect(sect.Calc_Fr()).toBeCloseTo(0.214, precDigits); + }); + + // tirant d'eau critique + it('Yc should equal to 0.286', () => { + expect(sect.Calc_Yc()).toBeCloseTo(0.286, precDigits); + }); + + // tirant d'eau normal + it('Yn should equal to 0.663', () => { + expect(sect.Calc_Yn()).toBeCloseTo(0.663, precDigits); + }); + + // tirant d'eau fluvial + it('Yf should equal to 0.8', () => { + expect(sect.Calc_Yf()).toBeCloseTo(0.8, precDigits); + }); + + // tirant d'eau torrentiel + it('Yt should equal to 0.131', () => { + expect(sect.Calc_Yt()).toBeCloseTo(0.131, precDigits); + }); + + // tirant d'eau conjugué + it('Yco should equal to 0.068', () => { + expect(sect.Calc_Yco()).toBeCloseTo(0.068, precDigits); + }); + + // perte de charge + it('J should equal to 0.00059', () => { + 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', () => { + sect = createSection(0.00001); + expect(sect.Calc("I-J")).toBeCloseTo(0.00041, precDigits); + }); + + // impulsion hydraulique + it('Imp should equal to 8568', () => { + expect(sect.Calc_Imp()).toBeCloseTo(8568, precDigits); + }); + + // force tractrice (contrainte de cisaillement) + it('Tau0 should equal to 2.804', () => { + expect(sect.Calc_Tau0()).toBeCloseTo(2.804, precDigits); + }); + }); +}); diff --git a/spec/section_param_puiss_torrentiel.spec.ts b/spec/section_param_puiss_torrentiel.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..413e6f41c9f49d4d675f5e106a88455ba39c8ff1 --- /dev/null +++ b/spec/section_param_puiss_torrentiel.spec.ts @@ -0,0 +1,118 @@ +/// <reference path="../node_modules/@types/jasmine/index.d.ts" /> + +import { Result } from "../src/base"; +import { nub, precDigits, precDist } from "./nubtest"; +import { ParamsSectionPuiss, cSnPuiss } from "../src/section/section_puissance"; + +let paramSection: ParamsSectionPuiss; +let sect: cSnPuiss; + +function createSection(prec: number): cSnPuiss { + paramSection = new ParamsSectionPuiss(0.5, // coefficient + 0.8, // tirant d'eau + 4, // largeur de berge + 40, // Ks=Strickler + 10, // 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 cSnPuiss(undefined, paramSection); +} + +xdescribe('Section paramétrée puissance :', () => { + beforeEach(() => { + sect = createSection(precDist); + }); + + describe('torrentiel / pas de débordement :', () => { + // charge spécifique + it('Hs should equal to 0.818', () => { + expect(sect.Calc_Hs()).toBeCloseTo(0.818, precDigits); + }); + + // charge critique + it('Hsc should equal to 0.43', () => { + expect(sect.Calc_Hsc()).toBeCloseTo(0.43, precDigits); + }); + + // largeur au miroir + it('B should equal to 2.5', () => { + expect(sect.Calc_B()).toBeCloseTo(2.5, precDigits); + }); + + // périmètre mouillé + it('P should equal to 4.1', () => { + expect(sect.Calc_P()).toBeCloseTo(4.1, precDigits); + }); + + // surface mouillée + it('S should equal to 2', () => { + expect(sect.Calc_S()).toBeCloseTo(2, precDigits); + }); + + // rayon hydraulique + it('R should equal to 0.488', () => { + expect(sect.Calc_R()).toBeCloseTo(0.488, precDigits); + }); + + // vitesse moyenne + it('V should equal to 0.6', () => { + expect(sect.Calc_V()).toBeCloseTo(0.6, precDigits); + }); + + // nombre de Froude + it('Fr should equal to 0.214', () => { + expect(sect.Calc_Fr()).toBeCloseTo(0.214, precDigits); + }); + + // tirant d'eau critique + it('Yc should equal to 0.286', () => { + expect(sect.Calc_Yc()).toBeCloseTo(0.286, precDigits); + }); + + // tirant d'eau normal + it('Yn should equal to 0.663', () => { + expect(sect.Calc_Yn()).toBeCloseTo(0.663, precDigits); + }); + + // tirant d'eau fluvial + it('Yf should equal to 0.8', () => { + expect(sect.Calc_Yf()).toBeCloseTo(0.8, precDigits); + }); + + // tirant d'eau torrentiel + it('Yt should equal to 0.131', () => { + expect(sect.Calc_Yt()).toBeCloseTo(0.131, precDigits); + }); + + // tirant d'eau conjugué + it('Yco should equal to 0.068', () => { + expect(sect.Calc_Yco()).toBeCloseTo(0.068, precDigits); + }); + + // perte de charge + it('J should equal to 0.00059', () => { + 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', () => { + sect = createSection(0.00001); + expect(sect.Calc("I-J")).toBeCloseTo(0.00041, precDigits); + }); + + // impulsion hydraulique + it('Imp should equal to 8568', () => { + expect(sect.Calc_Imp()).toBeCloseTo(8568, precDigits); + }); + + // force tractrice (contrainte de cisaillement) + it('Tau0 should equal to 2.804', () => { + expect(sect.Calc_Tau0()).toBeCloseTo(2.804, precDigits); + }); + }); +}); diff --git a/spec/section_param_rect_fluvial.spec.ts b/spec/section_param_rect_fluvial.spec.ts index 488453f098b21a096c4defee783aa5bfa35910c3..9292c3449054e2349976914bb49cc9349953adb8 100644 --- a/spec/section_param_rect_fluvial.spec.ts +++ b/spec/section_param_rect_fluvial.spec.ts @@ -21,12 +21,122 @@ function createSection(prec: number): cSnRectang { return new cSnRectang(undefined, paramSection); } -describe('Section paramétrée rectangulaire : ', () => { +function createSectionDebordement(prec: number): cSnRectang { + paramSection = new ParamsSectionRectang(2, // 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); +} + +xdescribe('Section paramétrée rectangulaire : ', () => { beforeEach(() => { sect = createSection(precDist); }); - describe('fluvial :', () => { + describe('fluvial / pas de débordement :', () => { + // charge spécifique + it('Hs should equal to 0.818', () => { + expect(sect.Calc_Hs()).toBeCloseTo(0.818, precDigits); + }); + + // charge critique + it('Hsc should equal to 0.43', () => { + expect(sect.Calc_Hsc()).toBeCloseTo(0.43, precDigits); + }); + + // largeur au miroir + it('B should equal to 2.5', () => { + expect(sect.Calc_B()).toBeCloseTo(2.5, precDigits); + }); + + // périmètre mouillé + it('P should equal to 4.1', () => { + expect(sect.Calc_P()).toBeCloseTo(4.1, precDigits); + }); + + // surface mouillée + it('S should equal to 2', () => { + expect(sect.Calc_S()).toBeCloseTo(2, precDigits); + }); + + // rayon hydraulique + it('R should equal to 0.488', () => { + expect(sect.Calc_R()).toBeCloseTo(0.488, precDigits); + }); + + // vitesse moyenne + it('V should equal to 0.6', () => { + expect(sect.Calc_V()).toBeCloseTo(0.6, precDigits); + }); + + // nombre de Froude + it('Fr should equal to 0.214', () => { + expect(sect.Calc_Fr()).toBeCloseTo(0.214, precDigits); + }); + + // tirant d'eau critique + it('Yc should equal to 0.286', () => { + expect(sect.Calc_Yc()).toBeCloseTo(0.286, precDigits); + }); + + // tirant d'eau normal + it('Yn should equal to 0.663', () => { + expect(sect.Calc_Yn()).toBeCloseTo(0.663, precDigits); + }); + + // tirant d'eau fluvial + it('Yf should equal to 0.8', () => { + expect(sect.Calc_Yf()).toBeCloseTo(0.8, precDigits); + }); + + // tirant d'eau torrentiel + it('Yt should equal to 0.131', () => { + expect(sect.Calc_Yt()).toBeCloseTo(0.131, precDigits); + }); + + // tirant d'eau conjugué + it('Yco should equal to 0.068', () => { + expect(sect.Calc_Yco()).toBeCloseTo(0.068, precDigits); + }); + + // perte de charge + it('J should equal to 0.00059', () => { + 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', () => { + sect = createSection(0.00001); + expect(sect.Calc("I-J")).toBeCloseTo(0.00041, precDigits); + }); + + // impulsion hydraulique + it('Imp should equal to 8568', () => { + expect(sect.Calc_Imp()).toBeCloseTo(8568, precDigits); + }); + + // force tractrice (contrainte de cisaillement) + it('Tau0 should equal to 2.804', () => { + expect(sect.Calc_Tau0()).toBeCloseTo(2.804, precDigits); + }); + }); +}); + + +xdescribe('Section paramétrée rectangulaire : ', () => { + beforeEach(() => { + sect = createSectionDebordement(precDist); + }); + + describe('fluvial / débordement :', () => { // charge spécifique it('Hs should equal to 0.818', () => { expect(sect.Calc_Hs()).toBeCloseTo(0.818, precDigits); diff --git a/spec/section_param_trapez_fluvial.spec.ts b/spec/section_param_trapez_fluvial.spec.ts index 896fdc87b11c6d5b17f46b3a2104806dd8aacf31..9b04df031031db8ef8f6c2a40acb2213540db504 100644 --- a/spec/section_param_trapez_fluvial.spec.ts +++ b/spec/section_param_trapez_fluvial.spec.ts @@ -22,12 +22,122 @@ function createSection(prec: number): cSnTrapez { return new cSnTrapez(undefined, paramSection); } -describe('Section paramétrée trapèze : ', () => { +function createSectionDebordement(prec: number): cSnTrapez { + paramSection = new ParamsSectionTrapez(2.5, // largeur de fond + 0.56, // fruit + 2, // 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); +} + +xdescribe('Section paramétrée trapèze : ', () => { beforeEach(() => { sect = createSection(precDist); }); - describe('fluvial :', () => { + describe('fluvial / pas de débordement :', () => { + // charge spécifique + it('Hs should equal to 0.813', () => { + expect(sect.Calc_Hs()).toBeCloseTo(0.813, precDigits); + }); + + // charge critique + it('Hsc should equal to 0.413', () => { + expect(sect.Calc_Hsc()).toBeCloseTo(0.413, precDigits); + }); + + // largeur au miroir + it('B should equal to 3.396', () => { + expect(sect.Calc_B()).toBeCloseTo(3.396, precDigits); + }); + + // périmètre mouillé + it('P should equal to 4.334', () => { + expect(sect.Calc_P()).toBeCloseTo(4.334, precDigits); + }); + + // surface mouillée + it('S should equal to 2.358', () => { + expect(sect.Calc_S()).toBeCloseTo(2.358, precDigits); + }); + + // rayon hydraulique + it('R should equal to 0.544', () => { + expect(sect.Calc_R()).toBeCloseTo(0.544, precDigits); + }); + + // vitesse moyenne + it('V should equal to 0.509', () => { + expect(sect.Calc_V()).toBeCloseTo(0.509, precDigits); + }); + + // nombre de Froude + it('Fr should equal to 0.195', () => { + expect(sect.Calc_Fr()).toBeCloseTo(0.195, precDigits); + }); + + // tirant d'eau critique + it('Yc should equal to 0.28', () => { + expect(sect.Calc_Yc()).toBeCloseTo(0.28, precDigits); + }); + + // tirant d'eau normal + it('Yn should equal to 0.587', () => { + expect(sect.Calc_Yn()).toBeCloseTo(0.587, precDigits); + }); + + // tirant d'eau fluvial + it('Yf should equal to 0.8', () => { + expect(sect.Calc_Yf()).toBeCloseTo(0.8, precDigits); + }); + + // tirant d'eau torrentiel + it('Yt should equal to 0.127', () => { + expect(sect.Calc_Yt()).toBeCloseTo(0.127, precDigits); + }); + + // tirant d'eau conjugué + it('Yco should equal to 0.061', () => { + expect(sect.Calc_Yco()).toBeCloseTo(0.061, precDigits); + }); + + // perte de charge + it('J should equal to 0.00036', () => { + let sect = createSection(0.00001); + expect(sect.Calc_J()).toBeCloseTo(0.00036, precDigits); + }); + + // Variation linéaire de l'énergie spécifique + it('I-J should equal to 0.001', () => { + expect(sect.Calc("I-J")).toBeCloseTo(0.001, precDigits); + }); + + // impulsion hydraulique + it('Imp should equal to 9396.158', () => { + expect(sect.Calc_Imp()).toBeCloseTo(9396.158, precDigits); + }); + + // force tractrice (contrainte de cisaillement) + it('Tau0 should equal to 1.944', () => { + expect(sect.Calc_Tau0()).toBeCloseTo(1.944, precDigits); + }); + }); +}); + + +xdescribe('Section paramétrée trapèze : ', () => { + beforeEach(() => { + sect = createSectionDebordement(precDist); + }); + + describe('fluvial / débordement :', () => { // charge spécifique it('Hs should equal to 0.813', () => { expect(sect.Calc_Hs()).toBeCloseTo(0.813, precDigits); diff --git a/src/base.ts b/src/base.ts index cc396210e2a41c2608444b4feba216fe7ec19682..ff3902082344a76a75b70d8f9e21a8f4c47db1b8 100644 --- a/src/base.ts +++ b/src/base.ts @@ -50,3 +50,15 @@ export abstract class Debug { get DBG() { return this._DBG; } } + + +/** + * Méthode simulant l'opérateur booléen xor + * @see http://www.howtocreate.co.uk/xor.html + */ +export function XOR(a: boolean, b: boolean) { + return (a || b) && !(a && b); +} + +export class UndefinedError extends Error { +} diff --git a/src/cond_distri.ts b/src/cond_distri.ts index f4bbc0f4dfaba58997d3375d100cc3b751841d51..8eaf87c7d5d8c3d944180ee4af648985dcfc691a 100644 --- a/src/cond_distri.ts +++ b/src/cond_distri.ts @@ -2,23 +2,9 @@ import { Result } from "./base"; import { ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability, IParamsEquation } from "../src/param"; import { Nub } from "./nub"; - -// // export interface IParamConduiteDistrib extends IParametres { -// export class ParamConduiteDistrib implements IParamsEquation { -// [key: string]: number; - -// /** Débit */ -// ["q"]: number = 0; -// /** Diamètre */ -// ["d"]: number = 0; -// /** Perte de charge */ -// ["j"]: number = 0; -// /** Longueur de la conduite */ -// ["lg"]: number = 0; -// /** Viscosité dynamique ni */ -// ["nu"]: number = 0; -// } - +/** + * paramètres pour la conduite distributrice + */ export class ConduiteDistribParams implements IParamsEquation { /** Débit */ private _Q: ParamDefinition; @@ -64,11 +50,17 @@ export class ConduiteDistribParams implements IParamsEquation { } } +/** + * classe de calcul sur la conduite distributrice + */ export class ConduiteDistrib extends Nub { constructor(prms: ConduiteDistribParams, dbg: boolean = false) { super(prms, dbg); } + /** + * paramétrage de la calculabilité des paramètres + */ protected setParametersCalculability() { this.prms.J.calculability = ParamCalculability.EQUATION; this.prms.D.calculability = ParamCalculability.EQUATION; @@ -77,15 +69,23 @@ export class ConduiteDistrib extends Nub { this.prms.Nu.calculability = ParamCalculability.EQUATION; } + /** + * paramètres castés au bon type + */ get prms(): ConduiteDistribParams { return <ConduiteDistribParams>this._prms; } + /** + * calcul direct des différents paramètres + * @param sVarCalc nom du paramètre + * @return valeur calculée + */ Equation(sVarCalc: string): Result { let res: Result; let v: number; - var K = 0.3164 * Math.pow(4, 1.75) / (5.5 * 9.81 * Math.pow(3.1415, 1.75)); // Constante de la formule + let K = 0.3164 * Math.pow(4, 1.75) / (5.5 * 9.81 * Math.pow(3.1415, 1.75)); // Constante de la formule switch (sVarCalc) { case "J": diff --git a/src/dichotomie.ts b/src/dichotomie.ts index 3fbc004cbf9052b81e8559ecd89a950e1b2713b5..2c0512bfe47618c585abe7abd7e15ac7e662603a 100644 --- a/src/dichotomie.ts +++ b/src/dichotomie.ts @@ -1,12 +1,15 @@ -import { Debug, Result } from "./base"; +import { XOR, Debug, Result } from "./base"; import { Nub } from "./nub"; +/** + * calcul par dichotomie + */ export class Dichotomie extends Debug { /** Pas de parcours de l'intervalle pour initialisation dichotomie */ - readonly IDEFINT = 100; - /** Nombre d'itérations maximum de la dichotomie */ - readonly IDICMAX = 100; + private readonly IDEFINT = 100; + /** Nombre d'itérations maximum de la dichotomie */ + private readonly IDICMAX = 100; /** * Construction de la classe. @@ -15,43 +18,30 @@ export class Dichotomie extends Debug { */ constructor(private nub: Nub, private sVarCalc: string, dbg: boolean = false) { super(dbg); - //this.debug(nub); } /** * Valeur inconnue à rechercher */ get vX(): number { - // return this.nub.prms[this.sVarCalc]; return this.nub.getParameter(this.sVarCalc).v; } set vX(vCalc: number) { - //this.nub.prms[this.sVarCalc] = vCalc; this.nub.getParameter(this.sVarCalc).v = vCalc; } - /** - * Méthode simulant l'opérateur booléen xor - * @see http://www.howtocreate.co.uk/xor.html - */ - XOR(a: boolean, b: boolean) { - return (a || b) && !(a && b); - } - /** * Calcul de l'équation analytique. * @note Wrapper vers this.nub.Equation pour simplifier le code. - * On utilise la première variable du tableau des variables pourvant être calculées analytiquement + * On utilise la première variable du tableau des variables pouvant être calculée analytiquement * Il faudra s'assurer que cette première variable correspond à la méthode de calcul la plus rapide */ private Calcul() { - /** - * @note - */ - // let r = this.nub.Equation(this.nub.sVarsEq[0]); - let r = this.nub.Equation(this.nub.getFirstAnalyticalParameter().symbol); - this.debug('dicho : Calcul(vX=' + this.vX + ')=' + r.vCalc); + //return this.nub.Equation(this.nub.getFirstAnalyticalParameter().symbol); + let targetParam = this.nub.getFirstAnalyticalParameter(); + let r = this.nub.Equation(targetParam.symbol); + this.debug("dicho : Calcul(vX=" + this.sVarCalc + "=" + this.vX + ") -> " + targetParam.symbol + "=" + r.vCalc); return r; } @@ -70,10 +60,7 @@ export class Dichotomie extends Debug { let res: Result; let XminInit: number = 1E-8; - // let v1: number = this.CalculX(XminInit).vCalc; - let XmaxInit: number = Math.max(1, rInit) * 100; - // let v2: number = this.CalculX(XmaxInit).vCalc; let DX = (XmaxInit - XminInit) / this.IDEFINT; let nIterMax = Math.floor(Math.max(XmaxInit - rInit, rInit - XminInit) / DX + 1); @@ -81,7 +68,7 @@ export class Dichotomie extends Debug { let Xmax = rInit; let X1 = rInit; let X2 = rInit; - this.debug("rInit: " + rInit); + this.debug("dicho : rInit(" + this.sVarCalc + ")=" + rInit + " target=" + rTarget); let v = this.CalculX(rInit).vCalc; if (isNaN(v)) { @@ -92,39 +79,43 @@ export class Dichotomie extends Debug { let v1 = v; let v2 = v; + this.debug("dicho : recherche intervalle"); + //** @todo : Chercher en dehors de l'intervalle en le décalant à droite ou à gauche en fonction de la valeur */ let nIter: number; for (nIter = 1; nIter < nIterMax; nIter++) { //Ouverture de l'intervalle des deux côtés : à droite puis à gauche Xmax = Xmax + DX; - if (this.XOR(Xmax > XmaxInit, DX <= 0)) + if (XOR(Xmax > XmaxInit, DX <= 0)) Xmax = XmaxInit; + this.debug("dicho interv. : iter=" + nIter); v = this.CalculX(Xmax).vCalc; - if (this.XOR(v1 < v2, v <= v2)) { + if (XOR(v1 < v2, v <= v2)) { v2 = v; X2 = Xmax; } - if (this.XOR(v1 < v2, v >= v1)) { + if (XOR(v1 < v2, v >= v1)) { v1 = v; X1 = Xmax; } Xmin = Xmin - DX; - if (this.XOR(Xmin < XminInit, DX <= 0)) { + if (XOR(Xmin < XminInit, DX <= 0)) { Xmin = XminInit; } + this.debug("dicho interv. : iter=" + nIter); v = this.CalculX(Xmin).vCalc; - if (this.XOR(v1 < v2, v <= v2)) { + if (XOR(v1 < v2, v <= v2)) { v2 = v; X2 = Xmin; } - if (this.XOR(v1 < v2, v >= v1)) { + if (XOR(v1 < v2, v >= v1)) { v1 = v; X1 = Xmin; } - if (this.XOR(rTarget > v1, rTarget >= v2)) + if (XOR(rTarget > v1, rTarget >= v2)) break; } this.debug("intervalle initial " + X1 + ", " + X2); @@ -132,7 +123,7 @@ export class Dichotomie extends Debug { // Gestion de l'absence de solution dans l'intervalle de recherche if (nIter >= this.IDEFINT) { this.debug("nIter >= this.IDEFINT"); - + this.debug("dicho interv. : iter=" + nIter); if (v2 < rTarget && v1 < rTarget) { // Cote de l'eau trop basse pour passer le débit il faut ouvrir un autre ouvrage res = this.CalculX(XmaxInit); @@ -149,11 +140,10 @@ export class Dichotomie extends Debug { this.debug("start dicho"); let X = rInit; for (nIter = 1; nIter <= this.IDICMAX; nIter++) { - // this.vX = X; - // v = this.Calcul().vCalc; + this.debug("dicho : iter=" + nIter); v = this.CalculX(X).vCalc; if (rTarget != 0 && Math.abs(X1 - X2) <= rTol) { break; } - if (this.XOR(rTarget < v, v1 <= v2)) { + if (XOR(rTarget < v, v1 <= v2)) { // rTarget < IQ et v(X1) > v(X2) ou pareil en inversant les inégalités X1 = this.vX; } @@ -162,10 +152,10 @@ export class Dichotomie extends Debug { X2 = this.vX; } X = (X2 + X1) * 0.5; - this.debug((X)); + //this.debug((X)); } if (nIter == this.IDICMAX) { - res = this.Calcul(); // ???? + res = this.Calcul(); res.extraVar["flag"] = -1; // la valeur cible n'est pas dans l'intervalle de recherche return res; } diff --git a/src/lechaptcalmon.ts b/src/lechaptcalmon.ts index c88ca8701b2cf210abe579a7b1e5ec167b665c5a..9edb0a2690348670612e225cf5ac42b41500d1b2 100644 --- a/src/lechaptcalmon.ts +++ b/src/lechaptcalmon.ts @@ -2,7 +2,10 @@ import { Result } from "./base"; import { ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability, IParamsEquation } from "../src/param"; import { Nub } from "./nub"; -class LechaptCalmonParams implements IParamsEquation { +/** + * paramètres pour le calcul Lechapt et Calmon + */ +export class LechaptCalmonParams implements IParamsEquation { /** Débit */ private _Q: ParamDefinition; @@ -63,28 +66,27 @@ class LechaptCalmonParams implements IParamsEquation { } } -class LechaptCalmon extends Nub { - constructor(prms: LechaptCalmonParams) { - super(prms, false); +/** + * Calcul des pertes de charge dans un tube à partir des tables de Lechapt et Calmon + */ +export class LechaptCalmon extends Nub { + constructor(prms: LechaptCalmonParams, dbg: boolean = false) { + super(prms, dbg); } + /** + * paramétrage de la calculabilité des paramètres + */ protected setParametersCalculability() { this.prms.Q.calculability = ParamCalculability.EQUATION; this.prms.D.calculability = ParamCalculability.EQUATION; this.prms.J.calculability = ParamCalculability.EQUATION; this.prms.Lg.calculability = ParamCalculability.EQUATION; - - /* - this._Q = new ParamDefinition('Q', ParamDomainValue.POS, ParamCalculability.EQUATION); - this._D = new ParamDefinition('D', ParamDomainValue.POS, ParamCalculability.EQUATION); - this._J = new ParamDefinition('J', ParamDomainValue.POS, ParamCalculability.EQUATION); - this._Lg = new ParamDefinition('Lg', ParamDomainValue.POS, ParamCalculability.EQUATION); - this._L = new ParamDefinition('L', ParamDomainValue.POS, ParamCalculability.DICHO); - this._M = new ParamDefinition('M', ParamDomainValue.POS, ParamCalculability.DICHO); - this._N = new ParamDefinition('N', ParamDomainValue.POS, ParamCalculability.DICHO); -*/ } + /** + * paramètres castés au bon type + */ get prms(): LechaptCalmonParams { return <LechaptCalmonParams>this._prms; } @@ -107,6 +109,7 @@ class LechaptCalmon extends Nub { case "Lg": v = ((this.prms.J.v * Math.pow(this.prms.D.v, this.prms.N.v)) / (this.prms.L.v * Math.pow(this.prms.Q.v, this.prms.M.v))) * 1000; + break; default: throw "LechaptCalmon.Equation() : invalid variable name " + sVarCalc; diff --git a/src/nub.ts b/src/nub.ts index af7ce428cea2b897bdc6d40dc2ea4f733757e431..c5f1223e5be0a77609e0f642d83a42c215ff05ca 100644 --- a/src/nub.ts +++ b/src/nub.ts @@ -2,23 +2,10 @@ import { Debug, Result, Serie } from "./base" import { Dichotomie } from "./dichotomie" import { ComputeNode, ParamDefinition, IParamsEquation } from "./param" -// interface IPrmsEquation { -// [key: string]: number; // map : array of numbers with string keys -// } - /** * Classe abstraite de Noeud de calcul : classe de base pour tous les calculs */ export abstract class Nub extends ComputeNode { - /// Nom des variables calculées par la méthode Equation - //private _varsEq: string[] = []; - - // protected _prms: IParamsEquation; - - // constructor(prms: IParamsEquation, dbg: boolean = false) { - // super(prms, dbg); - // } - private checkParametersCalculability() { let res = []; @@ -44,10 +31,6 @@ export abstract class Nub extends ComputeNode { * @param rPrec précision de calcul */ 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); - if (this._prms[sVarCalc].isAnalytical()) return this.Equation(sVarCalc); diff --git a/src/param.ts b/src/param.ts index 8d8a751ae5b71c6e38934816b023a1a836aa9955..f164f4a6eacfafe4636aa14b7fa07275b14f58b1 100644 --- a/src/param.ts +++ b/src/param.ts @@ -1,4 +1,4 @@ -import { Debug } from './base'; +import { Debug, UndefinedError } from './base'; /** * domaine de définition du paramètre @@ -26,23 +26,23 @@ export enum ParamDomainValue { NOT_NULL, /** - * interval + * intervalle */ INTERVAL } export class ParamDomain { - private _value: ParamDomainValue; + private _domain: ParamDomainValue; - private _min: number; + private _minValue: number; - private _max: number; + private _maxValue: number; constructor(d: ParamDomainValue, min: number = 0, max: number = -1) { this.checkValue(d, min, max); - this._value = d; - this._min = min; - this._max = max; + this._domain = d; + this._minValue = min; + this._maxValue = max; } private checkValue(val, min, max) { @@ -57,16 +57,16 @@ export class ParamDomain { } } - get value() { - return this._value; + get domain() { + return this._domain; } - get min() { - return this._min; + get minValue() { + return this._minValue; } - get max() { - return this._max; + get maxValue() { + return this._maxValue; } } @@ -178,7 +178,7 @@ export class ParamDefinition { */ get v(): number { if (this._value == undefined) - throw "value of '" + this._symbol + "' parameter is not defined"; + throw new UndefinedError("value of '" + this._symbol + "' parameter is not defined"); return this._value; } @@ -194,9 +194,9 @@ export class ParamDefinition { } private checkValue(v: number) { - let sDomain = ParamDomainValue[this._domain.value]; + let sDomain = ParamDomainValue[this._domain.domain]; - switch (this._domain.value) { + switch (this._domain.domain) { case ParamDomainValue.ANY: break; @@ -216,8 +216,8 @@ export class ParamDefinition { break; case ParamDomainValue.INTERVAL: - let min = this._domain.min; - let max = this._domain.max; + let min = this._domain.minValue; + let max = this._domain.maxValue; if (v < min || v > max) throw "parameter '" + this._symbol + "' : value " + v + " is out of [" + min + ", " + max + "] interval"; break; @@ -269,7 +269,6 @@ export class ParamDefinition { * liste des paramètres d'une équation */ export interface IParamsEquation { - //[key: string]: ParamDefinition; // map : array of ParamDefinition with string keys // [key: string]: number; // map : array of ParamDefinition with string keys } diff --git a/src/regime_uniforme.ts b/src/regime_uniforme.ts index 260198b76395069ae91b99a37dc134f0288e9201..a92d7434dff869b86796e9493ebdd4575b3c7356 100644 --- a/src/regime_uniforme.ts +++ b/src/regime_uniforme.ts @@ -4,7 +4,7 @@ import { ParamsSection, acSection } from "./section/section_type"; import { ParamDefinition, ParamCalculability, IParamsEquation } from "./param" export class RegimeUniforme extends Nub { - private Sn: acSection; ///< Objet section + private Sn: acSection; constructor(s: acSection, dbg: boolean = false) { super(s.prms, dbg); @@ -26,17 +26,17 @@ export class RegimeUniforme extends Nub { */ Calc_Qn(): number { this.Sn.Reset(true); - if (this.Sn.prms.If.v <= 0) { - var Qn: number = 0; // ? false bool - //this.oLog.Add('h_normale_pente_neg_nul',true); - } else { - Qn = this.Sn.prms.Ks.v * Math.pow(this.Sn.Calc("R", this.Sn.prms.Y.v), 2 / 3) * this.Sn.Calc("S", this.Sn.prms.Y.v) * Math.sqrt(this.Sn.prms.If.v); - //this.debug("RU : Qn=" + Qn); - } - return Qn; + if (this.Sn.prms.If.v <= 0) + return 0; + + this.debug("RU: Calc_Qn : "); + this.debug(this.Sn.prms); + + return this.Sn.prms.Ks.v * Math.pow(this.Sn.Calc("R", this.Sn.prms.Y.v), 2 / 3) * this.Sn.Calc("S", this.Sn.prms.Y.v) * Math.sqrt(this.Sn.prms.If.v); } Equation(sVarCalc: string): Result { + this.debug("RU: Equation(" + sVarCalc + ")") let v: number; switch (sVarCalc) { @@ -48,11 +48,6 @@ export class RegimeUniforme extends Nub { v = this.Calc_Qn(); break; - // default: - // var oDicho = new cDichotomie(this.oLog, this, 'Calc_Qn'); - // v = oDicho.calculer(this.v['Q'], this.precision, rInit); - // break; - default: throw "RegimeUniforme.Equation() : invalid variable name " + sVarCalc; } diff --git a/src/section/hauteur.ts b/src/section/hauteur.ts index c56073acf3de656291903aad4571e84643a3c3ab..84e313dd9ee3c6ad449bab8f38da8d0bc7487668 100644 --- a/src/section/hauteur.ts +++ b/src/section/hauteur.ts @@ -7,12 +7,14 @@ import { cLog } from "./log"; * Calcul de la hauteur critique */ export class cHautCritique extends acNewton { + /** + * Section sur laquuelle porte le calcul + */ private Sn: acSection; /** * Constructeur de la classe - * @param oSn Section sur laquelle on fait le calcul - * @param oP Paramètres supplémentaires (Débit, précision...) + * @param Sn Section sur laquelle on fait le calcul */ constructor(Sn: acSection, dbg: boolean = false) { super(Sn.prms, dbg); @@ -25,13 +27,10 @@ export class cHautCritique extends acNewton { */ CalcFn(rX) { // Calcul de la fonction - if (this.Sn.Calc("S", rX) != 0) { - var Fn = (Math.pow(this.Sn.prms.Q.v, 2) * this.Sn.Calc("B", rX) / Math.pow(this.Sn.Calc("S", rX), 3) / cParamsCanal.G - 1); - } - else { - Fn = Infinity; - } - return Fn; + if (this.Sn.Calc("S", rX) != 0) + return (Math.pow(this.Sn.prms.Q.v, 2) * this.Sn.Calc("B", rX) / Math.pow(this.Sn.Calc("S", rX), 3) / cParamsCanal.G - 1); + + return Infinity; } /** @@ -39,16 +38,15 @@ export class cHautCritique extends acNewton { * @param rX Variable dont dépend la fonction */ CalcDer(rX) { - if (this.Sn.Calc("S") != 0) { + let S = this.Sn.Calc("S"); + if (S != 0) { + let B = this.Sn.Calc("B"); // L'initialisation à partir de rX a été faite lors de l'appel à CalcFn - var Der = (this.Sn.Calc("dB") * this.Sn.Calc("S") - 3 * this.Sn.Calc("B") * this.Sn.Calc("B")); - Der = Math.pow(this.Sn.prms.Q.v, 2) / cParamsCanal.G * Der / Math.pow(this.Sn.Calc("S"), 4); + let Der = (this.Sn.Calc("dB") * S - 3 * B * B); + return Math.pow(this.Sn.prms.Q.v, 2) / cParamsCanal.G * Der / Math.pow(S, 4); } - else { - Der = Infinity; - } - //spip_log('cHautCritique:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); - return Der; + + return Infinity; } } @@ -56,15 +54,29 @@ export class cHautCritique extends acNewton { * Calcul de la hauteur normale */ export class cHautNormale extends acNewton { + /** + * Section sur laquuelle porte le calcul + */ private Sn: acSection; + + /** + * Débit connu + */ private Q: number; + + /** + * Coefficient de Strickler + */ private Ks: number; + + /** + * Pente du fond + */ private If: number; /** * Constructeur de la classe * @param oSn Section sur laquelle on fait le calcul - * @param oP Paramètres supplémentaires (Débit, précision...) */ constructor(Sn: acSection, dbg: boolean = false) { super(Sn.prms, dbg); @@ -80,8 +92,7 @@ export class cHautNormale extends acNewton { */ CalcFn(rX) { // Calcul de la fonction - var Fn = (this.Q - this.Ks * Math.pow(this.Sn.Calc("R", rX), 2 / 3) * this.Sn.Calc("S", rX) * Math.sqrt(this.If)); - return Fn; + return (this.Q - this.Ks * Math.pow(this.Sn.Calc("R", rX), 2 / 3) * this.Sn.Calc("S", rX) * Math.sqrt(this.If)); } /** @@ -90,10 +101,9 @@ export class cHautNormale extends acNewton { */ CalcDer(rX) { // L'initialisation a été faite lors de l'appel à CalcFn - var Der = 2 / 3 * this.Sn.Calc("dR") * Math.pow(this.Sn.Calc("R"), -1 / 3) * this.Sn.Calc("S"); + let Der = 2 / 3 * this.Sn.Calc("dR") * Math.pow(this.Sn.Calc("R"), -1 / 3) * this.Sn.Calc("S"); Der = Der + Math.pow(this.Sn.Calc("R"), 2 / 3) * this.Sn.Calc("B"); Der = Der * -this.Ks * Math.sqrt(this.If); - //spip_log('cHautNormale:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); return Der; } } @@ -102,15 +112,29 @@ export class cHautNormale extends acNewton { * Calcul de la hauteur correspondante (charge égale) */ export class cHautCorrespondante extends acNewton { - private Y: number; // Tirant d'eau connu - private rS2: number; // 1/S^2 associé au tirant d'eau connu - private Sn: acSection; // Section contenant les données de la section avec la hauteur à calculer - private rQ2G: number; // Constante de gravité + /** + * Tirant d'eau connu + */ + private Y: number; + + /** + * 1/S^2 associé au tirant d'eau connu + */ + private rS2: number; + + /** + * Section contenant les données de la section avec la hauteur à calculer + */ + private Sn: acSection; + + /** + * Constante de gravité + */ + private rQ2G: number; /** * Constructeur de la classe * @param oSn Section sur laquelle on fait le calcul - * @param oP Paramètres supplémentaires (Débit, précision...) */ constructor(Sn: acSection, dbg: boolean = false) { super(Sn.prms, dbg); @@ -126,9 +150,7 @@ export class cHautCorrespondante extends acNewton { */ CalcFn(rX) { // Calcul de la fonction - var Fn = this.Y - rX + (this.rS2 - Math.pow(this.Sn.Calc("S", rX), -2)) * this.rQ2G; - //~ spip_log('cHautCorrespondante:CalcFn('.rX.')='.rFn,'hydraulic.'._LOG_DEBUG); - return Fn; + return this.Y - rX + (this.rS2 - Math.pow(this.Sn.Calc("S", rX), -2)) * this.rQ2G; } /** @@ -136,15 +158,12 @@ export class cHautCorrespondante extends acNewton { * @param rX Variable dont dépend la fonction */ CalcDer(rX) { + let S = this.Sn.Calc("S"); // L'initialisation a été faite lors de l'appel à CalcFn - if (this.Sn.Calc("S") != 0) { - var Der = -1 + 2 * this.rQ2G * this.Sn.Calc("B") / Math.pow(this.Sn.Calc("S"), 3); - } - else { - Der = Infinity; - } - //~ spip_log('cHautCorrespondante:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); - return Der; + if (S != 0) + return -1 + 2 * this.rQ2G * this.Sn.Calc("B") / Math.pow(S, 3); + + return Infinity; } } @@ -152,27 +171,24 @@ export class cHautCorrespondante extends acNewton { * Calcul de la hauteur conjuguée (Impulsion égale) */ export class cHautConjuguee extends acNewton { - /** Tirant d'eau connu */ - private Y: number; - /** 1/S^2 associé au tirant d'eau connu */ - private rS2: number; /** Section contenant les données de la section avec la hauteur à calculer */ private Sn: acSection; + /** Carré du débit */ private rQ2: number; + /** Surface hydraulique associée au tirant d'eau connu */ private rS: number; + /** SYg associée au tirant d'eau connu */ private rSYg: number; /** * Constructeur de la classe * @param oSn Section sur laquelle on fait le calcul - * @param oP Paramètres supplémentaires (Débit, précision...) */ constructor(oSn: acSection, dbg: boolean = false) { super(oSn.prms, dbg); - this.Y = oSn.prms.Y.v; this.rQ2 = Math.pow(oSn.prms.Q.v, 2); this.Sn = oSn; this.rS = oSn.Calc("S"); @@ -186,14 +202,11 @@ export class cHautConjuguee extends acNewton { CalcFn(rX) { // Réinitialisation des paramètres hydrauliques de oSn avec l'appel this->oSn->Calc("S',rX) if (this.rS > 0 && this.Sn.Calc("S", rX) > 0) { - var Fn = this.rQ2 * (1 / this.rS - 1 / this.Sn.Calc("S")); - Fn = Fn + cParamsCanal.G * (this.rSYg - this.Sn.Calc("SYg")); + let Fn = this.rQ2 * (1 / this.rS - 1 / this.Sn.Calc("S")); + return Fn + cParamsCanal.G * (this.rSYg - this.Sn.Calc("SYg")); } - else { - Fn = -Infinity; - } - //~ spip_log('cHautConjuguee:CalcFn('.rX.')='.rFn,'hydraulic.'._LOG_DEBUG); - return Fn; + + return -Infinity; } /** @@ -201,15 +214,13 @@ export class cHautConjuguee extends acNewton { * @param rX Variable dont dépend la fonction */ CalcDer(rX) { + let S = this.Sn.Calc("S"); // L'initialisation a été faite lors de l'appel à CalcFn - if (this.rS > 0 && this.Sn.Calc("S") > 0) { - var Der = this.rQ2 * this.Sn.Calc("dS") * Math.pow(this.Sn.Calc("S"), -2); - Der = Der - cParamsCanal.G * this.Sn.Calc("dSYg", rX); - } - else { - Der = -Infinity; + if (this.rS > 0 && S > 0) { + let Der = this.rQ2 * this.Sn.Calc("dS") * Math.pow(S, -2); + return Der - cParamsCanal.G * this.Sn.Calc("dSYg", rX); } - //~ spip_log('cHautConjuguee:CalcDer('.rX.')='.rDer,'hydraulic.'._LOG_DEBUG); - return Der; + + return -Infinity; } } diff --git a/src/section/newton.ts b/src/section/newton.ts index f89e2bc775538d89a1383f9d563462ce21614215..35626027896eac54d49c3cc9b29b64a7df2a38a5 100644 --- a/src/section/newton.ts +++ b/src/section/newton.ts @@ -1,4 +1,4 @@ -import { Debug } from "../base" +import { XOR, Debug } from "../base" import { cParamsCanal } from "./section_type" import { cLog } from "./log"; @@ -6,20 +6,19 @@ export abstract class acNewton extends Debug { protected rTol: number; protected Dx: number; private iCpt = 0; - private iCptMax = 50; + private readonly iCptMax = 50; private rRelax = 1; /// Coefficient de relaxation private rFnPrec = 0; /// Mémorisation du Fn précédent pour détecter le changement de signe private iOscil = 0; /// Nombre de changement de signe de Delta - private oLog: cLog; /** * Constructeur de la classe - * @param oP Paramètres supplémentaires (Débit, précision...) + * @param prms Paramètres supplémentaires (Débit, précision...) */ - constructor(oP: cParamsCanal, dbg: boolean = false) { + constructor(prms: cParamsCanal, dbg: boolean = false) { super(dbg); - this.rTol = oP.Prec.v; - this.Dx = oP.Prec.v / 10; + this.rTol = prms.Prec.v; + this.Dx = prms.Prec.v / 10; } /** @@ -35,7 +34,6 @@ export abstract class acNewton extends Debug { * @return Calcul de la fonction */ protected CalcDer(x) { - //~ spip_log('Newton:CalcDer rX='.x,'hydraulic.'._LOG_DEBUG); return (this.CalcFn(x + this.Dx) - this.CalcFn(x - this.Dx)) / (2 * this.Dx); } @@ -48,76 +46,51 @@ export abstract class acNewton extends Debug { return (Math.abs(rFn) < this.rTol); } + /** * Fonction récursive de calcul de la suite du Newton * @param rX x * @return Solution du zéro de la fonction */ - XOR(a, b) { - return (a || b) && !(a && b); - } - public Newton(rX) { - this.debug('in Newton(rX=' + rX + ')'); this.iCpt++; - this.debug('Newton : calcul de Fn...') var rFn = this.CalcFn(rX); - this.debug('Newton : Fn -> ' + rFn) - if (this.FuzzyEqual(rFn) || this.iCpt >= this.iCptMax) { + if (this.FuzzyEqual(rFn) || this.iCpt >= this.iCptMax) return rX; - } - else { - this.debug('Newton : calcul de rDer...') - var rDer = this.CalcDer(rX); - this.debug('Newton : rDer -> ' + rDer) - //~ echo(' - f\' = '.rDer); - if (rDer != 0) { - if (this.XOR(rFn < 0, this.rFnPrec < 0)) { - this.iOscil++; - if (this.rRelax > 1) { - // Sur une forte relaxation, au changement de signe on réinitialise - this.rRelax = 1; - } - else if (this.iOscil > 2) { - // On est dans le cas d'une oscillation autour de la solution - // On réduit le coefficient de relaxation - this.rRelax = this.rRelax * 0.5; - } - } - this.rFnPrec = rFn; - var Delta = rFn / rDer; - //2^8 = 2E8 ? - while (Math.abs(Delta * this.rRelax) < this.rTol && rFn > 10 * this.rTol && this.rRelax < 2E8) { - // On augmente le coefficicient de relaxation s'il est trop petit - this.rRelax = this.rRelax * 2; + + var rDer = this.CalcDer(rX); + if (rDer != 0) { + if (XOR(rFn < 0, this.rFnPrec < 0)) { + this.iOscil++; + if (this.rRelax > 1) { + // Sur une forte relaxation, au changement de signe on réinitialise + this.rRelax = 1; } - var rRelax = this.rRelax; - while (rX - Delta * rRelax <= 0 && rRelax > 1E-4) { - // On diminue le coeficient de relaxation si on passe en négatif - rRelax = rRelax * 0.5; // Mais on ne le mémorise pas pour les itérations suivantes + else if (this.iOscil > 2) { + // On est dans le cas d'une oscillation autour de la solution + // On réduit le coefficient de relaxation + this.rRelax = this.rRelax * 0.5; } - rX = rX - Delta * rRelax; - //this.rDelta = Delta; ??? - if (rX < 0) { rX = this.rTol; } // Aucune valeur recherchée ne peut être négative ou nulle - return this.Newton(rX); } - else { - // Echec de la résolution - return false; + this.rFnPrec = rFn; + var Delta = rFn / rDer; + //2^8 = 2E8 ? + while (Math.abs(Delta * this.rRelax) < this.rTol && rFn > 10 * this.rTol && this.rRelax < 2E8) { + // On augmente le coefficicient de relaxation s'il est trop petit + this.rRelax = this.rRelax * 2; } + var rRelax = this.rRelax; + while (rX - Delta * rRelax <= 0 && rRelax > 1E-4) { + // On diminue le coeficient de relaxation si on passe en négatif + rRelax = rRelax * 0.5; // Mais on ne le mémorise pas pour les itérations suivantes + } + rX = rX - Delta * rRelax; + //this.rDelta = Delta; ??? + if (rX < 0) { rX = this.rTol; } // Aucune valeur recherchée ne peut être négative ou nulle + return this.Newton(rX); } - } - /** - * Pour savoir si le Newton a convergé - * @return true si oui, false sinon - */ - public HasConverged() { - if (this.iCpt >= this.iCptMax) { - return false; - } - else { - return true; - } + // Echec de la résolution + return undefined; } } \ No newline at end of file diff --git a/src/section/section_circulaire.ts b/src/section/section_circulaire.ts index ee0ddbb888eb74c44a5065020b5f8b933b9dd7e2..ba1b26d738bb34c4e99b78227460ea7090c0e08e 100644 --- a/src/section/section_circulaire.ts +++ b/src/section/section_circulaire.ts @@ -23,18 +23,14 @@ export class ParamsSectionCirc extends ParamsSection { * Calculs de la section circulaire */ export class cSnCirc extends acSection { - - //public D; /// Diamètre du cercle - private Alpha: number; /// Angle de la surface libre par rapport au fond protected nbDessinPoints = 50; - // constructor(oLog: cLog, oP: cParamsCanal, D: number, dbg: boolean = false) { - constructor(oLog: cLog, oP: ParamsSectionCirc, dbg: boolean = false) { - super(oLog, oP, dbg); - // commenté car si D est la variable à déterminer, il peut valoir n'importe quoi... if (oP.v.YB > D) { oP.v.YB = D; } // On place la berge au sommet du cercle + constructor(oLog: cLog, prms: ParamsSectionCirc, dbg: boolean = false) { + super(oLog, prms, dbg); + // commenté car si D est la variable à déterminer, il peut valoir n'importe quoi... if (prms.YB.v > D) { prms.YB.v = D; } // On place la berge au sommet du cercle - if (this.prms.D.isDefined() && this.prms.YB.isDefined()) - this.CalcGeo('B'); + // if (this.prms.D.isDefined() && this.prms.YB.isDefined()) + // this.CalcGeo('B'); } protected setParametersCalculability() { @@ -52,22 +48,7 @@ export class cSnCirc extends acSection { * au cas où le canal soit "enterré" (côte de berge > diamètre) */ private valeurYDebordement(): number { - // this.debug('deb'); - // this.debug('YB ' + this.prms.YB.v); - // this.debug('D ' + this.prms.D.v); - // this.debug('min ' + Math.min(this.prms.YB.v, this.prms.D.v)); - // this.debug('Y ' + this.prms.Y.v); - - // let min = Math.min(this.prms.YB.v, this.prms.D.v); - // this.debug('min( YB(=' + this.prms.YB.v + '), D(=' + this.prms.D.v + ')) = ' + min); - // this.debug('max(0, Y(=' + this.prms.Y.v + ') - min(YB, D)(=' + min + ') = ' + Math.max(0, this.prms.Y.v - Math.min(this.prms.YB.v, this.prms.D.v))); - // return Math.max(0, this.prms.Y.v - Math.min(this.prms.YB.v, this.prms.D.v)); return this.prms.Y.v - Math.min(this.prms.YB.v, this.prms.D.v); // >= 0 par définition, et toujours vrai car utilisé après test isDebordement() - - // if (this.isDebordement()) - // return this.prms.Y.v - this.prms.YB.v; - - // return 0; } /** @@ -75,56 +56,35 @@ export class cSnCirc extends acSection { * @returns true en cas de débordement */ 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 + this.debug("circ.isDebordement() : Y " + this.prms.Y.toString()); + this.debug("circ.isDebordement() : D " + this.prms.D.toString()); + this.debug("circ.isDebordement() : YB " + this.prms.YB.toString()); + this.debug("circ.isDebordement() : res=" + (this.prms.Y.v > Math.min(this.prms.D.v, this.prms.YB.v))); + + return this.prms.Y.v > Math.min(this.prms.D.v, this.prms.YB.v); } /** * Calcul de l'angle Alpha de la surface libre par rapport au fond. * @return Alpha */ - // Calc_Alpha() { - // if (this.prms.Y.v > this.oP.v.YB) { - // // var rY = this.oP.v.YB; - // var rY = this.prms.YB.v; - // } - // else { - // rY = this.prms.Y.v; - // } - // if (rY <= 0) { - // return 0; - // } - // else if (rY > this.prms.D.v) { - // return Math.PI; - // } - // else { - // var alpha = Math.acos(1. - rY / (this.prms.D.v / 2.)); - // if (alpha > Math.PI) { - // return Math.PI; - // } - // else { - // return alpha; - // } - // } - // } private Calc_AlphaY(Y: number, D: number) { let alpha = Math.acos(1. - Y / (D / 2.)); return Math.min(alpha, Math.PI); } Calc_Alpha() { + this.debug("Calc_Alpha : bSnFermee " + this.bSnFermee); + if (this.prms.Y.v <= 0) return 0; - if (this.isDebordement()) - return Math.PI; - // let alpha = Math.acos(1. - this.prms.Y.v / (this.prms.D.v / 2.)); - // if (alpha > Math.PI) - // return Math.PI; + if (this.isDebordement()) { + if (this.bSnFermee) + return Math.PI; + return this.Calc_AlphaY(this.prms.YB.v, this.prms.D.v); + } - // return alpha; return this.Calc_AlphaY(this.prms.Y.v, this.prms.D.v); } @@ -133,21 +93,24 @@ export class cSnCirc extends acSection { * @return dAlpha */ Calc_dAlpha() { - // if (this.prms.Y.v <= 0 || this.prms.Y.v >= this.prms.D.v || this.prms.Y.v > this.oP.v.YB) { if (this.prms.Y.v <= 0 || this.isDebordement()) return 0; return 2. / this.prms.D.v / Math.sqrt(1. - Math.pow(1. - 2. * this.prms.Y.v / this.prms.D.v, 2)); } - Calc_LargeurBerge() { - if (this.prms.D.isDefined && this.prms.YB.isDefined) { - let d = this.prms.D.v; - let yb = this.prms.YB.v; - if (yb >= d) - return 0; - return this.Calc_AlphaY(yb, d); - } + private Calc_LargeurBerge() { + // let d = this.prms.D.v; + // let yb = this.prms.YB.v; + // if (yb >= d) + // return 0; + // return d * Math.sin(this.Calc_AlphaY(yb, d)); + let d = this.prms.D.v; + let yb = Math.min(this.prms.YB.v, d); + // return d * Math.sin(this.Calc_AlphaY(yb, d)); + let res = d * Math.sin(this.Calc_AlphaY(yb, d)); + this.debug("Calc_LargeurBerge res=" + res); + return res; } /** @@ -155,28 +118,35 @@ export class cSnCirc extends acSection { * @return B */ Calc_B() { - // if (this.prms.Y.v > this.oP.v.YB) { + this.debug("circ.Calc_B() : LargeurBerge " + this.prms.LargeurBerge.toString()); + this.debug("circ.Calc_B() : D " + this.prms.D.toString()); + this.debug("circ.Calc_B() : Y " + this.prms.Y.toString()); + if (this.isDebordement()) { - if (!this.prms.LargeurBerge.isDefined()) - this.prms.LargeurBerge.v = this.Calc_LargeurBerge(); + this.debug("circ.Calc_B() : débordement"); + //if (!this.prms.LargeurBerge.isDefined()) + // this.prms.LargeurBerge.v = this.Calc_LargeurBerge(); + // return super.Calc_B_Debordement(); - return super.Calc_B_Debordement(); + return this.Calc_LargeurBerge(); } - return this.prms.D.v * Math.sin(this.Calc("Alpha")); + this.debug("circ.Calc_B() : PAS débordement"); + if (this.prms.D.isDefined() && this.prms.Y.isDefined()) { + //return this.prms.D.v * Math.sin(this.Calc("Alpha")); + let res = this.prms.D.v * Math.sin(this.Calc("Alpha")); + this.debug("circ.Calc_B() : res=" + res); + return res; + } } /** * Calcul du périmètre mouillé. - * @param rY Uniquement présent car la méthode parent a cet argument * @return B */ - // Calc_P(rY = 0) { Calc_P() { - // if (this.prms.Y.v > this.oP.v.YB && !this.bSnFermee) { - if (this.isDebordement() && !this.bSnFermee) + if (!this.bSnFermee && this.isDebordement()) // On n'ajoute pas le périmètre dans le cas d'une fente de Preissmann - // return this.CalcGeo("P') + super.Calc_P_Debordement(this.prms.Y.v - this.oP.v.YB); return this.CalcGeo("P") + super.Calc_P_Debordement(this.valeurYDebordement()); return this.prms.D.v * this.Calc("Alpha"); @@ -184,14 +154,10 @@ export class cSnCirc extends acSection { /** * Calcul de la surface mouillée. - * @param rY Uniquement présent car la méthode parent a cet argument * @return S */ - // Calc_S(rY = 0) { Calc_S() { - // if (this.prms.Y.v > this.oP.v.YB) { - if (this.isDebordement() && !this.bSnFermee) - // return this.CalcGeo("S") + super.Calc_S_Debordement(this.prms.Y.v - this.oP.v.YB); + if (!this.bSnFermee && this.isDebordement()) return this.CalcGeo("S") + super.Calc_S_Debordement(this.valeurYDebordement()); let alpha = this.Calc("Alpha"); @@ -204,8 +170,7 @@ export class cSnCirc extends acSection { * @return dP */ Calc_dP() { - // if (this.prms.Y.v > this.oP.v.YB && !this.bSnFermee) { - if (this.isDebordement() && !this.bSnFermee) + if (!this.bSnFermee && this.isDebordement()) return super.Calc_dP_Debordement(); return this.prms.D.v * this.Calc("dAlpha"); @@ -216,7 +181,6 @@ export class cSnCirc extends acSection { * @return dB */ Calc_dB() { - // if (this.prms.Y.v > this.oP.v.YB) { if (this.isDebordement()) return super.Calc_dB_Debordement(); @@ -226,10 +190,8 @@ export class cSnCirc extends acSection { /** * Calcul de la distance du centre de gravité de la section à la surface libre * multiplié par la surface hydraulique - * @param rY Uniquement présent car la méthode parent a cet argument * @return S x Yg */ - // Calc_SYg(rY = 0) { Calc_SYg() { let alpha = this.Calc("Alpha"); let SYg = Math.sin(alpha) - Math.pow(Math.sin(alpha), 3) / 3 - alpha * Math.cos(alpha); @@ -240,10 +202,8 @@ export class cSnCirc extends acSection { /** * Calcul de la dérivée de la distance du centre de gravité de la section à la surface libre * multiplié par la surface hydraulique - * @param rY Uniquement présent car la méthode parent a cet argument * @return S x Yg */ - // Calc_dSYg(rY = 0) { Calc_dSYg() { let alpha = this.Calc("Alpha"); let dAlpha = this.Calc("dAlpha"); diff --git a/src/section/section_puissance.ts b/src/section/section_puissance.ts index d458864c954d77727f96a7d969b934a887d7edf8..95ea2c372f88b5f3798dabcd376a9e7597e3a504 100644 --- a/src/section/section_puissance.ts +++ b/src/section/section_puissance.ts @@ -3,6 +3,9 @@ import { acSection, ParamsSection } from "./section_type"; import { cLog } from "./log"; +/** + * Paramètres de la section parabolique ou "puissance" + */ export class ParamsSectionPuiss extends ParamsSection { private _k: ParamDefinition; // Coefficient de forme compris entre 0 et 1 @@ -23,14 +26,10 @@ export class ParamsSectionPuiss extends ParamsSection { * Calculs de la section parabolique ou "puissance" */ export class cSnPuiss extends acSection { - //public k; /// Coefficient de forme compris entre 0 et 1 - //LargeurBerge => La largeur des berges est déjà présente dans acSection protected nbDessinPoints = 50; - constructor(oLog: cLog, oP: ParamsSectionPuiss, dbg: boolean = false) { - super(oLog, oP, dbg); - // this.prms.k = rk; - // this.prms.LargeurBerge = LargeurBerge; + constructor(oLog: cLog, prms: ParamsSectionPuiss, dbg: boolean = false) { + super(oLog, prms, dbg); } protected setParametersCalculability() { @@ -49,24 +48,22 @@ export class cSnPuiss extends acSection { Calc_Alpha(): number { return this.prms.LargeurBerge.v / Math.pow(this.prms.YB.v, this.prms.k.v); } + /** * Calcul de la largeur au miroir. * @return B */ Calc_B(): number { - if (this.prms.Y.v >= this.prms.YB.v) { + if (this.prms.Y.v >= this.prms.YB.v) return this.prms.LargeurBerge.v; - } - else { - return this.Calc("Alpha") * Math.pow(this.prms.Y.v, this.prms.k.v); - } + + return this.Calc("Alpha") * Math.pow(this.prms.Y.v, this.prms.k.v); } + /** * Calcul du périmètre mouillé. - * @param rY Uniquement présent car la méthode parent a cet argument * @return B */ - // Calc_P(rY = 0) { Calc_P(): number { var n = 100; /// Le nombre de partie pour le calcul de l'intégrale var Lambda2 = Math.pow(this.Calc("Alpha"), 2); @@ -83,10 +80,8 @@ export class cSnPuiss extends acSection { /** * Calcul de la surface mouillée. - * @param rY Uniquement présent car la méthode parent a cet argument * @return S */ - // Calc_S(rY = 0) { Calc_S(): number { let k = this.prms.k.v; return this.Calc("Alpha") * Math.pow(this.prms.Y.v, k + 1) / (k + 1); @@ -109,24 +104,22 @@ export class cSnPuiss extends acSection { let k = this.prms.k.v; return this.Calc("Alpha") * k * Math.pow(this.prms.Y.v, k - 1); } + /** * Calcul de la distance du centre de gravité de la section à la surface libre * multiplié par la surface hydraulique - * @param rY Uniquement présent car la méthode parent a cet argument * @return S x Yg */ - // Calc_SYg(rY = 0) { Calc_SYg(): number { let k = this.prms.k.v; return this.Calc("Alpha") * Math.pow(this.prms.Y.v, k + 2) / ((k + 1) * (k + 2)); } + /** * Calcul de la dérivée distance du centre de gravité de la section à la surface libre * multiplié par la surface hydraulique - * @param rY Uniquement présent car la méthode parent a cet argument * @return S x Yg */ - // Calc_dSYg(rY = 0) { Calc_dSYg(): number { let k = this.prms.k.v; let Y = this.prms.Y.v; diff --git a/src/section/section_rectang.ts b/src/section/section_rectang.ts index f0dfb3ecd6723f60efe126c21d85fd082acdf616..b1dde765bb860c5b7deec62831812ae269c3be8c 100644 --- a/src/section/section_rectang.ts +++ b/src/section/section_rectang.ts @@ -14,8 +14,8 @@ export class ParamsSectionRectang extends ParamsSection { * Calculs de la section rectangulaire */ export class cSnRectang extends acSection { - constructor(oLog: cLog, oP: ParamsSectionRectang, dbg: boolean = false) { - super(oLog, oP, dbg); + constructor(oLog: cLog, prms: ParamsSectionRectang, dbg: boolean = false) { + super(oLog, prms, dbg); } get prms(): ParamsSectionRectang { @@ -24,10 +24,8 @@ export class cSnRectang extends acSection { /** * Calcul du périmètre mouillé - * @param rY Uniquement présent car la méthode parent à cet argument * @return Périmètre mouillé (m) */ - // Calc_P(rY = 0) { Calc_P(): number { return this.prms.LargeurBerge.v + super.Calc_P_Debordement(this.prms.Y.v); } diff --git a/src/section/section_trapez.ts b/src/section/section_trapez.ts index f8d71c0110c9a65ede8fe19fefa940da62188a14..9b3096834ba7c9009e0c79095dbbfd250d96a344 100644 --- a/src/section/section_trapez.ts +++ b/src/section/section_trapez.ts @@ -33,13 +33,10 @@ export class ParamsSectionTrapez extends ParamsSection { * Calculs de la section trapézoïdale */ export class cSnTrapez extends acSection { - // public LargeurFond; /// Largeur au fond - // public Fruit; /// Fruit des berges - constructor(oLog: cLog, oP: ParamsSectionTrapez, dbg: boolean = false) { - super(oLog, oP, dbg); + constructor(oLog: cLog, prms: ParamsSectionTrapez, dbg: boolean = false) { + super(oLog, prms, dbg); } - protected setParametersCalculability() { super.setParametersCalculability(); this.prms.LargeurFond.calculability = ParamCalculability.DICHO; @@ -50,47 +47,37 @@ export class cSnTrapez extends acSection { return <ParamsSectionTrapez>this._prms; } + private isDebordement(): boolean { + return this.prms.Y.v > this.prms.YB.v; + } + Calc_B(bBerge = false): number { - if (!bBerge && this.prms.Y > this.prms.YB) { + if (!bBerge && this.isDebordement()) return this.prms.LargeurBerge.v; - } - else { - return this.prms.LargeurFond.v + 2 * this.prms.Fruit.v * this.prms.Y.v; - } + + return this.prms.LargeurFond.v + 2 * this.prms.Fruit.v * this.prms.Y.v; } /** * Calcul du périmètre mouillé - * @param rY Uniquement présent car la méthode parent à cet argument * @return Périmètre mouillé (m) */ - // Calc_P(rY = 0) { Calc_P(): number { - if (this.prms.Y > this.prms.YB) { - var P = this.CalcGeo("P") + super.Calc_P_Debordement(this.prms.Y.v - this.prms.YB.v); - } - else { - P = this.prms.LargeurFond.v + 2 * Math.sqrt(1 + Math.pow(this.prms.Fruit.v, 2)) * this.prms.Y.v; - } - //~ spip_log('Trapez->CalcP(rY='.this->rY.')='.P,'hydraulic.'._LOG_DEBUG); - return P; + if (this.isDebordement()) + return this.CalcGeo("P") + super.Calc_P_Debordement(this.prms.Y.v - this.prms.YB.v); + + return this.prms.LargeurFond.v + 2 * Math.sqrt(1 + Math.pow(this.prms.Fruit.v, 2)) * this.prms.Y.v; } /** * Calcul de la surface mouillée - * @param rY Uniquement présent car la méthode parent à cet argument * @return Surface mouillée (m2) */ - // Calc_S(rY = 0) { Calc_S(): number { - if (this.prms.Y > this.prms.YB) { - var S = this.CalcGeo("S") + super.Calc_S_Debordement(this.prms.Y.v - this.prms.YB.v); - } - else { - S = this.prms.Y.v * (this.prms.LargeurFond.v + this.prms.Fruit.v * this.prms.Y.v); - } - //~ spip_log('Trapez->CalcS(rY='.this->rY.')='.S,'hydraulic.'._LOG_DEBUG); - return S; + if (this.isDebordement()) + return this.CalcGeo("S") + super.Calc_S_Debordement(this.prms.Y.v - this.prms.YB.v); + + return this.prms.Y.v * (this.prms.LargeurFond.v + this.prms.Fruit.v * this.prms.Y.v); } /** @@ -98,12 +85,10 @@ export class cSnTrapez extends acSection { * @return dS */ Calc_dS(): number { - if (this.prms.Y > this.prms.YB) { + if (this.isDebordement()) return super.Calc_dS(); - } - else { - return this.prms.LargeurFond.v + 2 * this.prms.Fruit.v * this.prms.Y.v; - } + + return this.prms.LargeurFond.v + 2 * this.prms.Fruit.v * this.prms.Y.v; } /** @@ -111,12 +96,10 @@ export class cSnTrapez extends acSection { * @return dP */ Calc_dP(): number { - if (this.prms.Y > this.prms.YB) { + if (this.isDebordement()) return super.Calc_dP_Debordement(); - } - else { - return 2 * Math.sqrt(1 + this.prms.Fruit.v * this.prms.Fruit.v); - } + + return 2 * Math.sqrt(1 + this.prms.Fruit.v * this.prms.Fruit.v); } /** @@ -124,30 +107,26 @@ export class cSnTrapez extends acSection { * @return dB */ Calc_dB(): number { - if (this.prms.Y > this.prms.YB) { + if (this.isDebordement()) return super.Calc_dB_Debordement(); - } - else { - return 2 * this.prms.LargeurFond.v * this.prms.Fruit.v; - } + + return 2 * this.prms.LargeurFond.v * this.prms.Fruit.v; } + /** * Calcul de la distance du centre de gravité de la section à la surface libre * multiplié par la surface hydraulique - * @param rY Uniquement présent car la méthode parent à cet argument * @return S x Yg */ - // Calc_SYg(rY = 0) { Calc_SYg(): number { return (this.prms.LargeurFond.v / 2 + this.prms.Fruit.v * this.prms.Y.v / 3) * Math.pow(this.prms.Y.v, 2); } + /** * Calcul de la dérivée de la distance du centre de gravité de la section à la surface libre * multiplié par la surface hydraulique - * @param rY Uniquement présent car la méthode parent à cet argument * @return S x Yg */ - // Calc_dSYg(rY = 0) { Calc_dSYg(): number { var SYg = this.prms.Fruit.v / 3 * Math.pow(this.prms.Y.v, 2); SYg += (this.prms.LargeurFond.v / 2 + this.prms.Fruit.v * this.prms.Y.v / 3) * 2 * this.prms.Y.v; diff --git a/src/section/section_type.ts b/src/section/section_type.ts index e8eb850893b9f74bf41e22a5480fefd4f1de763d..dbd9a6084d54d2de9ecffce5c1f38c0df69f2c3a 100644 --- a/src/section/section_type.ts +++ b/src/section/section_type.ts @@ -1,3 +1,4 @@ +import { XOR } from "../base"; import { cLog } from "./log"; import { ComputeNode, ParamDefinition, ParamDomain, ParamDomainValue, ParamCalculability, IParamsEquation } from "../param"; import { cHautCritique, cHautNormale, cHautCorrespondante, cHautConjuguee } from "./hauteur"; @@ -17,8 +18,8 @@ export abstract class cParamsCanal implements IParamsEquation { private _YCL: ParamDefinition; // Condition limite en cote à l'amont ou à l'aval private _Dx: ParamDefinition; // Pas d'espace (positif en partant de l'aval, négatif en partant de l'amont) private _Long: ParamDefinition; // Longueur du bief - // public Resolution; /// Méthode de résolution "Euler" ou "RK4" + constructor(rKs, rQ, rIf, rPrec, rYB, rYCL = undefined, rDx = undefined, rLong = undefined) //, sResolution = '') { { //this.prms.Resolution = sResolution; @@ -129,12 +130,9 @@ export abstract class ParamsSection extends cParamsCanal { * Comprend les formules pour la section rectangulaire pour gérer les débordements */ export abstract class acSection extends ComputeNode { - //public Y; /// Tirant d'eau public HautCritique: number; /// Tirant d'eau critique public HautNormale; /// Tirant d'eau normal - //public oP: ParamsSection; /// Paramètres du système canal (classe oParam) protected oLog: cLog; /// Pour l'affichage du journal de calcul - //public LargeurBerge; /// largeur au débordement /** * true si la section est fermée (on considère alors qu'il existe une fente de Preissmann) @@ -170,16 +168,15 @@ export abstract class acSection extends ComputeNode { * Construction de la classe. * Calcul des hauteurs normale et critique */ - constructor(oLog: cLog, oP: ParamsSection, dbg: boolean = false) { - super(oP, dbg); - //this.prms = oP; + constructor(oLog: cLog, prms: ParamsSection, dbg: boolean = false) { + super(prms, dbg); this.oLog = oLog; // this._v = oP.v; // copie la référence au tableau // this.prms.Y.v = 0; // this.prms.LargeurBerge.v = 0; - // this.CalcGeo("B'); // à ce point, il manque des paramètres pour certaines sections (ex : fruit pour trapèze) + // this.CalcGeo("B"); // à ce point, il manque des paramètres pour certaines sections (ex : fruit pour trapèze) } protected setParametersCalculability() { @@ -209,10 +206,17 @@ export abstract class acSection extends ComputeNode { * @param bGeo Réinitialise les données de géométrie aussi */ Reset(bGeo = true) { + this.debug("reset(" + bGeo + ")"); this.arCalc = {}; if (bGeo) { + this.debug("reset Geo"); this.arCalcGeo = {}; + this.bSnFermee = false; } + this.debug("reset arCalc :"); + this.debug(this.arCalc); + this.debug("reset arCalcGeo :"); + this.debug(this.arCalcGeo); } /** @@ -221,12 +225,12 @@ export abstract class acSection extends ComputeNode { */ private Swap(bMem) { if (bMem) { - this.debug('save Y=' + this.prms.Y.toString()); + this.debug("save Y=" + this.prms.Y.toString()); this.Y_old = this.prms.Y.uncheckedValue; this.Calc_old = this.arCalc; } else { - this.debug('restore Y=' + this.Y_old); + this.debug("restore Y=" + this.Y_old); this.prms.Y.v = this.Y_old; this.arCalc = this.Calc_old; this.Calc_old = {}; @@ -236,14 +240,13 @@ export abstract class acSection extends ComputeNode { /** * Calcul des données à la section * @param sDonnee Clé de la donnée à calculer (voir this->arCalc) - * @param bRecalc Pour forcer le recalcul de la donnée + * @param rY valeur de Y à utiliser * @return la donnée calculée */ Calc(sDonnee: string, rY: number = undefined): number { - this.debug("in Calc(" + sDonnee + ", rY = " + rY + ") old " + sDonnee + "= " + this.arCalc[sDonnee]); + this.debug("in Calc(" + sDonnee + ", rY=" + rY + ") old " + sDonnee + "=" + this.arCalc[sDonnee]); this.debug("this.Y=" + this.prms.Y.toString()); - //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 @@ -256,9 +259,6 @@ export abstract class acSection extends ComputeNode { this.arCalc[sDonnee] = this.prms.If.v - this.Calc("J"); break; - // case 'Yn': // Hauteur normale - // return this.Calc_Yn(); - default: let methode = 'Calc_' + sDonnee; @@ -285,26 +285,23 @@ export abstract class acSection extends ComputeNode { /** * Calcul des données uniquement dépendantes de la géométrie de la section * @param sDonnee Clé de la donnée à calculer (voir this->arCalcGeo) - * @param rY Hauteur d'eau * @return la donnée calculée */ CalcGeo(sDonnee): number { - this.debug("in CalcGeo(" + sDonnee + ') old ' + sDonnee + '=' + this.arCalcGeo[sDonnee]); - this.debug('this.Y=' + this.prms.Y.toString()); + this.debug("in CalcGeo(" + sDonnee + ") old " + sDonnee + "=" + this.arCalcGeo[sDonnee]); + this.debug("this.Y=" + this.prms.Y.toString()); - // if (sDonnee != 'B' && !this.arCalcGeo['B']) { - if (sDonnee != 'B' && this.arCalcGeo['B'] == undefined) { - // Si la largeur aux berges n'a pas encore été calculée, on commence par ça + // Si la largeur aux berges n'a pas encore été calculée, on commence par ça + if (sDonnee != "B" && this.arCalcGeo["B"] == undefined) this.CalcGeo("B"); - } - // if (!this.arCalcGeo[sDonnee]) { + if (this.arCalcGeo[sDonnee] == undefined) { // La donnée a besoin d'être calculée this.Swap(true); // On mémorise les données hydrauliques en cours this.Reset(false); this.prms.Y.v = this.prms.YB.v; switch (sDonnee) { - case 'B': // Largeur aux berges + case "B": // Largeur aux berges this.arCalcGeo[sDonnee] = this.Calc_B(); if (this.arCalcGeo[sDonnee] < this.prms.YB.v / 100) { // Section fermée @@ -316,17 +313,15 @@ export abstract class acSection extends ComputeNode { break; default: - let methode = 'Calc_' + sDonnee; + let methode = "Calc_" + sDonnee; // this.arCalcGeo[sDonnee] = this[methode](); let res = this[methode](); this.arCalcGeo[sDonnee] = res; break; } - //~ spip_log('CalcGeo(".sDCalcGeonnee.',rY='.this->oP->rYB.')='.this->arCalcGeo[sDonnee],'hydraulic.'._LOG_DEBUG); this.Swap(false); // On restitue les données hydrauliques en cours this.debug("CalcGeo(" + sDonnee + ") resultat -> " + this.arCalcGeo[sDonnee]); } - // this.debug('CalcGeo(" + sDonnee + ')=' + this.arCalcGeo[sDonnee]); else this.debug("CalcGeo(" + sDonnee + ") cache= " + this.arCalcGeo[sDonnee]); @@ -351,22 +346,19 @@ export abstract class acSection extends ComputeNode { * @param Y hauteur d'eau au dela de la berge **/ Calc_S_Debordement(Y: number): number { - this.debug('section->CalcS(rY=' + Y + ') LargeurBerge=' + this.prms.LargeurBerge); - return Y * this.prms.LargeurBerge.v; + // this.debug('section->CalcS(rY=' + Y + ') LargeurBerge=' + this.prms.LargeurBerge); + this.debug('section->CalcS(rY=' + Y + ') LargeurBerge=' + this.CalcGeo("B")); + // return Y * this.prms.LargeurBerge.v; + return Y * this.CalcGeo("B"); } - /** - * Calcul de la dérivée surface hydraulique. - * @return La dérivée de la surface hydraulique - */ - //abstract Calc_dS(); - /** * Calcul de la dérivée surface hydraulique en cas de débordement * @return La dérivée de la surface hydraulique en cas de débordement */ Calc_dS_Debordement(): number { - return this.prms.LargeurBerge.v; + // return this.prms.LargeurBerge.v; + return this.CalcGeo("B"); } /** @@ -402,7 +394,6 @@ export abstract class acSection extends ComputeNode { * @return Le rayon hydraulique */ Calc_R(): number { - this.debug("in calc_R") let P = this.Calc("P"); if (P != 0) return this.Calc("S") / P; @@ -434,7 +425,8 @@ export abstract class acSection extends ComputeNode { * @return La largeur au miroir en cas de débordement */ Calc_B_Debordement(): number { - return this.prms.LargeurBerge.v; + // return this.prms.LargeurBerge.v; + return this.CalcGeo("B"); } /** @@ -483,10 +475,6 @@ export abstract class acSection extends ComputeNode { return - (this.prms.If.v - this.Calc("J", Y) / (1 - Math.pow(this.Calc("Fr", Y), 2))); } - XOR(a, b) { - return (a || b) && !(a && b); - } - /** * Calcul du point suivant de la courbe de remous par la méthode Euler explicite. * @return Tirant d'eau @@ -494,7 +482,7 @@ export abstract class acSection extends ComputeNode { Calc_Y_Euler(Y): number { // L'appel à Calc("J') avec Y en paramètre réinitialise toutes les données dépendantes de la ligne d'eau var Y2 = Y + this.prms.Dx.v * this.Calc_dYdX(Y); - if (this.XOR(this.prms.Dx.v > 0, !(Y2 < this.HautCritique))) + if (XOR(this.prms.Dx.v > 0, !(Y2 < this.HautCritique))) return undefined; return Y2; @@ -508,13 +496,13 @@ export abstract class acSection extends ComputeNode { // L'appel à Calc("J') avec Y en paramètre réinitialise toutes les données dépendantes de la ligne d'eau var Dx = this.prms.Dx.v; var k1 = this.Calc_dYdX(Y); - if (this.XOR(Dx > 0, !(Y + Dx / 2 * k1 < this.HautCritique))) { return undefined; } + if (XOR(Dx > 0, !(Y + Dx / 2 * k1 < this.HautCritique))) { return undefined; } var k2 = this.Calc_dYdX(Y + Dx / 2 * k1); - if (this.XOR(Dx > 0, !(Y + Dx / 2 * k2 < this.HautCritique))) { return undefined; } + if (XOR(Dx > 0, !(Y + Dx / 2 * k2 < this.HautCritique))) { return undefined; } var k3 = this.Calc_dYdX(Y + Dx / 2 * k2); - if (this.XOR(Dx > 0, !(Y + Dx / 2 * k3 < this.HautCritique))) { return undefined; } + if (XOR(Dx > 0, !(Y + Dx / 2 * k3 < this.HautCritique))) { return undefined; } var k4 = this.Calc_dYdX(Y + Dx * k3); - if (this.XOR(Dx > 0, !(Y + Dx / 6 * (k1 + 2 * (k2 + k3) + k4) < this.HautCritique))) { return undefined; } + if (XOR(Dx > 0, !(Y + Dx / 6 * (k1 + 2 * (k2 + k3) + k4) < this.HautCritique))) { return undefined; } return Y + Dx / 6 * (k1 + 2 * (k2 + k3) + k4); } // /** @@ -574,12 +562,7 @@ export abstract class acSection extends ComputeNode { * @return tirant d'eau critique */ Calc_Yc(): number { - //this.debug("in calcYc"); var hautCritique = new cHautCritique(this, this.DBG); - /*if(!this.HautCritique == hautCritique.Newton(this.prms.YB) || !hautCritique.HasConverged()) { - //traduction de code de langue: - //this.oLog.Add(_T('hydraulic:h_critique')+' : '+_T('hydraulic:newton_non_convergence'),true); - }*/ this.HautCritique = hautCritique.Newton(this.prms.YB.v); return this.HautCritique; } @@ -590,18 +573,11 @@ export abstract class acSection extends ComputeNode { */ Calc_Yn(): number { this.debug("in calc_Yn"); - if (this.prms.If.v <= 0) { - this.HautNormale = false; - //this.oLog.Add(_T('hydraulic:h_normale_pente_neg_nul'),true); - } else { - var oHautNormale = new cHautNormale(this, this.DBG); - //if(!this.HautNormale == oHautNormale.Newton(this.CalcGeo("Yc')) || !oHautNormale.HasConverged()) { - //this.oLog.Add(_T('hydraulic:h_normale').' : '._T('hydraulic:newton_non_convergence'),true); - this.HautNormale = oHautNormale.Newton(this.CalcGeo("Yc")); - this.debug("hautnormale" + this.HautNormale); - // } - } - return this.HautNormale; + if (this.prms.If.v <= 0) + return undefined; + + var oHautNormale = new cHautNormale(this, this.DBG); + return oHautNormale.Newton(this.CalcGeo("Yc")); } /** @@ -662,11 +638,9 @@ export abstract class acSection extends ComputeNode { * multiplié par la surface hydraulique * @return S x Yg */ - // Calc_SYg(rY) { - // return Math.pow(rY, 2) * this.prms.LargeurBerge / 2; - // } Calc_SYg(): number { - return Math.pow(this.prms.Y.v, 2) * this.prms.LargeurBerge.v / 2; + // return Math.pow(this.prms.Y.v, 2) * this.prms.LargeurBerge.v / 2; + return Math.pow(this.prms.Y.v, 2) * this.CalcGeo("B") / 2; } /** @@ -674,11 +648,9 @@ export abstract class acSection extends ComputeNode { * multiplié par la surface hydraulique * @return S x Yg */ - // Calc_dSYg(rY) { - // return rY * this.prms.LargeurBerge; - // } Calc_dSYg(): number { - return this.prms.Y.v * this.prms.LargeurBerge.v; + // return this.prms.Y.v * this.prms.LargeurBerge.v; + return this.prms.Y.v * this.CalcGeo("B"); } /**