From d73455cafecd8e01c3a53edb9bd24b472afd1308 Mon Sep 17 00:00:00 2001 From: Markus Metz Date: Wed, 6 Nov 2024 22:29:56 +0100 Subject: [PATCH 1/9] improve manual, add info about progress --- raster/r.sim/r.sim.water/r.sim.water.html | 37 +++++++++++++++++++++++ raster/r.sim/simlib/hydro.c | 2 ++ 2 files changed, 39 insertions(+) diff --git a/raster/r.sim/r.sim.water/r.sim.water.html b/raster/r.sim/r.sim.water/r.sim.water.html index 79cef1bfadc..0a4140e6a27 100644 --- a/raster/r.sim/r.sim.water/r.sim.water.html +++ b/raster/r.sim/r.sim.water/r.sim.water.html @@ -25,6 +25,16 @@

DESCRIPTION

can be used to compute partial derivates of the predefined flow using its direction given by aspect and slope. +

+The equations are +

+dx = tan(slope) * cos(aspect)
+
+and +
+dy = tan(slope) * sin(aspect)
+
+

r.sim.water generated depth map
@@ -99,6 +109,10 @@

DESCRIPTION

diffusion term increases as given by halpha and advection term (direction of flow) is given as "prevailing" direction of flow computed as average of flow directions from the previous hbeta number of grid cells. +The model is for shallow water flow, where "shallow" is defined by hmax, +default 0.3 meters. Depending on the area of interest and the used digital +elevation model, hmax, halpha and hbeta might need to +be adjusted in order to deal realistically with elevation depressions or obstacles.

NOTES

@@ -146,6 +160,29 @@

NOTES

are useful both for everyday exploratory work using a desktop computer and for large, cutting-edge applications using high performance computing. +

+Manning's n for surface roughness
+from https://baharmon.github.io/hydrology-in-grass +

+ + + + + + + + + + + + + + + + + +
Landcover CategoryManning’s n value
Open Water0.001
Developed, Open Space0.0404
Developed, Low Intensity0.0678
Developed, Medium Intensity0.0678
Developed, High Intensity0.0404
Barren Land0.0113
Deciduous Forest0.36
Evergreen Forest0.32
Mixed Forest0.4
Shrub/Scrub0.4
Grassland/Herbaceuous0.368
Pasture/Hay0.325
Cultivated Crops0.325
Woody Wetlands0.086
Emergent Herbaceuous Wetlands0.1825
+

EXAMPLE

