-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbogdanov_map.py
More file actions
35 lines (25 loc) · 1019 Bytes
/
bogdanov_map.py
File metadata and controls
35 lines (25 loc) · 1019 Bytes
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
import numpy as np
import matplotlib.pyplot as plt
def bogdanov_map(eps=0,k=1.2,mu=0,posx=(-0.7,1.3),posy=(-1,1),precision=800,iter=200,display=True):
# Initilize gridspace
precisiony = int((max(posy)-min(posy))/(max(posx)-min(posx)) * precision) # adapt y precision if grid not a square
xa = np.linspace(posx[0],posx[1],precision)
ya = np.linspace(posy[0],posy[1],precisiony)
x,y = np.meshgrid(xa,ya)
n_iter_diverg = np.zeros(x.shape)
def bogdanov_step(x,y):
y = y*(1+eps+mu*x) + k*x*(x-1)
x = x+y
return x,y
for _ in range(iter):
not_div = np.where(np.abs(y)>2,False,True) + np.where(np.abs(x)>2,False,True)
n_iter_diverg[not_div] += 1
x[not_div],y[not_div] = bogdanov_step(x[not_div],y[not_div])
if display :
plt.imshow(np.sqrt(n_iter_diverg),cmap=plt.cm.binary)
plt.show()
return n_iter_diverg
def main():
b = bogdanov_map(precision=1500)
if __name__ == "__main__":
main()