simple harmonic pendumlum motion
AIM:
Here our main aim is to solving second order differential equation of a simple pendulum and to simulate using MATLAB program.
THEORY:
-We know that a simple pendulum is one which can be considered to be a point mass (m),suspend from a string(length(L)) or rod of negligible massand with a fixed point P..It is a resonant system with single resonant frequency.
-Here simple harmonic motion(a type of periodic motionwhere restoring force is dierectly propotional to displacement and acts in dierction oppoosite to displacement) plays important during to and fro motion of the pendulum
Daigram of simple pendulm:
sample curve graph.
-When given an initial push ,it will swing back and forth with a constant amplitude.Now by applying newtons second law for rotational motion,equation of motion for simple pendulum can be written as:
`d^2\'(theta)/dt^2+b/m(d theta/dt)+g/l(sintheta)=0`
where theta = angular displacement
t=time (seconds)
d=damping coefficient(Ns/m)
m=mass(kg)
g=acceleration due to gravity(whose value is 9.81)
l=length of pendulum(m)
-Now lets try to solve using the matlab programing:
Program1:
% ODE
clear all
close all
clc
% inputs
b= 0.05;
g= 9.81;
l= 1;
m= 1;
%initial condition
x_0= [0;3];
% time points
t_span = linspace(0,20,200);
% solve ode
[t, results] = ode45(@(t,x) ode_func(t, x, b, g, l, m), t_span, x_0);
figure(1)
hold on
plot(t, results(:,1))
plot(t, results(:,2))
xlabel(\'time span\')
ylabel(\'x\')
legend(\'Angular Displacement\',\'Angular Velocity\')
hold off
ct = 1;
for i=1:length(results)
x0=0;
y0=0;
x1=1*sin(results(i,1));
y1=-1*cos(results(i,1));
figure(2)
plot([x0,x1],[y0,y1],\'color\',\'b\')
hold on
plot([-1 1],[0 0])
plot(x1,y1,\'marker\',\'.\',\'markersize\',50)
axis([-1 1 -1 1])
hold off
M(ct)=getframe(gcf);
ct=ct+1;
end
Now we have to write a program for converting ODE from second order to first order:
function [dx_dt] = ode_func(t, x, b, g, l, m)
x1 = x(1)
x2 = x(2)
dx1_dt = x2;
dx2_dt = -(b/m)*x2 - (g/l)*sin(x1);
dx_dt = [dx1_dt; dx2_dt];
end
Explaination to the code:
-Initially we give the input value (which was given in the question) for the variables like length ,mass and damping coefficient of the pendulm.
-Here i have mentioned the initial condition as x_0,then the stime span array is formed.
-Now we introduce new funtion ode_funtion which is defined in MATLAB to convert second order ODE to first order using the below equation:
-ode45 which is a built in solver in matlab,to solve the obtained first order in above step to get angular displacement and velocity at all time span.And the above value will be used for ploting in the graph
-Results:
Animation:
https://youtu.be/EvMTPy0xRlo
Conclusion:
Transient behaviour of simple pendulum was calculated and simulation was done using MATLAB.