Project

Transient behaviour of a Simple pendulum

SIMPLE PENDULUM

A pendulum is a weight suspended from a pivot so that it can swing freely. When a pendulum is displaced sideways from its resting, equilibrium position, it is subject to a restoring force due to gravity that will accelerate it back toward the equilibrium position. When released, the restoring force acting on the pendulum's mass causes it to oscillate about the equilibrium position, swinging back and forth. The time for one complete cycle, a left swing and a right swing, is called the period. The period depends on the length of the pendulum and also to a slight degree on the amplitude, the width of the pendulum's swing.

The Simple Harmonic Motion of a Pendulum

When we pull a simple pendulum from its equilibrium position and then release it, it swings in a vertical plane under the influence of gravity. It begins to oscillate about its mean position. Therefore, the motion is periodic and oscillatory. Now, if we displace the pendulum by a very small angle Θ, then it performs the simple harmonic motion.

Consider a simple pendulum having mass ‘m’, length L and displaced by a small angle Θ with the vertical. Thus, it oscillates about its mean position. In the displaced position, two forces are acting on the bob,

Gravitational force, which is the weight of the bob – ‘mg’ acting in the downward direction.

Tension T’ in the string.

Now, weight mg is resolved in two components,

Radial component mgcosΘ along the string.

Tangential component mgsinΘ perpendicular to the string.

Radial component mgcosΘ is balanced by Tension T’ in the string and the Tangential component mgsinΘ is the restoring force acting on mass m towards the equilibrium position. Therefore,

Restoring force, F =-mgsinΘ

The negative sign indicates that F and Θ are in opposite directions. Note that the restoring force is proportional to sinΘ instead of Θ. Therefore, it is not yet a simple harmonic motion. However, if the angle is very small, we can assume that sinΘ is nearly equal to Θ in radian. Thus, the displacement x= LΘ and for a small angle, it is nearly a straight line.

∴ Θ= x/L

Hence, assuming sinΘ= Θ,(since Θ is very less ie, almost upto 10degrees)

F = -mgΘ = -mgx/L.

As m,g, and L are constant. For a small displacement, the restoring force is directly proportional to the displacement and its direction is opposite to that of displacement. Therefore, Simple pendulum performs linear S.H.M.

Assumptions

All models are full of assumptions. Some of these assumptions are very accurate,

such as the pendulum is unaffected by the day of the week. Some of these

assumptions are less accurate but we are still going to make them, friction does

not effect the system. Here is a list of some of the more notable assumptions of

this model of a pendulum.

  • Friction from both air resistance and the system is negligible.
  • The pendulum swings in a perfect plane.
  • The arm of the pendulum cannot bend or stretch/compress.
  • The arm is massless.
  • Gravity is a constant 9.8 meter/second2

AIM:

To write a progrm to solve an ODE in MATLAB to plot the transcient (time based) behaviour of a pendulum between 0 - 20 seconds.

PROCEDURE:

Deriving the sencond order differential equation

TThe simple pendulum can be considered as a torque system as the restoring force is acting at the tip of the string and is perpendicular.

Torque = Force * perpendicular distance = (mgsinΘ-bΘ') * L

Applying Newtons 2nd law to rotational motion,

Torque = Moment of Ineria * angular accleration

Torque = I * Θ''

Equating Torque in above equation,

(mgsinΘ-bΘ') * L = mL^2 * Θ'' (since I = mL^2 )

Rearranging above equation and dividing by m we get,

The above second order equation is converted to a first order ODE and is then used in the ode_func_pendulum code as shown below.

Programming steps:

1) Assign the initial values of length, damping coefficient, accleration due to gravity, angular velocity and angular displacement.

2) Assign Time span values from 0 to 20 and using lin space command assign 500 values between the time span so that we can get a smooth movement of the pendulum.

3)using the ode45 code (which is the ode solver in MATLAB) we can solve the ode function.

4) The ode function is defined separately and is then called into the main program.

5) The results are then placed in the 'ode_results' and then plotted in a graph.

6) Using the plot command plot the values of angular velocity and displacement fro the ode_results.

7) Now the position of the pendulum bob is now plotted with the (x1,y1) position values for each value of the Timespan using the 'FOR' loop.

8) Now at each end of for loop the position is plotted. Thus all the position values are plotted until the FOR loop is termninated.

9)Now Animation is created using the getframe command and the video is saved in a filenamed 'Pendulum'

clear all
close all
clc

%Assigning the values of initial known parameters
l = 1;   % Length of the string
m = 1;   % MAss of Pendulum Bob
b = 0.05; % Damping Coefficient
g = 9.81; % Accleration due to gravity

%Assigning the value of anguar displacement(0) and angular velocity(3rad/s) in a vector theta_0 
theta_0 = [0;3];
%Assigning time range of 0 to 20 seconds and choosing 500 interstate pointsbetween the range
t_span = linspace(0,20,500);

%solve ode
[t, ode_results] = ode45(@(t,theta) ode_func_pendulum(t,theta, b,g,l,m),t_span, theta_0);

%Plotting Graph of the results from ode solver
figure(1)
plot(t,ode_results(:,1),'color','b') % plotting the column 1 of ode_results which is the angular displacement   
hold on
plot(t,ode_results(:,2),'color','r')  % plotting the column 2 of ode_results which is the angular velocity
legend('Ang disp','Ang vel');
xlabel('time')
axis([0 20 -5 5])


%Pendulum Motion Simulation and creating animation
x0 = 0;
y0 = 0;
ct = 1; % initialising count value for animation
%Getting the position values of pendulum to plot the position at different time intervals
for i = 1:length(t_span);
    x1 = l*sin(ode_results(i,1))
    y1 = -(l*cos(ode_results(i,1))) % negative sign is used so that the pendulum oscillates towards gravity or the negative Y-plot.
    
    %Animation
    figure(2)
    plot([-2,2],[0,0],'linewidth',10)
    hold on
    plot([x0 x1],[y0 y1],'linewidth',3)
    hold off
    hold on
    plot(x1,y1,'o','markersize',20,'markerfacecolor','b')
    hold off
    axis([-1 1 -2 0.5])
    grid on
    pause(0.04)
 M(ct) = getframe(gcf);
 ct = ct + 1;
end

% ANIMATION OF PENDULUM
movie(M)
penudulum = VideoWriter('PENDULUM.avi','Uncompressed AVI');
open(pendulum)
writeVideo(pendulum,M)
close(pendulum)

The ODE function is defined separately and is then called in to the main function using 'ode_func_pendulum' function.

function [dtheta_dt] = ode_func_pendulum(t,theta,b,g,l,m)

theta1 = theta(1)
theta2 = theta(2)
dtheta1_dt = theta2;
dtheta2_dt = -(b/m)*theta2 - (g/l)*sin(theta1);
dtheta_dt = [dtheta1_dt; dtheta2_dt];
end

Errors faced while programming

1)WHile defining ode45 function failed to include theta_0 value and an error popped up saying less number of arguments or input values to solve the ode.

The error was overcome by including the angular disp and velocity vector.

2)While plotting the angular displacement and velocity plot failed to mention column number of the ode_results.

The error was solved by including the column number in the plot command of the ode_results.

Results:

The results were plotted and the graphs and animation containing the variation of angular displacement, velocity and pendulum oscillation w.r.t time were done and the output is as follows,

From the above plots the following results were inferred,

  • It can be seen that the Angular displacement is damped slightly due to the lower value of damping coefficient (0.05).
  • Also the pendulum doesnot come to a standstill within the 0 - 20 second time span due to the lower value of damping coefficient. In order to make the pendulum to a standstill within 20 second the damping coeff value can be increased and the same program can be used.
  • Youtube link : https://youtu.be/ddPcXxufFio

Below is the result in case damping coeff value is increased,

  • Thus it can be seen that when damping coeff is 0.5, the angular displacement and velocity is damped at a faster rate.
  • Also the pendulum is coming to the vertical position at the end of 20 seconds.
  • Youtube link : https://youtu.be/vuVlt_SSnn4

References

https://www.mathworks.com/matlabcentral/fileexchange/46101-simple-pendulum-simulation

https://www.mathworks.com/help/symbolic/examples/simulate-physics-pendulum-swing.html

https://www.myphysicslab.com/pendulum/pendulum-en.html

https://www.acs.psu.edu/drussell/Demos/Pendulum/Pendulum.html

http://physics.bu.edu/~duffy/py105/SHM.html

https://www.youtube.com/watch?v=BkAnmKI_4Io

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.