Skip to content

Commit 7d73c32

Browse files
authored
prevent div by zero in Froude computation (#213)
1 parent 9c2d9c8 commit 7d73c32

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

docs/conf_file.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ This does not apply to the map of maximum values.
220220

221221
If an exported map is totally empty, it is deleted at the end of the simulation when registered in the STRDS.
222222

223+
When the water depth is zero, the Froude number is set to zero to prevent undefined values.
224+
223225
[statistics]
224226
------------
225227

src/itzi/flow.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ def solve_h(
511511
vdir = vdir + 360. * (vdir < 0)
512512
arr_vdir[r, c] = vdir
513513

514-
# Froude number
515-
arr_fr[r, c] = v / c_sqrt(g * h_new)
514+
# Froude number - use epsilon to avoid division by zero
515+
arr_fr[r, c] = v / c_sqrt(g * fmax(h_new, eps)) * (h_new > 0.)
516516

517517

518518
@cython.wraparound(False) # Disable negative index check

0 commit comments

Comments
 (0)