Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparks29032 authored Feb 9, 2023
0 parents commit a3f0cc1
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 0 deletions.
40 changes: 40 additions & 0 deletions 3d_plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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 = 10000 * 2 * math.pi
dt = 0.01
t = 0
theta = 1
omega = 0
thresh = 0
phases = []
thetas = []
omegas = []
while t < tau:
if t >= thresh:
phases.append(t % period)
thetas.append((theta + math.pi) % (2 * math.pi) - math.pi)
omegas.append(omega)
thresh += 1
omega += alpha(t, theta, omega) * dt
theta += omega * dt
t += dt

ax = plt.axes(projection='3d')
ax.scatter(thetas, omegas, phases, s=0.1, c=phases, cmap="plasma")
plt.show()


69 changes: 69 additions & 0 deletions P_Plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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()

0 comments on commit a3f0cc1

Please sign in to comment.