forked from scienceetonnante/Chaos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
00-lorenz_poly vignette.py
66 lines (49 loc) · 1.73 KB
/
00-lorenz_poly vignette.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
import numpy as np
import matplotlib.pyplot as plt
import scipy.integrate as integrate
import matplotlib.animation as animation
import mpl_toolkits.mplot3d.axes3d as p3
plt.rcParams['animation.ffmpeg_path'] = r'/Volumes/Data/Youtube/[ffmpeg]/ffmpeg'
FIGSIZE = (16,9)
DPI = 120 # 240 For 4K, 60 for 720p
T = 30
###############################################################################
''' Parameters & Differential equation '''
sigma = 10
rho = 28
beta = 8/3
def derivs(state, t):
x, y, z = state[0], state[1], state[2]
res = np.zeros_like(state)
res[0] = sigma * (y - x)
res[1] = x * (rho - z) - y
res[2] = x * y - beta * z
return res
###############################################################################
# Time range
dt = 0.01
t = np.arange(0.0, T, dt)
# initial state
#init_state_list = []
init_state_list = [[-5, 5, 5],[10, 10, 10],[-10,10,10],[10,-10,-10],[-10,-10,10],
[3, 2, 1], [-8,1,-3]]
cols= ['lime','red','dodgerblue','green','darkorange','cyan','yellow']
# integration
res_list = [integrate.odeint(derivs, init_state, t) for init_state in init_state_list]
###############################################################################
fig = plt.figure(figsize=FIGSIZE,dpi=DPI)
ax = p3.Axes3D(fig)
ax.set_axis_bgcolor('black')
ax.w_xaxis.set_pane_color((0,0,0,0))
ax.w_yaxis.set_pane_color((0,0,0,0))
ax.w_zaxis.set_pane_color((0,0,0,0))
ax.set_xlim3d([-20, 20])
ax.set_ylim3d([-20, 20])
ax.set_zlim3d([15, 40])
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
ax.grid(True)
ax.view_init(azim=-30,elev=40)
lines = [plt.plot(res[100:,0],res[100:,1],res[100:,2], '-', color=col, lw=1) for (res, col) in zip(res_list,cols)]
plt.savefig("vignette.png")
plt.show()