Here is the updated plot showing the relationship between T² and 4π²L as the pendulum length L varies from 0.02 m to 0.1 m. The linearity of the plot reflects the theoretical relationship between these quantities, with longer lengths resulting in larger periods squared.
# Update the length range from 0.02m to 0.1m
L_values = np.linspace(0.02, 0.1, 100)
# Calculate T^2 and 4π²L for each length
T_squared_values = []
four_pi_squared_L_values = []
for L in L_values:
T = calculate_T(L)
T_squared_values.append(T**2)
four_pi_squared_L_values.append(4 * np.pi**2 * L)
# Plotting the results
plt.figure(figsize=(8, 6))
plt.plot(T_squared_values, four_pi_squared_L_values, color='blue', label=r'$4\pi^2 L$ vs $T^2$')
plt.title('Relationship Between $T^2$ and $4\pi^2 L$ for L from 0.02 m to 0.1 m')
plt.xlabel(r'$T^2$ (s$^2$)')
plt.ylabel(r'$4\pi^2 L$ (m)')
plt.grid(True)
plt.legend()
plt.show()
Here is the plot showing the motion of a simple pendulum over time, where the angle θ (in radians) is plotted against time. This simulation assumes a small initial angle (0.1 radians) and uses the small-angle approximation. The pendulum oscillates back and forth, with the motion described by a cosine function.
import numpy as np
import matplotlib.pyplot as plt
# Constants
g = 9.81 # acceleration due to gravity (m/s^2)
L = 1.0 # length of the pendulum (m)
theta_0 = 0.1 # initial angle (radians, small angle approximation)
time = np.linspace(0, 10, 1000) # time array
# Equation for simple pendulum (small angle approximation): theta(t) = theta_0 * cos(sqrt(g/L) * t)
theta = theta_0 * np.cos(np.sqrt(g / L) * time)
# Plotting the pendulum's angle over time
plt.figure(figsize=(8, 6))
plt.plot(time, theta, label="Pendulum Motion", color='b')
plt.xlabel('Time (s)')
plt.ylabel('Angle (radians)')
plt.title('Simple Pendulum Motion (Angle vs Time)')
plt.grid(True)
plt.legend()
plt.show()
A Python program was written to simulate this motion using the Euler-Cromer method. We'll track how the angular displacement changes over time and plot it.
Here is the plot showing the damped pendulum motion over time. As you can see, the angular displacement gradually decreases due to the damping effect, causing the pendulum to lose energy and reduce its amplitude until it eventually comes to rest.
This simulation demonstrates how damping affects pendulum motion, with the displacement steadily decaying over time.
# Re-running the code after environment reset
import numpy as np
import matplotlib.pyplot as plt
# Simulating damped pendulum motion using Euler-Cromer method
# Parameters for the simulation
g = 9.8 # acceleration due to gravity (m/s^2)
l = 0.1 # length of pendulum (m)
m = 0.1 # mass of pendulum (kg)
b = 0.05 # damping coefficient
theta_0 = 0.2 # initial angular displacement (radians)
omega_0 = 0 # initial angular velocity (rad/s)
dt = 0.01 # time step (s)
t_max = 10 # total simulation time (s)
# Time array
time = np.arange(0, t_max, dt)
# Arrays to store angular displacement and velocity
theta = np.zeros_like(time)
omega = np.zeros_like(time)
# Initial conditions
theta[0] = theta_0
omega[0] = omega_0
# Euler-Cromer method for solving the damped pendulum motion
for i in range(1, len(time)):
omega[i] = omega[i-1] - (g/l) * theta[i-1] * dt - (b/m) * omega[i-1] * dt
theta[i] = theta[i-1] + omega[i] * dt
# Plotting the angular displacement over time
plt.figure(figsize=(10, 6))
plt.plot(time, theta, label=r'Damped Pendulum Motion ($\theta(t)$)', color='blue')
plt.title('Damped Pendulum Motion Over Time')
plt.xlabel('Time (s)')
plt.ylabel('Angular Displacement (radians)')
plt.grid(True)
plt.legend()
plt.show()
Let's implement the Euler-Cromer method to simulate the driven damped pendulum. I'll set up a program where we can observe how the pendulum responds to the driving force. Here is the plot of the driven damped pendulum motion over time. You can observe how the periodic driving force affects the angular displacement. Depending on the frequency and amplitude of the driving force, the pendulum exhibits complex behaviors, such as increased oscillation amplitude or resonance, where the system matches the frequency of the driving force.
If you want to explore resonance or modify parameters (like increasing the driving force or frequency)
# Simulating driven pendulum motion using Euler-Cromer method
# Parameters for the simulation
g = 9.8 # acceleration due to gravity (m/s^2)
l = 0.1 # length of pendulum (m)
m = 0.1 # mass of pendulum (kg)
b = 0.05 # damping coefficient
theta_0 = 0.2 # initial angular displacement (radians)
omega_0 = 0 # initial angular velocity (rad/s)
F_drive = 0.2 # amplitude of the driving force
omega_drive = 1.5 # driving frequency
dt = 0.01 # time step (s)
t_max = 50 # total simulation time (s)
# Time array
time = np.arange(0, t_max, dt)
# Arrays to store angular displacement and velocity
theta = np.zeros_like(time)
omega = np.zeros_like(time)
# Initial conditions
theta[0] = theta_0
omega[0] = omega_0
# Euler-Cromer method for solving the driven damped pendulum motion
for i in range(1, len(time)):
omega[i] = omega[i-1] - (g/l) * np.sin(theta[i-1]) * dt - (b/m) * omega[i-1] * dt + (F_drive/m) * np.cos(omega_drive * time[i-1]) * dt
theta[i] = theta[i-1] + omega[i] * dt
# Plotting the angular displacement over time
plt.figure(figsize=(10, 6))
plt.plot(time, theta, label=r'Driven Damped Pendulum Motion ($\theta(t)$)', color='blue')
plt.title('Driven Damped Pendulum Motion Over Time')
plt.xlabel('Time (s)')
plt.ylabel('Angular Displacement (radians)')
plt.grid(True)
plt.legend()
plt.show()