% This script has been written to show the influence of the pulse duration
% on the response of a SDOF system to a square pulse.
%
% THE PROBLEM
%
% A single degree of freedom system is being considered.
%
% The mass is 1kg
% The stiffness is 1N/m
% The damping ratio is 0.1
%
% The system is subject to a force of 1 N applied as a step at time 0. The
% response for varying durations of pulse is then studied.
clear all
close all
% Define system properties
k=1;
m=1;
xi=0.1;
P=1;
t_end=5;
% Find the natural frequency
omega_n=sqrt(k/m);
omega_d=omega_n*sqrt(1-xi^2);
% Calculate the response to the step at time t=0
A=xi*omega_n/omega_d*P/k;
B=P/k;
tstep=0.0001;
t=[0:tstep:25];
u=P/k-exp(-xi*omega_n*t).*(A*sin(omega_d*t)+B*cos(omega_d*t));
f1=figure('Units','centimeters','Position',[5 5 20.99 14.05]);
hold on
kstep=100;
for i=1:100
t_end=round(i/kstep*2*pi/omega_n,4);
% Find the index of the end of the load pulse
idx=int32(t_end/tstep+1);
t_free=t(idx:length(t)); % time after the downward step
tau=t_free-t(idx); % shifted time, to calculate the downward step
P=-1;
A=xi*omega_n/omega_d*P/k;
B=P/k;
u_down=P/k-exp(-xi*omega_n*tau).*(A*sin(omega_d*tau)+B*cos(omega_d*tau));
% Add together the two responses
u_total=u;
u_total(idx:end)=u_total(idx:end)+u_down;
u_max(i)=max(u_total);
i_max=find(u_total==u_max(i));
t_max(i)=t(i_max);
t_r(i)=i/kstep;
if i==1
plot(t,u_total,'LineWidth',1.5)
end
if i==21
plot(t,u_total,'LineWidth',1.5)
end
if i==41
plot(t,u_total,'LineWidth',1.5)
end
if i==61
plot(t,u_total,'LineWidth',1.5)
end
if i==81
plot(t,u_total,'LineWidth',1.5)
end
end
grid on
xlabel('Time (secs)','Interpreter','Latex','FontSize',14)
ylabel('Displacement (m)','Interpreter','Latex','FontSize',14)
legend('$t_{end}=0.01$','$t_{end}=0.21$','$t_{end}=0.41$','$t_{end}=0.61$','$t_{end}=0.81$','Interpreter','Latex','FontSize',14)
% print(gcf,'FIGURES\Pulse_Duration_One.png','-dpng','-r300');
f2=figure('Units','centimeters','Position',[5 5 20.99 14.05]);
plot(t_r,u_max,'k','LineWidth',1.5);
grid on
xlabel('Normalised Pulse Length $\frac{t_{end}}{T_n}$','Interpreter','Latex','FontSize',14)
ylabel('Maximum Response Ratio','Interpreter','Latex','FontSize',14)
legend('$\xi=0.1$','Interpreter','Latex','FontSize',14,'Location','southeast')
% print(gcf,'FIGURES\Pulse_Duration_Two.png','-dpng','-r300');