-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP_Plot.py
69 lines (59 loc) · 1.43 KB
/
P_Plot.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
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))
tau = 25000 * 2 * math.pi
dt = 0.01
t = 0
theta = 0
omega = 1
thresh = 0
p_thetas = []
p_omegas = []
while t < tau:
if t >= thresh:
thresh += period
p_thetas.append((theta + math.pi) % (2 * math.pi) - math.pi)
p_omegas.append(omega)
omega += alpha(t, theta, omega) * dt
theta += omega * dt
t += dt
plt.scatter(p_thetas, p_omegas, s=0.1, c='blue')
t = 0
theta = 0.6
omega = 0.8
thresh = 0
p_thetas = []
p_omegas = []
while t < tau:
if t >= thresh:
thresh += period
p_thetas.append((theta + math.pi) % (2 * math.pi) - math.pi)
p_omegas.append(omega)
omega += alpha(t, theta, omega) * dt
theta += omega * dt
t += dt
plt.scatter(p_thetas, p_omegas, s=0.1, c='red')
t = 0
theta = 1
omega = 0
thresh = 0
p_thetas = []
p_omegas = []
while t < tau:
if t >= thresh:
thresh += period
p_thetas.append((theta + math.pi) % (2 * math.pi) - math.pi)
p_omegas.append(omega)
omega += alpha(t, theta, omega) * dt
theta += omega * dt
t += dt
plt.scatter(p_thetas, p_omegas, s=0.1, c='purple')
plt.show()