Skip to content

Commit 624803b

Browse files
author
Cinzia Mazzetti
committed
modified init values for mct channels
1 parent 35108a6 commit 624803b

File tree

2 files changed

+53
-16
lines changed

2 files changed

+53
-16
lines changed

src/lisflood/hydrological_modules/routing.py

+46-16
Original file line numberDiff line numberDiff line change
@@ -557,15 +557,29 @@ def initialMCT(self):
557557
# set max channel slope for MCT pixels
558558

559559
maskinfo = MaskInfo.instance()
560+
561+
# cmcheck
560562
# Initialisation for MCT routing
563+
# PrevQMCTin = loadmap('PrevQMCTinInitValue') # instant input discharge for MCT
564+
# self.var.PrevQMCTin = np.where(PrevQMCTin == -9999, maskinfo.in_zero(), PrevQMCTin) # np
565+
# # MCT inflow (x) to MCT pixel at time t0
566+
#
567+
# PrevQMCTout = loadmap('PrevQMCToutInitValue') # instant output discharge for MCT
568+
# self.var.PrevQMCTout = np.where(PrevQMCTout == -9999, maskinfo.in_zero(), PrevQMCTout) #np
569+
# # MCT outflow (x+dx) from MCT pixel at time t0
570+
561571
PrevQMCTin = loadmap('PrevQMCTinInitValue') # instant input discharge for MCT
562-
self.var.PrevQMCTin = np.where(PrevQMCTin == -9999, maskinfo.in_zero(), PrevQMCTin) # np
563-
# MCT inflow (x) to MCT pixel at time t0
572+
q00init = maskinfo.in_one() * 1e-06
573+
self.var.PrevQMCTin = np.where(PrevQMCTin == -9999, q00init, PrevQMCTin) # np
574+
# MCT inflow (x) to MCT pixel at time t0 - sum of upstream inputs
564575

576+
q10init = maskinfo.in_one() * 1e-06
565577
PrevQMCTout = loadmap('PrevQMCToutInitValue') # instant output discharge for MCT
566-
self.var.PrevQMCTout = np.where(PrevQMCTout == -9999, maskinfo.in_zero(), PrevQMCTout) #np
578+
self.var.PrevQMCTout = np.where(PrevQMCTout == -9999, q10init, PrevQMCTout) #np
567579
# MCT outflow (x+dx) from MCT pixel at time t0
568580

581+
582+
569583
PrevCmMCT = loadmap('PrevCmMCTInitValue')
570584
self.var.PrevCm0 = np.where(PrevCmMCT == -9999, maskinfo.in_one(), PrevCmMCT) #np
571585
# Courant numnber (Cm) for MCT
@@ -576,11 +590,15 @@ def initialMCT(self):
576590
self.var.ChanQ = np.where(self.var.IsChannelKinematic, self.var.ChanQ, self.var.PrevQMCTout)
577591
# Initialise discharge for kinematic and MCT grid cells
578592

579-
# #cmcheck
580-
# self.var.ChanM3 = np.where(self.var.IsChannelKinematic, self.var.ChanM3, self.var.PrevQMCTout)
581-
# # Initialise storage volume for kinematic and MCT grid cells
582-
# self.var.StorageStepINIT = self.var.ChanM3
583-
# # Initial storage volume for kinematic and MCT grid cells
593+
#cmcheck
594+
V00init = maskinfo.in_one() * 1e-06
595+
self.var.ChanM3 = np.where(self.var.IsChannelKinematic, self.var.ChanM3, V00init)
596+
# self.var.ChanM3 = np.where(self.var.IsChannelKinematic, self.var.ChanM3, maskinfo.in_zero())
597+
# Initialise storage volume for kinematic and MCT grid cells
598+
self.var.StorageStepINIT = self.var.ChanM3.copy()
599+
# Initial storage volume for kinematic and MCT grid cells
600+
self.var.ChanIniM3 = self.var.ChanM3.copy()
601+
# Initial storage volume for kinematic and MCT grid cells
584602

585603
# ************************************************************
586604
# ***** INITIALISE MUSKINGUM-CUNGE-TODINI WAVE ROUTER ********
@@ -671,6 +689,8 @@ def dynamic(self, NoRoutingExecuted):
671689
SideflowChan = np.where(self.var.IsChannelKinematic, SideflowChanM3 * self.var.InvChanLength * self.var.InvDtRouting,0)
672690
# Sideflow contribution to kinematic and split routing grid cells expressed in [cu m /s / m channel length]
673691

