@@ -1273,7 +1273,7 @@ def MCTRoutingLoop(self,ChanQMCTOutStart,ChanQMCTInStart,ChanQKinOut,ChanQKinOut
1273
1273
# q01[idpix] = eps
1274
1274
1275
1275
### calling MCT function for single cell
1276
- q11 [idpix ], V11 [idpix ], Cm0 [idpix ], Dm0 [idpix ] = self .MCTRouting_single (V00 [idpix ],q10 [idpix ], q01 [idpix ], q00 [idpix ], ql [idpix ], Cm0 [idpix ], Dm0 [idpix ],
1276
+ q11 [idpix ], V11 [idpix ],q1m [ idpix ], Cm0 [idpix ], Dm0 [idpix ] = self .MCTRouting_single (V00 [idpix ],q10 [idpix ], q01 [idpix ], q00 [idpix ], ql [ idpix ], q0m [idpix ], Cm0 [idpix ], Dm0 [idpix ],
1277
1277
dt , xpix [idpix ], s0 [idpix ], Balv [idpix ], ANalv [idpix ], Nalv [idpix ])
1278
1278
1279
1279
# # cmcheck - tanto entra tanto esce
@@ -1282,19 +1282,17 @@ def MCTRoutingLoop(self,ChanQMCTOutStart,ChanQMCTInStart,ChanQKinOut,ChanQKinOut
1282
1282
# # Set outflow to be the same as inflow in MCT grid cells ('tanto entra tanto esce')
1283
1283
# V11[idpix] = V00[idpix]
1284
1284
# # Set end volume to be the same as initial volume in MCT grid cells ('tanto entra tanto esce')
1285
- # V11[idpix] = V00[idpix] + q01[idpix] + ql[idpix] - q11[idpix]
1286
-
1287
-
1288
- ### calc integration on the control volume (pixel)
1289
- # calc average discharge outflow q1m for MCT channels during routing sub step dt
1290
- # Calculate average outflow using water balance for MCT channel grid cell over sub-routing step
1291
- q1m [idpix ] = q0m [idpix ] + ql [idpix ] + (V00 [idpix ] - V11 [idpix ]) / dt
1292
- # cmcheck no valori di portata negativi
1293
- if q1m [idpix ] < 0. :
1294
- q1m [idpix ] = eps
1295
- V11 [idpix ] = V00 [idpix ] + (q0m [idpix ] + ql [idpix ] - q1m [idpix ]) * dt
1296
1285
1297
1286
1287
+ # ### calc integration on the control volume (pixel)
1288
+ # moved to routing_single
1289
+ # # calc average discharge outflow q1m for MCT channels during routing sub step dt
1290
+ # # Calculate average outflow using water balance for MCT channel grid cell over sub-routing step
1291
+ # q1m[idpix] = q0m[idpix] + ql[idpix] + (V00[idpix] - V11[idpix]) / dt
1292
+ # # cmcheck no valori di portata negativi
1293
+ # if q1m[idpix] < 0.:
1294
+ # q1m[idpix] = eps
1295
+ # V11[idpix] = V00[idpix] + (q0m[idpix] + ql[idpix] - q1m[idpix]) * dt
1298
1296
1299
1297
1300
1298
# Update contribution from upstream pixels at time t+1 (dim=all pixels) using the newly calculated q11
@@ -1346,7 +1344,7 @@ def MCTRoutingLoop(self,ChanQMCTOutStart,ChanQMCTInStart,ChanQKinOut,ChanQKinOut
1346
1344
return ChanQMCTOutAvg , ChanQMCTOut , ChanM3MCTOut , Cmout , Dmout
1347
1345
1348
1346
1349
- def MCTRouting_single (self , V00 , q10 , q01 , q00 , ql , Cm0 , Dm0 , dt , xpix , s0 , Balv , ANalv , Nalv ):
1347
+ def MCTRouting_single (self , V00 , q10 , q01 , q00 , ql ,q0mm , Cm0 , Dm0 , dt , xpix , s0 , Balv , ANalv , Nalv ):
1350
1348
'''
1351
1349
This function implements Muskingum-Cunge-Todini routing method for a single channel pixel.
1352
1350
References:
@@ -1384,7 +1382,7 @@ def MCTRouting_single(self, V00, q10, q01, q00, ql, Cm0, Dm0, dt, xpix, s0, Balv
1384
1382
# check for negative and zero discharge values
1385
1383
# zero outflow is not allowed
1386
1384
if q11 <= 0 :
1387
- q11 = 0
1385
+ q11 = eps
1388
1386
1389
1387
# calc reference discharge at time t
1390
1388
# qm0 = (I(t)+O(t))/2
@@ -1470,11 +1468,22 @@ def MCTRouting_single(self, V00, q10, q01, q00, ql, Cm0, Dm0, dt, xpix, s0, Balv
1470
1468
# V11 = k1 * (x1 * q01 + (1. - x1) * q11) # MUST be the same as above!
1471
1469
1472
1470
1473
- if (V11 < 0 ):
1474
- V11 = 0.
1471
+
1472
+ ### calc integration on the control volume (pixel)
1473
+ # calc average discharge outflow q1m for MCT channels during routing sub step dt
1474
+ # Calculate average outflow using water balance for MCT channel grid cell over sub-routing step
1475
+ q1mm = q0mm + ql + (V00 - V11 ) / dt
1476
+
1477
+ # cmcheck
1478
+ # q1m cannot be too small or it will cause instability
1479
+ if q1mm < eps :
1480
+ q1mm = eps
1481
+ V11 = V00 + (q0mm + ql - q1mm ) * dt
1482
+
1483
+
1475
1484
1476
1485
# Outflow at O(t+dt), average outflow in time dt, water volume at t+dt, Courant and Reynolds numbers at t+1 for state files
1477
- return q11 , V11 , Cm1 , Dm1
1486
+ return q11 , V11 , q1mm , Cm1 , Dm1
1478
1487
1479
1488
1480
1489
def hoq (self ,q ,s0 ,Balv ,ANalv ,Nalv ):
0 commit comments