Using the North Carolina full sample dataset: diff --git a/raster/r.sim/simlib/hydro.c b/raster/r.sim/simlib/hydro.c index eb7649763e9..d5dd6f6d34c 100644 --- a/raster/r.sim/simlib/hydro.c +++ b/raster/r.sim/simlib/hydro.c @@ -156,6 +156,8 @@ void main_loop(void) for (iblock = 1; iblock <= nblock; iblock++) { /* ++icoub; */ + G_message(_("Processing block %d of %d"), iblock, nblock); + lw = 0; walkwe = 0.; barea = stepx * stepy; From a9308fc60c55a09ac13e132aa578a4e6abc3bfe3 Mon Sep 17 00:00:00 2001 From: Markus Metz <33666869+metzm@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:54:25 +0100 Subject: [PATCH 2/9] Update raster/r.sim/r.sim.water/r.sim.water.html Co-authored-by: Anna Petrasova --- raster/r.sim/r.sim.water/r.sim.water.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raster/r.sim/r.sim.water/r.sim.water.html b/raster/r.sim/r.sim.water/r.sim.water.html index 0a4140e6a27..08f878e0397 100644 --- a/raster/r.sim/r.sim.water/r.sim.water.html +++ b/raster/r.sim/r.sim.water/r.sim.water.html @@ -165,7 +165,7 @@

NOTES

from https://baharmon.github.io/hydrology-in-grass

- + From 795ce9607f434f08553ebb9d4548f720ec6e6e9d Mon Sep 17 00:00:00 2001 From: Markus Metz <33666869+metzm@users.noreply.github.com> Date: Wed, 6 Nov 2024 22:54:35 +0100 Subject: [PATCH 3/9] Update raster/r.sim/r.sim.water/r.sim.water.html Co-authored-by: Anna Petrasova --- raster/r.sim/r.sim.water/r.sim.water.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raster/r.sim/r.sim.water/r.sim.water.html b/raster/r.sim/r.sim.water/r.sim.water.html index 08f878e0397..ab434456ab2 100644 --- a/raster/r.sim/r.sim.water/r.sim.water.html +++ b/raster/r.sim/r.sim.water/r.sim.water.html @@ -161,7 +161,7 @@

NOTES

for large, cutting-edge applications using high performance computing.

-Manning's n for surface roughness
+Suggested Manning's n for surface roughness
from https://baharmon.github.io/hydrology-in-grass

Landcover CategoryManning’s n value
NLCD Landcover CategoryManning’s n value
Open Water0.001
Developed, Open Space0.0404
Developed, Low Intensity0.0678
From 2ae8b9f770e9f48f8da8f3111126c0ec42fddb68 Mon Sep 17 00:00:00 2001 From: Markus Metz Date: Wed, 6 Nov 2024 23:03:15 +0100 Subject: [PATCH 4/9] add reference for NLCD land cover classes --- raster/r.sim/r.sim.water/r.sim.water.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/raster/r.sim/r.sim.water/r.sim.water.html b/raster/r.sim/r.sim.water/r.sim.water.html index ab434456ab2..7ce8d669f99 100644 --- a/raster/r.sim/r.sim.water/r.sim.water.html +++ b/raster/r.sim/r.sim.water/r.sim.water.html @@ -183,6 +183,10 @@

NOTES

Emergent Herbaceuous Wetlands0.1825
+

+The NLCD user guide +provides more information about the different NLCD classes. +

EXAMPLE

Using the North Carolina full sample dataset: From 5b75f88588f47a54de8d2415c5a368cac3497cd6 Mon Sep 17 00:00:00 2001 From: Markus Metz Date: Wed, 13 Nov 2024 22:34:03 +0100 Subject: [PATCH 5/9] add mintimestep option --- raster/r.sim/r.sim.water/main.c | 18 ++++++++++++++++-- raster/r.sim/simlib/hydro.c | 1 + raster/r.sim/simlib/input.c | 5 +++++ raster/r.sim/simlib/simlib.h | 9 +++++---- raster/r.sim/simlib/waterglobs.h | 1 + 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/raster/r.sim/r.sim.water/main.c b/raster/r.sim/r.sim.water/main.c index 209be3e33d9..0000612e256 100644 --- a/raster/r.sim/r.sim.water/main.c +++ b/raster/r.sim/r.sim.water/main.c @@ -239,6 +239,18 @@ int main(int argc, char *argv[]) parm.niter->description = _("Time used for iterations [minutes]"); parm.niter->guisection = _("Parameters"); + parm.mintimestep = G_define_option(); + parm.mintimestep->key = "mintimestep"; + parm.mintimestep->type = TYPE_DOUBLE; + parm.mintimestep->answer = "0.0"; + parm.mintimestep->required = NO; + parm.mintimestep->label = + _("Minimum tine step for the simulation [seconds]"); + parm.mintimestep->description = + _("A larger minimum tine step substancially reduces processing time, " + "but at the cost of accuracy"); + parm.mintimestep->guisection = _("Parameters"); + parm.outiter = G_define_option(); parm.outiter->key = "output_step"; parm.outiter->type = TYPE_INTEGER; @@ -319,8 +331,9 @@ int main(int argc, char *argv[]) parm.threads->type = TYPE_INTEGER; parm.threads->answer = NUM_THREADS; parm.threads->required = NO; - parm.threads->description = - _("Number of threads which will be used for parallel compute"); + parm.threads->description = _( + "Number of threads which will be used for parallel compute. Increasing " + "the number of threads does not really speed up the simulation."); parm.threads->guisection = _("Parameters"); if (G_parser(argc, argv)) @@ -388,6 +401,7 @@ int main(int argc, char *argv[]) G_debug(3, "Parsing numeric parameters"); sscanf(parm.niter->answer, "%d", &wp.timesec); + sscanf(parm.mintimestep->answer, "%lf", &wp.mintimestep); sscanf(parm.outiter->answer, "%d", &wp.iterout); sscanf(parm.diffc->answer, "%lf", &wp.frac); sscanf(parm.hmax->answer, "%lf", &wp.hhmax); diff --git a/raster/r.sim/simlib/hydro.c b/raster/r.sim/simlib/hydro.c index d5dd6f6d34c..d8eea788641 100644 --- a/raster/r.sim/simlib/hydro.c +++ b/raster/r.sim/simlib/hydro.c @@ -104,6 +104,7 @@ int iterout, mx2o, my2o; int miter, nwalka; double timec; int ts, timesec; +double mintimestep; double rain_val; double manin_val; diff --git a/raster/r.sim/simlib/input.c b/raster/r.sim/simlib/input.c index e9f41b88709..44a948d0244 100644 --- a/raster/r.sim/simlib/input.c +++ b/raster/r.sim/simlib/input.c @@ -95,6 +95,7 @@ void WaterParams_init(struct WaterParams *wp) wp->timec = 0; wp->ts = 0; wp->timesec = 0; + wp->mintimestep = 0; wp->rain_val = 0; wp->manin_val = 0; @@ -201,6 +202,7 @@ void init_library_globals(struct WaterParams *wp) timec = wp->timec; ts = wp->ts; timesec = wp->timesec; + mintimestep = wp->mintimestep; rain_val = wp->rain_val; manin_val = wp->manin_val; @@ -508,6 +510,9 @@ int grad_check(void) deltaw = 0.8 / (sigmax * vmax); /*time step for sediment */ deltap = 0.25 * sqrt(stepx * stepy) / vmean; /*time step for water */ + if (deltap < mintimestep) + deltap = mintimestep; + if (deltaw > deltap) timec = 4.; else diff --git a/raster/r.sim/simlib/simlib.h b/raster/r.sim/simlib/simlib.h index 4a0fe592bb7..2b651bb5503 100644 --- a/raster/r.sim/simlib/simlib.h +++ b/raster/r.sim/simlib/simlib.h @@ -35,6 +35,7 @@ struct WaterParams { int miter, nwalka; double timec; int ts, timesec; + double mintimestep; double rain_val; double manin_val; @@ -86,10 +87,10 @@ void free_walkers(void); struct options { struct Option *elevin, *dxin, *dyin, *rain, *infil, *traps, *manin, - *observation, *depth, *disch, *err, *outwalk, *nwalk, *niter, *outiter, - *density, *diffc, *hmax, *halpha, *hbeta, *wdepth, *detin, *tranin, - *tauin, *tc, *et, *conc, *flux, *erdep, *rainval, *maninval, *infilval, - *logfile, *seed, *threads; + *observation, *depth, *disch, *err, *outwalk, *nwalk, *niter, + *mintimestep, *outiter, *density, *diffc, *hmax, *halpha, *hbeta, + *wdepth, *detin, *tranin, *tauin, *tc, *et, *conc, *flux, *erdep, + *rainval, *maninval, *infilval, *logfile, *seed, *threads; }; struct flags { diff --git a/raster/r.sim/simlib/waterglobs.h b/raster/r.sim/simlib/waterglobs.h index 7bf9fab74f2..10acce39c5b 100644 --- a/raster/r.sim/simlib/waterglobs.h +++ b/raster/r.sim/simlib/waterglobs.h @@ -111,6 +111,7 @@ extern int iterout, mx2o, my2o; extern int miter, nwalka; extern double timec; extern int ts, timesec; +extern double mintimestep; extern double rain_val; extern double manin_val; From ad725c7e65087f0c550971db3ed70603e1e3821d Mon Sep 17 00:00:00 2001 From: Markus Metz Date: Thu, 14 Nov 2024 19:07:27 +0100 Subject: [PATCH 6/9] try to explain diffusion --- raster/r.sim/r.sim.water/r.sim.water.html | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/raster/r.sim/r.sim.water/r.sim.water.html b/raster/r.sim/r.sim.water/r.sim.water.html index 7ce8d669f99..b7a2e332e69 100644 --- a/raster/r.sim/r.sim.water/r.sim.water.html +++ b/raster/r.sim/r.sim.water/r.sim.water.html @@ -109,10 +109,13 @@

DESCRIPTION

diffusion term increases as given by halpha and advection term (direction of flow) is given as "prevailing" direction of flow computed as average of flow directions from the previous hbeta number of grid cells. -The model is for shallow water flow, where "shallow" is defined by hmax, -default 0.3 meters. Depending on the area of interest and the used digital -elevation model, hmax, halpha and hbeta might need to -be adjusted in order to deal realistically with elevation depressions or obstacles. +The model tries to keep water "shallow" with maximum shallow water +depth defined by hmax default 0.3 meters. However, water depths +much higher than hmax can be observed if water accumulates in +natural sinks or river beds.Depending on the area of interest and the +used digital elevation model, hmax, halpha and +hbeta might need to be adjusted in order to deal realistically +with elevation depressions or obstacles.

NOTES

From 7b707066a8ae08a000e843c86bf4793e5f7ba06c Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 6 Jan 2025 22:11:04 +0100 Subject: [PATCH 7/9] fix typo --- raster/r.sim/r.sim.water/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/raster/r.sim/r.sim.water/main.c b/raster/r.sim/r.sim.water/main.c index 0000612e256..f80f99bb977 100644 --- a/raster/r.sim/r.sim.water/main.c +++ b/raster/r.sim/r.sim.water/main.c @@ -245,9 +245,9 @@ int main(int argc, char *argv[]) parm.mintimestep->answer = "0.0"; parm.mintimestep->required = NO; parm.mintimestep->label = - _("Minimum tine step for the simulation [seconds]"); + _("Minimum time step for the simulation [seconds]"); parm.mintimestep->description = - _("A larger minimum tine step substancially reduces processing time, " + _("A larger minimum time step substancially reduces processing time, " "but at the cost of accuracy"); parm.mintimestep->guisection = _("Parameters"); From a3a9d3fa57b37f3a649e6e83e30619056ec3519e Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 6 Jan 2025 22:13:52 +0100 Subject: [PATCH 8/9] fix typos --- raster/r.sim/r.sim.water/main.c | 4 ++-- raster/r.sim/r.sim.water/r.sim.water.html | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/raster/r.sim/r.sim.water/main.c b/raster/r.sim/r.sim.water/main.c index f80f99bb977..c4fda164276 100644 --- a/raster/r.sim/r.sim.water/main.c +++ b/raster/r.sim/r.sim.water/main.c @@ -247,7 +247,7 @@ int main(int argc, char *argv[]) parm.mintimestep->label = _("Minimum time step for the simulation [seconds]"); parm.mintimestep->description = - _("A larger minimum time step substancially reduces processing time, " + _("A larger minimum time step substantially reduces processing time, " "but at the cost of accuracy"); parm.mintimestep->guisection = _("Parameters"); @@ -332,7 +332,7 @@ int main(int argc, char *argv[]) parm.threads->answer = NUM_THREADS; parm.threads->required = NO; parm.threads->description = _( - "Number of threads which will be used for parallel compute. Increasing " + "Number of threads which will be used for parallel computation. Increasing " "the number of threads does not really speed up the simulation."); parm.threads->guisection = _("Parameters"); diff --git a/raster/r.sim/r.sim.water/r.sim.water.html b/raster/r.sim/r.sim.water/r.sim.water.html index b49adb166e0..06597470f35 100644 --- a/raster/r.sim/r.sim.water/r.sim.water.html +++ b/raster/r.sim/r.sim.water/r.sim.water.html @@ -27,10 +27,13 @@

DESCRIPTION

The equations are +

 dx = tan(slope) * cos(aspect)
 
+ and +
 dy = tan(slope) * sin(aspect)
 
From aa982288e87f1278f0216b132f97b924b1bedbe1 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 6 Jan 2025 22:14:12 +0100 Subject: [PATCH 9/9] fix typo --- raster/r.sim/r.sim.water/r.sim.water.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raster/r.sim/r.sim.water/r.sim.water.html b/raster/r.sim/r.sim.water/r.sim.water.html index 06597470f35..93ebecd706f 100644 --- a/raster/r.sim/r.sim.water/r.sim.water.html +++ b/raster/r.sim/r.sim.water/r.sim.water.html @@ -115,7 +115,7 @@

DESCRIPTION

The model tries to keep water "shallow" with maximum shallow water depth defined by hmax default 0.3 meters. However, water depths much higher than hmax can be observed if water accumulates in -natural sinks or river beds.Depending on the area of interest and the +natural sinks or river beds. Depending on the area of interest and the used digital elevation model, hmax, halpha and hbeta might need to be adjusted in order to deal realistically with elevation depressions or obstacles.