Description Details Slots Examples
A description of a process that transfers mass from one domain to
another. A common example is the dissolution of NAPL into groundwater.
In this case, slot from may be "NAPL", slot to may
be "plume" and slot flux will be a function which returns
the rate of mass transfer (dissolution) from the NAPL domain into the
plume domain, as a function of the NAPL mass.
The flux function must at least have the five arguments named
above, as well as any arguments for the parameters within the function,
even if in fact they are not all used. The function may also use
variables that will exist in the DNST solver function by
using, for example, get("qh", env). Typically, qh will
feature somewhere in some functions, as the dissolution mass flux, for
example, will depend on the water speed through the source zone.
qh is given to DNST as a layer-by-layer function of
time, so it is common to use get("qh", env)[[LAY]](time) in the
flux function. Some functions may also use the M array in
order to include some dependency on the source zone history. When
included as part of a DNAPLmodel (as intended), the
function may use any of the parameters saved in the slot params
as well. Remember to subset these parameters by layer
(par[[LAY]]) when the parameters could vary by layer.
When used in DNST, the solver function, no flux is allowed
to reduce the mass of a domain below 0, so the solution is always
stable. Therefore, this needn't be worried about in the flux
function.
Mredistribution objects are created within the provided
DNAPLmodel creation functions
(cstG.DNmodel, cnvG.DNmodel and
DDpg.DNmodel currently). Defining your own
Mredistribution is fairly advanced and will require some
understanding of environments in R.
fromcharacter string; the domain from which mass is taken
tocharacter string; the domaint to which mass is sent
fluxfunction;
a function whose arguments are:
fromM: mass of from domain
toM: mass of to domain
LAY: the layer of the DNAPL model
time: in days since 30/12/1899
env: the calling function's environment
other parameters used within the function that are not got from the DNST
environment (see example)
and whose output represents the rate of mass transfer between the
from and to domains (negative outputs are permitted and
imply a flux the other way; in this way an equilibrium may be set up)
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 | # exponentially declining dissolution of a NAPL pool
## Not run:
Ndiss <- Mredistribution(from = "pool",
to = "plume",
flux = function(fromM, toM, LAY, time, env,
pool.width, pool.height, solubility){
# get historic maximum of mass from this layer
# - use get("M", env) to access the mass array from
# the DNST master function which will call this
# function
max.mass.so.far <- max(get("M", env)[LAY,, "pool"])
# to use this redistribution model, pool.width and
# pool.height will need to be defined in the global
# environment or, better, included in the params
# slot of the DNAPLmodel object which contains this
# Mredistribution object
Xsect.area <- pool.width*pool.height
# again, horizontal flow (Darcy velocity) is accessed
# by get("qh", env)
# solubility must be defined in the same way as
# pool.width and pool.height (see comment above)
solubility*Xsect.area*get("qh", env)[[LAY]](time)*fromM/max.mass.so.far
})
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.