Commit 90ed9dd7 authored by Dorchies David's avatar Dorchies David
Browse files

fix(macrorugo): update tests and add Vg in results

Ref #283
Fix #285
parent 9410549c
function [f] = calcfFr(Frg)
if abs(Frg)>1.3
f=(Frg.^(-2/3)).^2;
else
f=(min(1./(1-(Frg.^2)/4),abs(Frg).^(-2/3))).^2;
end
endfunction
......@@ -16,20 +16,10 @@ function [res]=find_Q_nat(Q,ks,D,h,Cd0,S,L,pf,C,sigma,bDbg)
Fr=U0./(9.81*pf).^0.5;
Frg=Fr/(1-C^0.5);
if ks==0;ks=1e-34;end
//if Cd0==2
// fFr=(min(2.5,Frg^(-4/3)));//
//else
fFr=(min(1./(1-(Frg.^2)/4),abs(Frg).^(-2/3))).^2;
//end
if abs(Frg)>1.5
fFr=(Frg.^(-2/3)).^2;
end
fFr = calcfFr(Frg)
//Cd=Cd0.*(1+0.4./(pf./D).^2);
Cd=Cd0.*(1+1./(pf./D).^2);
Cd=Cd0.*min((1+1./(pf./D).^2), 3);
//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
......@@ -100,8 +90,8 @@ function [res]=find_Q_nat(Q,ks,D,h,Cd0,S,L,pf,C,sigma,bDbg)
alpha=1-(1.*C).^0.5-1/2*sigma.*C;
if bDbg then print_r('alpha'); end;
Cd=Cd0.*(1+1./(pf./D).^2).*fFr;
if bDbg then print_r('Cd'); end;
Cd2=Cd.*fFr;
if bDbg then print_r('Cd2'); end;
hstar=pf/D;
Re=U0.*pf/1e-6;
......@@ -114,10 +104,10 @@ function [res]=find_Q_nat(Q,ks,D,h,Cd0,S,L,pf,C,sigma,bDbg)
end
if bDbg then print_r('Cf'); end;
N= (1 .*Cf)./(pf./D.*Cd.*C);
N= (1 .*Cf)./(pf./D.*Cd2.*C);
if bDbg then print_r('N'); end;
U0a=(2*g.*S.*D.*(R)./(Cd.*C.*(1+N))).^0.5;
U0a=(2*g.*S.*D.*(R)./(Cd2.*C.*(1+N))).^0.5;
if bDbg then print_r("U0a");end;
U0complet = find_U0_complet(U0a, pf,C,D,sigma,Cd0,Cf,S, bDbg)
if bDbg then print_r("U0complet");end;
......
......@@ -26,6 +26,8 @@ if bDbgU0 then
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);
if bDbgU0 then
print_r("res")
end
endfunction
function macrorugo_resultComp(z_amont, S, long, Q, L, pf, C, Cd, h, D)
function macrorugo_resultComp(z_amont, S, long, Q, L, pf, C, Cd0, h, D)
g = 9.81
cote_bas=z_amont-S*long;
print_r("cote_bas");
ZF2=z_amont-S*long;
print_r("ZF2");
Vdeb=Q/L/pf;
print_r("Vdeb");
Vg=Q/L/pf/(1-C^0.5);
print_r("Vg");
Fr=Vg./(g.*pf).^0.5;
print_r("Fr");
P=1000*g*Vdeb*S;
print_r("P");
PV=1000*g*Vdeb*S;
print_r("PV");
if pf/h<1
flowcond = 'emergent'
......@@ -27,15 +28,15 @@ function macrorugo_resultComp(z_amont, S, long, Q, L, pf, C, Cd, h, D)
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
coeff_contraction=0.4*Cd+0.7;
if Cd==2
if Cd0==2
q_technique= 0.648*(pf/D)^1.084*S^0.56*C^(-0.456)*(9.81*D)^0.5.*D*L;
V_technique=3.35*(pf/D)^0.27*S^0.53*(9.81*D)^0.5;
else
q_technique=0.815*(pf/D)^1.45*S^0.557*C^(-0.456)*(9.81*D)^0.5.*D*L;
V_technique=4.54*(pf/D)^0.32*S^0.56*(9.81*D)^0.5;
end
Vmax=Vg.*(min(coeff_contraction/(1-(Fr.^2)/4),Fr.^(-2/3)));
coeff_contraction=0.2*Cd0+0.9;
Vmax=Vg.*coeff_contraction*calcfFr(Fr);
print_r("Vmax");
print_r("V_technique");
end
......
......@@ -17,7 +17,7 @@ function [Q] = macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg)
maxiter=1
end
opt = optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'TolFun',tolfun,'TolX',tolx)
if Cd0==2; sigma=1; else sigma=%pi/4; end
if Cd0>=2; sigma=1; else sigma=%pi/4; end
g=9.81
N=0;
q0=(2*g.*S.*D.*(1-(sigma*C))/(Cd0.*C.*(1+N))).^0.5*h*B;
......
......@@ -8,7 +8,6 @@ bDbg_RA = %f;
// Tests parameters
ks = 0.01 // Rugosité de fond (m)
Cd0=1.5 // Forme
S = 0.05 // Pente
C = 0.13; // Concentration
D = 0.5; // Diamètre
......@@ -17,33 +16,34 @@ z_amont = 12.5; // Cote amont (m)
long = 6; // Longueur rampe (m)
// *****************************************************************************
printf("\n*** Emergent conditions Cd=1.5***\n")
printf("\n*** Emergent conditions Cd=1.1***\n")
// *****************************************************************************
h = 0.6
k = 0.7
Cd0 = 1.5
Cd0 = 1.1 // Forme ronde
macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg)
// *****************************************************************************
printf("\n*** Emergent conditions Cd=2***\n")
printf("\n*** Emergent conditions Cd=2.6***\n")
// *****************************************************************************
h = 0.6
k = 0.7
Cd0 = 2
Cd0 = 2.6 // Forme plane
macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg)
// *****************************************************************************
printf("\n*** Submerged conditions ***\n")
printf("\n*** Submerged conditions Cd=1.1***\n")
// *****************************************************************************
k = 0.7
h = 0.8
Cd0 = 1.5
Cd0 = 1.1 // Forme ronde
C = 0.13
macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg)
// *****************************************************************************
printf("\n*** JalHyd #85 ***\n")
// *****************************************************************************
Cd0 = 1.1
k = 0.8
C = 0.2; // Concentration
Q = []
......@@ -52,4 +52,21 @@ for h = 0.7:0.1:1.2
end
disp Q
macrorugo_searchQ(ks, D, 0.5, 2, S, 2, 0.85, C, z_amont, long, bDbg)
macrorugo_searchQ(ks, D, 0.5, 2.6, S, 2, 0.85, C, z_amont, long, bDbg)
// *****************************************************************************
printf("\n*** JalHyd #144 ***\n")
// rZF1, rL, rB, rIf, rQ, rY, rRF, rCB, rPBD, rPBH, rCd0
// 100, 25, 5, 0.05, 1, 0.05, 0.15, 0.13, 0.5, 0.4, 1.1
// *****************************************************************************
// macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg)
//macrorugo_searchQ(0.15, 0.5, 0.4, 1.1, 0.05, 5, 0.05, 0.13, z_amont, long, bDbg)
// *****************************************************************************
printf("\n*** JalHyd #154 ***\n")
// *****************************************************************************
//Q = []
//for h = 0.34:0.01:0.41
// Q = [Q, macrorugo_searchQ(0.1, 0.4, 0.4, 1, S, 1, h, 0.13, z_amont, long, bDbg)]
//end
//print_r("Q")
......@@ -6,13 +6,13 @@ function print_r(s)
pat = "f"
end
if size(e,1) > 1 | size(e,2) > 1 then
printf("%s = [",s);
printf("%s: [",s);
if size(e,2) > 1 then
e = e'
end
printf("%f ",e)
printf("]\n")
else
printf("%s = %"+pat+"\n",s,e);
printf("%s: %"+pat+",\n",s,e);
end
endfunction
......@@ -4,145 +4,154 @@ import { MacrorugoParams } from "../../src/macrorugo/macrorugo_params";
import { checkResult } from "../test_func";
/*
*** Emergent conditions Cd=1.5***
*** Emergent conditions Cd=1.1***
*** INPUT ***
ks = 0.010000
D = 0.500000
k = 0.700000
Cd0 = 1.500000
Cd0 = 1.100000
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
find_Q_nat(1.052971)=0.600890
Q=0.692437 fVal=0.000000
cote_bas = 12.200000
Vdeb = 0.822881
Fr = 0.530425
P = 242.174003
Vdeb = 1.154061
Vg: 1.804786,
Fr = 0.743902
P = 566.066964
flowcond = emergent
Vmax = 1.799502
Vmax = 2.722572
V_technique = 1.991299
q_technique = 0.561860
Strickler = 5.173107
Strickler = 7.255093
*/
function macroRugoInstanceEmergentCd15(): MacroRugo {
function macroRugoInstanceEmergentCd11(): MacroRugo {
return new MacroRugo(
new MacrorugoParams(
12.5, // ZF1
6, // L
1, // B
0.05, // If
0.493729, // Q
0.692437, // Q
0.6, // h
0.01, // Ks
0.13, // C
0.5, // D
0.7, // k
1.5 // Cd0
1.1 // Cd0
)
);
}
const macroRugoExtraResultEmergentCd15: { [key: string]: number | MacroRugoFlowType } = {
const macroRugoExtraResultEmergentCd11: { [key: string]: number | MacroRugoFlowType } = {
ENUM_MacroRugoFlowType: MacroRugoFlowType.EMERGENT,
Fr: 0.530425,
PV: 403.623339,
Vdeb: 0.822881,
Vmax: 1.799502,
Strickler: 5.173107,
ZF2: 12.2
ZF2: 12.200000,
Vdeb: 1.154061,
Vg: 1.804786,
Fr: 0.743902,
PV: 566.066964,
Vmax: 2.722572,
Strickler: 7.255093
};
/*
*** Emergent conditions Cd=2***
ks = 0.010000
D = 0.500000
** Emergent conditions Cd=2.6***
*** INPUT ***
ks: 0.010000,
D: 0.500000,
k = 0.700000
Cd0 = 2.000000
S = 0.050000
B = 1.000000
h = 0.600000
C = 0.130000
Cd0: 2.600000,
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.628018
Fr = 0.404817
P = 184.825731
flowcond = emergent
Vmax = 1.536129
V_technique = 1.592932
q_technique = 0.414154
Strickler = 3.948084
find_Q_nat(0.674174)=0.320793
Q=0.481698 fVal=0.000000
ZF2: 12.200000,
Vdeb: 0.802831,
Vg: 1.255512,
Fr: 0.517500,
PV: 393.788411,
flowcond: emergent,
Vmax: 2.047863,
V_technique: 1.991299,
q_technique: 0.561860,
Strickler: 5.047056
*/
function macroRugoInstanceEmergentCd2(): MacroRugo {
const nub: MacroRugo = macroRugoInstanceEmergentCd15();
nub.prms.Cd0.singleValue = 2;
nub.prms.Q.singleValue = 0.376811;
function macroRugoInstanceEmergentCd26(): MacroRugo {
const nub: MacroRugo = macroRugoInstanceEmergentCd11();
nub.prms.Cd0.singleValue = 2.6;
nub.prms.Q.singleValue = 0.481698;
return nub;
}
const macroRugoExtraResultEmergentCd2: { [key: string]: number | MacroRugoFlowType } = {
const macroRugoExtraResultEmergentCd26: { [key: string]: number | MacroRugoFlowType } = {
ENUM_MacroRugoFlowType: MacroRugoFlowType.EMERGENT,
Fr: 0.404817,
PV: 308.042886,
Vdeb: 0.628018,
Vmax: 1.536129,
Strickler: 3.948084,
ZF2: 12.2
ZF2: 12.200000,
Vdeb: 0.802831,
Vg: 1.255512,
Fr: 0.517500,
PV: 393.788411,
Vmax: 2.047863,
Strickler: 5.047056
};
/*
*** Submerged conditions ***
ks = 0.010000
D = 0.500000
*** Submerged conditions Cd=1.1***
*** INPUT ***
ks: 0.010000,
D: 0.500000,
k = 0.700000
Cd0 = 1.500000
S = 0.050000
B = 1.000000
h = 0.800000
C = 0.130000
Cd0: 1.100000,
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.390328
Fr = 0.776130
P = 545.564782
flowcond = immerge
q_technique = 0.940450
Strickler = 7.215044
find_Q_nat(1.403961)=0.143445
Q=1.289205 fVal=0.000000
ZF2: 12.200000,
Vdeb: 1.611506,
Vg: 2.520165,
Fr: 0.899600,
PV: 790.443862,
flowcond: immerge,
q_technique: 0.940450,
Strickler: 8.362838
*/
function macroRugoInstanceSubmerged(): MacroRugo {
const nub: MacroRugo = macroRugoInstanceEmergentCd15();
const nub: MacroRugo = macroRugoInstanceEmergentCd11();
nub.prms.Y.singleValue = 0.8;
nub.prms.Q.singleValue = 1.112263;
nub.prms.Q.singleValue = 1.289205;
return nub;
}
const macroRugoExtraResultSubmerged: { [key: string]: number | MacroRugoFlowType } = {
ENUM_MacroRugoFlowType: MacroRugoFlowType.SUBMERGED,
Fr: 0.776130,
PV: 681.955977,
Vdeb: 1.390328,
Strickler: 7.215044,
ZF2: 12.2
ZF2: 12.200000,
Vdeb: 1.611506,
Vg: 2.520165,
Fr: 0.899600,
PV: 790.443862,
Strickler: 8.362838
};
function MacroRugoFactory(sInstance: string): MacroRugo {
let nub: MacroRugo;
switch (sInstance) {
case "EmergentCd15": {
nub = macroRugoInstanceEmergentCd15();
case "EmergentCd11": {
nub = macroRugoInstanceEmergentCd11();
break;
}
case "EmergentCd2": {
nub = macroRugoInstanceEmergentCd2();
case "EmergentCd26": {
nub = macroRugoInstanceEmergentCd26();
break;
}
case "Submerged": {
......@@ -191,7 +200,7 @@ function testMacroRugoConfig(sInstance: string, Q0: number, fVal0: number, mrExt
if (mrExtraRes.hasOwnProperty(sExtraRes)) {
it(`${sExtraRes} should be ${mrExtraRes[sExtraRes]}`, () => {
expect(MacroRugoFactory(sInstance).Calc("Q").values[sExtraRes])
.toBeCloseTo(mrExtraRes[sExtraRes], 5);
.toBeCloseTo(mrExtraRes[sExtraRes], 3);
});
}
}
......@@ -199,7 +208,7 @@ function testMacroRugoConfig(sInstance: string, Q0: number, fVal0: number, mrExt
}
function macroRugoInstanceJalHyd85(): MacroRugo {
const nubMR = macroRugoInstanceEmergentCd15();
const nubMR = macroRugoInstanceEmergentCd11();
nubMR.prms.C.singleValue = 0.2;
nubMR.prms.PBH.singleValue = 0.8;
nubMR.calculatedParam = nubMR.prms.Q;
......@@ -208,8 +217,8 @@ function macroRugoInstanceJalHyd85(): MacroRugo {
describe("Class MacroRugo: ", () => {
testMacroRugoConfig("EmergentCd15", 0.901710, 0.679969, macroRugoExtraResultEmergentCd15);
testMacroRugoConfig("EmergentCd2", 0.768677, 0.653110, macroRugoExtraResultEmergentCd2);
testMacroRugoConfig("EmergentCd11", 1.052971, 0.600890, macroRugoExtraResultEmergentCd11);
testMacroRugoConfig("EmergentCd26", 0.674174, 0.320793, macroRugoExtraResultEmergentCd26);
// Le test passe en debug mais pas sous Jasmine !??
// describe(`Condition Submerged` , () => {
// it(`resolveAlpha_t(0.07) should be 0.074752`, () => {
......@@ -217,7 +226,7 @@ describe("Class MacroRugo: ", () => {
// expect(macroRugoInstanceSubmerged()["resolveAlpha_t"](0.07)).toBeCloseTo(0.074752, 5);
// });
// });
testMacroRugoConfig("Submerged", 1.202280, 0.112522, macroRugoExtraResultSubmerged);
testMacroRugoConfig("Submerged", 1.403961, 0.143445, macroRugoExtraResultSubmerged);
describe("JalHyd #85", () => {
it("CalcSerie Q should return the good result :)", () => {
......@@ -225,7 +234,7 @@ describe("Class MacroRugo: ", () => {
const nubMR2 = macroRugoInstanceJalHyd85();
nubMR.prms.Y.setValues(0.7, 1.2, 0.1);
const aQ: number[] = [0.484255, 0.578363, 1.004229, 1.280269, 1.618937, 2.018687];
const aQ: number[] = [0.6885501, 0.8244762, 1.1663925, 1.4760379, 1.8506109, 2.2883764];
nubMR.CalcSerie();
for (let i = 0; i < aQ.length; i++) {
......
import { MacroRugo } from "../../src/macrorugo/macrorugo";
import { MacrorugoParams } from "../../src/macrorugo/macrorugo_params";
describe("Class MacroRugo: ", () => {
describe("jalhyd #144", () => {
it("Q should be 0.04033", () => {
const m = new MacroRugo(
new MacrorugoParams(
100, 25, 5, 0.05, 1, 0.05, 0.15, 0.13, 0.5, 0.4, 1
)
);
m.calculatedParam = m.prms.Q;
expect(m.CalcSerie().vCalc).toBeCloseTo(0.039283, 5);
});
});
});
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.407595];
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;
// tslint:disable-next-line: no-string-literal
m154["setFlowType"]();
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);
});
}
});
});
......@@ -109,14 +109,14 @@ export class MacroRugo extends FishPass {
}
r.resultElement.values.Vdeb = resVdeb;
// Froude
const vg: number = r.resultElement.values.Vdeb / (1 - Math.sqrt(MacroRugo.fracAxAy * this.prms.C.v));
let resFr = vg / Math.sqrt(MacroRugo.g * this.prms.Y.v);
r.resultElement.values.Vg = r.resultElement.values.Vdeb / (1 - Math.sqrt(MacroRugo.fracAxAy * this.prms.C.v));
let resFr = r.resultElement.values.Vg / Math.sqrt(MacroRugo.g * this.prms.Y.v);
if (isNaN(resFr)) { // if Y == 0
resFr = 0;
}
r.resultElement.values.Fr = resFr;
// Vitesse maximale
r.resultElement.values.Vmax = this.r * vg * this.fFr;
r.resultElement.values.Vmax = this.r * r.resultElement.values.Vg * this.CalcfFr(resVdeb);
// Puissance dissipée
r.resultElement.values.PV = 1000 * MacroRugo.g * r.resultElement.values.Vdeb * this.prms.If.v;
// Type d'écoulement
......@@ -167,9 +167,6 @@ export class MacroRugo extends FishPass {
}
this.prms.Q.v = Q;
return r;
// const Q = uniroot(this.resolveQ, this, 0, 1E7) * this.prms.B.v;
// return new Result(Q, this);
}
/**
......@@ -266,7 +263,7 @@ export class MacroRugo extends FishPass {
*/
private get sigma(): number {
if (this._cache.sigma === undefined) {
if (this.prms.Cd0.v === 2) {
if (this.prms.Cd0.v >= 2) {
this._cache.sigma = 1;
} else {
this._cache.sigma = Math.PI / 4;
......@@ -303,7 +300,7 @@ export class MacroRugo extends FishPass {
*/
private get Cd(): number {
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));
this._cache.Cd = this.prms.Cd0.v * Math.min(3, (1 + 1 / Math.pow(this.prms.Y.v / this.prms.PBD.v, 2)));
}
return this._cache.Cd;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment