0% found this document useful (0 votes)
3 views12 pages

DOV Session 1 Report

The document outlines tutorials for simulating a simple pendulum and a damped spring-mass system using MATLAB. It includes equations, initial parameters, and scripts for solving differential equations and plotting results. The conclusions highlight the effects of damping on oscillation behavior in the spring-mass system.

Uploaded by

anvenkatesh9314
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views12 pages

DOV Session 1 Report

The document outlines tutorials for simulating a simple pendulum and a damped spring-mass system using MATLAB. It includes equations, initial parameters, and scripts for solving differential equations and plotting results. The conclusions highlight the effects of damping on oscillation behavior in the spring-mass system.

Uploaded by

anvenkatesh9314
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Tutorial 1

Purpose/Problem Definition with diagram/eq.s


To write a general MATLAB code to obtain linear and non-linear response of a simple pendulum
system.
# By D Alembert’s principle,
Pendulum
arm
 Iθሷ = −mg x Sinθ x L
 (mL2 )θሷ = −mg x Sinθ x L
 Lθሷ + gSinθ = 0
Tr g
 θሷ + ( )Sinθ = 0
L
g
 θሷ = −(L)Sinθ
For small angle of θ,
g
 θሷ = −( )θ
L
Let,
Bob
θ = y(1) => 𝜃ሶ = 𝑦(1)

FBD of the bob 𝜃ሶ = y 2
# Above is the setup of the simple pendulum
system. Then,
# T and mgCosθ are in the same line of
# The length of the pendulum is ‘L’ and the
action. 𝑦(1)
ሶ = y(2)
mass of the bob is ‘m’
Therefore,
T = mg.Cosθ 𝑦()
g
ሶ = −( )Sin(y(1))
L
Tutorial 1
M. Script

clear all; %====== Solving differential equation ======%

clc; deq1=@(t,x) [x(2); -(g/L)*sin(x(1))] %Pendulum's differential equation

clf; [t,sol] = ode45(deq1, [0 run_time],[initial_angle_1 initial_angle_2])

%======Initial parameters ======% sol_1 = sol(:,1)' %quotations used to transpose the matrix

g = 9.81; %Gravitational Constant sol_2 = sol(:,2)' %quotations used to transpose the matrix

L = 1; %Pendulum Angle array_size = size(t)

initial_angle_1 = pi/2 %Initial angle 1 at 90 degree time_step = t(run_time) - t(run_time-1);

initial_angle_2 = 0 %Initial angle 2 at 0 degree cartesian_x = L*sin(sol_1)

%====== Coordinats ======% cartesian_y = L*cos(sol_2)

iterations

pendulum_top_x = 0

pendulum_top_y = L

fprintf('Single pendulum simulation\n\n')

iterations = 1 %Number of trials/ repeats

pause_time = 0.01

run_time = 10 %Simulation running time

tx = 0;
Tutorial 1
M. Script
%====== Plotting the results ======% subplot(3,1,2)

iterations

max(array_size) plot(sol_1(iterations), sol_2(iterations), 'bo')

cartesian_x(iterations) hold on

for i = 1: max(array_size) title('Simple pendulum phase portrait', 'FontSize', 12)

subplot(3,1,1) xlabel('\theta1', 'FontSize', 12)

plotarrayx = [pendulum_top_x cartesian_x(iterations)] ylabel('\theta2', 'FontSize', 12)

plotarrayy = [pendulum_top_y cartesian_y(iterations)]; axis([min(sol_1) max(sol_1) min(sol_2) max(sol_2)])

plot(cartesian_x(iterations), cartesian_y(iterations), 'ko', plotarrayx, plotarrayy,'r-') subplot(3,1,3)

title(['Simple pendulum simulation \theta = ' num2str(sol_1(iterations))], 'fontsize',12); plot(t(iterations), sol_1(iterations), 'bo')

xlabel('x [m]', 'FontSize',12) title(['Simple pendulum time series for \theta1 t =' num2str(t(iterations))], 'FontSize', 12)

ylabel('y [m]', 'FontSize',12) xlabel('t [seconds]', 'FontSize',12)

ylabel('\theta1', 'FontSize',12)

axis([min(cartesian_x) max(cartesian_x) min(cartesian_y) max(cartesian_y)]) hold on

axis([0 t(iterations)+(t(2)-t(1)) min(sol_1) max(sol_1)])

tx = tx + time_step;

pause(pause_time)

iterations = iterations+1;

end
Tutorial 1
M. Script Screen Shot
Tutorial 1
Results
Tutorial 1
Conclusion/Interpretation/Learning outcomes

# The oscillation of the pendulum never stops as there is no resistance given to stop it (no damper or air drag).
# The bob of the pendulum tries to reach its equilibrium position at any point of time.
# The time-period of a pendulum on depends on its length and acceleration due to gravity.
Tutorial 2
Purpose/Problem Definition with diagram/eq.s
To write a general MATLAB code to obtain the response of a spring mass system with a damper
(Damped free vibration)
General equation of a spring mass system with a damper

Three possibilities:

# m is the mass of the object.


# The mass is restricted to move/ Oscillate in only one direction i.e., x direction
# k is the stiffness of the spring.
# A damper is attached to the system to control the vibration/ Oscillation.
Tutorial 2
M. Script
for j = 1:3
subplot(3,1,1)
clc; if zeta(j)<1
plot(t, x(1,:))
clear all; zeta(j)
title(['Response for zeta =', num2str(zeta(1))])
close all; wd = wn*sqrt(1-zeta(j)^2)
ylabel('Response x')
numerator = sqrt((v0+(zeta(j)*wn*x0))^2+(x0*wd)^2)/wd

phi = atan2(wd*x0,(v0+(zeta(j)*wn*x0))) grid


k = input('Enter the spring stiffness value');

%k = 3 x(j,:) = numerator*exp(-zeta(j)*wn*t).*sin((wd*t)+phi)

m = input('Enter the lumped mass'); elseif zeta(j)==1 subplot(3,1,2)

%m = 30 zeta(j) plot(t, x(2,:))

wn = sqrt(k/m) a1 = x0 title(['Response for zeta =', num2str(zeta(2))])

x0 = input('Enter the initial displacement'); a2 = v0+(wn*x0) ylabel('Response x')


x(j,:) = (a1+(a2*t)).*exp(-wn*t) grid
%x0 = 5
elseif zeta(j) > 1
v0 = input('Enter the initial velocity');
zeta(j)
%v0 = 6 subplot(3,1,3)
a1n = -v0 + ((-zeta(j)+sqrt(zeta(j)^2-1))*wn*x0)
tf = input('Enter the time duration to test (in seconds)'); plot(t, x(3,:))
ad = 2*wn*sqrt(zeta(j)^2-1)
%tf = 30 title(['Response for zeta =', num2str(zeta(3))])
a2n = v0 + ((zeta(j)+sqrt(zeta(j)^2-1))*wn*x0)
ylabel('Response x')
a1 = a1n/ad
for zi = 1:3 xlabel('Time, seconds')
a2 = a2n/ad
zeta(zi) = input(['Enter a damping coefficient value' num2str(zi) ':']); grid
lambda = wn * t * sqrt(zeta(j)^2-1)
end
figure(2)
x(j,:) = (a1*exp(lambda)+(a2*exp(-lambda))).*exp(-zeta(j)*wn*t)

end
plot(t,x)

end
Tutorial 2
M. Script Screen Shot
Tutorial 2
Results

Input values
Tutorial 2
Conclusion/Interpretation/Learning outcomes
Zeta = 0.1 <1: Under damped:
The dampening effect or the resistance
to bring the system to rest is lower. So, it takes a
long time for the system to come to complete rest.
Example: Pendulum
Zeta = 1.9 >1: Over damped:
The dampening effect or the resistance to
bring the system to rest is more than what is required.
The system comes to rest faster than the case of under
damped. Number of oscillations will be very much
lower. Example: Automatic-Closing doors

Zeta = 1: Critically damped:


The dampening effect or the resistance
to bring the system to rest is more than what is
required. The system comes to rest immediately
after the driving forces are removed.
Example: Automobile Suspensions
Tutorial 2
Results – For a different set of values

Input values

You might also like