diff --git a/.gitignore b/.gitignore index be9681831172b58fc6a650e72e82ee85cab2f878..093e25d1dd984d5f09e0333161d0cb70f8d5ca8c 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ spec/test2.ts spec/tsconfig-test.spec.json spec/tsconfig-test2.spec.json src/util/http.ts +/doc/matlabl_macro_rugo/*.mat diff --git a/doc/matlab_macro_rugo/data_precalcul_nat.mat b/doc/matlab_macro_rugo/data_precalcul_nat.mat deleted file mode 100755 index 05669c6294edb6dbed271d525b9318ae6919f9b6..0000000000000000000000000000000000000000 Binary files a/doc/matlab_macro_rugo/data_precalcul_nat.mat and /dev/null differ diff --git a/doc/matlab_macro_rugo/rampe_rugueuse.m b/doc/matlab_macro_rugo/rampe_rugueuse.m index b153fa216e99cc8c1ef504223d7551519c26e461..58fcfbdcace8717e4a27c002dd3cd112c5bc1f37 100755 --- a/doc/matlab_macro_rugo/rampe_rugueuse.m +++ b/doc/matlab_macro_rugo/rampe_rugueuse.m @@ -61,7 +61,7 @@ guidata(hObject, handles); %cd('E:\lcassan\Mes documents\macro_rugosite\cassiopee\gui_matlab') %cd('D:\macrorugosite\cassiopee\gui_matlab') -if exist('data_precalcul_nat')==2 +if exist('data_precalcul_nat.mat')==2 load data_precalcul_nat diff --git a/doc/scilab_tests/macrorugo_find_Q_nat.sci b/doc/scilab_tests/macrorugo_find_Q_nat.sci index ec15feb197b0b90e1a449265ffa45c17bb4e3ce9..a80e5f88b850202a8dfedd0e6d88fd4982a99e38 100755 --- a/doc/scilab_tests/macrorugo_find_Q_nat.sci +++ b/doc/scilab_tests/macrorugo_find_Q_nat.sci @@ -1,19 +1,17 @@ function [res]=find_Q_nat(Q,ks,D,h,Cd0,S,L,pf,C,sigma,bDbg) - if bDbg then - printf('*************************************\n') - print_r('Q') - end - //fonction pour ax=ay + //fonction pour ax=ay maxfun=1000; maxiter=1000; + if bDbg_RA then + maxiter=1 + end tolfun=1e-8; tolx=1e-8; opt = optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'TolFun',tolfun,'TolX',tolx) g=9.81; kappa=0.41; U0=Q./L./pf; - if(bDbg) then print_r("U0"); end; Fr=U0./(9.81*pf).^0.5; Frg=Fr/(1-C^0.5); @@ -32,12 +30,17 @@ function [res]=find_Q_nat(Q,ks,D,h,Cd0,S,L,pf,C,sigma,bDbg) fFr=(Frg.^(-2/3)).^2; end - if(bDbg) then print_r("fFr"); end; //Cd=Cd0.*(1+0.4./(pf./D).^2); Cd=Cd0.*(1+1./(pf./D).^2); //Cd=Cd0.*(0.8-2*C).*(1+0.4./(pf./D).^2).*fFr; R=(1-sigma*C);//%.*(1-C.^0.5).^2; - + if(bDbg) then + printf('*************************************\n') + print_r('Q') + print_r("U0") + print_r("fFr") + print_r("R") + end if pf/h>1; //fFr=1; @@ -117,8 +120,11 @@ function [res]=find_Q_nat(Q,ks,D,h,Cd0,S,L,pf,C,sigma,bDbg) if bDbg then print_r('N'); end; U0a=(2*g.*S.*D.*(R)./(Cd.*C.*(1+N))).^0.5; + if bDbg then print_r("U0a");end; + U0complet = find_U0_complet(U0a, pf,C,D,sigma,Cd0,Cf,coeff_contraction,S, bDbg) + if bDbg then print_r("U0complet");end; - [u fval] = fminsearch(list(find_U0_complet, U0i,pf,C,D,sigma,Cd0,Cf,coeff_contraction,S), U0a, opt) + [u fval] = fminsearch(list(find_U0_complet, pf,C,D,sigma,Cd0,Cf,coeff_contraction,S), U0a, opt) res=abs(U0-u); diff --git a/doc/scilab_tests/find_U0_complet.sci b/doc/scilab_tests/macrorugo_find_U0_complet.sci similarity index 61% rename from doc/scilab_tests/find_U0_complet.sci rename to doc/scilab_tests/macrorugo_find_U0_complet.sci index 462b2a44ca56b7cbfa0a6ace8e7e63dabf05cefe..bd01b5b87cca7d912d0a4989090e13c78c836e67 100644 --- a/doc/scilab_tests/find_U0_complet.sci +++ b/doc/scilab_tests/macrorugo_find_U0_complet.sci @@ -1,12 +1,12 @@ -function [res]=find_U0_complet(U01,h,C,D,sigma,Cd0,cfmean,r,S) +function [res]=find_U0_complet(U01,h,C,D,sigma,Cd0,cfmean,r,S, bDbgU0) + if ~exists("bDbgU0","local"); bDbgU0 = %f; end; g=9.81; Frexp=U01./(1-(1.*C).^0.5)./(9.81*h)^0.5; + //Frexp=U01./(9.81*h)^0.5; fFr=(min(r./(1-(Frexp.^2)/4),Frexp.^(-2/3))).^2; - - if Frexp>=1.5 fFr=(Frexp.^(-2/3)).^2; end @@ -15,11 +15,17 @@ alpha=1-(1.*C).^0.5-1/2*sigma.*C; //Cd=Cd0.*(0.8-2*C).*(1+0.4./(h./D).^2).*fFr; Cd=Cd0.*(1+1./(h./D).^2).*fFr; - N= (alpha.*cfmean)./(h./D.*Cd.*C); -hstar=h/D; +N= (alpha.*cfmean)./(h./D.*Cd.*C); + +if bDbgU0 then + print_r("Frexp") + print_r("fFr") + print_r("Cd") + print_r("N") +end res=abs(U01-(2*g.*S.*D.*(1-(sigma*C))./(Cd.*C.*(1+N))).^0.5); //res=abs(U01-(1-C^0.5)*(2*g.*S.*D*(1-sigma.*C)./(Cd.*C.*(1+N))).^0.5); -endfunction \ No newline at end of file +endfunction diff --git a/doc/scilab_tests/macrorugo_resultats_complementaires.sci b/doc/scilab_tests/macrorugo_resultats_complementaires.sci index bf0a9c7c8402628121b21d46f6043d387ac30c71..84767ae19d295492c7d8a0fd2a5ddb25acfa3655 100644 --- a/doc/scilab_tests/macrorugo_resultats_complementaires.sci +++ b/doc/scilab_tests/macrorugo_resultats_complementaires.sci @@ -1,6 +1,6 @@ function macrorugo_resultComp(z_amont, S, long, Q, L, pf, C, Cd, h, D) g = 9.81 - + cote_bas=z_amont-S*long; print_r("cote_bas"); @@ -23,7 +23,7 @@ function macrorugo_resultComp(z_amont, S, long, Q, L, pf, C, Cd, h, D) flowcond = 'immerge' end print_r("flowcond"); - + if pf/h>1.1 q_technique=0.955*(pf/h)^2.282*S^0.466*C^(-0.23)*(9.81*h)^0.5.*h*L; else @@ -41,4 +41,7 @@ function macrorugo_resultComp(z_amont, S, long, Q, L, pf, C, Cd, h, D) end print_r("q_technique"); + Strickler = Q /(pf*L*pf^(2/3)*S^(1/2)); + print_r("Strickler"); + endfunction diff --git a/doc/scilab_tests/macrorugo_searchQ.sci b/doc/scilab_tests/macrorugo_searchQ.sci index 9a6fdf54e3e9e009104334e54497c7d55a7ca52a..35de45f1e4b6491fd4968e0d3ed5ceec70903101 100644 --- a/doc/scilab_tests/macrorugo_searchQ.sci +++ b/doc/scilab_tests/macrorugo_searchQ.sci @@ -1,4 +1,4 @@ -function macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg) +function [Q] = macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg) printf("*** INPUT *** \n") print_r("ks") print_r("D") @@ -13,9 +13,9 @@ function macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg) maxiter=1000; tolfun=1e-8; tolx=1e-8; -// if bDbg then -// maxiter=1 -// end + if bDbg then + maxiter=1 + end opt = optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'TolFun',tolfun,'TolX',tolx) if Cd0==2; sigma=1; else sigma=%pi/4; end g=9.81 diff --git a/doc/scilab_tests/main_macrorugo.sce b/doc/scilab_tests/main_macrorugo.sce index 4284cc28b689cf48afd01a787ee363b0bcbb8e1b..22098d35254401166203ade7c41d399add93c219 100644 --- a/doc/scilab_tests/main_macrorugo.sce +++ b/doc/scilab_tests/main_macrorugo.sce @@ -46,9 +46,10 @@ printf("\n*** JalHyd #85 ***\n") // ***************************************************************************** k = 0.8 C = 0.2; // Concentration +Q = [] for h = 0.7:0.1:1.2 - macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg) + Q = [Q, macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg)] end - +disp Q macrorugo_searchQ(ks, D, 0.5, 2, S, 2, 0.85, C, z_amont, long, bDbg) diff --git a/doc/scilab_tests/test_macrorugo_jalhyd154.sce b/doc/scilab_tests/test_macrorugo_jalhyd154.sce index 5feac7b8bb9b458aa1818577aecdea3169e708d8..9af579f89730c2161032775e92b8d09cb94f117a 100644 --- a/doc/scilab_tests/test_macrorugo_jalhyd154.sce +++ b/doc/scilab_tests/test_macrorugo_jalhyd154.sce @@ -6,8 +6,15 @@ getd(sCurrentPath); bDbg = %f; bDbg_RA = %f; +Q_na = [] +for q0 = 0.2:0.05:0.3 + Q_na = [Q_na find_Q_nat(q0,0.1,0.4,0.4,1,0.05,1,0.3,0.13,%pi/4,%t)] +end +printf("%f, ", Q_na') +Q = [] // macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg) -for h = 0.6 - macrorugo_searchQ(0.1, 0.4, 0.4, 1, 0.05, 1, h, 0.13, 12.5, 6, bDbg) +for h = 0.34:0.01:0.41 + Q = [Q macrorugo_searchQ(0.1, 0.4, 0.4, 1, 0.05, 1, h, 0.13, 12.5, 6, bDbg)] end +printf("%f, ", Q') diff --git a/spec/macrorugo/macrorugo.spec.ts b/spec/macrorugo/macrorugo.spec.ts index d1de2ba7fb6cdb79ed4465d023b5dda7fc1a18d1..e5c113dcb8413c4275e594713d3255d268b887b7 100644 --- a/spec/macrorugo/macrorugo.spec.ts +++ b/spec/macrorugo/macrorugo.spec.ts @@ -5,23 +5,26 @@ import { checkResult } from "../test_func"; /* *** Emergent conditions Cd=1.5*** -ks=0.010000 -D=0.500000 -k=0.700000 -Cd0=1.500000 -S=0.050000 -B=1.000000 -h=0.600000 -C=0.130000 -Q=0.493722 fVal=0.000000 +ks = 0.010000 +D = 0.500000 +k = 0.700000 +Cd0 = 1.500000 +S = 0.050000 +B = 1.000000 +h = 0.600000 +C = 0.130000 +RESULTS: +find_Q_nat(0.901710)=0.679969 +Q=0.493729 fVal=0.000000 cote_bas = 12.200000 -Vdeb = 0.822870 -Fr = 0.530417 -P = 242.170537 +Vdeb = 0.822881 +Fr = 0.530425 +P = 242.174003 flowcond = emergent -Vmax = 1.799472 +Vmax = 1.799502 V_technique = 1.991299 q_technique = 0.561860 +Strickler = 5.173107 */ function macroRugoInstanceEmergentCd15(): MacroRugo { @@ -31,7 +34,7 @@ function macroRugoInstanceEmergentCd15(): MacroRugo { 6, // L 1, // B 0.05, // If - 0.493722, // Q + 0.493729, // Q 0.6, // h 0.01, // Ks 0.13, // C @@ -50,80 +53,89 @@ const macroRugoExtraResultEmergentCd15: { [key: string]: number|MacroRugoFlowTyp V_GuideTech: 1.991299, Vdeb: 0.822881, Vmax: 1.799502, + Strickler: 5.173107, ZF2: 12.2 }; /* *** Emergent conditions Cd=2*** -ks=0.010000 -D=0.500000 -k=0.700000 -Cd0=2.000000 -S=0.050000 -B=1.000000 -h=0.600000 -C=0.130000 -Q=0.376808 fVal=0.000000 +ks = 0.010000 +D = 0.500000 +k = 0.700000 +Cd0 = 2.000000 +S = 0.050000 +B = 1.000000 +h = 0.600000 +C = 0.130000 +RESULTS: +find_Q_nat(0.768677)=0.653110 +Q=0.376811 fVal=0.000000 cote_bas = 12.200000 -Vdeb = 0.628013 -Fr = 0.404814 -P = 184.824088 +Vdeb = 0.628018 +Fr = 0.404817 +P = 184.825731 flowcond = emergent -Vmax = 1.536115 +Vmax = 1.536129 V_technique = 1.592932 q_technique = 0.414154 +Strickler = 3.948084 */ function macroRugoInstanceEmergentCd2(): MacroRugo { const nub: MacroRugo = macroRugoInstanceEmergentCd15(); nub.prms.Cd0.singleValue = 2; - nub.prms.Q.singleValue = 0.376808; + nub.prms.Q.singleValue = 0.376811; return nub; } const macroRugoExtraResultEmergentCd2: { [key: string]: number|MacroRugoFlowType } = { ENUM_MacroRugoFlowType: MacroRugoFlowType.EMERGENT, Fr: 0.404817, - PV: 184.825734, + PV: 184.825731, Q_GuideTech: 0.414154, V_GuideTech: 1.592932, Vdeb: 0.628018, Vmax: 1.536129, + Strickler: 3.948084, ZF2: 12.2 }; /* *** Submerged conditions *** -ks=0.010000 -D=0.500000 -k=0.700000 -Cd0=1.500000 -S=0.050000 -B=1.000000 -h=0.800000 -C=0.130000 -Q=0.908068 fVal=0.000000 +ks = 0.010000 +D = 0.500000 +k = 0.700000 +Cd0 = 1.500000 +S = 0.050000 +B = 1.000000 +h = 0.800000 +C = 0.130000 +RESULTS: +find_Q_nat(1.202280)=0.112522 +Q=1.112263 fVal=0.000000 cote_bas = 12.200000 -Vdeb = 1.135085 -Fr = 0.633645 -P = 445.407266 +Vdeb = 1.390328 +Fr = 0.776130 +P = 545.564782 flowcond = immerge q_technique = 0.940450 +Strickler = 7.215044 */ function macroRugoInstanceSubmerged(): MacroRugo { const nub: MacroRugo = macroRugoInstanceEmergentCd15(); nub.prms.Y.singleValue = 0.8; - nub.prms.Q.singleValue = 0.908068; + nub.prms.Q.singleValue = 1.112263; return nub; } const macroRugoExtraResultSubmerged: { [key: string]: number|MacroRugoFlowType } = { ENUM_MacroRugoFlowType: MacroRugoFlowType.SUBMERGED, - Fr: 0.633645, - PV: 445.407266, + Fr: 0.776130, + PV: 545.564782, Q_GuideTech: 0.940450, - Vdeb: 1.135085, + Vdeb: 1.390328, + Strickler: 7.215044, ZF2: 12.2 }; @@ -170,6 +182,8 @@ function testMacroRugoConfig(sInstance: string, Q0: number, fVal0: number, mrExt const nubit = MacroRugoFactory(sInstance); nubit.prms.Q.v = Q0; // tslint:disable-next-line:no-string-literal + nubit["bSubmerged"] = (nubit.prms.Y.v / nubit.prms.PBH.v > MacroRugo["limitSubmerg"]); + // tslint:disable-next-line:no-string-literal expect(nubit["resolveQ"]()).toBeCloseTo(fVal0, 5); }); const nub = MacroRugoFactory(sInstance); @@ -189,10 +203,18 @@ function testMacroRugoConfig(sInstance: string, Q0: number, fVal0: number, mrExt }); } +function macroRugoInstanceJalHyd85(): MacroRugo { + const nubMR = macroRugoInstanceEmergentCd15(); + nubMR.prms.C.singleValue = 0.2; + nubMR.prms.PBH.singleValue = 0.8; + nubMR.calculatedParam = nubMR.prms.Q; + return nubMR; +} + describe("Class MacroRugo: ", () => { - testMacroRugoConfig("EmergentCd15", 0.901710, 0.379539, macroRugoExtraResultEmergentCd15); - testMacroRugoConfig("EmergentCd2", 0.768677, 0.418029, macroRugoExtraResultEmergentCd2); + testMacroRugoConfig("EmergentCd15", 0.901710, 0.679969, macroRugoExtraResultEmergentCd15); + testMacroRugoConfig("EmergentCd2", 0.768677, 0.653110, macroRugoExtraResultEmergentCd2); // Le test passe en debug mais pas sous Jasmine !?? // describe(`Condition Submerged` , () => { // it(`resolveAlpha_t(0.07) should be 0.074752`, () => { @@ -200,21 +222,21 @@ describe("Class MacroRugo: ", () => { // expect(macroRugoInstanceSubmerged()["resolveAlpha_t"](0.07)).toBeCloseTo(0.074752, 5); // }); // }); - testMacroRugoConfig("Submerged", 1.202280, 0.145051, macroRugoExtraResultSubmerged); + testMacroRugoConfig("Submerged", 1.202280, 0.112522, macroRugoExtraResultSubmerged); describe("JalHyd #85", () => { - it("CalcSerie Q should return the goog result :)", () => { - const nubMR = macroRugoInstanceEmergentCd2(); - nubMR.prms.C.singleValue = 0.2; - nubMR.prms.PBH.singleValue = 0.8; - nubMR.calculatedParam = nubMR.prms.Q; + it("CalcSerie Q should return the good result :)", () => { + const nubMR = macroRugoInstanceJalHyd85(); + const nubMR2 = macroRugoInstanceJalHyd85(); nubMR.prms.Y.setValues(0.7, 1.2, 0.1); - const aQ: number[] = [ 0.363679, 0.433841, 0.595482, 0.768310, 0.991123, 1.441876 ]; + const aQ: number[] = [ 0.484255, 0.578363, 1.004229, 1.280269, 1.618937, 2.018687 ]; nubMR.CalcSerie(); for (let i = 0; i < aQ.length; i++) { expect(nubMR.result.resultElements[i].vCalc).toBeCloseTo(aQ[i], 4); + nubMR2.prms.Y.setValue(0.7 + i * 0.1); + expect(nubMR2.CalcSerie().vCalc).toBeCloseTo(aQ[i], 4); } }); }); diff --git a/spec/macrorugo/macrorugo_compound.spec.ts b/spec/macrorugo/macrorugo_compound.spec.ts index 7bff6322d4e57f56c6dd8855bb03274d2cd72e25..0c2f7fc208f0249e28d3338f36eb0309a8774cf6 100644 --- a/spec/macrorugo/macrorugo_compound.spec.ts +++ b/spec/macrorugo/macrorugo_compound.spec.ts @@ -56,7 +56,7 @@ describe("MacroRugoCompound", () => { beforeEach(() => { BR += 1; }); - for (let i = 1; i < 10; i += 1) { + for (let i = 1; i <= 10; i += 1) { it(`B = ${i} should return same result as Macrorugo`, () => { const mrc = Session.getInstance().createNub( new Props({ calcType: CalculatorType.MacroRugoCompound }) @@ -65,7 +65,7 @@ describe("MacroRugoCompound", () => { mrc.prms.BR.singleValue = BR; const mr = getMacroRugoRef(); expect(mrc.CalcSerie().vCalc) - .toBeCloseTo(mr.result.vCalc * mrc.prms.BR.currentValue / mr.prms.B.currentValue, 3); + .toBeCloseTo(mr.result.vCalc * mrc.prms.BR.currentValue / mr.prms.B.currentValue, 2); const ax = mrc.prms.PBD.v / Math.sqrt(mrc.prms.C.v); let B: number = 0; for (const child of mrc.children) { @@ -74,7 +74,7 @@ describe("MacroRugoCompound", () => { B += child.prms.B.v; expect(child.prms.B.v).toBeGreaterThanOrEqual(ax / 4); } - expect(B).toBeCloseTo(mrc.prms.BR.currentValue, 6); + expect(B).toBeCloseTo(mrc.prms.BR.currentValue, 2); }); } }); diff --git a/spec/macrorugo/macrorugo_jalhyd154.spec.ts b/spec/macrorugo/macrorugo_jalhyd154.spec.ts new file mode 100644 index 0000000000000000000000000000000000000000..c2d67190497004daedfeb107837553b5e3cefc4c --- /dev/null +++ b/spec/macrorugo/macrorugo_jalhyd154.spec.ts @@ -0,0 +1,47 @@ +import { CalculatorType } from "../../src/compute-node"; +import { MacroRugo } from "../../src/macrorugo/macrorugo"; +import { Props } from "../../src/props"; +import { Session } from "../../src/session"; + +let m154: MacroRugo; +const aQ154: number[] = [0.285749, 0.300390, 0.315000, 0.329554, 0.344031, 0.358410, 0.372674, 0.469966]; +let i154: number; +describe("Class MacroRugo: ", () => { + describe("jalhyd #154", () => { + it("Check values of resolveQ", () => { + m154 = Session.getInstance().createNub( + new Props({ calcType: CalculatorType.MacroRugo }) + ) as MacroRugo; + m154.prms.Ks.v = 0.1; + m154.prms.Cd0.v = 1; + m154.prms.Y.v = 0.3; + const aQ: number[] = [0.105312, 0.061355, 0.228021]; + for (let i = 0; i < aQ.length; i++) { + m154.prms.Q.v = 0.2 + i * 0.05; + // tslint:disable-next-line:no-string-literal + expect(Math.abs(m154["resolveQ"]())).toBeCloseTo(aQ[i], 5); + } + }); + }); + describe("jalhyd #154", () => { + beforeAll(() => { + m154 = Session.getInstance().createNub( + new Props({ calcType: CalculatorType.MacroRugo }) + ) as MacroRugo; + m154.prms.Ks.setValue(0.1); + m154.prms.Cd0.setValue(1); + m154.prms.Y.setValues(0.34, 0.41, 0.01); + m154.calculatedParam = m154.prms.Q; + m154.CalcSerie(); + i154 = 0; + }); + afterEach(() => { + i154++; + }); + for (let i = 0; i < aQ154.length; i++) { + it(`Q(Y=${0.34 + i * 0.01}) should be ${aQ154[i]}`, () => { + expect(m154.result.resultElements[i].vCalc).toBeCloseTo(aQ154[i154], 4); + }); + } + }); +}); diff --git a/src/macrorugo/macrorugo.ts b/src/macrorugo/macrorugo.ts index 50f38dd3164a0a9b6d1bd5514e2636e1b3570d25..7c2eb70527723cfacb81d1b7d2aa20af5e7bbc7c 100644 --- a/src/macrorugo/macrorugo.ts +++ b/src/macrorugo/macrorugo.ts @@ -26,16 +26,14 @@ export class MacroRugo extends Nub { private static readonly fracAxAy = 1; /** Limit between emergent and submerged flow */ - private static readonly limitSubmerg = 1.1; + private static readonly limitSubmerg = 1.01; - /** Averaged velocity (m.s-1) */ + /** Flag for submerged Flow */ + private bSubmerged: boolean; /** Velocity at the bed (m.s-1) */ private u0: number; - /** Discharge (m3/s) */ - private Q: number; - private _cache: { [key: string]: number }; constructor(prms: MacrorugoParams, dbg: boolean = false) { @@ -83,8 +81,8 @@ export class MacroRugo extends Nub { // Vitesse maximale const cc = 0.4 * this.prms.Cd0.v + 0.7; let resVmax = vg * Math.min( - cc / (1 - Math.pow(r.resultElement.values.Fr, 2) / 4), - Math.pow(r.resultElement.values.Fr, -2 / 3) + cc / (1 - Math.pow(resFr, 2) / 4), + Math.pow(resFr, -2 / 3) ); if (isNaN(resVmax)) { // if Y == 0 resVmax = 0; @@ -124,22 +122,28 @@ export class MacroRugo extends Nub { r.resultElement.values.V_GuideTech = cV[0] * Math.pow(this.prms.Y.v / this.prms.PBD.v, cV[1]) * Math.pow(this.prms.If.v, cV[2]) * Math.sqrt(MacroRugo.g * this.prms.PBD.v); } - + if (this.prms.Y.v > 0 && this.prms.If.v > 0) { + r.resultElement.values.Strickler = + this.prms.Q.V / (Math.pow(this.prms.Y.v, 5 / 3) * this.prms.B.v * Math.pow(this.prms.If.v, 0.5)); + } else { + r.resultElement.values.Strickler = 0; + } return r; } public Equation(sVarCalc: string): Result { - this.Q = this.prms.Q.v; - const q0 = Math.sqrt(2 * MacroRugo.g * this.prms.If.v * this.prms.PBD.v * ( 1 - (this.sigma * this.prms.C.v)) / + const Q = this.prms.Q.v; + const q0 = Math.sqrt(2 * MacroRugo.g * this.prms.If.v * this.prms.PBD.v * (1 - (this.sigma * this.prms.C.v)) / (this.prms.Cd0.v * this.prms.C.v)) * this.prms.Y.v * this.prms.B.v; let r: Result; if (q0 > 0) { + this.bSubmerged = (this.prms.Y.v / this.prms.PBH.v > MacroRugo.limitSubmerg); const dicho = new Dichotomie(this, "Q", false, this.resolveQ); r = dicho.Dichotomie(0, SessionSettings.precision, q0); } else { r = new Result(0); } - this.prms.Q.v = this.Q; + this.prms.Q.v = Q; return r; // const Q = uniroot(this.resolveQ, this, 0, 1E7) * this.prms.B.v; @@ -181,69 +185,16 @@ export class MacroRugo extends Nub { private resolveQ(): number { // Reset cached variables depending on Q (or not...) this._cache = {}; - /** Tirant d'eau (m) */ - const h: number = this.prms.Y.v; - /** Concentration de blocs (-) */ - const C: number = this.prms.C.v; - /** Paramètre de bloc : Diamètre (m) */ - const D: number = this.prms.PBD.v; - /** Paramètre de bloc : Hauteur (m) */ - const k: number = this.prms.PBH.v; /** adimensional water depth */ - const hstar: number = h / k; - /** Slope (m/m) */ - const S: number = this.prms.If.v; - /** Rugosity (m) */ - const ks = this.prms.Ks.v; - /** Accélération gravité (m/s²) */ - const g = MacroRugo.g; - /** Constante von Karman */ - const kappa = 0.41; + const hstar: number = this.prms.Y.v / this.prms.PBH.v; - if (hstar > MacroRugo.limitSubmerg) { + if (this.bSubmerged) { // Submerged conditions - - /** Velocity at the bed §2.3.2 Cassan et al., 2016 */ - this.u0 = Math.sqrt(k * 2 * g * S * this.R - / (this.Cd * C * k / D + this.calcCf(k) * this.R)); - /** turbulent length scale (m) within the blocks layer (alpha_t) */ - const alpha = uniroot(this.resolveAlpha_t, this, 1E-6, 100); - /** averaged velocity at the top of blocks (m.s-1) */ - const uk = this.calcUz(alpha); - /** Equation (13) Cassan et al., 2016 */ - const d = k - 1 / kappa * alpha * uk / this.ustar; - /** Equation (14) Cassan et al., 2016 */ - const z0 = (k - d) * Math.exp(- kappa * uk / this.ustar); - /** Integral of Equation (12) Cassan et al., 2016 */ - // tslint:disable-next-line:variable-name - const Qsup = this.ustar / kappa * ( - (h - d) * (Math.log((h - d) / z0) - 1) - - ((k - d) * (Math.log((k - d) / z0) - 1)) - ); - - // calcul intégrale dans la canopée---- - // tslint:disable-next-line:variable-name - let Qinf: number = this.u0; - let u = 0; - let uOld: number; - const step = 0.01; - const zMax = 1 + step / 2; - for (let z = step; z < zMax; z += step) { - uOld = u; - u = this.calcUz(alpha, z); - Qinf += (uOld + u) ; - } - Qinf = Qinf / 2 * step * k; - - // Calcul de u moyen - return this.U0 - (Qinf + Qsup) / h; - + return this.resolveQSubmerged(); } else { // Emergent conditions - - // Resolve equation (4) Cassan et al., 2016 - return this.resolveEmergent(); + return this.resolveQEmergent(); } } @@ -305,7 +256,10 @@ export class MacroRugo extends Nub { * Calculation of Cd : drag coefficient of a block under the actual flow conditions */ private get Cd(): number { - return this.prms.Cd0.v * (1 + 0.4 / Math.pow(this.prms.Y.v / this.prms.PBD.v, 2)) * this.fFr; + if (this._cache.Cd === undefined) { + this._cache.Cd = this.prms.Cd0.v * (1 + 1 / Math.pow(this.prms.Y.v / this.prms.PBD.v, 2)); + } + return this._cache.Cd; } /** @@ -346,40 +300,116 @@ export class MacroRugo extends Nub { return alpha * this.calcUz(alpha) - l0 * this.ustar; } - private resolveEmergent(): number { - const alpha = 1 - Math.pow(1 * this.prms.C.v, 0.5) - 0.5 * this.sigma * this.prms.C.v; + private resolveQSubmerged(): number { + /** Tirant d'eau (m) */ + const h: number = this.prms.Y.v; + + /** Concentration de blocs (-) */ + const C: number = this.prms.C.v; + /** Paramètre de bloc : Diamètre (m) */ + const D: number = this.prms.PBD.v; + /** Paramètre de bloc : Hauteur (m) */ + const k: number = this.prms.PBH.v; + /** Slope (m/m) */ + const S: number = this.prms.If.v; + /** Accélération gravité (m/s²) */ + const g = MacroRugo.g; + /** Constante von Karman */ + const kappa = 0.41; + /** Velocity at the bed §2.3.2 Cassan et al., 2016 */ + this.u0 = Math.sqrt(k * 2 * g * S * this.R + / (this.Cd * C * k / D + this.calcCf(k) * this.R)); + /** turbulent length scale (m) within the blocks layer (alpha_t) */ + const alpha = uniroot(this.resolveAlpha_t, this, 1E-3, 10); + /** averaged velocity at the top of blocks (m.s-1) */ + const uk = this.calcUz(alpha); + /** Equation (13) Cassan et al., 2016 */ + const d = k - 1 / kappa * alpha * uk / this.ustar; + /** Equation (14) Cassan et al., 2016 */ + const z0 = (k - d) * Math.exp(- kappa * uk / this.ustar); + /** Integral of Equation (12) Cassan et al., 2016 */ // tslint:disable-next-line:variable-name - const Cd = this.prms.Cd0.v * (1 + 1 / Math.pow(this.prms.Y.v / this.prms.PBD.v, 2)) * this.fFr; + let Qsup: number; + if (z0 > 0) { + Qsup = this.ustar / kappa * ( + (h - d) * (Math.log((h - d) / z0) - 1) + - ((k - d) * (Math.log((k - d) / z0) - 1)) + ); + } else { + Qsup = 0; + } + // calcul intégrale dans la canopée---- + // tslint:disable-next-line:variable-name + let Qinf: number = this.u0; + let u = 0; + let uOld: number; + const step = 0.01; + const zMax = 1 + step / 2; + for (let z = step; z < zMax; z += step) { + uOld = u; + u = this.calcUz(alpha, z); + Qinf += (uOld + u); + } + Qinf = Qinf / 2 * step * k; + + // Calcul de u moyen + return this.U0 - (Qinf + Qsup) / h; + } + + private resolveQEmergent(): number { + // tslint:disable-next-line: variable-name + const Cd = this.Cd * this.fFr; /** N from Cassan 2016 eq(2) et Cassan 2014 eq(12) */ - const N = (alpha * this.calcCf(this.prms.Y.v)) / (this.prms.Y.v / this.prms.PBD.v * Cd * this.prms.C.v); + const N = (1 * this.calcCf(this.prms.Y.v)) / (this.prms.Y.v / this.prms.PBD.v * Cd * this.prms.C.v); + + // const U0i = Math.sqrt( + // 2 * MacroRugo.g * this.prms.If.v * this.prms.PBD.v * + // (1 - this.sigma * this.prms.C.v) / (Cd * this.prms.C.v * (1 + N)) + // ); + + return this.U0 - uniroot(this.resolveU0Complete, this, 1E-6, 100); + } - return this.U0 - Math.sqrt( + private resolveU0Complete(U0: number): number { + + const fFr = this.CalcfFr(U0); + + const alpha = 1 - Math.pow(1 * this.prms.C.v, 0.5) - 0.5 * this.sigma * this.prms.C.v; + + const N = (alpha * this.calcCf(this.prms.Y.v)) / + (this.prms.Y.v / this.prms.PBD.v * this.Cd * fFr * this.prms.C.v); + + return U0 - Math.sqrt( 2 * MacroRugo.g * this.prms.If.v * this.prms.PBD.v * - (1 - this.sigma * this.prms.C.v) / (Cd * this.prms.C.v * (1 + N)) + (1 - this.sigma * this.prms.C.v) / (this.Cd * fFr * this.prms.C.v * (1 + N)) ); } + private get fFr(): number { + if (this._cache.fFr === undefined) { + this._cache.fFr = this.CalcfFr(this.U0); + } + return this._cache.fFr; + } + /** * Froude correction function */ - private get fFr(): number { - if (this._cache.fFr === undefined) { - // tslint:disable-next-line:variable-name - const Fr = this.U0 / - (1 - Math.sqrt(MacroRugo.fracAxAy * this.prms.C.v)) / - Math.sqrt(MacroRugo.g * this.prms.Y.v); + private CalcfFr(U0: number): number { + // tslint:disable-next-line:variable-name + const Fr = U0 / + (1 - Math.sqrt(MacroRugo.fracAxAy * this.prms.C.v)) / + Math.sqrt(MacroRugo.g * this.prms.Y.v); - /** Interpolation linéaire entre le bloc rond (Cd0=1) et le carré (Cd0=2) */ - const r = 0.4 * this.prms.Cd0.v + 0.7; + /** Interpolation linéaire entre le bloc rond (Cd0=1) et le carré (Cd0=2) */ + const r = 0.4 * this.prms.Cd0.v + 0.7; - if (Fr < 1.3) { - this._cache.fFr = Math.pow(Math.min(r / (1 - Math.pow(Fr, 2) / 4), Math.pow(Fr, -2 / 3)), 2); - } else { - this._cache.fFr = Math.pow(Fr, -4 / 3); - } + if (Fr < 1.3) { + return Math.pow(Math.min(r / (1 - Math.pow(Fr, 2) / 4), Math.pow(Fr, -2 / 3)), 2); + } else { + return Math.pow(Fr, -4 / 3); } - return this._cache.fFr; } } @@ -402,7 +432,7 @@ export class MacroRugo extends Nub { * */ function uniroot<T>(func: (param: number) => number, thisArg: T, lowerLimit: number, upperLimit: number, - errorTol: number = 0, maxIter: number = 1000 + errorTol: number = 0, maxIter: number = 1000 ) { let a = lowerLimit; let b = upperLimit; diff --git a/src/session.ts b/src/session.ts index c0b6133601a6537ecd788ac067098229323eceb1..43a006b2e5f0fc8c914af461bd32b2ae1f8eb5c2 100644 --- a/src/session.ts +++ b/src/session.ts @@ -429,9 +429,9 @@ export class Session { 1.57, // Q 0.6, // h 0.01, // Ks - 0.05, // C - 0.5, // D - 0.8, // k + 0.13, // C + 0.4, // D + 0.4, // k 1.5 // Cd0 ), dbg ); @@ -493,9 +493,9 @@ export class Session { 3, // DH 0.05, // If 0.01, // Ks - 0.05, // C - 0.5, // D - 0.8, // k + 0.13, // C + 0.4, // D + 0.4, // k 1.5 // Cd0 ) );