@@ -557,15 +557,29 @@ def initialMCT(self):
557
557
# set max channel slope for MCT pixels
558
558
559
559
maskinfo = MaskInfo .instance ()
560
+
561
+ # cmcheck
560
562
# 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
+
561
571
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
564
575
576
+ q10init = maskinfo .in_one () * 1e-06
565
577
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
567
579
# MCT outflow (x+dx) from MCT pixel at time t0
568
580
581
+
582
+
569
583
PrevCmMCT = loadmap ('PrevCmMCTInitValue' )
570
584
self .var .PrevCm0 = np .where (PrevCmMCT == - 9999 , maskinfo .in_one (), PrevCmMCT ) #np
571
585
# Courant numnber (Cm) for MCT
@@ -576,11 +590,15 @@ def initialMCT(self):
576
590
self .var .ChanQ = np .where (self .var .IsChannelKinematic , self .var .ChanQ , self .var .PrevQMCTout )
577
591
# Initialise discharge for kinematic and MCT grid cells
578
592
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
584
602
585
603
# ************************************************************
586
604
# ***** INITIALISE MUSKINGUM-CUNGE-TODINI WAVE ROUTER ********
@@ -671,6 +689,8 @@ def dynamic(self, NoRoutingExecuted):
671
689
SideflowChan = np .where (self .var .IsChannelKinematic , SideflowChanM3 * self .var .InvChanLength * self .var .InvDtRouting ,0 )
672
690
# Sideflow contribution to kinematic and split routing grid cells expressed in [cu m /s / m channel length]
673
691
692
+ #cmcheck
693
+ # non c'e' bisogno di questo if?
674
694
if option ['MCTRouting' ]:
675
695
SideflowChanMCT = np .where (self .var .IsChannelMCT , SideflowChanM3 * self .var .InvDtRouting ,0 ) #Ql
676
696
# Sideflow contribution to MCT grid cells expressed in [m3/s]
@@ -1145,6 +1165,14 @@ def MCTRoutingLoop(self,ChanQMCTOutStart,ChanQMCTInStart,ChanQKinOut,SideflowCha
1145
1165
# get pixel ID
1146
1166
idpix = self .mct_river_router .pixels_ordered [index ]
1147
1167
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
+
1148
1176
### calling MCT function for single cell
1149
1177
q11 [idpix ], V11 [idpix ], Cm0 [idpix ], Dm0 [idpix ] = self .MCTRouting_single (q10 [idpix ], q01 [idpix ], q00 [idpix ], ql [idpix ], Cm0 [idpix ], Dm0 [idpix ],
1150
1178
dt , xpix [idpix ], s0 [idpix ], Balv [idpix ], ANalv [idpix ], Nalv [idpix ])
@@ -1155,7 +1183,8 @@ def MCTRoutingLoop(self,ChanQMCTOutStart,ChanQMCTInStart,ChanQKinOut,SideflowCha
1155
1183
# # Set outflow to be the same as inflow in MCT grid cells ('tanto entra tanto esce')
1156
1184
# V11[idpix] = ChanM3MCT0[idpix]
1157
1185
# # 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]
1159
1188
1160
1189
1161
1190
@@ -1241,14 +1270,14 @@ def MCTRouting_single(self, q10, q01, q00, ql, Cm0, Dm0, dt, xpix, s0, Balv, ANa
1241
1270
1242
1271
# reference I discharge at x=0
1243
1272
qmx0 = (q00 + q01 ) / 2.
1244
- if qmx0 == 0 :
1245
- qmx0 = eps
1273
+ # if qmx0 == 0:
1274
+ # qmx0 = eps
1246
1275
hmx0 = self .hoq (qmx0 , s0 , Balv , ANalv , Nalv )
1247
1276
1248
1277
# reference O discharge at x=1
1249
1278
qmx1 = (q10 + q11 ) / 2.
1250
- if qmx1 == 0 :
1251
- qmx1 = eps
1279
+ # if qmx1 == 0:
1280
+ # qmx1 = eps
1252
1281
hmx1 = self .hoq (qmx1 , s0 ,Balv ,ANalv ,Nalv )
1253
1282
1254
1283
# Calc riverbed slope correction factor
@@ -1261,8 +1290,8 @@ def MCTRouting_single(self, q10, q01, q00, ql, Cm0, Dm0, dt, xpix, s0, Balv, ANa
1261
1290
# Q(t+dt)=(I(t+dt)+O'(t+dt))/2
1262
1291
qm1 = (q01 + q11 ) / 2.
1263
1292
#cm
1264
- if qm1 == 0 :
1265
- qm1 = eps
1293
+ # if qm1 == 0:
1294
+ # qm1 = eps
1266
1295
#cm
1267
1296
hm1 = self .hoq (qm1 ,s0 ,Balv ,ANalv ,Nalv )
1268
1297
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
1283
1312
c3 = (1 - Cm0 + Dm0 ) / den * (Cm1 / Cm0 )
1284
1313
c4 = (2 * Cm1 ) / den
1285
1314
1315
+ # cmcheck
1286
1316
# Calc outflow q11 at time t+1
1287
1317
# Mass balance equation without lateral flow
1288
1318
# q11 = c1 * q01 + c2 * q00 + c3 * q10
1289
1319
# Mass balance equation that takes into consideration the lateral flow
1290
1320
q11 = c1 * q01 + c2 * q00 + c3 * q10 + c4 * ql
1291
1321
1292
1322
if q11 < 0. :
1293
- q11 = eps
1323
+ q11 = 0
1294
1324
1295
1325
#### end of for loop
1296
1326
0 commit comments