Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
cassiopee
jalhyd
Commits
9d3abff3
Commit
9d3abff3
authored
Feb 05, 2019
by
Le Faucheux Pierre
Browse files
#22
MacroRugo All calculation tests OK
parent
89f6e2fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
doc/scilab_tests/macrorugo_find_Q_nat.sci
View file @
9d3abff3
...
...
@@ -48,6 +48,7 @@ function [res]=find_Q_nat(Q,ks,D,h,Cd0,S,L,pf,C,sigma,bDbg)
if bDbg then print_r('ustar'); end;
Cd1=Cd0.*(1+0.4./(pf./D).^2).*fFr;
if bDbg then print_r('Cd1'); end;
CdCh=Cd1.*C.*htilde;
if bDbg then print_r('CdCh'); end;
...
...
@@ -79,6 +80,8 @@ function [res]=find_Q_nat(Q,ks,D,h,Cd0,S,L,pf,C,sigma,bDbg)
dzinf=0.01;
Zinf=(0:dzinf:1);
Uinf = U0b.*(beta.*Rh./h.*sinh(beta*Zinf)./cosh(beta)+1).^0.5;
if bDbg then print_r('Uinf(2)'); end;
if bDbg then print_r('Uinf($)'); end;
Ub=zeros(Uinf);
Ub(1:$-1)=Uinf(2:$);
qinf=sum((Uinf(1:$-1)+Ub(1:$-1))/2*dzinf.*h);
...
...
spec/macrorugo/macrorugo.spec.ts
View file @
9d3abff3
...
...
@@ -8,7 +8,7 @@
import
{
ParamCalculability
,
ParamValueMode
}
from
"
../../src
"
;
import
{
MacroRugo
,
MacroRugoFlowType
,
MacrorugoParams
}
from
"
../../src/macrorugo/macrorugo
"
;
import
{
checkPercent
,
checkResult
}
from
"
../test_func
"
;
import
{
checkResult
}
from
"
../test_func
"
;
/*
*** Emergent conditions Cd=1.5***
...
...
@@ -163,7 +163,7 @@ function testMacroRugo(sInstance: string, varTest: string, valRef: number) {
}
function
testMacroRugoConfig
(
sInstance
:
string
,
Q0
:
number
,
fVal0
:
number
,
mrExtraRes
:
{
[
key
:
string
]:
number
})
{
describe
(
`Condition
s:
${
sInstance
}
`
,
()
=>
{
describe
(
`Condition
${
sInstance
}
`
,
()
=>
{
it
(
`resolveQ(
${
Q0
}
) should be
${
fVal0
}
`
,
()
=>
{
const
nubit
=
MacroRugoFactory
(
sInstance
);
// tslint:disable-next-line:no-string-literal
...
...
@@ -190,5 +190,12 @@ describe("Class MacroRugo: ", () => {
testMacroRugoConfig
(
"
EmergentCd15
"
,
0.901710
,
0.379574
,
macroRugoExtraResultEmergentCd15
);
testMacroRugoConfig
(
"
EmergentCd2
"
,
0.768677
,
0.418044
,
macroRugoExtraResultEmergentCd2
);
// Le test passe en debug mais pas sous Jasmine !??
// describe(`Condition Submerged` , () => {
// it(`resolveAlpha_t(0.07) should be 0.074752`, () => {
// // tslint:disable-next-line:no-string-literal
// expect(macroRugoInstanceSubmerged()["resolveAlpha_t"](0.07)).toBeCloseTo(0.074752, 5);
// });
// });
testMacroRugoConfig
(
"
Submerged
"
,
1.202280
,
0.145051
,
macroRugoExtraResultSubmerged
);
});
src/macrorugo/macrorugo.ts
View file @
9d3abff3
...
...
@@ -31,11 +31,13 @@ export class MacroRugo extends Nub {
private
ks
:
number
;
/** Averaged velocity (m.s-1) */
private
U0
:
number
;
/** 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
)
{
...
...
@@ -139,40 +141,36 @@ export class MacroRugo extends Nub {
* @param sVarCalc Variable à calculer
*/
private
resolveQ
(
this
:
MacroRugo
,
Q
:
number
):
number
{
this
.
Q
=
Q
;
// Reset cached variables depending on Q (or not...)
this
.
_cache
=
{};
/** Longueur (m) */
const
L
:
number
=
this
.
prms
.
L
.
v
;
/** Tirant d'eau (m) */
const
h
:
number
=
this
.
prms
.
Y
.
v
;
/** Paramètre de bloc : Forme (1 pour rond, 2 pour carré)
* drag coefficient of a block considering a single block
* infinitely high with F ≪ 1;
*/
// tslint:disable-next-line:variable-name
const
Cd0
:
number
=
this
.
prms
.
Cd0
.
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
;
/** Pente (m/m) */
/** 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
;
const
kappa
=
0.41
;
// von Karman constant
// U0 = Averaged velocity (m.s-1)
this
.
U0
=
Q
/
this
.
prms
.
B
.
v
/
h
;
/** Constante von Karman */
const
kappa
=
0.41
;
/** Calulated average velocity */
let
uMoy
:
number
;
if
(
h
/
k
>
MacroRugo
.
limitSubmerg
)
{
if
(
hstar
>
MacroRugo
.
limitSubmerg
)
{
// Submerged conditions
/** Velocity at the bed §2.3.2 Cassan et al., 2016 */
this
.
u0
=
Math
.
sqrt
(
2
*
g
*
S
*
D
*
this
.
R
/
(
this
.
calcCd
(
this
.
calc_fFr
(
this
.
U0
))
*
C
));
const
cf
=
2
/
Math
.
pow
(
5.1
*
Math
.
log10
(
k
/
ks
)
+
6
,
2
);
this
.
u0
=
Math
.
sqrt
(
k
*
2
*
g
*
S
*
this
.
R
/
(
this
.
Cd
*
C
*
k
/
D
+
cf
*
this
.
R
));
/** turbulent length scale (m) within the blocks layer (alpha_t) */
const
alpha
=
uniroot
(
this
.
resolveAlpha_t
,
this
,
1
E
-
6
,
100
);
/** averaged velocity at the top of blocks (m.s-1) */
...
...
@@ -191,18 +189,19 @@ export class MacroRugo extends Nub {
// calcul intégrale dans la canopée----
// tslint:disable-next-line:variable-name
let
Qinf
:
number
=
this
.
u0
;
let
u
=
this
.
u
0
;
let
u
=
0
;
let
uOld
:
number
;
const
step
=
0.1
;
for
(
let
z
=
step
;
z
<=
1
;
z
+=
step
)
{
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
)
/
2
;
Qinf
+=
(
uOld
+
u
)
;
}
Qinf
=
Qinf
*
step
*
k
;
Qinf
=
Qinf
/
2
*
step
*
k
;
// Calcul de u moyen
uMoy
=
(
Qinf
+
Qsup
)
/
k
;
return
this
.
U0
-
(
Qinf
+
Qsup
)
/
h
;
}
else
{
// Emergent conditions
...
...
@@ -210,35 +209,44 @@ export class MacroRugo extends Nub {
// Resolve equation (4) Cassan et al., 2016
return
this
.
resolveEmergent
();
}
return
this
.
U0
-
uMoy
;
}
/**
* Averaged velocity (m.s-1)
*/
private
get
U0
():
number
{
if
(
this
.
_cache
.
U0
===
undefined
)
{
this
.
_cache
.
U0
=
this
.
Q
/
this
.
prms
.
B
.
v
/
this
.
prms
.
Y
.
v
;
}
return
this
.
_cache
.
U0
;
}
private
get
CdChD
():
number
{
if
(
this
.
_cache
.
CdChD
!
==
undefined
)
{
return
this
.
_cache
.
CdChD
;
if
(
this
.
_cache
.
CdChD
=
==
undefined
)
{
this
.
_cache
.
CdChD
=
this
.
Cd
*
this
.
prms
.
C
.
v
*
this
.
prms
.
PBH
.
v
/
this
.
prms
.
PBD
.
v
;
}
return
this
.
ca
lcCd
(
1
)
*
this
.
prms
.
C
.
v
*
this
.
prms
.
PBH
.
v
/
this
.
prms
.
PBD
.
v
;
return
this
.
_
ca
che
.
CdChD
;
}
/**
* sigma ratio between the block area in the x, y plane and D2
*/
private
get
sigma
():
number
{
if
(
this
.
_cache
.
sigma
!==
undefined
)
{
return
this
.
_cache
.
sigma
;
}
if
(
this
.
prms
.
Cd0
.
v
===
2
)
{
return
1
;
}
else
{
return
Math
.
PI
/
4
;
if
(
this
.
_cache
.
sigma
===
undefined
)
{
if
(
this
.
prms
.
Cd0
.
v
===
2
)
{
this
.
_cache
.
sigma
=
1
;
}
else
{
this
.
_cache
.
sigma
=
Math
.
PI
/
4
;
}
}
return
this
.
_cache
.
sigma
;
}
private
get
R
():
number
{
if
(
this
.
_cache
.
R
!
==
undefined
)
{
return
this
.
_cache
.
R
;
if
(
this
.
_cache
.
R
=
==
undefined
)
{
this
.
_cache
.
R
=
(
1
-
this
.
sigma
*
this
.
prms
.
C
.
v
)
;
}
return
(
1
-
this
.
sigma
*
this
.
prms
.
C
.
v
)
;
return
this
.
_cache
.
R
;
}
/**
...
...
@@ -258,10 +266,9 @@ export class MacroRugo extends Nub {
/**
* Calculation of Cd : drag coefficient of a block under the actual flow conditions
* @param fFr
*/
private
calcCd
(
fFr
:
number
):
number
{
return
this
.
prms
.
Cd0
.
v
*
(
1
+
0.4
/
Math
.
pow
(
this
.
prms
.
Y
.
v
/
this
.
prms
.
PBD
.
v
,
2
))
*
fFr
;
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
;
}
/**
...
...
@@ -287,10 +294,10 @@ export class MacroRugo extends Nub {
}
private
get
ustar
():
number
{
if
(
this
.
_cache
.
ustar
!
==
undefined
)
{
return
this
.
_cache
.
ustar
;
if
(
this
.
_cache
.
ustar
=
==
undefined
)
{
this
.
_cache
.
ustar
=
Math
.
sqrt
(
MacroRugo
.
g
*
this
.
prms
.
If
.
v
*
(
this
.
prms
.
Y
.
v
-
this
.
prms
.
PBH
.
v
))
;
}
return
Math
.
sqrt
(
MacroRugo
.
g
*
this
.
prms
.
If
.
v
*
(
this
.
prms
.
Y
.
v
-
this
.
prms
.
PBH
.
v
))
;
return
this
.
_cache
.
ustar
;
}
private
resolveAlpha_t
(
alpha
:
number
):
number
{
...
...
@@ -298,7 +305,6 @@ export class MacroRugo extends Nub {
const
s
=
this
.
prms
.
PBD
.
v
*
(
1
/
Math
.
sqrt
(
this
.
prms
.
C
.
v
)
-
1
);
/** Equation(11) Cassan et al., 2016 */
const
l0
=
Math
.
min
(
s
,
0.15
*
this
.
prms
.
PBH
.
v
);
// Equation(10) Cassan et al., 2016
return
alpha
*
this
.
calcUz
(
alpha
)
-
l0
*
this
.
ustar
;
}
...
...
@@ -308,7 +314,7 @@ export class MacroRugo extends Nub {
const
alpha
=
1
-
Math
.
pow
(
1
*
this
.
prms
.
C
.
v
,
0.5
)
-
0.5
*
this
.
sigma
*
this
.
prms
.
C
.
v
;
// 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
.
calc_fFr
(
this
.
U0
)
;
const
Cd
=
this
.
prms
.
Cd0
.
v
*
(
1
+
1
/
Math
.
pow
(
this
.
prms
.
Y
.
v
/
this
.
prms
.
PBD
.
v
,
2
))
*
this
.
fFr
;
/** N from Cassan 2016 eq(2) et Cassan 2014 eq(12) */
const
N
=
(
alpha
*
this
.
calcCf
())
/
(
this
.
prms
.
Y
.
v
/
this
.
prms
.
PBD
.
v
*
Cd
*
this
.
prms
.
C
.
v
);
...
...
@@ -321,23 +327,25 @@ export class MacroRugo extends Nub {
/**
* Froude correction function
* @param u0 Average velocity
*/
private
calc_fFr
(
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
);
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
);
/** 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
)
{
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
);
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
);
}
}
return
this
.
_cache
.
fFr
;
}
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment