Skip to content

How to deal with negative inflow into HydPy-Musk-MCT? #168

@tyralla

Description

@tyralla

It is expected that HydPy-Musk-MCT receives positive inflow values. However, it sometimes might receive negative inflow values due to configuration mistakes or minor rounding errors. Currently, our documentation does not define the model's behaviour for such cases. As we do not raise exceptions during simulation runs (harder to do in Cython in nogil mode and could cause relevant performance losses), the only options seem to be to reset negative inflow values to zero or to always pass nan values as outflow after the first negative inflow occurred.

I tried to analyse the current behaviour by modifying MCT's base example by setting nmbsegments to 1 and length to 2 and decreasing the inflow linearly by subtracting 2 * ts. The results vary between different HydPy versions:

6.0a0
Image

6.1.1
Image

6.1.2
Image

6.1.3
Image

6.1.4
Image

However, I am not sure if these two modes ("reflecting" and "stop working") are stable for all considered versions, or if differences in other model components cause minor simulation differences which trigger either the first or the second behaviour.

Anyhow, we should decide on the desired behaviour and ensure Musk-MCT always holds to it. "Reflection" makes no sense. I would prefer the "stop working" mode because then users can see (when inspecting the results) that something is wrong. However, technical rounding errors should not cause Musk-CT to stop working. Maybe we could introduce a solver parameter that defines a threshold below which setting inflow values to zero is okay, similar to ToleranceDischarge.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions