phaseR (version 2.0)

flowField: Flow Field

Description

Plots the flow or velocity field for a one or two dimensional autonomous ODE system.

Usage

flowField(deriv, xlim, ylim, parameters = NULL, system = "two.dim",
  points = 21, col = "gray", arrow.type = "equal",
  arrow.head = 0.05, frac = 1, add = TRUE, xlab = "x",
  ylab = "y", state.names = c("x", "y"), ...)

Arguments

deriv

A function computing the derivative at a point for the ODE system to be analysed. Discussion of the required format of these functions can be found in the package guide.

xlim

In the case of a two dimensional system, this sets the limits of the first dependent variable in which gradient reflecting line segments should be plotted. In the case of a one dimensional system, this sets the limits of the independent variable in which these line segments should be plotted. Should be a vector of length two.

ylim

In the case of a two dimensional system this sets the limits of the second dependent variable in which gradient reflecting line segments should be plotted. In the case of a one variable system, this sets the limits of the dependent variable in which these line segments should be plotted. Should be a vector of length two.

parameters

Parameters of the ODE system, to be passed to deriv. Supplied as a vector; the order of the parameters can be found from the deriv file. Defaults to NULL.

system

Set to either "one.dim" or "two.dim" to indicate the type of system being analysed. Defaults to "two.dim".

points

Sets the density of the line segments to be plotted. points segments will be plotted in the x and y directions. Fine tuning here, by shifting points up and down, allows for the creation of more aesthetically pleasing plots. Defaults to 11.

col

Sets the colour of the plotted line segments. Should be a vector of length one. Will be reset accordingly if it is a vector of the wrong length. Defaults to "gray".

arrow.type

Sets the type of line segments plotted. If set to "proportional" the length of the line segments reflects the magnitude of the derivative. If set to "equal" the line segments take equal lengths, simply reflecting the gradient of the derivative(s). Defaults to "equal".

arrow.head

Sets the length of the arrow heads. Passed to arrows. Defaults to 0.05.

frac

Sets the fraction of the theoretical maximum length line segments can take without overlapping, that they can actually attain. In practice, frac can be set to greater than 1 without line segments overlapping. Fine tuning here assists the creation of aesthetically pleasing plots. Defaults to 1.

add

Logical. If TRUE, the flow field is added to an existing plot. If FALSE, a new plot is created. Defaults to TRUE.

xlab

Label for the x-axis of the resulting plot. Defaults to "x".

ylab

Label for the y-axis of the resulting plot. Defaults to "y".

state.names

State names for ode functions that do not use positional states

Additional arguments to be passed to either plot or arrows.

Value

Returns a list with the following components (the exact make up is dependent upon the value of system):

add

As per input.

arrow.head

As per input.

arrow.type

As per input.

col

As per input, but with possible editing if a vector of the wrong length was supplied.

deriv

As per input.

dx

A matrix. In the case of a two dimensional system, the values of the derivative of the first dependent derivative at all evaluated points.

dy

A matrix. In the case of a two dimensional system, the values of the derivative of the second dependent variable at all evaluated points. In the case of a one dimensional system, the values of the derivative of the dependent variable at all evaluated points.

frac

As per input.

parameters

As per input.

points

As per input.

system

As per input.

x

A vector. In the case of a two dimensional system, the values of the first dependent variable at which the derivatives were computed. In the case of a one dimensional system, the values of the independent variable at which the derivatives were computed.

xlab

As per input.

xlim

As per input.

y

A vector. In the case of a two dimensional system, the values of the second dependent variable at which the derivatives were computed. In the case of a one dimensional system, the values of the dependent variable at which the derivatives were computed.

ylab

As per input.

ylim

As per input.

See Also

arrows, plot

Examples

Run this code
# NOT RUN {
# Plot the flow field, nullclines and several trajectories for the one
# dimensional autonomous ODE system logistic.
logistic.flowField <- flowField(logistic, xlim = c(0, 5), ylim = c(-1, 3),
                                parameters = c(1, 2), points = 21, system = "one.dim",
								add = FALSE)
logistic.nullclines <- nullclines(logistic, xlim = c(0, 5), ylim = c(-1, 3),
                                  parameters = c(1, 2), system = "one.dim")
logistic.trajectory <- trajectory(logistic, y0 = c(-0.5, 0.5, 1.5, 2.5), tlim = c(0, 5),
                                  parameters = c(1, 2), system = "one.dim")

# Plot the velocity field, nullclines and several trajectories for the two dimensional
# autonomous ODE system simplePendulum.
simplePendulum.flowField  <- flowField(simplePendulum, xlim = c(-7, 7),
                                       ylim = c(-7, 7), parameters = 5, points = 19,
									   add = FALSE)
y0                        <- matrix(c(0, 1, 0, 4, -6, 1, 5, 0.5, 0, -3), ncol = 2,
                                    nrow = 5, byrow = TRUE)
simplePendulum.nullclines <- nullclines(simplePendulum, xlim = c(-7, 7),
                                        ylim = c(-7, 7), parameters = 5, points = 500)
simplePendulum.trajectory <- trajectory(simplePendulum, y0 = y0, tlim = c(0, 10),
                                        parameters = 5)

# }

Run the code above in your browser using DataLab