Learn R Programming

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("introduction", package = "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

542

Version

2.2.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Michael J Grayling

Last Published

September 2nd, 2022

Functions in phaseR (2.2.1)

example13

Example ODE system 13
example14

Example ODE system 14
.paramDummy

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

Stable and unstable manifolds
example3

Example ODE system 3
example4

Example ODE system 4
example9

Example ODE system 9
exponential

The exponential growth model
example1

Example ODE system 1
example10

Example ODE system 10
example2

Example ODE system 2
example15

Example ODE system 15
example5

Example ODE system 5
example6

Example ODE System 6
example8

Example ODE system 8
example7

Example ODE system 7
findEquilibrium

Equilibrium point identification
flowField

Flow field
numericalSolution

Numerical solution and plotting
phasePlaneAnalysis

Phase plane analysis
lotkaVolterra

The Lotka-Volterra model
monomolecular

The monomolecular growth model
lindemannMechanism

The Lindemann mechanism
logistic

The logistic growth model
morrisLecar

The Morris-Lecar model
nullclines

Nullclines
toggle

The genetic toggle switch model
stability

Stability analysis
simplePendulum

The simple pendulum model
vonBertalanffy

The von Bertalanffy growth model
vanDerPol

The Van der Pol oscillator
phasePortrait

Phase portrait plot
trajectory

Phase plane trajectory plotting
phaseR-package

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

Example ODE system 11
SIR

The SIR epidemic model
example12

Example ODE system 12
competition

The species competition model