Learn R Programming

⚠️There's a newer version (2.2.1) of this package.Take me there.

phaseR

Phase plane analysis of one- and two-dimensional autonomous ODE systems

Description

phaseR provides functions to perform a qualitative analysis of one- and two-dimensional autonomous ordinary differential equation (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, programs are additionally available to plot nullclines and stable/unstable manifolds of saddle points. Many example systems are provided for the user.

Getting started

You can install the released version of phaseR from CRAN with:

install.packages("phaseR")

Alternatively, the latest development version available from GitHub can be installed with:

devtools::install_github("mjg211/phaseR")

An introductory example of how to make use of the package’s core functionality can be found below. More detailed support is available in the package vignette, which can be accessed with vignette("phaseR"). For further help, please contact Michael Grayling at michael.grayling@newcastle.ac.uk.

Example

As a basic example, we consider analysing the non-linear two-dimensional system of ODEs provided in phaseR via example12(). By hand, we typically first locate the nullclines and then identify the equilibrium points. Following this, we produce a plot from which trajectories can be sketched. This can all be seamlessly carried out in phaseR with:

example12_flowField   <- flowField(example12,
                                   xlim = c(-4, 4),
                                   ylim = c(-4, 4),
                                   add  = FALSE)
example12_nullclines  <- nullclines(example12,
                                    xlim   = c(-4, 4), 
                                    ylim   = c(-4, 4),
                                    points = 500)
y0                    <- matrix(c( 2,  2,
                                  -3,  0,
                                   0,  2,
                                   0, -3), 
                                nrow  = 4,
                                ncol  = 2,
                                byrow = TRUE)
example12_trajectory  <- trajectory(example12,
                                    y0   = y0,
                                    tlim = c(0, 10))
#> Note: col has been reset as required

It appears that both of the equilibria are unstable. We could verify this by hand, but we can also perform this analysis in phaseR using stability():

example12_stability_1 <- stability(example12,
                                   ystar = c(1, 1))
#> tr = 3, Delta = 4, discriminant = -7, classification = Unstable focus
example12_stability_2 <- stability(example12,
                                   ystar = c(-1, -1),
                                   h     = 1e-8)
#> tr = -1, Delta = -4, discriminant = 17, classification = Saddle

References

Grayling MJ (2014) phaseR: An R Package for Phase Plane Analysis of Autonomous ODE Systems. The R Journal 6(2):43-51. DOI: 10.32614/RJ-2014-023.

Copy Link

Version

Install

install.packages('phaseR')

Monthly Downloads

636

Version

2.1.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Michael J Grayling

Last Published

October 12th, 2019

Functions in phaseR (2.1.3)

example12

Example ODE system 12
example1

Example ODE system 1
example10

Example ODE system 10
competition

The species competition model
example14

Example ODE system 14
example11

Example ODE system 11
.paramDummy

A function such that we can apply DRY in param documentation
example13

Example ODE system 13
SIR

The SIR epidemic model
drawManifolds

Stable and unstable manifolds
example9

Example ODE system 9
example8

Example ODE system 8
example7

Example ODE system 7
example3

Example ODE system 3
example4

Example ODE system 4
exponential

The exponential growth model
example2

Example ODE system 2
example15

Example ODE system 15
logistic

The logistic growth model
findEquilibrium

Equilibrium point identification
lindemannMechanism

The Lindemann mechanism
flowField

Flow field
example6

Example ODE System 6
example5

Example ODE system 5
morrisLecar

The Morris-Lecar model
numericalSolution

Numerical solution and plotting
phasePlaneAnalysis

Phase plane analysis
nullclines

Nullclines
vanDerPol

The Van der Pol oscillator
vonBertalanffy

The von Bertalanffy growth model
toggle

The genetic toggle switch model
trajectory

Phase plane trajectory plotting
simplePendulum

The simple pendulum model
stability

Stability analysis
lotkaVolterra

The Lotka-Volterra model
monomolecular

The monomolecular growth model
phasePortrait

Phase portrait plot
phaseR-package

Phase plane analysis of one- and two-dimensional autonomous ODE systems