Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Pendulum With Springs' Large Oscillations: Joshua Olowoyeye 2115521164

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Pendulum with springs’ large

oscillations

Joshua Olowoyeye
2115521164

4/3/2023

PHYS 2010 Classical Mechanics

Prof. Christopher Bergevin
Homework question

A uniform rod of mass M, length L


swings as a pendulum from the
top end with two horizontal
springs of negligible mass and
constants k1 and k2 acting at the
bottom end, as shown in Fig. 17-3.
Both springs are relaxed when the
rod is vertical. Write code to
display the angular position and
angular acceleration of the
pendulum and deformation of the
springs due to large oscillations.

REPORT TITLE PAGE 2


THE PROCESS

Summary

I solved this using MATLAB. For this process I set up the system with
parameters for the mass of the stating positions and innate
characteristics of the pendulum and the springs (mass, spring
constant, length etc.) I make heavy use of trigonometric identities to
determine the deformation and angles of the springs. With that I
create a for loop that iterates every hundredth of a second to
determine the forces working on the rod by the deformed springs and
gravity. From there I use the minute changes in angular acceleration
and angular velocity to determine the minute change of position.
Finally, I graph the angular position and angular acceleration of the
pendulum and deformation of each spring.
The initial angle of the pendulum should be within the hypotenuse
angle (the angle between the spring base and the pendulum base with
respect to gravity), because the code malfunctions when the initial
angle is substantially above it.

Code

% System parameters
g = 9.81; % acceleration due to gravity (m/s^2)
dt = 0.01; % time step (s)
t = 0:dt:10; % time vector

% Initial conditions of the pendulum


lP = 2; % length of the pendulum (m)
m = 1; % mass of the pendulum (kg)
thetaP0 = deg2rad( 10 ); % initial angle of the pendulum with respect
to down* (radians)
omegaP0 = 0; % initial angular velocity of the pendulum (rad/s)

REPORT TITLE PAGE 3


% Initial conditions of the spring 1
k1 = 10; % spring constant the spring 1 (N/m)
lS1r= 1; % resting length of spring 1
hypS1 = sqrt(lS1r^2+lP^2); % distance from hook for the spring and the
pendulum
thetaHypS1 = atan( lS1r/lP); % angle from hook for the spring and the
pendulum respect to down*
lS10 = sqrt(hypS1^2+lP^2-2*hypS1*lP*cos(thetaHypS1-thetaP0));% Initial
deformed length of spring 1
thetaS10 = (pi/2)-thetaHypS1-asin(lP*sin(thetaHypS1-thetaP0)/lS10); %
initial angle of the spring 1 with respect to the floor(radians)
dS10 = lS10-lS1r; % initial displacement of the spring 1 (m)

% Initial conditions of the spring 2


k2 = 10; % spring constant the spring 2 (N/m)
lS2r= 1; % resting length of spring 2
hypS2 = sqrt(lS2r^2+lP^2); % distance from hook for the spring and the
pendulum
thetaHypS2 = atan( lS2r/lP); % angle from hook for the spring and the
pendulum respect to down*
lS20 = sqrt(hypS2^2+lP^2-2*hypS2*lP*cos(thetaHypS2+thetaP0)); % Initial
deformed length of spring 2
thetaS20 = (pi/2)-thetaHypS2-asin(lP*sin(thetaHypS2+thetaP0)/lS20); %
initial angle of the spring 2 with respect to the floor (radians)
dS20 = lS20-lS2r; % initial displacement of the spring 2 (m)

% Preallocate arrays
theta = zeros(size(t)); % angle of the pendulum (radians)
thetaS1i = zeros(size(t)); % angle of the spring 1 (radians)
thetaS2i = zeros(size(t)); % angle of the spring 2 (radians)
omega = zeros(size(t)); % angular velocity of the pendulum (rad/s)
alpha = zeros(size(t)); % angular velocity of the pendulum (rad/s)
x1 = zeros(size(t)); % displacement of the spring 1 vertically (m)
x2 = zeros(size(t)); % displacement of the spring 2 vertically (m)

% Set initial values


theta(1) = thetaP0; % initial angle of the pendulum (radians)
thetaS1i(1) = thetaS10; % initial angle of the spring 1 with respect to
the floor (radians)
thetaS2i(1) = thetaS10; % initial angle of the spring 2 with respect to
the floor (radians)
omega(1) = omegaP0; % initial angular velocity of the pendulum
(radians/sec)
x1(1) = dS10; % initial displacement of the spring 1 (m)
x2(1) = dS20; % initial displacement of the spring 2 (m)

% Simulate the system


for i = 2:length(t)
% Calculate the force on the pendulum by the springs
Fx = + k1*x1(i-1)*cos(thetaS1i(i-1)) - k2*x2(i-1)*cos(thetaS2i(i-

REPORT TITLE PAGE 4


1));
Fy = + k1*x1(i-1)*sin(thetaS2i(i-1)) - k2*x2(i-1)*sin(thetaS2i(i-
1));

% Calculate the angular acceleration of the pendulum


alpha(i) = (-m*g*sin(theta(i-1))/(m*lP/2)) + (Fx*sin((pi/2)-
theta(i-1)) + Fy*sin(theta(i-1))) / (m*lP);

% Update the angular velocity and angle of the pendulum


omega(i) = omega(i-1) + alpha(i)*dt;
theta(i) = theta(i-1) + omega(i)*dt;

% Update the length and angle of the springs


lS1i = sqrt(hypS1^2+lP^2-2*hypS1*lP*cos(thetaHypS1-theta(i)));
lS2i = sqrt(hypS2^2+lP^2-2*hypS2*lP*cos(thetaHypS2+theta(i)));
thetaS1i(i) =
(pi/2)-thetaHypS1-asin(lP*sin(thetaHypS1-theta(i))/lS1i);
thetaS2i(i) =
(pi/2)-thetaHypS2-asin(lP*sin(thetaHypS2+theta(i))/lS2i); % initial
angle of the spring 2 with respect to the floor (radians)

% calculate the new displacement of the springs


x1(i) = (lS1i-lS1r);
x2(i) = (lS2i-lS2r);

end

% Plot the results


subplot(4,1,1)
plot(t,theta)
xlabel('Time (s)')
ylabel('Angle (radians)')
title('Angular position of the pendulum over time')

subplot(4,1,2)
plot(t,alpha)
xlabel('Time (s)')
ylabel('Angular acceleration (radians/sec^2)')
title('Angular acceleration of the pendulum over time')

subplot(4,1,3)
plot(t,x1)
xlabel('Time (s)')
ylabel('Displacement x1 (m)')
title('Displacement of the spring 1 over time')

subplot(4,1,4)
plot(t,x2)
xlabel('Time (s)')

REPORT TITLE PAGE 5


ylabel('Displacement x2 (m)')
title('Displacement of the spring 2 over time')

Results

REPORT TITLE PAGE 6

You might also like