Learn R Programming

ReacTran (version 1.4.3.1)

p.exp: Common Properties with Distance, to be used with setup.prop.1D

Description

Functions that define an y-property as a function of the one-dimensional x-coordinate. These routines can be used to specify properties and parameters as a function of distance, e.g. depth in the water column or the sediment.

They make a transition from an upper (or upstream) zone, with value y.0 to a lower zone with a value y.inf.

Particularly useful in combination with setup.prop.1D

  • p.exp: exponentially decreasing transition $$ y = y_{\inf} + (y_0-y_{\inf}) \exp(-\max(0,x-x_0)/x_a) $$

  • p.lin: linearly decreasing transition $$ y = y_0; y = y_0 - (y_0-y_{inf})*(x-x_L)/x_{att}) ; y = y_{inf} $$

    for \(0 \leq x \leq x_L\), \(x_L \leq x \leq x_L + x_{att}\) and \((x \geq x_L + x.att )\) respectively.

  • p.sig: sigmoidal decreasing transition $$ y = y_{inf} + (y_0-y_{inf})\frac{\exp(-(x-x_L)/ (0.25 x_{att}))}{(1+\exp(-(x-x_L))/(0.25 x_{att}))}) $$

Usage

p.exp(x, y.0 = 1, y.inf = 0.5, x.L = 0, x.att = 1)
p.lin(x, y.0 = 1, y.inf = 0.5, x.L = 0, x.att = 1)
p.sig(x, y.0 = 1, y.inf = 0.5, x.L = 0, x.att = 1)

Arguments

x

the x-values for which the property has to be calculated.

y.0

the y-value at the origin

y.inf

the y-value at infinity

x.L

the x-coordinate where the transition zone starts; for x <= x.0, the value will be equal to y.0. For x >> x.L + x.att the value will tend to y.inf

x.att

attenuation coefficient in exponential decrease, or the size of the transition zone in the linear and sigmoid decrease

Value

the property value, estimated for each x-value.

Details

For p.lin, the width of the transition zone equals x.att and the depth where the transition zone starts is x.L.

For p.sig, x.L is located the middle of the smooth transition zone of approaximate width x.att.

For p.exp, there is no clearly demarcated transition zone; there is an abrupt change at x.L after which the property exponentially changes from y.0 towards y.L with attenuation coefficient x.att; the larger x.att the less steep the change.

Examples

Run this code
# NOT RUN {
x <- seq(0, 5, len = 100)
plot(x, p.exp(x, x.L = 2), 
     xlab = "x.coordinate", ylab = "y value", ylim = c(0, 1))
lines(x, p.lin(x, x.L = 2), col = "blue")
lines(x, p.sig(x, x.L = 2), col = "red")
# }

Run the code above in your browser using DataLab