692+
#cmcheck
693+
# non c'e' bisogno di questo if?
674694
if option['MCTRouting']:
675695
SideflowChanMCT = np.where(self.var.IsChannelMCT, SideflowChanM3 * self.var.InvDtRouting,0) #Ql
676696
# Sideflow contribution to MCT grid cells expressed in [m3/s]
@@ -1145,6 +1165,14 @@ def MCTRoutingLoop(self,ChanQMCTOutStart,ChanQMCTInStart,ChanQKinOut,SideflowCha
11451165
# get pixel ID
11461166
idpix = self.mct_river_router.pixels_ordered[index]
11471167

1168+
# cmcheck
1169+
eps = 1e-06
1170+
# check upstream inflow
1171+
# q01 cannot be zero
1172+
# This is a problem for head pixels
1173+
if q01[idpix] == 0:
1174+
q01[idpix] = eps
1175+
11481176
### calling MCT function for single cell
11491177
q11[idpix], V11[idpix], Cm0[idpix], Dm0[idpix] = self.MCTRouting_single(q10[idpix], q01[idpix], q00[idpix], ql[idpix], Cm0[idpix], Dm0[idpix],
11501178
dt, xpix[idpix], s0[idpix], Balv[idpix], ANalv[idpix], Nalv[idpix])
@@ -1155,7 +1183,8 @@ def MCTRoutingLoop(self,ChanQMCTOutStart,ChanQMCTInStart,ChanQKinOut,SideflowCha
11551183
# # Set outflow to be the same as inflow in MCT grid cells ('tanto entra tanto esce')
11561184
# V11[idpix] = ChanM3MCT0[idpix]
11571185
# # Set end volume to be the same as initial volume in MCT grid cells ('tanto entra tanto esce')
1158-
1186+
# #cmcheck - aggiusto il bilancio
1187+
# V11[idpix] = ChanM3MCT0[idpix] + q01[idpix] + ql[idpix] - q11[idpix]
11591188

11601189

11611190

@@ -1241,14 +1270,14 @@ def MCTRouting_single(self, q10, q01, q00, ql, Cm0, Dm0, dt, xpix, s0, Balv, ANa
12411270

12421271
# reference I discharge at x=0
12431272
qmx0 = (q00 + q01) / 2.
1244-
if qmx0 == 0:
1245-
qmx0 = eps
1273+
# if qmx0 == 0:
1274+
# qmx0 = eps
12461275
hmx0 = self.hoq(qmx0, s0, Balv, ANalv, Nalv)
12471276

12481277
# reference O discharge at x=1
12491278
qmx1 = (q10 + q11) / 2.
1250-
if qmx1 == 0:
1251-
qmx1 = eps
1279+
# if qmx1 == 0:
1280+
# qmx1 = eps
12521281
hmx1 = self.hoq(qmx1, s0,Balv,ANalv,Nalv)
12531282

12541283
# Calc riverbed slope correction factor
@@ -1261,8 +1290,8 @@ def MCTRouting_single(self, q10, q01, q00, ql, Cm0, Dm0, dt, xpix, s0, Balv, ANa
12611290
# Q(t+dt)=(I(t+dt)+O'(t+dt))/2
12621291
qm1 = (q01 + q11) / 2.
12631292
#cm
1264-
if qm1 == 0:
1265-
qm1 = eps
1293+
# if qm1 == 0:
1294+
# qm1 = eps
12661295
#cm
12671296
hm1 = self.hoq(qm1,s0,Balv,ANalv,Nalv)
12681297
dummy, Ax1,Bx1,Px1,ck1 = self.qoh(hm1,s0,Balv,ANalv,Nalv)
@@ -1283,14 +1312,15 @@ def MCTRouting_single(self, q10, q01, q00, ql, Cm0, Dm0, dt, xpix, s0, Balv, ANa
12831312
c3 = (1 - Cm0 + Dm0) / den * (Cm1 / Cm0)
12841313
c4 = (2 * Cm1) / den
12851314

1315+
# cmcheck
12861316
# Calc outflow q11 at time t+1
12871317
# Mass balance equation without lateral flow
12881318
# q11 = c1 * q01 + c2 * q00 + c3 * q10
12891319
# Mass balance equation that takes into consideration the lateral flow
12901320
q11 = c1 * q01 + c2 * q00 + c3 * q10 + c4 * ql
12911321

12921322
if q11 < 0.:
1293-
q11 = eps
1323+
q11 = 0
12941324

12951325
#### end of for loop
12961326

src/lisflood/hydrological_modules/waterbalance.py

+7
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ def dynamic(self):
204204
WaterStored_nextstep += np.take(np.bincount(self.var.Catchments,weights=HillslopeStoredM3),self.var.Catchments)
205205

206206
# Total water stored [m3]
207+
208+
207209
# This goes out:
208210
HillslopeOutM3 = (self.var.TaWB + self.var.TaInterceptionWB + self.var.ESActWB + self.var.GwLossWB) * self.var.MMtoM3
209211
# Water that goes out of the system at the hillslope level [m3]
@@ -213,6 +215,9 @@ def dynamic(self):
213215
sum1 = self.var.ChanQAvg.copy()
214216
sum1[self.var.AtLastPointC == 0] = 0
215217
WaterOut = np.take(np.bincount(self.var.Catchments,weights=sum1 * self.var.DtSec),self.var.Catchments)
218+
# Water that goes out of the system at the channels level [m3]
219+
# (rivers flow)
220+
216221
WaterOut += np.take(np.bincount(self.var.Catchments,weights=HillslopeOutM3),self.var.Catchments)
217222

218223
#WaterOut = areatotal(cover(ifthen(
@@ -261,6 +266,8 @@ def dynamic(self):
261266
# Discharge just upstream of structure locations (coded as pits) in [cu m / time step]
262267
# Needed for mass balance error calculations, because of double counting of structure
263268
# storage and water in the channel.
269+
270+
264271
# Mass balance:
265272
self.var.MBError = self.var.WaterInit + WaterIn - WaterStored - WaterOut - DischargeM3Structures
266273
# Totl mass balance error per catchment [cu m]. Mass balance error is computed for each computational time step.

0 commit comments

Comments
 (0)