Title: | Phase Plane Analysis of One- And Two-Dimensional Autonomous ODE Systems |
---|---|
Description: | Performs a qualitative analysis of one- and two-dimensional autonomous ordinary differential equation systems, using phase plane methods. Programs are available to identify and classify equilibrium points, plot the direction field, and plot trajectories for multiple initial conditions. In the one-dimensional case, a program is also available to plot the phase portrait. Whilst in the two-dimensional case, programs are additionally available to plot nullclines and stable/unstable manifolds of saddle points. Many example systems are provided for the user. For further details can be found in Grayling (2014) <doi:10.32614/RJ-2014-023>. |
Authors: | Michael J Grayling [aut, cre] |
Maintainer: | Michael J Grayling <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.2.1 |
Built: | 2025-01-20 03:25:05 UTC |
Source: | https://github.com/mjg211/phaser |
phaseR is an R package for the qualitative analysis of one- and two-dimensional autonomous ODE systems, using phase plane methods. Programs are available to identify and classify equilibrium points, plot the direction field, and plot trajectories for multiple initial conditions. In the one-dimensional case, a program is also available to plot the phase portrait. Whilst in the two-dimensional case, additionally programs are available to plot nullclines and stable/unstable manifolds of saddle points. Many example systems are provided for the user.
Package: | phaseR |
Type: | Package |
Version: | 2.1 |
Date: | 2019-31-05 |
License: | GNU GPLv3 |
The package contains nine main functions for performing phase plane analyses:
drawManifolds
: Draws the stable and unstable manifolds
of a saddle point in a two dimensional autonomous ODE system.
findEquilibrium
: Identifies a nearby equilibrium point of
an autonomous ODE system based on a specified starting point.
flowField
: Plots the flow or velocity field of a one- or
two-dimensional autonomous ODE system.
nullclines
: Plots the nullclines of a two-dimensional
autonomous ODE system.
numericalSolution
: Numerically solves a two-dimensional
autonomous ODE system in order to plot the two dependent variables against
the independent variable.
phasePlaneAnalysis
: Provides a simple means of performing
a phase plane analysis by typing only numbers in to the command line.
phasePortrait
: Plots the phase portrait of a
one-dimensional autonomous ODE system, for use in classifying equilibria.
stability
: Performs stability, or perturbation, analysis
in order to classify equilibria.
trajectory
: Numerically solves a one- or two-dimensional
ODE system to plot trajectories in the phase plane.
In addition, the package contains over 25 derivative functions for example systems. Links to these can be found in the package index.
An accompanying vignette containing further information, examples, and
exercises, can also be accessed with
vignette("introduction", package = "phaseR")
.
This package makes use of the ode
function in the
package deSolve
.
Michael J Grayling ([email protected])
Contributors: Gerhard Burger, Tomas Capretto, Stepehn P Ellner, John M Guckenheimer
A function such that we can apply DRY in param documentation
.paramDummy(state.names)
.paramDummy(state.names)
state.names |
The state names for |
The derivative function of the species competition model, an example of a two-dimensional autonomous ODE system.
competition(t, y, parameters)
competition(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent
variables, to evaluate the derivative at. Should be a
|
parameters |
The values of the parameters of the system. Should be a
|
competition
evaluates the derivative of the following coupled ODE
system at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
Plots the stable and unstable manifolds of a saddle point. A search procedure is utilised to identify an equilibrium point, and if it is a saddle then its manifolds are added to the plot.
drawManifolds( deriv, y0 = NULL, parameters = NULL, tstep = 0.1, tend = 100, col = c("green", "red"), add.legend = TRUE, state.names = c("x", "y"), method = "lsoda", ... )
drawManifolds( deriv, y0 = NULL, parameters = NULL, tstep = 0.1, tend = 100, col = c("green", "red"), add.legend = TRUE, state.names = c("x", "y"), method = "lsoda", ... )
deriv |
A function computing the derivative at a point for the ODE
system to be analysed. Discussion of the required structure of these
functions can be found in the package vignette, or in the help file for the
function |
y0 |
The initial point from which a saddle will be searched for. This
can either be a |
parameters |
Parameters of the ODE system, to be passed to |
tstep |
The step length of the independent variable, used in numerical
integration. Decreasing the absolute magnitude of |
tend |
The final time of the numerical integration performed to identify the manifolds. |
col |
Sets the colours used for the stable and unstable manifolds.
Should be a |
add.legend |
Logical. If |
state.names |
The state names for |
method |
Passed to |
... |
Additional arguments to be passed to plot. |
Returns a list
with the following components:
add.legend |
As per input. |
col |
As per input, but with possible editing if a
|
deriv |
As per input. |
method |
As per input. |
parameters |
As per input. |
stable.1 |
A |
stable.2 |
A |
tend |
As per input. |
unstable.1 |
A |
unstable.2 |
A |
y0 |
As per input. |
ystar |
Location of the identified equilibrium point. |
Michael J Grayling, Stephen P Ellner, John M Guckenheimer
The derivative function of an example one-dimensional autonomous ODE system.
example1(t, y, parameters)
example1(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The value of y, the dependent
variable, to evaluate the derivative at. Should be a
|
parameters |
The values of the parameters of the system. Not used here. |
example1
evaluates the derivative of the following ODE at the point
(t, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the value of the
derivative at (t, y).
Michael J Grayling
The derivative function of an example two-dimensional autonomous ODE system.
example10(t, y, parameters)
example10(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example10
evaluates the derivatives of the following coupled ODE
system at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
The derivative function of an example two-dimensional autonomous ODE system.
example11(t, y, parameters)
example11(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example11
evaluates the derivatives of the following coupled ODE
system at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
# Plot the velocity field, nullclines and several trajectories example11_flowField <- flowField(example11, xlim = c(-5, 5), ylim = c(-5, 5), points = 21, add = FALSE) y0 <- matrix(c(4, 4, -1, -1, -2, 1, 1, -1), 4, 2, byrow = TRUE) example11_nullclines <- nullclines(example11, xlim = c(-5, 5), ylim = c(-5, 5), points = 200) example11_trajectory <- trajectory(example11, y0 = y0, tlim = c(0, 10)) # Determine the stability of the equilibrium points example11_stability_1 <- stability(example11, ystar = c(0, 0)) example11_stability_2 <- stability(example11, ystar = c(0, 2)) example11_stability_3 <- stability(example11, ystar = c(1, 1)) example11_stability_4 <- stability(example11, ystar = c(3, 0))
# Plot the velocity field, nullclines and several trajectories example11_flowField <- flowField(example11, xlim = c(-5, 5), ylim = c(-5, 5), points = 21, add = FALSE) y0 <- matrix(c(4, 4, -1, -1, -2, 1, 1, -1), 4, 2, byrow = TRUE) example11_nullclines <- nullclines(example11, xlim = c(-5, 5), ylim = c(-5, 5), points = 200) example11_trajectory <- trajectory(example11, y0 = y0, tlim = c(0, 10)) # Determine the stability of the equilibrium points example11_stability_1 <- stability(example11, ystar = c(0, 0)) example11_stability_2 <- stability(example11, ystar = c(0, 2)) example11_stability_3 <- stability(example11, ystar = c(1, 1)) example11_stability_4 <- stability(example11, ystar = c(3, 0))
The derivative function of an example two-dimensional autonomous ODE system.
example12(t, y, parameters)
example12(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example12
evaluates the derivatives of the following coupled ODE
system at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
# Plot the velocity field, nullclines and several trajectories example12_flowField <- flowField(example12, xlim = c(-4, 4), ylim = c(-4, 4), points = 17, add = FALSE) y0 <- matrix(c(2, 2, -3, 0, 0, 2, 0, -3), 4, 2, byrow = TRUE) example12_nullclines <- nullclines(example12, xlim = c(-4, 4), ylim = c(-4, 4), points = 200) example12_trajectory <- trajectory(example12, y0 = y0, tlim = c(0, 10)) # Determine the stability of the equilibrium points example12_stability_1 <- stability(example12, ystar = c(1, 1)) example12_stability_2 <- stability(example12, ystar = c(-1, -1))
# Plot the velocity field, nullclines and several trajectories example12_flowField <- flowField(example12, xlim = c(-4, 4), ylim = c(-4, 4), points = 17, add = FALSE) y0 <- matrix(c(2, 2, -3, 0, 0, 2, 0, -3), 4, 2, byrow = TRUE) example12_nullclines <- nullclines(example12, xlim = c(-4, 4), ylim = c(-4, 4), points = 200) example12_trajectory <- trajectory(example12, y0 = y0, tlim = c(0, 10)) # Determine the stability of the equilibrium points example12_stability_1 <- stability(example12, ystar = c(1, 1)) example12_stability_2 <- stability(example12, ystar = c(-1, -1))
The derivative function of an example two-dimensional autonomous ODE system.
example13(t, y, parameters)
example13(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example13
evaluates the derivatives of the following coupled ODE
system at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
The derivative function of an example two-dimensional autonomous ODE system.
example14(t, y, parameters)
example14(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example14
evaluates the derivatives of the following coupled ODE
system at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
The derivative function of an example two-dimensional autonomous ODE system.
example15(t, y, parameters)
example15(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example15
evaluates the derivatives of the following coupled ODE
system at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
The derivative function of an example one-dimensional autonomous ODE system.
example2(t, y, parameters)
example2(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The value of y, the dependent
variable, to evaluate the derivative at. Should be a
|
parameters |
The values of the parameters of the system. Not used here. |
example2
evaluates the derivative of the following ODE at the point
(t, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the value of the
derivative at (t, y).
Michael J Grayling
# Plot the flow field and several trajectories example2_flowField <- flowField(example2, xlim = c(0, 4), ylim = c(-1, 3), system = "one.dim", add = FALSE, xlab = "t") example2_trajectory <- trajectory(example2, y0 = c(-0.5, 0.5, 1.5, 2.5), tlim = c(0, 4), system = "one.dim") # Plot the phase portrait example2_phasePortrait <- phasePortrait(example2, ylim = c(-0.5, 2.5), frac = 0.5) # Determine the stability of the equilibrium points example2_stability_1 <- stability(example2, ystar = 0, system = "one.dim") example2_stability_2 <- stability(example2, ystar = 1, system = "one.dim") example2_stability_3 <- stability(example2, ystar = 2, system = "one.dim")
# Plot the flow field and several trajectories example2_flowField <- flowField(example2, xlim = c(0, 4), ylim = c(-1, 3), system = "one.dim", add = FALSE, xlab = "t") example2_trajectory <- trajectory(example2, y0 = c(-0.5, 0.5, 1.5, 2.5), tlim = c(0, 4), system = "one.dim") # Plot the phase portrait example2_phasePortrait <- phasePortrait(example2, ylim = c(-0.5, 2.5), frac = 0.5) # Determine the stability of the equilibrium points example2_stability_1 <- stability(example2, ystar = 0, system = "one.dim") example2_stability_2 <- stability(example2, ystar = 1, system = "one.dim") example2_stability_3 <- stability(example2, ystar = 2, system = "one.dim")
The derivative function of an example two-dimensional autonomous ODE system.
example3(t, y, parameters)
example3(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example3
evaluates the derivatives of the following coupled ODE system
at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
The derivative function of an example two-dimensional autonomous ODE system.
example4(t, y, parameters)
example4(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example4
evaluates the derivatives of the following coupled ODE system
at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
# Plot the velocity field, nullclines and several trajectories example4_flowField <- flowField(example4, xlim = c(-3, 3), ylim = c(-5, 5), points = 19, add = FALSE) y0 <- matrix(c(1, 0, -1, 0, 2, 2, -2, 2, -3, -4), 5, 2, byrow = TRUE) example4_nullclines <- nullclines(example4, xlim = c(-3, 3), ylim = c(-5, 5)) example4_trajectory <- trajectory(example4, y0 = y0, tlim = c(0,10))
# Plot the velocity field, nullclines and several trajectories example4_flowField <- flowField(example4, xlim = c(-3, 3), ylim = c(-5, 5), points = 19, add = FALSE) y0 <- matrix(c(1, 0, -1, 0, 2, 2, -2, 2, -3, -4), 5, 2, byrow = TRUE) example4_nullclines <- nullclines(example4, xlim = c(-3, 3), ylim = c(-5, 5)) example4_trajectory <- trajectory(example4, y0 = y0, tlim = c(0,10))
The derivative function of an example two-dimensional autonomous ODE system.
example5(t, y, parameters)
example5(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example5
evaluates the derivatives of the following coupled ODE system
at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
# Plot the velocity field, nullclines, manifolds and several trajectories example5_flowField <- flowField(example5, xlim = c(-3, 3), ylim = c(-3, 3), points = 19, add = FALSE) y0 <- matrix(c(1, 0, -1, 0, 2, 2, -2, 2, 0, 3, 0, -3), 6, 2, byrow = TRUE) example5_nullclines <- nullclines(example5, xlim = c(-3, 3), ylim = c(-3, 3)) example5_trajectory <- trajectory(example5, y0 = y0, tlim = c(0,10)) # Plot x and y against t example5_numericalSolution <- numericalSolution(example5, y0 = c(0, 3), tlim = c(0, 3)) # Determine the stability of the equilibrium point example5_stability <- stability(example5, ystar = c(0, 0))
# Plot the velocity field, nullclines, manifolds and several trajectories example5_flowField <- flowField(example5, xlim = c(-3, 3), ylim = c(-3, 3), points = 19, add = FALSE) y0 <- matrix(c(1, 0, -1, 0, 2, 2, -2, 2, 0, 3, 0, -3), 6, 2, byrow = TRUE) example5_nullclines <- nullclines(example5, xlim = c(-3, 3), ylim = c(-3, 3)) example5_trajectory <- trajectory(example5, y0 = y0, tlim = c(0,10)) # Plot x and y against t example5_numericalSolution <- numericalSolution(example5, y0 = c(0, 3), tlim = c(0, 3)) # Determine the stability of the equilibrium point example5_stability <- stability(example5, ystar = c(0, 0))
The derivative function of an example two-dimensional autonomous ODE system.
example6(t, y, parameters)
example6(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example6
evaluates the derivatives of the following coupled ODE system
at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
The derivative function of an example two-dimensional autonomous ODE system.
example7(t, y, parameters)
example7(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example7
evaluates the derivatives of the following coupled ODE system
at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
The derivative function of an example two-dimensional autonomous ODE system.
example8(t, y, parameters)
example8(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example8
evaluates the derivatives of the following coupled ODE system
at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
The derivative function of an example two-dimensional autonomous ODE system.
example9(t, y, parameters)
example9(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Not used here. |
example9
evaluates the derivatives of the following coupled ODE system
at the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
# Plot the velocity field, nullclines and several trajectories example9_flowField <- flowField(example9, xlim = c(-3, 3), ylim = c(-3, 3), points = 19, add = FALSE) y0 <- matrix(c(1, 0, -3, 2, 2, -2, -2, -2), 4, 2, byrow = TRUE) example9_nullclines <- nullclines(example9, xlim = c(-3, 3), ylim = c(-3, 3)) example9_trajectory <- trajectory(example9, y0 = y0, tlim = c(0, 10)) # Determine the stability of the equilibrium point example9_stability <- stability(example9, ystar = c(0, 0))
# Plot the velocity field, nullclines and several trajectories example9_flowField <- flowField(example9, xlim = c(-3, 3), ylim = c(-3, 3), points = 19, add = FALSE) y0 <- matrix(c(1, 0, -3, 2, 2, -2, -2, -2), 4, 2, byrow = TRUE) example9_nullclines <- nullclines(example9, xlim = c(-3, 3), ylim = c(-3, 3)) example9_trajectory <- trajectory(example9, y0 = y0, tlim = c(0, 10)) # Determine the stability of the equilibrium point example9_stability <- stability(example9, ystar = c(0, 0))
The derivative function of the exponential growth model, an example of a one- dimensional autonomous ODE system.
exponential(t, y, parameters)
exponential(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The value of y, the dependent
variable, to evaluate the derivative at. Should be a
|
parameters |
The values of the parameters of the system. Should be a
|
exponential
evaluates the derivative of the following ODE at the point
(t, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the value of the
derivative at (t, y).
Michael J Grayling
Searches for an equilibium point of a system, taking the starting point of the search as a user specified location. On identifying such a point, a classification is performed, and an informatively shaped point can be added to the plot.
findEquilibrium( deriv, y0 = NULL, parameters = NULL, system = "two.dim", tol = 1e-16, max.iter = 50, h = 1e-06, plot.it = FALSE, summary = TRUE, state.names = if (system == "two.dim") c("x", "y") else "y" )
findEquilibrium( deriv, y0 = NULL, parameters = NULL, system = "two.dim", tol = 1e-16, max.iter = 50, h = 1e-06, plot.it = FALSE, summary = TRUE, state.names = if (system == "two.dim") c("x", "y") else "y" )
deriv |
A function computing the derivative at a point for the ODE
system to be analysed. Discussion of the required structure of these
functions can be found in the package vignette, or in the help file for the
function |
y0 |
The starting point of the search. In the case of a one-dimensional
system, this should be a |
parameters |
Parameters of the ODE system, to be passed to |
system |
Set to either |
tol |
The tolerance for the convergence of the search algorithm.
Defaults to |
max.iter |
The maximum allowed number of iterations of the search
algorithm. Defaults to |
h |
Step length used to approximate the derivative(s). Defaults to
|
plot.it |
Logical. If |
summary |
Set to either |
state.names |
The state names for |
Returns a list with the following components (the exact make up is
dependent on the value of system
):
classification |
The classification of the identified equilibrium point. |
Delta |
In the two-dimensional system case, value of the Jacobian's determinant at the equilibrium point. |
deriv |
As per input. |
discriminant |
In the one-dimensional system case, the value of the
discriminant used in perturbation analysis to assess stability. In the
two-dimensional system case, the value of |
eigenvalues |
In the two-dimensional system case, the value of the Jacobian's eigenvalues at the equilibrium point. |
eigenvectors |
In the two-dimensional system case, the value of the Jacobian's eigenvectors at the equilibrium point. |
jacobian |
In the two-dimensional system case, the Jacobian at the equilibrium point. |
h |
As per input. |
max.iter |
As per input. |
parameters |
As per input. |
plot.it |
As per input. |
summary |
As per input. |
system |
As per input. |
tr |
In the two-dimensional system case, the value of the Jacobian's trace at the equilibrium point. |
tol |
As per input. |
y0 |
As per input. |
ystar |
The location of the identified equilibrium point. |
Michael J Grayling, Stephen P Ellner, John M Guckenheimer
Plots the flow or velocity field for a one- or two-dimensional autonomous ODE system.
flowField( deriv, xlim, ylim, parameters = NULL, system = "two.dim", points = 21, col = "gray", arrow.type = "equal", arrow.head = 0.05, frac = 1, add = TRUE, state.names = if (system == "two.dim") c("x", "y") else "y", xlab = if (system == "two.dim") state.names[1] else "t", ylab = if (system == "two.dim") state.names[2] else state.names[1], ... )
flowField( deriv, xlim, ylim, parameters = NULL, system = "two.dim", points = 21, col = "gray", arrow.type = "equal", arrow.head = 0.05, frac = 1, add = TRUE, state.names = if (system == "two.dim") c("x", "y") else "y", xlab = if (system == "two.dim") state.names[1] else "t", ylab = if (system == "two.dim") state.names[2] else state.names[1], ... )
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 vignette, or in the help file for the
function |
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 |
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-dimensional system, this sets the
limits of the dependent variable in which these line segments should be
plotted. Should be a |
parameters |
Parameters of the ODE system, to be passed to |
system |
Set to either |
points |
Sets the density of the line segments to be plotted;
|
col |
Sets the colour of the plotted line segments. Should be a
|
arrow.type |
Sets the type of line segments plotted. If set to
|
arrow.head |
Sets the length of the arrow heads. Passed to
|
frac |
Sets the fraction of the theoretical maximum length line
segments can take without overlapping, that they can actually attain. In
practice, |
add |
Logical. If |
state.names |
The state names for |
xlab |
Label for the x-axis of the resulting plot. |
ylab |
Label for the y-axis of the resulting plot. |
... |
Returns a list
with the following components (the
exact make up is dependent on 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
|
deriv |
As per input. |
dx |
A |
dy |
A |
frac |
As per input. |
parameters |
As per input. |
points |
As per input. |
system |
As per input. |
x |
A |
xlab |
As per input. |
xlim |
As per input. |
y |
A |
ylab |
As per input. |
ylim |
As per input. |
Michael J Grayling
# 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), 5, 2, 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)
# 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), 5, 2, 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)
The derivative function of the non-dimensional version of the Lindemann mechanism, an example of a two-dimensional autonomous ODE system.
lindemannMechanism(t, y, parameters)
lindemannMechanism(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Should be a
|
lindemannMechanism
evaluates the derivative of the following ODE at
the point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
The derivative function of the logistic growth model, an example of a two-dimensional autonomous ODE system.
logistic(t, y, parameters)
logistic(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The value of y, the dependent
variable, to evaluate the derivative at. Should be a
|
parameters |
The values of the parameters of the system. Should be a
|
logistic
evaluates the derivative of the following ODE at the point
(t, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the value of the
derivative at (t, y).
Michael J Grayling
# Plot the velocity field, nullclines and several trajectories 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 phase portrait logistic_phasePortrait <- phasePortrait(logistic, ylim = c(-0.5, 2.5), parameters = c(1, 2), points = 10, frac = 0.5) # Determine the stability of the equilibrium points logistic_stability_1 <- stability(logistic, ystar = 0, parameters = c(1, 2), system = "one.dim") logistic_stability_2 <- stability(logistic, ystar = 2, parameters = c(1, 2), system = "one.dim")
# Plot the velocity field, nullclines and several trajectories 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 phase portrait logistic_phasePortrait <- phasePortrait(logistic, ylim = c(-0.5, 2.5), parameters = c(1, 2), points = 10, frac = 0.5) # Determine the stability of the equilibrium points logistic_stability_1 <- stability(logistic, ystar = 0, parameters = c(1, 2), system = "one.dim") logistic_stability_2 <- stability(logistic, ystar = 2, parameters = c(1, 2), system = "one.dim")
The derivative function of the Lotka-Volterra model, an example of a two-dimensional autonomous ODE system.
lotkaVolterra(t, y, parameters)
lotkaVolterra(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Should be a
|
lotkaVolterra
evaluates the derivative of the following ODE at the
point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
The derivative function of the monomolecular growth model, an example of a one-dimensional autonomous ODE system.
monomolecular(t, y, parameters)
monomolecular(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The value of y, the dependent
variable, to evaluate the derivative at. Should be a
|
parameters |
The values of the parameters of the system. Should be a
|
monomolecular
evaluates the derivative of the following ODE at the
point (t, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the value of the
derivative at (t, y).
Michael J Grayling
The derivative function of the Morris-Lecar model, an example of a two-dimensional autonomous ODE system.
morrisLecar(t, y, parameters)
morrisLecar(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Should be a
|
morrisLecar
evaluates the derivative of the following ODE at the point
(t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
Plots nullclines for two-dimensional autonomous ODE systems. Can also be used to plot horizontal lines at equilibrium points for one-dimensional autonomous ODE systems.
nullclines( deriv, xlim, ylim, parameters = NULL, system = "two.dim", points = 101, col = c("blue", "cyan"), add = TRUE, add.legend = TRUE, state.names = if (system == "two.dim") c("x", "y") else "y", ... )
nullclines( deriv, xlim, ylim, parameters = NULL, system = "two.dim", points = 101, col = c("blue", "cyan"), add = TRUE, add.legend = TRUE, state.names = if (system == "two.dim") c("x", "y") else "y", ... )
deriv |
A function computing the derivative at a point for the ODE
system to be analysed. Discussion of the required structure of these
functions can be found in the package vignette, or in the help file for the
function |
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 |
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-dimensional system, this sets the
limits of the dependent variable in which these line segments should be
plotted. Should be a |
parameters |
Parameters of the ODE system, to be passed to |
system |
Set to either |
points |
Sets the density at which derivatives are computed;
|
col |
In the case of a two-dimensional system, sets the colours used
for the x- and y-nullclines. In the case of a one-dimensional system, sets
the colour of the lines plotted horizontally along the equilibria. Should be
a |
add |
Logical. If |
add.legend |
Logical. If |
state.names |
The state names for |
... |
Additional arguments to be passed to either
|
Returns a list
with the following components (the
exact make up is dependent on the value of system
):
add |
As per input. |
add.legend |
As per input. |
col |
As per input, but with possible editing if a
|
deriv |
As per input. |
dx |
A |
dy |
A |
parameters |
As per input. |
points |
As per input. |
system |
As per input. |
x |
A |
xlim |
As per input. |
y |
A |
ylim |
As per input. |
In order to ensure a nullcline is plotted, set xlim
and
ylim
strictly enclosing its location. For example, to ensure a
nullcline is plotted along x = 0, set ylim
to, e.g., begin at -1.
Michael J Grayling
# 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), 5, 2, 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)
# 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), 5, 2, 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)
Numerically solves a two-dimensional autonomous ODE system for a given
initial condition, using ode
from the package
deSolve
. It then plots the dependent variables against
the independent variable.
numericalSolution( deriv, y0 = NULL, tlim, tstep = 0.01, parameters = NULL, type = "one", col = c("red", "blue"), add.grid = TRUE, add.legend = TRUE, state.names = c("x", "y"), xlab = "t", ylab = state.names, method = "ode45", ... )
numericalSolution( deriv, y0 = NULL, tlim, tstep = 0.01, parameters = NULL, type = "one", col = c("red", "blue"), add.grid = TRUE, add.legend = TRUE, state.names = c("x", "y"), xlab = "t", ylab = state.names, method = "ode45", ... )
deriv |
A function computing the derivative at a point for the ODE
system to be analysed. Discussion of the required structure of these
functions can be found in the package vignette, or in the help file for the
function |
y0 |
The initial condition. Should be a |
tlim |
Sets the limits of the independent variable for which the
solution should be plotted. Should be a |
tstep |
The step length of the independent variable, used in numerical
integration. Decreasing the absolute magnitude of |
parameters |
Parameters of the ODE system, to be passed to |
type |
If set to |
col |
Sets the colours of the trajectories of the two dependent
variables. Should be a |
add.grid |
Logical. If |
add.legend |
Logical. If |
state.names |
The state names for |
xlab |
Label for the x-axis of the resulting plot. |
ylab |
Label for the y-axis of the resulting plot. |
method |
Passed to |
... |
Additional arguments to be passed to
|
Returns a list
with the following components:
add.grid |
As per input. |
add.legend |
As per input. |
col |
As per input, but with possible editing if a
|
deriv |
As per input. |
method |
As per input. |
parameters |
As per input. |
t |
A |
tlim |
As per input. |
tstep |
As per input. |
x |
A |
y |
A |
y0 |
As per input. |
Michael J Grayling
# A two-dimensional autonomous ODE system, vanDerPol. vanDerPol_numericalSolution <- numericalSolution(vanDerPol, y0 = c(4, 2), tlim = c(0, 100), parameters = 3)
# A two-dimensional autonomous ODE system, vanDerPol. vanDerPol_numericalSolution <- numericalSolution(vanDerPol, y0 = c(4, 2), tlim = c(0, 100), parameters = 3)
Allows the user to perform a basic phase plane analysis and produce a simple plot without the need to use the other functions directly. Specifically, a range of options are provided and the user inputs a value to the console to decide what is added to the plot.
phasePlaneAnalysis( deriv, xlim, ylim, tend = 100, parameters = NULL, system = "two.dim", add = FALSE, state.names = if (system == "two.dim") c("x", "y") else "y" )
phasePlaneAnalysis( deriv, xlim, ylim, tend = 100, parameters = NULL, system = "two.dim", add = FALSE, state.names = if (system == "two.dim") c("x", "y") else "y" )
deriv |
A function computing the derivative at a point for the ODE
system to be analysed. Discussion of the required structure of these
functions can be found in the package vignette, or in the help file for the
function |
xlim |
In the case of a two-dimensional system, this sets the limits of
the first dependent variable in any subsequent plot. In the case of a
one-dimensional system, this sets the limits of the independent variable.
Should be a |
ylim |
In the case of a two-dimensional system this sets the limits of
the second dependent variable in any subsequent plot. In the case of a
one-dimensional system, this sets the limits of the dependent variable.
Should be a |
tend |
The value of the independent variable to end any subsequent numerical integrations at. |
parameters |
Parameters of the ODE system, to be passed to |
system |
Set to either |
add |
Logical. If |
state.names |
The state names for |
The user designates the derivative file and other arguments as per the above. Then the following ten options are available for execution:
1. Flow field: Plots the flow field of the system. See
flowField
.
2. Nullclines: Plots the nullclines of the system. See
nullclines
.
3. Find fixed point (click on plot): Searches for an equilibrium point
of the system, taking the starting point of the search as where the user
clicks on the plot. See findEquilibrium
.
4. Start forward trajectory (click on plot): Plots a trajectory, i.e.,
a solution, forward in time with the starting point taken as where the user
clicks on the plot. See trajectory
.
5. Start backward trajectory (click on plot): Plots a trajectory,
i.e., a solution, backward in time with the starting point taken as where the
user clicks on the plot. See trajectory
.
6. Extend Current trajectory (a trajectory must already be plotted):
Extends already plotted trajectories further on in time. See
trajectory
.
7. Local stable/unstable manifolds of a saddle (two-dimensional
systems only) (click on plot): Plots the stable and unstable manifolds of a
saddle point. The user clicks on the plot and an equilibrium point is
identified see (3) above, if this point is a saddle then the manifolds are
plotted. See drawManifolds
.
8. Grid of trajectories: Plots a set of trajectories, with the starting
points defined on an equally spaced grid over the designated plotting range
for the dependent variable(s). See trajectory
.
9. Exit: Exits the current call to phasePlaneAnalysis().
10. Save plot as PDF: Saves the produced plot as "phasePlaneAnalysis.pdf" in the current working directory.
Michael J Grayling, Stephen P Ellner, John M Guckenheimer
For a one-dimensional autonomous ODE, it plots the phase portrait, i.e., the derivative against the dependent variable. In addition, along the dependent variable axis it plots arrows pointing in the direction of dependent variable change with increasing value of the independent variable. From this stability of equilibrium points (i.e., locations where the horizontal axis is crossed) can be determined.
phasePortrait( deriv, ylim, ystep = 0.01, parameters = NULL, points = 10, frac = 0.75, arrow.head = 0.075, col = "black", add.grid = TRUE, state.names = "y", xlab = state.names, ylab = paste0("d", state.names), ... )
phasePortrait( deriv, ylim, ystep = 0.01, parameters = NULL, points = 10, frac = 0.75, arrow.head = 0.075, col = "black", add.grid = TRUE, state.names = "y", xlab = state.names, ylab = paste0("d", state.names), ... )
deriv |
A function computing the derivative at a point for the ODE
system to be analysed. Discussion of the required structure of these
functions can be found in the package vignette, or in the help file for the
function |
ylim |
Sets the limits of the dependent variable for which the
derivative should be computed and plotted. Should be a
|
ystep |
Sets the step length of the dependent variable vector for which
derivatives are computed and plotted. Decreasing |
parameters |
Parameters of the ODE system, to be passed to |
points |
Sets the density at which arrows are plotted along the
horizontal axis; |
frac |
Sets the fraction of the theoretical maximum length line
segments can take without overlapping, that they actually attain. Fine
tuning here assists the creation of aesthetically pleasing plots. Defaults
to |
arrow.head |
Sets the length of the arrow heads. Passed to
|
col |
Sets the colour of the line in the plot, as well as the arrows.
Should be a |
add.grid |
Logical. If |
state.names |
The state names for |
xlab |
Label for the x-axis of the resulting plot. |
ylab |
Label for the y-axis of the resulting plot. |
... |
Additional arguments to be passed to either plot or arrows. |
Returns a list with the following components:
add.grid |
As per input. |
arrow.head |
As per input. |
col |
As per input, but with possible editing if a
|
deriv |
As per input. |
dy |
A |
frac |
As per input. |
parameters |
As per input. |
points |
As per input. |
xlab |
As per input. |
y |
A |
ylab |
As per input. |
ylim |
As per input. |
ystep |
As per input. |
Michael J Grayling
# A one-dimensional autonomous ODE system, example2. example2_phasePortrait <- phasePortrait(example2, ylim = c(-0.5, 2.5), points = 10, frac = 0.5)
# A one-dimensional autonomous ODE system, example2. example2_phasePortrait <- phasePortrait(example2, ylim = c(-0.5, 2.5), points = 10, frac = 0.5)
The derivative function of the simple pendulum model, an example of a two-dimensional autonomous ODE system.
simplePendulum(t, y, parameters)
simplePendulum(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Should be a
|
simplePendulum
evaluates the derivative of the following ODE at the
point (t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
# Plot the velocity field, nullclines and several trajectories 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), 5, 2, 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) # Determine the stability of two equilibrium points simplePendulum_stability_1 <- stability(simplePendulum, ystar = c(0, 0), parameters = 5) simplePendulum_stability_2 <- stability(simplePendulum, ystar = c(pi, 0), parameters = 5)
# Plot the velocity field, nullclines and several trajectories 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), 5, 2, 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) # Determine the stability of two equilibrium points simplePendulum_stability_1 <- stability(simplePendulum, ystar = c(0, 0), parameters = 5) simplePendulum_stability_2 <- stability(simplePendulum, ystar = c(pi, 0), parameters = 5)
The derivative function of the SIR epidemic model, an example of a two-dimensional autonomous ODE system.
SIR(t, y, parameters)
SIR(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Should be a
|
SIR
evaluates the derivative of the following ODE at the point
(t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
Uses stability analysis to classify equilibrium points. Uses the Taylor Series approach (also known as perturbation analysis) to classify equilibrium points of a one -imensional autonomous ODE system, or the Jacobian approach to classify equilibrium points of a two-dimensional autonomous ODE system. In addition, it can be used to return the Jacobian at any point of a two-dimensional system.
stability( deriv, ystar = NULL, parameters = NULL, system = "two.dim", h = 1e-07, summary = TRUE, state.names = if (system == "two.dim") c("x", "y") else "y" )
stability( deriv, ystar = NULL, parameters = NULL, system = "two.dim", h = 1e-07, summary = TRUE, state.names = if (system == "two.dim") c("x", "y") else "y" )
deriv |
A function computing the derivative at a point for the ODE
system to be analysed. Discussion of the required structure of these
functions can be found in the package vignette, or in the help file for the
function |
ystar |
The point at which to perform stability analysis. For a
one-dimensional system this should be a |
parameters |
Parameters of the ODE system, to be passed to |
system |
Set to either |
h |
Step length used to approximate the derivative(s). Defaults to
|
summary |
Set to either |
state.names |
The state names for |
Returns a list
with the following components (the
exact make up is dependent upon the value of system):
classification |
The classification of |
Delta |
In the two-dimensional system case, the value of the Jacobian's
determinant at |
deriv |
As per input. |
discriminant |
In the one-dimensional system case, the value of the
discriminant used in perturbation analysis to assess stability. In the
two-dimensional system case, the value of |
eigenvalues |
In the two-dimensional system case, the value of the
Jacobian's eigenvalues at |
eigenvectors |
In the two-dimensional system case, the value of the
Jacobian's eigenvectors at |
jacobian |
In the two-dimensional system case, the Jacobian at
|
h |
As per input. |
parameters |
As per input. |
summary |
As per input. |
system |
As per input. |
tr |
In the two-dimensional system case, the value of the Jacobian's
trace at |
ystar |
As per input. |
Michael J Grayling
# Determine the stability of the equilibrium points of the one-dimensional # autonomous ODE system example2 example2_stability_1 <- stability(example2, ystar = 0, system = "one.dim") example2_stability_2 <- stability(example2, ystar = 1, system = "one.dim") example2_stability_3 <- stability(example2, ystar = 2, system = "one.dim") # Determine the stability of the equilibrium points of the two-dimensional # autonomous ODE system example11 example11_stability_1 <- stability(example11, ystar = c(0, 0)) example11_stability_2 <- stability(example11, ystar = c(0, 2)) example11_stability_3 <- stability(example11, ystar = c(1, 1)) example11_stability_4 <- stability(example11, ystar = c(3, 0))
# Determine the stability of the equilibrium points of the one-dimensional # autonomous ODE system example2 example2_stability_1 <- stability(example2, ystar = 0, system = "one.dim") example2_stability_2 <- stability(example2, ystar = 1, system = "one.dim") example2_stability_3 <- stability(example2, ystar = 2, system = "one.dim") # Determine the stability of the equilibrium points of the two-dimensional # autonomous ODE system example11 example11_stability_1 <- stability(example11, ystar = c(0, 0)) example11_stability_2 <- stability(example11, ystar = c(0, 2)) example11_stability_3 <- stability(example11, ystar = c(1, 1)) example11_stability_4 <- stability(example11, ystar = c(3, 0))
The derivative function of a simple genetic toggle switch model, an example of a two-dimensional autonomous ODE system.
toggle(t, y, parameters)
toggle(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Should be a
|
toggle
evaluates the derivative of the following ODE at the point
(t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
Performs numerical integration of the chosen ODE system, for a user specified set of initial conditions. Plots the resulting solution(s) in the phase plane.
trajectory( deriv, y0 = NULL, n = NULL, tlim, tstep = 0.01, parameters = NULL, system = "two.dim", col = "black", add = TRUE, state.names = if (system == "two.dim") c("x", "y") else "y", method = "ode45", ... )
trajectory( deriv, y0 = NULL, n = NULL, tlim, tstep = 0.01, parameters = NULL, system = "two.dim", col = "black", add = TRUE, state.names = if (system == "two.dim") c("x", "y") else "y", method = "ode45", ... )
deriv |
A function computing the derivative at a point for the ODE
system to be analysed. Discussion of the required structure of these
functions can be found in the package vignette, or in the help file for the
function |
y0 |
The initial condition(s). In the case of a one-dimensional system,
this can either be a |
n |
If |
tlim |
Sets the limits of the independent variable for which the
solution should be plotted. Should be a |
tstep |
The step length of the independent variable, used in numerical
integration. Decreasing the absolute magnitude of |
parameters |
Parameters of the ODE system, to be passed to |
system |
Set to either |
col |
The colour(s) to plot the trajectories in. Should be a
|
add |
Logical. If |
state.names |
The state names for |
method |
Passed to |
... |
Additional arguments to be passed to plot. |
Returns a list with the following components (the exact make up is
dependent on the value of system
):
add |
As per input. |
col |
As per input, but with possible editing if a
|
deriv |
As per input. |
n |
As per input. |
method |
As per input. |
parameters |
As per input. |
system |
As per input. |
tlim |
As per input. |
tstep |
As per input. |
t |
A |
x |
In the two-dimensional system case, a |
y |
In the two-dimensional system case, a |
y0 |
As per input, but converted to a |
Michael J Grayling
# 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), 5, 2, 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)
# 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), 5, 2, 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)
The derivative function of the Van der Pol Oscillator, an example of a two-dimensional autonomous ODE system.
vanDerPol(t, y, parameters)
vanDerPol(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The values of x and
y, the dependent variables, to evaluate
the derivative at. Should be a |
parameters |
The values of the parameters of the system. Should be a
|
vanDerPol
evaluates the derivative of the following ODE at the point
(t, x, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling
# Plot the velocity field, nullclines and several trajectories. vanDerPol_flowField <- flowField(vanDerPol, xlim = c(-5, 5), ylim = c(-5, 5), parameters = 3, points = 15, add = FALSE) y0 <- matrix(c(2, 0, 0, 2, 0.5, 0.5), 3, 2, byrow = TRUE) vanDerPol_nullclines <- nullclines(vanDerPol, xlim = c(-5, 5), ylim = c(-5, 5), parameters = 3, points = 500) vanDerPol_trajectory <- trajectory(vanDerPol, y0 = y0, tlim = c(0, 10), parameters = 3) # Plot x and y against t vanDerPol_numericalSolution <- numericalSolution(vanDerPol, y0 = c(4, 2), tlim = c(0, 100), parameters = 3) # Determine the stability of the equilibrium point vanDerPol_stability <- stability(vanDerPol, ystar = c(0, 0), parameters = 3)
# Plot the velocity field, nullclines and several trajectories. vanDerPol_flowField <- flowField(vanDerPol, xlim = c(-5, 5), ylim = c(-5, 5), parameters = 3, points = 15, add = FALSE) y0 <- matrix(c(2, 0, 0, 2, 0.5, 0.5), 3, 2, byrow = TRUE) vanDerPol_nullclines <- nullclines(vanDerPol, xlim = c(-5, 5), ylim = c(-5, 5), parameters = 3, points = 500) vanDerPol_trajectory <- trajectory(vanDerPol, y0 = y0, tlim = c(0, 10), parameters = 3) # Plot x and y against t vanDerPol_numericalSolution <- numericalSolution(vanDerPol, y0 = c(4, 2), tlim = c(0, 100), parameters = 3) # Determine the stability of the equilibrium point vanDerPol_stability <- stability(vanDerPol, ystar = c(0, 0), parameters = 3)
The derivative function of the von Bertalanffy growth model, an example of a one-dimensional autonomous ODE system.
vonBertalanffy(t, y, parameters)
vonBertalanffy(t, y, parameters)
t |
The value of t, the independent
variable, to evaluate the derivative at. Should be a
|
y |
The value of y, the dependent
variable, to evaluate the derivative at. Should be a
|
parameters |
The values of the parameters of the system. Should be a
|
vonBertalanffy
evaluates the derivative of the following ODE at the
point (t, y):
Its format is designed to be compatible with ode
from
the deSolve
package.
Returns a list
containing the values of the two
derivatives at
(t, x, y).
Michael J Grayling