[GRASS-git] [OSGeo/grass] ec90b1: r.sim: Fix null Manning's n and infiltration handl...

Vaclav Petras noreply at github.com
Wed Sep 30 20:30:28 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: ec90b1cd771ea026dd64772fc1b816cac64a9c11
      https://github.com/OSGeo/grass/commit/ec90b1cd771ea026dd64772fc1b816cac64a9c11
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M raster/r.sim/r.sim.sediment/r.sim.sediment.html
    M raster/r.sim/r.sim.sediment/r.sim.sediment.md
    M raster/r.sim/r.sim.water/r.sim.water.html
    M raster/r.sim/r.sim.water/r.sim.water.md
    A raster/r.sim/r.sim.water/tests/r_sim_water_mannings_null_test.py
    M raster/r.sim/simlib/input.c

  Log Message:
  -----------
  r.sim: Fix null Manning's n and infiltration handling (#7981)

Nulls in the Manning's n raster map were read as the internal undefined
value -9999, but unlike nulls in the rainfall excess, partial derivative
and sediment input maps, they were not copied into the elevation grid,
so these cells stayed in the simulation domain with n = -9999. The
inverse 1/n was then -1e-4, which made the velocity there about 1e-5 of
the velocity for n = 0.1 and pointed it uphill. The cells also entered
the mean velocity, and so the time step and the number of iterations for
the whole domain, and the mean Manning's n in the -p summary and the map
history. The discharge output was negative in them.

Copy the nulls of the Manning's n map into the elevation grid as it is
done for the other input maps. The cells are now outside of the domain:
the outputs are null there and walkers which reach them leave the
domain. r.sim.water and r.sim.sediment share this code, so this applies
to both.

Nulls in the infiltration raster map were also read as -9999. The
walker loop skipped these cells, so they had no infiltration, but the
value entered the reported mean infiltration, which came out negative.
Set them to zero infiltration when the map is read. While this is
inconsistent with the other null handling, the "no infiltration"
intuitively means zero as opposed unknown. 

Only runs with nulls in the Manning's n map change their outputs. With
a Manning's n map without nulls, the r.sim.water and r.sim.sediment
outputs from the nc_spm elevation are byte-identical to those before
this change.

A new test checks that a run with a null patch in the Manning's n map
gives the same depth, discharge and run summary as a run with null
elevation over the same patch, with the partial derivatives given as
inputs so that they are the same in both runs. Another test checks that
null infiltration gives the same outputs and run summary as zero
infiltration.

Written with the help of Claude Code.



To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications


More information about the grass-commit mailing list