-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3d_plot_over_time
78 lines (66 loc) · 1.42 KB
/
3d_plot_over_time
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
import math
import matplotlib.pyplot as plt
m = 1
g = 1
l = 1
gamma = 0.05
F_0 = 0.7
omega_d = 0.7
period = 2 * math.pi / omega_d
def alpha(t: float, theta: float, omega: float):
return (1 / (m * l)) * (- g * math.sin(theta) - gamma * omega + F_0 * math.cos(omega_d * t))
ax = plt.axes(projection='3d')
ax.set_title("Phase Plot Over Time")
ax.set_xlabel("$\\theta$")
ax.set_ylabel("$\omega$")
ax.set_zlabel("$t$")
tau = 12 * 2 * math.pi
dt = 0.1
t = 0
theta = 0
omega = 1
thresh = 0
phases = []
thetas = []
omegas = []
while t < tau:
phases.append(t)
thetas.append(theta)
omegas.append(omega)
omega += alpha(t, theta, omega) * dt
theta += omega * dt
t += dt
ax.plot(thetas, omegas, phases, c='purple', linewidth=1)
dt = 0.1
t = 0
theta = 0
omega = 0.99
thresh = 0
phases = []
thetas = []
omegas = []
while t < tau:
phases.append(t)
thetas.append(theta)
omegas.append(omega)
omega += alpha(t, theta, omega) * dt
theta += omega * dt
t += dt
ax.plot(thetas, omegas, phases, c='blue', linewidth=1)
dt = 0.1
t = 0
theta = 0
omega = 1.01
thresh = 0
phases = []
thetas = []
omegas = []
while t < tau:
phases.append(t)
thetas.append(theta)
omegas.append(omega)
omega += alpha(t, theta, omega) * dt
theta += omega * dt
t += dt
ax.plot(thetas, omegas, phases, c='red', linewidth=1)
plt.show()