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
2bcdf686
Commit
2bcdf686
authored
Oct 12, 2019
by
Dorchies David
Browse files
Fix
#154
again. Solve test at submergence limit
parent
6ffa7818
Changes
4
Hide whitespace changes
Inline
Side-by-side
spec/macrorugo/macrorugo.spec.ts
View file @
2bcdf686
...
...
@@ -182,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
);
...
...
spec/macrorugo/macrorugo_jalhyd154.spec.ts
0 → 100644
View file @
2bcdf686
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
);
});
}
});
});
src/macrorugo/macrorugo.ts
View file @
2bcdf686
...
...
@@ -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
;
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
)
{
...
...
@@ -134,18 +132,18 @@ export class MacroRugo extends Nub {
}
public
Equation
(
sVarCalc
:
string
):
Result
{
this
.
Q
=
this
.
prms
.
Q
.
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);
r
=
dicho
.
Dichotomie
(
0
,
1
E
-
10
,
q0
);
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;
...
...
@@ -187,68 +185,15 @@ 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
.
limit
Submerg
)
{
if
(
this
.
b
Submerg
ed
)
{
// 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
,
1
E
-
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
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
.
resolveQEmergent
();
}
}
...
...
@@ -355,6 +300,63 @@ export class MacroRugo extends Nub {
return
alpha
*
this
.
calcUz
(
alpha
)
-
l0
*
this
.
ustar
;
}
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
,
1
E
-
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
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
;
...
...
@@ -430,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
;
...
...
src/session.ts
View file @
2bcdf686
...
...
@@ -430,8 +430,8 @@ export class Session {
0.6
,
// h
0.01
,
// Ks
0.13
,
// C
0.
5
,
// D
0.
8
,
// k
0.
4
,
// D
0.
4
,
// k
1.5
// Cd0
),
dbg
);
...
...
@@ -494,8 +494,8 @@ export class Session {
0.05
,
// If
0.01
,
// Ks
0.13
,
// C
0.
5
,
// D
0.
8
,
// k
0.
4
,
// D
0.
4
,
// k
1.5
// Cd0
)
);
...
...
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