Skip to content

[Bug] - Noisy warning during distributing well rates #1836

@JoerivanEngelen

Description

@JoerivanEngelen

Bug description
In the Peelvenen case, there is a noisy warning when distributing the well rates which will probably affect other models as well. This is probably because of model cells with zero thicknesses. Best is to drop these beforehand.

....
C:\src\imod-python\imod\prepare\wells.py:90: RuntimeWarning: invalid value encountered in divide
  return 1.0 - np.abs(Z_c - F_c) / (0.5 * D)
C:\src\imod-python\imod\prepare\wells.py:90: RuntimeWarning: divide by zero encountered in divide
  return 1.0 - np.abs(Z_c - F_c) / (0.5 * D)
C:\src\imod-python\imod\prepare\wells.py:90: RuntimeWarning: invalid value encountered in divide
  return 1.0 - np.abs(Z_c - F_c) / (0.5 * D)
C:\src\imod-python\imod\prepare\wells.py:90: RuntimeWarning: divide by zero encountered in divide
  return 1.0 - np.abs(Z_c - F_c) / (0.5 * D)
C:\src\imod-python\imod\prepare\wells.py:90: RuntimeWarning: invalid value encountered in divide
  return 1.0 - np.abs(Z_c - F_c) / (0.5 * D)

Relevant comment from @Huite in a slightly different context (was distributing conductances in the top system):

Divide by zero seems to happen when you divide e.g. np.array([1.0]) / np.array([0.0]); invalid seems to happen when np.array([0.0]) / np.array([0.0]).

Most likely, there are zero thickness layers? Maybe zero conductivities as well?

My gut feeling is that there are many variables which shouldn't be allowed zero or negative (i.e. what the validation checks).
What feels most explicit to me here is to explicitly set 0 or negative values to NaN, i.e. call where() a bunch of times. Since you mention the output is fine, you're now getting implicit conversion to NaN.
There's some overhead associated with whereing everything, but it'll probably save us from a few bugs in the future...?

Setting to NaN has the benefit of being clearly (in)visible in xarray/xugrid plotting as well -- unlike zero, which tends to get a color and which has thwarted me before thinking it was valid...

Originally posted by @Huite in #1479

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    📯 New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions