MassTrack: MassTrack

Description Usage Arguments Value Examples

View source: R/MassTrack.R

Description

Track particle mass along a MODPATH-5 generated pathline

Usage

1
2
3
4
MassTrack(ptl = "pathline", gwnc, wtop = "wtop.nc", phi, m0 = 1,
  retain.storage = TRUE, truncate = TRUE, confined = FALSE,
  outmass = TRUE, loss = TRUE, outmass.array = FALSE,
  tlumpoutmass = FALSE, linear.decay = FALSE, react.loss = TRUE, end.t)

Arguments

ptl

a data.frame, data.table or string giving the path to a data file containing a pathline data set produced by MODPATH

gwnc

a NetCDF of MODFLOW simulation data produced by GW.nc, or a path to one

wtop

a NetCDF of water height or path to one (MassTrack can generate one if this hasn't been made)

phi

porosity: single value, layer by layer (vector) or distributed array

m0

initial mass of particles: single value, vector of values or function of time only

retain.storage

should mass flux to storage be retained on a pathline?

truncate

if TRUE, once a particle is completely drained, further trajectory information is not returned with the result

confined

not yet implemented

outmass

return cell referenced information about where the mass is abstracted?

loss

return information about where particle mass is not released

outmass.array

logical [1]; if outmass = TRUE, then outmass.array = TRUE signals that the abstracted mass information should be returned in an array rather than a data.table

tlumpoutmass

logical [1]; should the outmass array only show the spatial cell location (TRUE), or show during which time step the abstractions occurred as well (in which case the outmass array will be four-dimensional and potentially very large)

linear.decay

double [1]; linear decay constant, defaults to 0 which is no decay

react.loss

logical [1]; similar to outmass, save locational reaction loss information?

end.t

double [1]; specify the end time of the simulation; if missing, it will be inferred from ptl, but the last particles to arrive at an abstraction may not be drained because the simulation will be assumed to have finished as soon as or just after they arrive

Value

A list of results:
$trace, data.table: the pathline data table with new columns for mass and, if outmass.array = FALSE, mass loss and reactive mass loss
$outmass, numeric array: if outmass = TRUE and outmass.array = TRUE, the mass removed from the system by column, row and layer and, if tlumpoutmass = FALSE, time step
$react.loss, numeric array: as with outmass but for reactive loss
$loss, numeric [Np]: mass which is lost otherwise (e.g. particle wasn't released)

Only requested outputs are returned and if only traces are returned, then the data table is not put in a list.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# MODFLOW NetCDF dataset
library("RNetCDF")
mfdata <- open.nc(system.file("masstrack_mf_demo.nc",
                              package = "MassTrack"))

# pathline file
library("data.table")
ptl <- fread(system.file("masstrack_mp_demo.ptl",
                         package = "MassTrack"), skip = 1L)

# run MassTrack
# - this will generate a new NetCDF for the water top (see wtop
#    argument)
# - a simple example in which all particles start with mass 1, and there
#    is no degradationg
mt <- MassTrack(ptl, mfdata, "MT_EXAMPLE_wtop.nc", phi = .1, end.t = 1500)

# plot results
# - plot MODFLOW model boundaries
library("Rflow")
MFimage(is.na(var.get.nc(mfdata, "Head",
                         c(NA, NA, 1L, 1L),
                         c(NA, NA, 1L, 1L))),
        gccs(mfdata), grcs(mfdata), 0:1,
        c("transparent", "grey"), asp = 1)

MFimage(var.get.nc(mfdata, "ConstantHead",
                   c(NA, NA, 1L, 1L),
                   c(NA, NA, 1L, 1L)) != 0,
        gccs(mfdata), grcs(mfdata), 0:1,
        c("transparent", "blue"), add = TRUE)

MFimage(var.get.nc(mfdata, "RiverLeakage",
                   c(NA, NA, 1L, 1L),
                   c(NA, NA, 1L, 1L)) != 0,
        gccs(mfdata), grcs(mfdata), 0:1,
        c("transparent", "green"), add = TRUE)

MFimage(var.get.nc(mfdata, "Wells",
                   c(NA, NA, 1L, 1L),
                   c(NA, NA, 1L, 1L)) != 0,
        gccs(mfdata), grcs(mfdata), 0:1,
        c("transparent", "red"), add = TRUE)

# plot pathlines
# - note that data.table subsetting often doesn't work with lines
ptl <- fread(system.file("masstrack_mp_demo.ptl",
                         package = "MassTrack"), skip = 1L)
setnames(ptl, c("ptlno", "x", "y", "z_off", "z",
                "t", "C", "R", "L", "timestep"))

for(p in unique(ptl$ptlno)) ptl[ptlno == p, lines(x, y)]

# plot particle masses
mt$traces[, points(x, y, pch = 16L, col = "darkgreen", cex = m)]

# you can save the results to file using rlist::list.save, for example
## Not run: 
  rlist::list.save(mt, "MT_EXAMPLE.rds")

## End(Not run)

CJBarry/MassTrack documentation built on May 6, 2019, 9:25 a.m.