-
Notifications
You must be signed in to change notification settings - Fork 0
/
fhn.py
78 lines (54 loc) · 1.31 KB
/
fhn.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
71
72
73
74
75
from numpy import array, zeros_like, ones_like
def FHNNonlinearity(x, p):
a = p['a']
b = p['b']
e = p['e']
# u = x[...,0]
# v = x[...,1]
u, v = x[...,0], x[...,1]
f = zeros_like(x)
f[...,0] = (u-u*u*u/3.0 - v)/e
f[...,1] = (u - a*v + b) *e
return f
def FHNJacobian(x, p):
a = p['a']
b = p['b']
e = p['e']*ones_like(x[...,0]) # make it a vector!
u = x[...,0]
v = x[...,1]
return array([[(1.0 - u*u)/e, -1.0/e],
[e, -a*e]])
# derivative of the RHS with respect to e
def FHNdE(x, p):
a = p['a']
b = p['b']
e = p['e']
u = x[...,0]
v = x[...,1]
d = zeros_like(x)
d[...,0] =-(u - u*u*u/3.0 - v)/e/e
d[...,1] = (u - a*v + b)
return d
fhnParameters = {'a': 0.5, 'b': 0.88, 'e': 0.3} # for contracting
fhnC = array([0.0, 1.45])
fhnDiffusion = [[1.0, 0.0],
[0.0, 0.0]]
fhnDim = (225, 150)
fhnSize = (75.0, 50.0)
def fhnFe(x, p):
a = p['a']
b = p['b']
e = p['e0'] + p['e1']
u, v = x[...,0], x[...,1]
f = zeros_like(x)
f[...,0] = (u-u*u*u/3.0 - v)/e
f[...,1] = (u - a*v + b) *e
return f
def fhnJe(x, p):
a = p['a']
b = p['b']
e = (p['e0'] + p['e1'])*ones_like(x[...,0]) # make it a vector!
u = x[...,0]
v = x[...,1]
return array([[(1.0 - u*u)/e, -1.0/e],
[e, -a*e]])