Skip to content

Commit

Permalink
shorter example times for tracelines and capzone
Browse files Browse the repository at this point in the history
  • Loading branch information
cneyens committed Jul 30, 2024
1 parent cddb152 commit aad6055
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 83 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
^pkgdown$
^codecov\.yml$
^cran-comments\.md$
^CRAN-SUBMISSION$
15 changes: 8 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Package: raem
Title: Analytic Element Modeling of Steady Single-Layer Groundwater Flow
Version: 0.0.0.9000
Version: 0.1.0
Authors@R:
person("Cas", "Neyens", , "[email protected]", role = c("aut", "cre", "cph"))
Description: Analytic element modeling of steady-state, single-layer
groundwater flow under the Dupuit-Forchheimer assumption. Elements
such as wells, area-sinks and line-sinks can be placed at arbitrary
locations in the flow field. Output variables include hydraulic head
and the discharge vector. Tracelines can be computed numerically in
three dimensions.
groundwater flow under the 'Dupuit-Forchheimer' assumption. Elements
such as wells, area-sinks and line-sinks can be placed at arbitrary
locations in the flow field. Output variables include hydraulic head
and the discharge vector. Particle traces can be computed numerically
in three dimensions.
License: MIT + file LICENSE
URL: https://github.com/cneyens/raem, https://cneyens.github.io/raem/
BugReports: https://github.com/cneyens/raem/issues
Expand All @@ -24,6 +24,8 @@ Suggests:
sf,
terra,
testthat (>= 3.0.0)
VignetteBuilder:
knitr
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand All @@ -40,4 +42,3 @@ Collate:
'uniformflow.R'
'utils.R'
'well.R'
VignetteBuilder: knitr
71 changes: 38 additions & 33 deletions R/tracelines.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ outside_vertical <- function(aem, x, y, z, ...) {
#' @export
#' @seealso [capzone()]
#' @examples
#' # -------
#' # create a model with uniform background flow
#' k <- 10
#' top <- 10; base <- 0
#' n <- 0.2
Expand All @@ -199,14 +201,16 @@ outside_vertical <- function(aem, x, y, z, ...) {
#'
#' m <- aem(k, top, base, n = n, uf, rf)
#'
#' x0 <- -200; y0 <- seq(-200, 200, 50)
#' # calculate forward particle traces
#' x0 <- -200; y0 <- seq(-200, 200, 200)
#' times <- seq(0, 25 * 365, 365 / 4)
#' paths <- tracelines(m, x0 = x0, y0 = y0, z = top, times = times)
#' endp <- endpoints(paths)
#'
#' xg <- seq(-500, 500, length = 100)
#' yg <- seq(-300, 300, length = 100)
#'
#' # plot
#' contours(m, xg, yg, col = 'dodgerblue', nlevels = 20)
#' plot(paths, add = TRUE, col = 'orange')
#' points(endp[, c('x', 'y')])
Expand All @@ -215,58 +219,69 @@ outside_vertical <- function(aem, x, y, z, ...) {
#' paths_back <- tracelines(m, x0 = x0, y0 = y0, z0 = top, times = times, R = R, forward = FALSE)
#' plot(paths_back, add = TRUE, col = 'forestgreen', marker = 5*365, cex = 0.5)
#'
#' # Termination at wells and line-sinks
#' # -------
#' # Termination at wells, line-sinks and user-defined zone
#' w1 <- well(200, 50, Q = 250)
#' w2 <- well(-200, -100, Q = 450)
#' ls <- headlinesink(x0 = -100, y0 = 100, x1 = 400, y1 = -300, hc = 7)
#'
#' m <- aem(k, top, base, n = n, uf, rf, w1, w2, ls)
#' contours(m, xg, yg, col = 'dodgerblue', nlevels = 20)
#' plot(m, add = TRUE)
#'
#' x0 <- seq(-400, 400, 50); y0 <- 200
#' times <- seq(0, 5 * 365, 365 / 20)
#' paths <- tracelines(m, x0 = x0, y0 = y0, z0 = top, times = times)
#' plot(paths, add = TRUE, col = 'orange')
#'
#' # User-defined termination in rectangular zone
#' tzone <- cbind(x = c(-300, -200, -200, -300), y = c(150, 150, 100, 100))
#' termf <- function(t, coords, parms) {
#' x <- coords[1]
#' y <- coords[2]
#' in_poly <- x <= max(tzone[,'x']) & x >= min(tzone[,'x']) &
#' y <= max(tzone[,'y']) & y >= min(tzone[,'y'])
#' y <= max(tzone[,'y']) & y >= min(tzone[,'y'])
#' return(in_poly)
#' }
#'
#' x0 <- c(-300, -200, 0, 200, 300)
#' y0 <- 200
#' times <- seq(0, 5 * 365, 365 / 15)
#' paths <- tracelines(m, x0 = x0, y0 = y0, z0 = top, times = times, tfunc = termf)
#'
#' contours(m, xg, yg, col = 'dodgerblue', nlevels = 20)
#' plot(m, add = TRUE)
#' polygon(tzone)
#' plot(paths, add = TRUE, col = 'orange')
#'
#' # -------
#' # model with vertical flow due to area-sink
#' as <- areasink(xc = 0, yc = 0, N = 0.001, R = 1500)
#' m <- aem(k, top, base, n = n, uf, rf, w1, w2, as)
#'
#' # starting z0 locations are above aquifer top and will be reset to top with warning
#' x0 <- seq(-400, 200, 200); y0 <- 200
#' times <- seq(0, 5 * 365, 365 / 4)
#' paths <- tracelines(m, x0 = x0, y0 = y0, z0 = top + 0.5, times = times)
#'
#' contours(m, xg, yg, col = 'dodgerblue', nlevels = 20)
#' plot(m, add = TRUE)
#' plot(paths, add = TRUE, col = 'orange')
#'
#' # -------
#' # plot vertical cross-section of traceline 4 along increasing y-axis (from south to north)
#' plot(paths[[4]][,c('y', 'z')], type = 'l')
#'
#' @examplesIf parallel::detectCores() > 1
#' # -------
#' # parallel computing by setting ncores > 0
#' mp <- aem(k, top, base, n = n, uf, rf)
#'
#' x0 <- -200; y0 <- seq(-200, 200, 50)
#' times <- seq(0, 25 * 365, 365 / 4)
#' pathsp <- tracelines(mp, x0 = x0, y0 = y0, z = top, times = times, ncores = 2)
#'
#' # -------
#' # plot arrows
#' contours(m, xg, yg, col = 'dodgerblue', nlevels = 20)
#' plot(paths, add = TRUE, col = 'orange', arrows = TRUE, length = 0.05)
#'
#' # plot point markers every 2.5 years
#' contours(m, xg, yg, col = 'dodgerblue', nlevels = 20)
#' plot(paths, add = TRUE, col = 'orange', marker = 2.5 * 365, pch = 20)
#'
#' # plot point markers every 600 days
#' plot(paths, add = TRUE, col = 'forestgreen', marker = 600, pch = 1)
#'
tracelines <- function(aem, x0, y0, z0, times, forward = TRUE, R = 1, tfunc = NULL, tol = 1e-3, ncores = 0, ...) {

if(!is.null(tfunc) & !is.list(tfunc)) tfunc <- list(tfunc)
Expand Down Expand Up @@ -412,41 +427,31 @@ endpoints <- function(tracelines, ...) {
#' @export
#' @seealso [tracelines()]
#' @examples
#' # A model with vertical flow components
#' k <- 10
#' top <- 10; base <- 0
#' n <- 0.3
#'
#' uf <- uniformflow(TR = 100, gradient = 0.001, angle = -10)
#' rf <- constant(TR, xc = -1000, yc = 0, hc = 20)
#' w1 = well(200, 50, Q = 250)
#' w2 = well(-200, -100, Q = 450)
#' w1 <- well(200, 50, Q = 250)
#' w2 <- well(-200, -100, Q = 450)
#' as <- areasink(0, 0, N = 0.001, R = 1500)
#'
#' m <- aem(k, top, base, n = n, uf, rf, w1, w2)
#' m <- aem(k, top, base, n = n, uf, rf, w1, w2, as)
#'
#' # 5-year and 10-year capture zones
#' cp5 <- capzone(m, w1, time = 5*365)
#' cp10 <- capzone(m, w2, time = 10*365)
#' # 5-year capture zone at two different starting levels
#' cp5a <- capzone(m, w1, time = 5 * 365, zstart = base, npar = 6, dt = 365 / 4)
#' cp5b <- capzone(m, w1, time = 5 * 365, zstart = 8, npar = 6, dt = 365 / 4)
#'
#' xg <- seq(-800, 800, length = 100)
#' yg <- seq(-500, 500, length = 100)
#'
#' contours(m, xg, yg, col = 'dodgerblue', nlevels = 20)
#' plot(cp5, add = TRUE)
#' plot(cp10, add = TRUE, col = 'orange')
#'
#' # model with vertical flow components
#' as <- areasink(0, 0, N = 0.001, R = 1500)
#' m <- aem(k, top, base, n = n, uf, rf, w1, w2, as)
#'
#' # two different starting levels
#' cp5a <- capzone(m, w1, time = 5*365, zstart = base)
#' cp5b <- capzone(m, w1, time = 5*365, zstart = 8)
#'
#' contours(m, xg, yg, col = 'dodgerblue', nlevels = 20)
#' plot(cp5a, add = TRUE)
#' plot(cp5b, add = TRUE, col = 'forestgreen') # smaller zone
#'
#' # plot the convex hull of the endpoints as a polygon
#' # increase the number of particles to obtain a sharper delineation of the envelope
#' endp <- endpoints(cp5b)
#' hull <- chull(endp[, c('x', 'y')])
#' polygon(endp[hull, c('x', 'y')], col = adjustcolor('forestgreen', alpha.f = 0.7))
Expand Down
16 changes: 7 additions & 9 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
## Resubmission
This is a resubmission. In this version I have:

* Reduced the elapsed time of some examples.

* Handled words flagged as possibly misspelled in DESCRIPTION.

## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.

* checking examples ... [32s] NOTE
Examples with CPU (user + system) or elapsed time > 5s
user system elapsed
capzone 16.41 0.28 17.02
tracelines 12.42 0.33 14.34

The underlying computations require numerical integration which is slow.
Reducing the run time of the examples would require changing them in such a way that
they are no longer meaningful examples.

28 changes: 9 additions & 19 deletions man/capzone.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 30 additions & 15 deletions man/tracelines.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit aad6055

Please sign in to comment.