Commit 1f9fd5c3 authored by David's avatar David
Browse files

fix(RunModel_Lag_Enhanced): case of all upstream flow with lenght at zero

Refs #181
1 merge request!109Draft: Resolve "Simulation of water losses on routed flows based on GR groundwater exchange function"
Pipeline #62545 passed with stage
in 8 minutes and 35 seconds
Showing with 5 additions and 1 deletion
+5 -1
......@@ -156,9 +156,13 @@ RunModel_Lag_enhanced <- function(InputsModel, RunOptions, Param, QcontribDown)
InputsModel$Qupstream[IndPeriod1, upstream_basin])
# Leaks application on routed flows
if (HasRoutedFlowLeaks) {
# Leak are applied based on downstream sub-basin area and residence time
Eup <- Exch * PT[upstream_basin] *
InputsModel$LengthHydro[upstream_basin] / sum(InputsModel$LengthHydro) *
InputsModel$BasinAreas[length(InputsModel$BasinAreas)] * 1e3
# Leaks are shared between upstream flows based on their routing length
if (sum(InputsModel$LengthHydro) > 0) {
Eup <- Eup * InputsModel$LengthHydro[upstream_basin] / sum(InputsModel$LengthHydro)
}
I2 <- IndPeriod2 + 1
# Don't apply leaks on upstream negative flows (distant abstractions)
Eup[Qupstream[I2] < 0] <- 0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment