-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhasePlaneBasics-manual.tex
174 lines (160 loc) · 5.69 KB
/
PhasePlaneBasics-manual.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
\nonstopmode{}
\documentclass[a4paper]{book}
\usepackage[times,inconsolata,hyper]{Rd}
\usepackage{makeidx}
\makeatletter\@ifl@t@r\fmtversion{2018/04/01}{}{\usepackage[utf8]{inputenc}}\makeatother
% \usepackage{graphicx} % @USE GRAPHICX@
\makeindex{}
\begin{document}
\chapter*{}
\begin{center}
{\textbf{\huge Package `PhasePlaneBasics'}}
\par\bigskip{\large \today}
\end{center}
\ifthenelse{\boolean{Rd@use@hyper}}{\hypersetup{pdftitle = {PhasePlaneBasics: Introductory Tools for Phase Plane Analysis}}}{}
\begin{description}
\raggedright{}
\item[Type]\AsIs{Package}
\item[Title]\AsIs{Introductory Tools for Phase Plane Analysis}
\item[Version]\AsIs{0.1.0}
\item[Author]\AsIs{Patrick F. Bloniasz [aut, cre]}
\item[Maintainer]\AsIs{Patrick F. Bloniasz }\email{patrick.bloniasz@gmail.com}\AsIs{}
\item[Description]\AsIs{Provides functions to draw phase arrows and nullclines
for 2D dynamical systems. It is designed to allow students to
easily plot nullclines and phase arrows in one and
two dimensional ODEs. Modified from the original script pplane.r written by Daniel Kaplan,
Dept. of Mathematics, Macalester College, kaplan@macalester.edu
Modifications by S. Ellner for use in connection with the textbook
Dynamic Models in Biology by S.P. Ellner and J. Guckenheimer,
Princeton University Press (2006).
Further Modifications by Patrick F. Bloniasz for use in connection with Math 1808
Biomathematics at Bowdoin College. The code has been condensed to only have
phase planes and nullclines. This script is being used under the presumption of
Fair Use copyright law for educational purposes. }
\item[License]\AsIs{GPL-3}
\item[Encoding]\AsIs{UTF-8}
\item[Roxygen]\AsIs{list(markdown = FALSE)}
\item[RoxygenNote]\AsIs{7.3.2}
\item[Imports]\AsIs{graphics, stats}
\item[NeedsCompilation]\AsIs{no}
\end{description}
\Rdcontents{Contents}
\HeaderA{nullclines}{Create nullclines for the phase plane}{nullclines}
%
\begin{Description}
This function creates nullclines within a phase plane. It assumes that you
have a differential equation or system of DEs of the following form:
\end{Description}
%
\begin{Usage}
\begin{verbatim}
nullclines(fun, xlims, ylims, resol = 250, add = FALSE, parms = NULL)
\end{verbatim}
\end{Usage}
%
\begin{Arguments}
\begin{ldescription}
\item[\code{fun}] A function of two variables \code{(x, y)} (plus optional \code{parms})
that returns a vector \code{c(dx/dt, dy/dt)}.
\item[\code{xlims}] A numeric vector \code{c(xmin, xmax)} specifying plot range for x.
\item[\code{ylims}] A numeric vector \code{c(ymin, ymax)} specifying plot range for y.
\item[\code{resol}] Resolution of the grid. Default is 250.
\item[\code{add}] Logical. If \code{FALSE}, a new plot is created; if \code{TRUE},
nullclines are added to an existing plot.
\item[\code{parms}] Optional list of parameters to pass to \code{fun}.
\end{ldescription}
\end{Arguments}
%
\begin{Details}
\code{morrislecar <- function(V, W, parms) \{
g\_L = 2; g\_Ca = 4; g\_K = 8; phi = 0.04;
cap = 20; V\_1 = -1.2; V\_2 = 18; V\_3 = 2;
V\_4 = 30; V\_L = -60; V\_Ca = 120; V\_K = -84;
I = 0;
c(
(1 / cap) * (I - g\_Ca * 0.5 * (1 + tanh((V - V\_1) / V\_2)) * (V - V\_Ca)
- g\_K * W * (V - V\_K) - g\_L * (V - V\_L)),
phi * (0.5 * (1 + tanh((V - V\_3) / V\_4)) - W) *
cosh((V - V\_3) / (2 * V\_4))
)
\}}
It calculates points (x, y) where dx/dt = 0 and/or dy/dt = 0, and draws
contour lines for those solutions.
\end{Details}
%
\begin{Value}
Called for its side effect of drawing nullcline contours on a plot.
\end{Value}
%
\begin{Examples}
\begin{ExampleCode}
# Example usage with the morrislecar function:
# nullclines(morrislecar, xlims = c(-100, 50), ylims = c(0, 1), resol = 250)
\end{ExampleCode}
\end{Examples}
\HeaderA{phasearrows}{Create phase arrows}{phasearrows}
%
\begin{Description}
This function creates phase arrows within a phase plane. It assumes that you
have a differential equation or system of DEs of the following form:
\end{Description}
%
\begin{Usage}
\begin{verbatim}
phasearrows(
fun,
xlims,
ylims,
resol = 25,
col = "black",
add = FALSE,
parms = NULL,
jitter = FALSE
)
\end{verbatim}
\end{Usage}
%
\begin{Arguments}
\begin{ldescription}
\item[\code{fun}] A function of two variables \code{(x, y)} (plus optional \code{parms})
that returns a vector \code{c(dx/dt, dy/dt)}.
\item[\code{xlims}] A numeric vector \code{c(xmin, xmax)} specifying plot range for x.
\item[\code{ylims}] A numeric vector \code{c(ymin, ymax)} specifying plot range for y.
\item[\code{resol}] Resolution of the grid. Default is 25.
\item[\code{col}] Arrow color. Default is "black".
\item[\code{add}] Logical. If \code{FALSE}, a new plot is created; if \code{TRUE}, arrows
are added to an existing plot.
\item[\code{parms}] Optional list of parameters to pass to \code{fun}.
\item[\code{jitter}] Logical. If \code{TRUE}, jitter the grid points slightly for a
less striped pattern of arrows.
\end{ldescription}
\end{Arguments}
%
\begin{Details}
\code{morrislecar <- function(V, W, parms) \{
g\_L = 2; g\_Ca = 4; g\_K = 8; phi = 0.04;
cap = 20; V\_1 = -1.2; V\_2 = 18; V\_3 = 2;
V\_4 = 30; V\_L = -60; V\_Ca = 120; V\_K = -84;
I = 0;
c(
(1 / cap) * (I - g\_Ca * 0.5 * (1 + tanh((V - V\_1) / V\_2)) * (V - V\_Ca)
- g\_K * W * (V - V\_K) - g\_L * (V - V\_L)),
phi * (0.5 * (1 + tanh((V - V\_3) / V\_4)) - W) *
cosh((V - V\_3) / (2 * V\_4))
)
\}}
It calculates x' and y' at a grid of points and draws small arrows.
\end{Details}
%
\begin{Value}
Called for its side effect of drawing arrows on a plot.
\end{Value}
%
\begin{Examples}
\begin{ExampleCode}
# Example usage with the morrislecar function:
# phasearrows(morrislecar, xlims = c(-100, 50), ylims = c(0,1), resol = 25)
\end{ExampleCode}
\end{Examples}
\printindex{}
\end{document}