setup.prop.2D: Attaches a Property to a Two-Dimensional Grid

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/setup.prop.2D.R

Description

Calculates the value of a given property at the middle of grid cells (mid) and at the interfaces of the grid cells (int).

Two possibilities are available: either specifying a mathematical function (func) that describes the spatial dependency of the property, or asssuming a constant value (value). To allow for anisotropy, the spatial dependency can be different in the x and y direction.

For example, in a sediment model, the routine can be used to specify the porosity, the mixing intensity or other parameters over the grid of the reactangular sediment domain.

Usage

1
2
3
4
5
setup.prop.2D(func = NULL, value = NULL, grid, y.func = func, 
              y.value = value, ...)

## S3 method for class 'prop.2D'
contour(x, grid, xyswap = FALSE, filled = FALSE, ...)

Arguments

func

function that describes the spatial dependency in the x-direction; defined as func <- function (x,y, ...); it should return as many elements as in x or y

value

constant value given to the property in the x-direction

grid

list specifying the 2D grid characteristics, see setup.grid.2D for details on the structure of this list

y.func

function that describes the spatial dependency in the y-direction; defined as y.func <- function (x, y, ...); it should return as many elements as in x or y. By default the same as in the x-direction.

y.value

constant value given to the property in the y-direction. By default the same as in the x-direction.

x

the object of class prop.2D that needs plotting

filled

if TRUE, uses filled.contour, else contour

xyswap

if TRUE, then x- and y-values are swapped and the y-axis is oriented from top to bottom. Useful for drawing vertical depth profiles

...

additional arguments that are passed on to func or to the method

Details

Value

A list of type prop.2D containing:

x.mid

property value in the x-direction defined at the middle of the grid cells; Nx * Ny matrix (where Nx and Ny = number of cells in x, y direction)

y.mid

property value in the y-direction at the middle of the grid cells; Nx * Ny matrix

x.int

property value in the x-direction defined at the x-interfaces of the grid cells; (Nx+1)*Ny matrix

y.int

property value in the y-direction at the y-interfaces of the grid cells; Nx*(Ny+1) matrix

Note

For some properties, it does not make sense to use y.func different to func. For instance, for volume fractions, AFDW.

For other properties, it may be usefull to have y.func or y.value different from func or value, for instance for velocities, surface areas, ...

Author(s)

Filip Meysman <filip.meysman@nioz.nl>, Karline Soetaert <karline.soetaert@nioz.nl>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Inverse quadratic function 
inv.quad <- function(x, y, a = NULL, b = NULL)
   return(1/((x-a)^2+(y-b)^2))


# Construction of the 2D grid 
x.grid <- setup.grid.1D (x.up = 0, L = 10, N = 10)
y.grid <- setup.grid.1D (x.up = 0, L = 10, N = 10)
grid2D <- setup.grid.2D (x.grid, y.grid)

# Attaching the inverse quadratic function to the 2D grid 
(twoD <- setup.prop.2D (func = inv.quad, grid = grid2D, a = 5, b = 5))

# show 
contour(log(twoD$x.int))

ReacTran documentation built on Dec. 18, 2019, 3:12 a.m.