-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathfhn_explore_student.py
71 lines (51 loc) · 1.88 KB
/
fhn_explore_student.py
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
from __future__ import division
from PyDSTool import *
from PyDSTool.Toolbox import phaseplane as pp
from matplotlib import pyplot as plt
pars = # Your definitions here
icdict = {'x': 0,
'y': 1}
xstr = # Your definition here
ystr = # Your definition here
event_x_a = makeZeroCrossEvent('x-a+b*y', 1,
{'name': 'event_x_a',
'eventtol': 1e-6,
'term': False,
'active': True},
varnames=['x'], parnames=['a','b'],
targetlang='C') # 'python'
DSargs = args(name='fhn') # struct-like data
DSargs.events = [event_x_a]
DSargs.pars = pars
DSargs.tdata = [0, 10]
DSargs.algparams = {'max_pts': 3000, 'init_step': 0.02} #, 'stiff': True}
DSargs.varspecs = {'x': xstr, 'y': ystr}
DSargs.xdomain = {'x': [-2.2, 2.5], 'y': [-3, 3]}
DSargs.fnspecs = {'Jacobian': (['t','x','y'],
"""[[(1-x*x)/eps, -1/eps ],
[ 1, -b ]]""")}
DSargs.ics = icdict
fhn = Dopri_ODEsystem(DSargs) # Vode_ODEsystem
traj = fhn.compute('v')
pts = traj.sample()
plt.plot(pts['t'], pts['x'], 'k.-')
def freq(I):
# Your code here
# let solution settle
transient = fhn.compute('trans')
fhn.set(ics=transient(10),
tdata=[0,20])
# More of your code here
# Your code here for the frequency plot
1/0 # comment this to apply phase plane picture to whatever
# are the current parameters of FHN model
## Optional code
fp_coord = pp.find_fixedpoints(fhn, n=25, eps=1e-6)[0]
fp = pp.fixedpoint_2D(fhn, Point(fp_coord), eps=1e-6)
nulls_x, nulls_y = pp.find_nullclines(fhn, 'x', 'y', n=3, eps=1e-6,
max_step=0.1, fps=[fp_coord])
plt.figure(3)
pp.plot_PP_fps(fp)
plt.plot(nulls_x[:,0], nulls_x[:,1], 'b')
plt.plot(nulls_y[:,0], nulls_y[:,1], 'g')
plt.show()