Skip to content

Commit a58d403

Browse files
author
Cinzia Mazzetti
committed
adjusting checks for small q values
1 parent ef1dfc3 commit a58d403

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/lisflood/hydrological_modules/routing.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ def MCTRouting_single(self, V00, q10, q01, q00, ql,q0mm, Cm0, Dm0, dt, xpix, s0,
13811381

13821382
# check for negative and zero discharge values
13831383
# zero outflow is not allowed
1384-
if q11 <= 0:
1384+
if q11 < eps: # cmcheck <=0
13851385
q11 = eps
13861386

13871387
# calc reference discharge at time t
@@ -1393,13 +1393,13 @@ def MCTRouting_single(self, V00, q10, q01, q00, ql,q0mm, Cm0, Dm0, dt, xpix, s0,
13931393

13941394
# reference I discharge at x=0
13951395
qmx0 = (q00 + q01) / 2.
1396-
if qmx0 == 0:
1396+
if qmx0 < eps: # cmcheck ==0
13971397
qmx0 = eps
13981398
hmx0 = self.hoq(qmx0, s0, Balv, ANalv, Nalv)
13991399

14001400
# reference O discharge at x=1
14011401
qmx1 = (q10 + q11) / 2.
1402-
if qmx1 == 0:
1402+
if qmx1 < eps: # cmcheck ==0
14031403
qmx1 = eps
14041404
hmx1 = self.hoq(qmx1, s0,Balv,ANalv,Nalv)
14051405

@@ -1413,7 +1413,7 @@ def MCTRouting_single(self, V00, q10, q01, q00, ql,q0mm, Cm0, Dm0, dt, xpix, s0,
14131413
# Q(t+dt)=(I(t+dt)+O'(t+dt))/2
14141414
qm1 = (q01 + q11) / 2.
14151415
#cm
1416-
if qm1 == 0:
1416+
if qm1 < eps: # cmcheck ==0
14171417
qm1 = eps
14181418
#cm
14191419
hm1 = self.hoq(qm1,s0,Balv,ANalv,Nalv)
@@ -1442,7 +1442,7 @@ def MCTRouting_single(self, V00, q10, q01, q00, ql,q0mm, Cm0, Dm0, dt, xpix, s0,
14421442
# Mass balance equation that takes into consideration the lateral flow
14431443
q11 = c1 * q01 + c2 * q00 + c3 * q10 + c4 * ql
14441444

1445-
if q11 <= 0.:
1445+
if q11 < eps: # cmcheck <=0
14461446
q11 = eps
14471447

14481448
#### end of for loop
@@ -1475,7 +1475,7 @@ def MCTRouting_single(self, V00, q10, q01, q00, ql,q0mm, Cm0, Dm0, dt, xpix, s0,
14751475
q1mm = q0mm + ql + (V00 - V11) / dt
14761476

14771477
# cmcheck
1478-
# q1m cannot be too small or it will cause instability
1478+
# q1m cannot be smaller than eps or it will cause instability
14791479
if q1mm < eps:
14801480
q1mm = eps
14811481
V11 = V00 + (q0mm + ql - q1mm) * dt
@@ -1486,6 +1486,7 @@ def MCTRouting_single(self, V00, q10, q01, q00, ql,q0mm, Cm0, Dm0, dt, xpix, s0,
14861486
return q11, V11, q1mm, Cm1, Dm1
14871487

14881488

1489+
14891490
def hoq(self,q,s0,Balv,ANalv,Nalv):
14901491
"""Water depth from discharge.
14911492
Given a generic cross-section (rectangular, triangular or trapezoidal) and a steady-state discharge q=Q*, it computes

0 commit comments

Comments
 (0)