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
2122c739
Commit
2122c739
authored
Jul 23, 2019
by
Dorchies David
Browse files
Solves
#85
parent
a805b1e5
Changes
3
Hide whitespace changes
Inline
Side-by-side
spec/macrorugo/macrorugo.spec.ts
View file @
2122c739
...
...
@@ -83,8 +83,8 @@ q_technique = 0.414154
function
macroRugoInstanceEmergentCd2
():
MacroRugo
{
const
nub
:
MacroRugo
=
macroRugoInstanceEmergentCd15
();
nub
.
prms
.
Cd0
.
v
=
2
;
nub
.
prms
.
Q
.
v
=
0.376808
;
nub
.
prms
.
Cd0
.
singleValue
=
2
;
nub
.
prms
.
Q
.
singleValue
=
0.376808
;
return
nub
;
}
...
...
@@ -120,8 +120,8 @@ q_technique = 0.940450
function
macroRugoInstanceSubmerged
():
MacroRugo
{
const
nub
:
MacroRugo
=
macroRugoInstanceEmergentCd15
();
nub
.
prms
.
Y
.
v
=
0.8
;
nub
.
prms
.
Q
.
v
=
0.908068
;
nub
.
prms
.
Y
.
singleValue
=
0.8
;
nub
.
prms
.
Q
.
singleValue
=
0.908068
;
return
nub
;
}
...
...
@@ -135,20 +135,28 @@ const macroRugoExtraResultSubmerged: { [key: string]: number|MacroRugoFlowType }
};
function
MacroRugoFactory
(
sInstance
:
string
):
MacroRugo
{
let
nub
:
MacroRugo
;
switch
(
sInstance
)
{
case
"
EmergentCd15
"
:
{
return
macroRugoInstanceEmergentCd15
();
nub
=
macroRugoInstanceEmergentCd15
();
break
;
}
case
"
EmergentCd2
"
:
{
return
macroRugoInstanceEmergentCd2
();
nub
=
macroRugoInstanceEmergentCd2
();
break
;
}
case
"
Submerged
"
:
{
return
macroRugoInstanceSubmerged
();
nub
=
macroRugoInstanceSubmerged
();
break
;
}
default
:
{
throw
new
Error
(
"
Instance name error
"
);
}
}
for
(
const
p
of
nub
.
parameterIterator
)
{
p
.
v
=
p
.
singleValue
;
}
return
nub
;
}
function
testMacroRugo
(
sInstance
:
string
,
varTest
:
string
,
valRef
:
number
)
{
...
...
@@ -166,8 +174,9 @@ function testMacroRugoConfig(sInstance: string, Q0: number, fVal0: number, mrExt
describe
(
`Condition
${
sInstance
}
`
,
()
=>
{
it
(
`resolveQ(
${
Q0
}
) should be
${
fVal0
}
`
,
()
=>
{
const
nubit
=
MacroRugoFactory
(
sInstance
);
nubit
.
prms
.
Q
.
v
=
Q0
;
// tslint:disable-next-line:no-string-literal
expect
(
nubit
[
"
resolveQ
"
](
Q0
)).
toBeCloseTo
(
fVal0
,
5
);
expect
(
nubit
[
"
resolveQ
"
]()).
toBeCloseTo
(
fVal0
,
5
);
});
const
nub
=
MacroRugoFactory
(
sInstance
);
for
(
const
prm
of
nub
.
prms
)
{
...
...
@@ -198,4 +207,21 @@ describe("Class MacroRugo: ", () => {
// });
// });
testMacroRugoConfig
(
"
Submerged
"
,
1.202280
,
0.145051
,
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
;
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
];
nubMR
.
CalcSerie
();
for
(
let
i
=
0
;
i
<
aQ
.
length
;
i
++
)
{
expect
(
nubMR
.
result
.
resultElements
[
i
].
vCalc
).
toBeCloseTo
(
aQ
[
i
],
4
);
}
});
});
});
spec/pab/pab.spec.ts
View file @
2122c739
...
...
@@ -250,7 +250,7 @@ describe("Class Pab: ", () => {
expect
(
pab
.
calculatedParam
.
symbol
).
toBe
(
"
Z1
"
);
});
it
(
"
try setting Q and Z1 to
MINMAX
"
,
()
=>
{
it
(
"
try setting Q and Z1 to
LISTE
"
,
()
=>
{
pab
.
calculatedParam
=
pab
.
prms
.
Q
;
pab
.
prms
.
Z1
.
valueMode
=
ParamValueMode
.
LISTE
;
expect
(
pab
.
calculatedParam
.
symbol
).
toBe
(
"
Q
"
);
...
...
src/macrorugo/macrorugo.ts
View file @
2122c739
import
{
CalculatorType
}
from
"
../compute-node
"
;
import
{
Dichotomie
}
from
"
../dichotomie
"
;
import
{
Nub
}
from
"
../nub
"
;
import
{
ParamCalculability
,
ParamFamily
}
from
"
../param/param-definition
"
;
import
{
ParamValueMode
}
from
"
../param/param-value-mode
"
;
...
...
@@ -121,8 +122,16 @@ export class MacroRugo extends Nub {
}
public
Equation
(
sVarCalc
:
string
):
Result
{
const
Q
=
uniroot
(
this
.
resolveQ
,
this
,
0
,
1
E7
)
*
this
.
prms
.
B
.
v
;
return
new
Result
(
Q
,
this
);
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
))
/
(
this
.
prms
.
Cd0
.
v
*
this
.
prms
.
C
.
v
))
*
this
.
prms
.
Y
.
v
*
this
.
prms
.
B
.
v
;
const
dicho
=
new
Dichotomie
(
this
,
"
Q
"
,
false
,
this
.
resolveQ
);
const
r
:
Result
=
dicho
.
Dichotomie
(
0
,
this
.
prms
.
Pr
.
v
,
q0
);
this
.
prms
.
Q
.
v
=
this
.
Q
;
return
r
;
// const Q = uniroot(this.resolveQ, this, 0, 1E7) * this.prms.B.v;
// return new Result(Q, this);
}
/**
...
...
@@ -154,8 +163,7 @@ export class MacroRugo extends Nub {
* Knowledge & Management of Aquatic Ecosystems 45.
* @param sVarCalc Variable à calculer
*/
private
resolveQ
(
this
:
MacroRugo
,
Q
:
number
):
number
{
this
.
Q
=
Q
;
private
resolveQ
():
number
{
// Reset cached variables depending on Q (or not...)
this
.
_cache
=
{};
/** Tirant d'eau (m) */
...
...
@@ -230,7 +238,7 @@ export class MacroRugo extends Nub {
*/
private
get
U0
():
number
{
if
(
this
.
_cache
.
U0
===
undefined
)
{
this
.
_cache
.
U0
=
this
.
Q
/
this
.
prms
.
B
.
v
/
this
.
prms
.
Y
.
v
;
this
.
_cache
.
U0
=
this
.
prms
.
Q
.
v
/
this
.
prms
.
B
.
v
/
this
.
prms
.
Y
.
v
;
}
return
this
.
_cache
.
U0
;
}
...
...
@@ -291,7 +299,7 @@ export class MacroRugo extends Nub {
* @param alpha \alpha_t turbulent length scale (m) within the blocks layer
*/
private
calcBeta
(
alpha
:
number
):
number
{
return
Math
.
sqrt
(
this
.
prms
.
PBH
.
v
*
this
.
CdChD
/
alpha
/
this
.
R
);
return
Math
.
min
(
100
,
Math
.
sqrt
(
this
.
prms
.
PBH
.
v
*
this
.
CdChD
/
alpha
/
this
.
R
)
)
;
}
/**
...
...
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