xswms2d {SoPhy} | R Documentation |
Interactive surface that is used to define a soil profile and to give the physical and chemical properties for each horizon. It simulates the water flux and solute transport using swms2d by J. Simunek, T. Vogel, and M.Th. van Genuchten.
sophy(...) xswms2d(h, xlim, ylim, step, picture=NULL, water=list( TPrint=500, red=4, print=7, mesh=TRUE, lim.rf = 1, lim.swms2d = 1, TolTh=0.0001, TolH=0.01, lWat=TRUE, dt=1, dtMinMax = c(0.01, 60), max.iteration=1000, max.iter.prec=50000, iter.print=100, breakpoint=100, top.bound=2, top.value=0, bottom.bound=1, bottom.value=0 ), materials=list( thr=.02, ths=0.35, tha=0.02, thm=0.35, Alfa=0.041, n=1.964, Ks=0.000722, Kk=0.000695, thk=0.2875, first=1, second=1, angle=0, Hslope=0, Hseg=-100, POptm=-25, sharpness=1, Bulk.d=1500, Diffus=0, longiDisper=1, transvDisper=0.5, Adsorp=0.0004, SinkL1=-0.01, SinkS1=-0.01, SinkL0=0, SinkS0=0 ), Hinit = function(Hseg, depth) Hseg, model=list(model="exp", param=c(0, 0.25, 0, diff(ylim) * 0.1)), anisotropy=NULL, miller.link=function(rf) exp(sign(rf) * sqrt(abs(rf))), millerH = function(lambda) lambda, millerK = function(lambda) lambda^-2, millerT = function(lambda) 1, chemical=list( lChem=FALSE, Epsi=2, lUpW=1, lArtD=FALSE, PeCr=10, tPulse=500, top.bound=2, top.value=1, bottom.bound=1, bottom.value=0, root.uptake=0, intern.source=0 ), atmosphere=list( AtmInf=TRUE, tInit=0, Aqh=-.1687, Bqh=-.02674, hCritS=1.e30, GWL0L=ylim[2], rLen=diff(xlim) ), atm.periods=1, atm.data=c( end=100000000, prec=0, cPrec=0, rSoil=0, rRoot=0, hCritA= 1000000, rGWL=0, GWL=0, crt=0, cht=0 ), stone=list( value=NA, lambda=0, no.upper=FALSE, no.lower=TRUE, no.overlap=FALSE, main.distr=rnorm, main.mean=diff(ylim)/20, main.s=diff(ylim)/400, sec.distr=rnorm, sec.mean=diff(ylim)/50, sec.s=diff(ylim)/400, phi.distr=rnorm, phi.mean=1, phi.s=0 ), plant.types=1, Kf=function(plant, distances, depth, rf, param=list(field.value=1, field.factor=0)) rep(param$field.value, length(rf)) + param$field.factor * rf, beta=function(plant, distances, depth, rf, param=list(beta.value=1, beta.factor=0)) rep(param$beta.value, length(rf)) + param$beta.factor * rf, root=list( plants.lambda=0, plants.mindist=diff(xlim) / 20, mean=sqrt(diff(ylim) * diff(xlim)), sd=sqrt(diff(ylim) * diff(xlim)) / 5, knot.probab=0.1, knot.mindist = 5 * step, shoots.3=0.4, shoots.4=0, stop.probab=function(knot, dist, m, s) 1 - exp(-m + s * dist), stop.m=0, stop.s=0, rf.link=function(v, m, s){ v <- s * v m * (exp(sign(v) * sqrt(abs(v))))^(-2) }, rf.m=0, rf.s=0, no.own.root=TRUE, age.bonus=1.2, depth.bonus=5.2, side.bonus=5.1, diagonal=TRUE, dir.ch=3.71, dir.ch.s=0.5, rf.Kf=FALSE, P0=-10, P2H=-200, P2L=-800, P3=-8000, r2H=0.5, r2L=0.1, root.condition=3, root.uptake=-150 ), root.zone = NULL, col.rf = NULL, col.simu = NULL, MaxIt=20, hTab=c(0.001,200), DMul=c(1.1, 0.33), col.rect="red", col.bg="yellow", col.sep="gray", col.left="red", col.mid="darkgreen", col.right="darkgreen", col.line="red", col.txt="black", col.submenue="darkgreen", col.subord="steelblue", col.forbid="gray88", col.bg.forbid="lightyellow", col.flash="blue", ## drawing configure CFLAGS="-O2 -Wall -pedantic" col.hor=c("#000000", "#996600", "#660000", "#CC9933", "#666600", "#CCCC99", "#CCCCCC", "#990000", "#FFCC00", "#FFFFCC"), col.draw="green", col.mess="red", col.mesh="blue", col.mesh.pt="green", col.exception = c("brown", "lightgray"), cex.eval = 0.8, areas=is.null(h$picture), PrintLevel=RFparameters()$Print, new=TRUE, X11.width=9.5, X11.height=X11.width * 0.789, frequent.reset = TRUE, update=FALSE, waterflow=FALSE, zlim = NULL, Zlim = NULL, print.par=list(ps="sophy", height=3, titl=TRUE, legend = TRUE) )
h |
a list of the output format, see the Details.
If h is given the parameters xlim , ..., col.simu
are ignored. |
xlim |
vector of two elements. The horizontal extension of the
profile, see also
picture . If diff(xlim) is not an integer multiple of
step then xlim[2] is decreased suitably. |
ylim |
vector of two elements. The vertical extension of the
profile, see also
picture . If diff(ylim) is not an integer multiple of
step then ylim[2] is decreased suitably. |
step |
numeric. the grid spacing for both directions. The finite element method is essentially based on a quadratic mesh. |
picture |
array or file name for a digitised profile in tif or jpeg
format; if picture
is an array it must have three dimensions, where the third
dimension has 3 or 4 components (RGB or RGBA format).
If picture is given then either xlim or
ylim might be missing and is calculated from the other lim
parameter and the dimension of the picture. |
water |
{swms2d, water} list of the following components
|
materials |
{material (phys) / material (chem)};
thr ,...,sharpness are found in the menue for the
physical
properties, Bulk.d ,...,SinkS0 in the menue for
the chemical
ones. List has the following components
|
Hinit |
function of two variables; the first varible is
a vector of Hseg , the second the depths d.
the initial h values are calculated as
where Z is the simulated random field. The initial h value may afterwards be modified for certain segments due to the given boundary conditions and to a given given Dirichlet condition for the roots. |
model |
{structure} the covariance model for the Gaussian random
fields used for the definition of the Miller similar media.
See CovarianceFct for details on the
definiton of the covariance model.
If the mean equals NA and if it is the last horizon,
the area is interpreted as air. |
anisotropy |
logical or NULL . If logical it overrides the
anisotropy condition given by model. If model was
anisotropic and anisotropic=FALSE , the first anisotropic
scale parameter is used as scale for the isotropic model.
If model is isotropic, only the representation is changed,
and the user has the opportunity to change the values to an
truely anisotropic model. |
miller.link |
function that transforms the Gaussian
random field to a
field of non-negative values. The argument and the value are
matrices (of the same size). If NULL the miller.link
is the identity.
|
millerH |
function that transforms the miller.link ed
field into a field of water potential H.
This field is used for areas of constant potential, and for the
potential at starting time. For the latter the millerH
transformed field is further transformed linearly by
a function of
$matrials$Hslope , see Hinit , and $matrials$Hseg .
The argument and the value are
matrices (of the same size). |
millerK |
function that transforms the miller.link ed
field into a field of scaling factors that are
associated with the saturated hydraulic
conductivity. The argument and the value are
matrices (of the same size). |
millerT |
function that transforms the miller.link ed
field into a field of scaling factors that are
associated with the water content.
The argument and the value are
matrices (of the same size). |
chemical |
{swms2d (chem)} list of the following components
|
atmosphere |
{atmosphere, control}
list of the following components
|
atm.periods |
(maximum) number of atmospherical periods. Only
used if atm.data is a vector. Otherwise atm.periods
is set to the number of the rows of atm.data . |
atm.data |
{atmosphere, data}
vector of 10 components or matrix of 10 columns.
The 10 components are
|
stone |
{stones} list of the following components
|
plant.types |
positive integer. Number of different types of root systemes that will be generated |
Kf |
function(plant, distances, depths, rf,
param=list(field.value=1, field.factor=0)) .
According to the parameters the (Gaussian) random field get
a new value if there is a root pixel.
Here, plant is the type
of plant (scalar integer value 1..plant.types ),
distances a vector of distances from the
considered locations
to the surface along the root, depth is a vector of depths
of the considered locations, and rf is the value of the
Gaussian
random field (including the stones).
param is a list of named elements (possibly empty)
whose values can be
modified interactively; all parameters are real valued and the
usual magnitude of the range is 1; the names may not match any
name in the list for root , since the parameters are included
in the root list, which is passed to Kf as a whole.
The function is only used if root$rf.Kf is TRUE for the specific
plant type. This function is still in an experimental stage.
|
beta |
function(plant, distances, depths, rf,
param= list(beta.value=1, beta.factor=0)) .
beta gives the raw potential root
water uptake according to a single plant type, the
distances
to the beginning of the root, the depths , and rf (see
also Kf ). The raw potential
values are subsequently normed such that
they sum up to one. This gives
the potential root water uptake. param is a list of named
elements (possibly empty) whose values can be can be
modified interactively; all parameters are real valued and the
usual magnitude of the range is 1; the names may not match any
name in the list for root
or any parameter name within the parameter
list in Kf , since the parameters are included
into the root list, which is passed to beta as a whole. |
root |
{root growth} for plants.lambda to dir.ch.s
and{root, water uptake} otherwise. Any plant type is set to the values of root at starting time.
root is a list of the following components
|
root.zone |
NULL or function of one variable.
If not NULL then rootzone defines for any given
x coordinate the interval for the height of the rootzone.
A plant of species 1 is defined so that
all segments within the so defined root zone contains a root of this
plant.
|
col.rf |
sequence of colours that are used to show the
random field; if NULL then some internally
defined color sequence is used |
col.simu |
sequence of colours that are used to present any
simulation result by swms2d; if NULL then some internally
defined color sequence is used
|
MaxIt |
maximum number of iteration during any time step. |
hTab |
c(hTab1, hTabN) , interval of pressure heads
within which a table of hydraulic properties is generated. |
DMul |
c(dMul, dMul2) ,
dMul >= 1 ,
dMul2 <= 1 ;
if the number of required iterations is less than 4 or greater than 6
then the next time
step is multiplied by dMul and dMul2 , respectively. |
col.rect |
colour of the button for free input; see
eval.parameters |
col.bg |
colour of a interactive bar; see
eval.parameters |
col.sep |
colour of the separating line; see
eval.parameters |
col.left |
colour of preceding element; see
eval.parameters |
col.mid |
colour for the message; see
eval.parameters |
col.right |
colour of subsequent element; see
eval.parameters |
col.line |
colour of the marking line in interactive bars of
absolute choice; see eval.parameters |
col.txt |
colour of headers; see
eval.parameters |
col.submenue |
colour for the text in the main menue |
col.subord |
colour for the text in the title of a secondary menue |
col.forbid |
colour for text that indicate forbidden main menues, e.g. ‘polygon’ after having defined already the maximum number of allowed horizons |
col.bg.forbid |
background colour for forbidden menue points |
col.flash |
colour for hints or the titles of active windows |
col.hor |
vector of 10 components. Colours that are used to draw the horizons |
col.draw |
colour for drawing or showing selected horizons |
col.mess |
colour for warning or error messages |
col.mesh |
colour for the edges of the finite element mesh |
col.mesh.pt |
colour for the vertices of the finite element mesh |
col.exception |
vector of 2 components; colour plotted values
that are below or above the given range of zlim ,
see lim.swms2s and zlim . |
cex.eval |
value for the parameters cex and cex.i
of eval.parameters and
for the parameter cex.names in
ShowModels .
|
areas |
logical. If TRUE the horizons are coloured. If
FALSE only the border lines between the horizons are given. |
PrintLevel |
If <=0 nothing is printed. The higher the value the more information is given. |
new |
logical or NULL . If TRUE the interactive plot is
opened in a new window. If NULL then the interactive window
is not opened and the standard definitions are returned. |
X11.width |
numeric. Width of the window. Only used if
new=TRUE . |
X11.height |
numeric. Height of the window. Only used if
new=TRUE . |
frequent.reset |
logical.
Background: the current implementation of xswms2d
uses split.screen to build the interactive plot;
split.screen memorises all changings in the plot and
replays them all if the X11 window has to be rebuilt.
If frequent.reset=TRUE then the memory effect is reduced
at the cost of some flickering of the X11 window in the main menu.
|
update |
{updating} logical. If TRUE the simulations are
updated after any changing of the parameters.
Independently of the value of update an update of the
simulation is performed if the user clicks on any of the given
titles or subtitles of the submenu.
|
waterflow |
{water flow} logical. If TRUE swms2d is run |
zlim |
vector of 2 components or NULL which gives the
limits for the plotted values in the image s. If
NULL then zlim is calculated internally, cf.
plotWater .
|
Zlim |
vector of 2 components or NULL which gives the
limits for the plotted values in ShowModels .
|
print.par |
{postscript} list of the following components
|
... |
sophy is alias for xswms2d and
takes the same arguments as xswms2d . |
The interactive plot is organised as follows:
picture
)
and the user draws the boundaries of the horizons by
a sequence of left mouse button clicks.miller.link
and then millerK
has been applied.
(In the standard setting, the modulus of the
Gaussian random field is anti-proportional to the root of the
hydraulic conductivity K and proportional to
the initial
water potential H.)The menue points of the interactive plot are
print.par
.ShowModels
for details,
miller.link
. If the model
is anisotrope or
anisotrop=TRUE
is given explicitely, the models are shown
for the two main axis.FALSE
TRUE
then the
(isotropic) covariance model is
rescaled such that at distance 1 the value of the model is
approximately 0.05.
=NA
the angle equals the angle of the anisotropy
specification.
TRUE
then
the same transformation as for the hydraulic conductivity
parameter alpha_k is applied, i.e.,
millerK(miller.link( ))
This menue is left by the right mouse button. A menue for choosing another variogram model is reached. Again, the right mouse button leaves the menue.
The first horizon gets as default the model and the
parameter values passed to xswms2d
by model
and
anisotropy
.
For the following horizons the values of the previously considered
horizon are taken over, when considered first.
plant.types
is
greater than 1, the user first chooses among the different types,
then enters
the submenue. ‘plant type’ is used to name a species only,
and
is used nowhere else. The decription of all the other variables
(‘mean # of plants’,...,‘no dir. change, rel. sd’)
is given above; see
the input variable root
.materials
.materials
.root
.atm.data
for a description.
If nrow(atm.data)
or atm.periods
is greater than 1
then the user chooses the atmospherical period first.water
for a descriptionchemical
for a
descriptionatmosphere
for a descriptionHere, a simulation is redone from scratch, based on a new random seed.
water$red
) the
finite
element mesh can be coarsened for faster simulations. If the
coarsening is genuine, i.e. water$red
>1, then this
menue point is active. If pressed, a simulation is performed on
the original finite element mesh.General information
h$max.horizon
=10.
NA
within the menue
‘structure’, then this part of the profile is interpreted as
air and
the previously defined horizons are genuine ones.
Any other horizon but the last one should not have mean
NA
.
simulateHorizons
and the references therein for further details on the stochastic
simulation. See the SWMS2D manuscript for details on SWMS2D.
sophy
is a synonym for xswms2d
A list is returned, where
the first 10 components contain the definitions of the
horizons; these 10 components
are called by their position in the list. Any other list component
does not have a predefined location and may be called only by name.
Note that if sophy
or xswms2d
is called with
parameter new=NULL
the interactive window is not opened, but
the initial list (of h
) is returned immediately.
1:10 |
Each of the first 10 components is a list of the following
elements:
|
grid.x |
seq(xlim[1], xlim[2], step) |
grid.y |
seq(ylim[1], xlim[2], step) |
idx.rf |
integer. Matrix of size
length(grid.x) x length(grid.y)
indicates the affiliation to a horizon or polygon (number is
decremented by 1, i.e., 0,...,h\$n -1), see also
the output variable border within the specific horizons.
It allows also for the indication of the presence of a stone; then, if a stone is present, the horizon number is incremented by h$max.horizon .
The modulus by h$max.horizon gives the by 1 decremented
number of the horizon. |
n |
current number of horizons |
step |
input parameter step |
max.horizons |
maximum number of horizons; currently 10. The value of this variable may never be changed! |
beta |
input parameter beta |
root |
list, where length(root) equals the
input parameter plant.types .
Each component of the list is a list with the same components as
the input parameter root . Additionally, it has the
components
|
atmophere |
input parameter atmosphere |
atm.data |
matrix of 10 columns, corresponding to the input
parameter atm.data and atm.periods . |
water |
input parameter water |
chem |
input parameter chemical |
Kf |
input parameter Kf |
RF |
matrix of size
length(grid.x) x length(grid.y) or
NULL .
RF contains the Gaussian random field resulting from all
definitions for the horizons.
RF is NULL if
simulate.horizon has not been called yet. |
Stones.RF |
matrix of size
length(grid.x) x length(grid.y) or
NULL .
The value of Stones.RF is
the Gaussian random field modified by the
stones (concerning hydraulic conductivity).
Stones have usually value NA , whereas air has value
NaN .
Stones.RF is NULL if
simulate.horizon has not been called yet or terminated
with an error. Further Stones.RF is set to NULL if
materials$sharpness has been changed, or ‘structure’,
‘undo’, ‘horizon’, or ‘polygon’ has
been called. |
Root.RF |
matrix of size
length(grid.x) xlength(grid.y) or
NULL .
The value of Root.RF is the value of Stones.RF
modified by the roots (concerning hydraulic conductivity).
That is, if root$rf.Kf is TRUE
the values at the respecitve root segments are given by
h$KF .
Root.RF is NULL if
simulate.horizon has not been called yet or terminated
with an error. Further Root.RF is set to NULL if
materials$sharpness has been changed, or ‘structure’,
‘undo’, ‘horizon’, or ‘polygon’ has
been called. |
m.link |
link function used in the submenue ‘structure’,
currently the function is identical to miller.link |
miller.link |
input parameter miller.link |
col.rf |
input parameter col.rf if not NULL and
the internally defined sequence of colors otherwise |
col.simu |
input parameter col.simu if not NULL and
the internally defined sequence of colors otherwise
|
random.seed |
list or NULL .
Each element contains the random seed for the
simulation of the Gaussian random field in the respective horizon.
random.seed is NULL if
simulateHorizons
has not been called yet.
|
stone.random.seed |
The random seed for the simulation of the stones |
root.random.seed |
The random seed for the simulaton of the roots |
rf.complete |
logical. TRUE if the stochastic simulation
has been performed completely. |
plants |
list or NULL .
Each component contains the information on the roots of
a single plant. Each component is a matrix of 8 columns and rows
according to the number of root segments.
The 8 columns are
plants is NULL if simulateHorizons
has not been called yet, or any parameter in root
has been changed.
|
plants.idx |
vector or NULL . plant.idx[i] gives the
plant type (1,...,plant.types )
of the i th simulated plant.
plants.idx is NULL if
create.roots or simulateHorizons
has not been called yet. |
water.x |
the coordinates of grid.x after thinning by
factor water$red |
water.y |
the coordinates of grid.y after thinning by
factor water$red |
flux |
logical vector of
length(water.x) x length(water.y) elements.
flux indicates which pixels of the
length(water.x) xlength(water.y)
grid are used in the SWMS2D simulation. (Pixel are left out
if they indicate stones (NA ) or air (NaN ).) |
swms2d |
three dimensional array or NULL .
The first dimension has 6 components which are
sum(flux) .
swms2s is NULL if
the water flux has not been simulated yet
because no simulation has been performed or one of the stochastic
simulations (Gaussian random field, stones, roots) failed,
or ‘water flow’ has been
set to ‘no’. Further swms2d is set to NULL
if an error occurs when trying to plot
the SWMS2D simulation results (by plotWater ); this
happens if the result has no finite values.
Finally, swms2d is set to NULL if a relevant
parameters was changed, such as those in
atmosphere , atm.data , materials , chem
or water .
|
Any of the lists that contain input parameters may have the additional
component .history
, an internal variable used by the
interactive menue algorithm that gives the last entries by the user;
see eval.parameters
.
The user should consider the following parameters
of h[[i]]
as being read-only:
cut.x
cut.y
border
idx
Further, h$max.horizon
may never be changed.
The phrases in brackets in the argument section of this documents give the respective menue points of the interactive plot.
Martin Schlather, martin.schlather@math.uni-goettingen.de http://www.stochastik.math.uni-goettingen.de/institute
calculate.horizons
,
create.roots
,
create.stones
,
create.waterflow
,
draw.horizons
,
modify.horizons
,
plotRF
,
plotWater
,
simulateHorizons
,
SoPhy
,
swms2d
## Not run: ### without underlying profile h0 <- xswms2d(xlim=c(1, 100), ylim=c(1, 100), step=1) # or, equivalently: # h1 <- sophy(xlim=c(1, 100), ylim=c(1, 100), step=1) ### underlying profile ### the profile was taken by M. Flury, J. Leuenberger, ### B. Studer, W.A. Jury and H. Fl\"uhler, see also URL ### \url{http://www.ito.umnw.ethz.ch/SoilPhys/Fliessmuster/projekt_flury.html} pic <- paste(system.file(package='SoPhy'), 'tracer', 'K06', sep="/") h <- xswms2d(xlim=c(0,160), step=1, aniso=TRUE, update=FALSE, waterflow=FALSE, pict=pic) ### repeated call h <- xswms2d(h=h, update=TRUE, waterflow=TRUE) ### an example for non-atmospheric root uptake h <- sophy(xl=c(1,10), yl=c(1,10), step=0.1, new=NULL) ## get standard h$root[[1]]$root.condition <- 1 ## dirichlet condition for roots h$root[[1]]$root.uptake <- -200 ## value for dirichlet condition h$root[[1]]$plants.lambda <- 0.07 ## intensity of plants h$water$TPrint <- 2 ## end point of simulation (film lasts about 2 min) h$water$red <- 1 ## precise simulation h$water$breakpoint <- 3 ## high image frequency (close to a film) h$water$top.bound <- 2 ## dirichlet h$water$top.value <- -8 ## value on the boundary h <- xswms2d(h=h, update=TRUE, waterflow=TRUE) ## End(Not run)