Deltares / Ribasim

Water resources modeling
https://ribasim.org/
MIT License
39 stars 5 forks source link

Models with (multiple) discrete control(_states) raise exceptions #1567

Closed DanielTollenaar closed 3 months ago

DanielTollenaar commented 3 months ago

What Models with (multiple) discrete control raise exceptions in ribasim 2024.8.0.

For the Ribasim RWS-HWS model we are trying to build-in verdeelsleutels; discrete control controlling fractions between basins depending on upstream discharges. We have two Lobith controlling discharge over Rhine branches and Monsin controlling Meuse discharge over lower Meuse and canal systems.

Reproduction We increased complexity starting with a model without control 1 untill crashing models 3 and 4. Except controls the rest of the models is the same:

  1. Model without verdeelsleutels (no control), works, see: https://we.tl/t-VE2QSqci24
  2. Model with Lobith only, works as well, see: https://we.tl/t-LDyMnJXCia
  3. Model with Monsinonly, raises an Exception: https://we.tl/t-uW9usryf0C image
  4. Model with both Monsin and Lobith, raises another Exception: https://we.tl/t-St9vuGqJZO image

Issue 3 we cannot follow; it seems to pass the validator, but than doesn't give any info. At 4, it seems the validator get's messed up with different control_states; it seems to expect control_states of Monsin at Rhine-fractions and vise-versa. As:

gijsber commented 3 months ago

good to keep #720 in the back of your mind

visr commented 3 months ago

See #1569 for a fix to the validation code that triggered point 4.

Point 3 is a more difficult issue. It is thrown due to this TODO: https://github.com/Deltares/Ribasim/blob/0c19719ea764499495dad4af003f640587382376/core/src/solve.jl#L619

If you replace the Outlet with a Pump it should work. This is because the Pump will always move a 1Q over a FractionalFlow to fractions of say 0.4Q and 0.6Q.

The Outlet reduces the flow to 0 if the downstream level approaches the upstream level. But what are we supposed to do in the FractionalFlow if one path is blocked or reduced in this way? Should we give up on the fraction and just send it where it can go? Right now the assumption in the FractionalFlow is that the upstream side alone determines Q, and FractionalFlow only has to take fractions off.

DanielTollenaar commented 3 months ago

Check, I'll change to a fake TabulatedRatingCurve for now as it should go to a real-one, in time, any way. Two questions:

visr commented 3 months ago

Yeah good points, I added #1570.

You mean changing it to two TabulatedRatingCurves one one Basin? Right now one TabulatedRatingCurve to two FractionalFlow also works, but if we stop it from sending water to higher downstream levels that will have the same issue.