0% found this document useful (0 votes)
8 views

New Text Document

This document presents code for numerically solving the equations of motion for a two degree of freedom linear system subjected to ground motion. The code uses the Newmark beta method to integrate the equations of motion over time and plots the resulting displacements and accelerations.

Uploaded by

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

New Text Document

This document presents code for numerically solving the equations of motion for a two degree of freedom linear system subjected to ground motion. The code uses the Newmark beta method to integrate the equations of motion over time and plots the resulting displacements and accelerations.

Uploaded by

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

format short g

nd = 2;
m = 10;
k = 1000;
M = [2*m 0;0 m];
K = [12*k -4*k;-4*k 4*k];
[V,D] = eig(K,M);
w = sqrt([D]);
phi1 = [V(1)/V(2);V(2)/V(1)];
phi2 = [V(3)/V(4);V(4)/V(4)];
w1 = sqrt(D(1));
w2 = sqrt(D(4));
dt1 = 0.02;
t_t = (l-1)*dt1;
zhy = 5;
w = [1/(2*w1) w1/2;1/(2*w2) w2/2];
Zhy = [zhy/100;zhy/100];
const_matrx = w\Zhy;
alpha = const_matrx(1);
beta = const_matrx(2);
C = alpha*[M]+beta*[K];
load elcentro.mat
l = length(a);
a = elcentro.mat(:,2)*9.81;
t=0:dt1:t_t;
time = t';
n = a;
div = 1;
dt = dt1/div;
ti = 0:dt:t_t;
time1 = ti';
ni = interp1(t,n,ti);
a = ni';
l1= length(a);
A = [zeros(nd,nd) eye(nd);-inv(M)*K -inv(M)*C];
Ad = expm([[A]*dt]);
D = inv(A)*[Ad-eye(2*nd)];
E = [zeros(nd,1);-1;-1];
Ed = [D]*[E];
z = zeros(2*nd,1);
d1 = 0;
d2 = 0;
v1 = 0;
v2 = 0;
v11 = 0;
v21 = 0;
a1 = -a(1);
a2 = -a(1);
for i = 1:l1-1
z = [Ad]*[z]+[Ed]*[a(i)];
zdot = A*z+E*a(i+1);
if i == j
d1 = [d1;z(1)];
d2 = [d2;z(2)];
v1 = [v1;z(3)];
v2 = [v2;z(4)];
v11 = [v11;zdot(1)];
v21 = [v21;zdot(2)];
a1 = [a1;zdot(3)];
a2 = [a2;zdot(4)];
j = j+div;
end
end
a_abs_1 = [a1+a];
a_abs_2 = [a2+a];
Max_d1 = max(abs(d1));
Max_d2 = max(abs(d2));
Max_a1 = max(abs(a1));
Max_a2 = max(abs(a2));
Max_a_abs_1 = max(abs(a_abs_1));
Max_a_abs_2 = max(abs(a_abs_2));
RMS_d1 = sqrt(sum(d1.*conj(d1))/size(d1,1));
RMS_d2 = sqrt(sum(d2.*conj(d1))/size(d2,1));
RMS_a1 = sqrt(sum(a1.*conj(a1))/size(a1,1));
RMS_a2 = sqrt(sum(a2.*conj(a2))/size(a2,1));
RMS_a_abs_1 = sqrt(sum(a_abs_1.*conj(a_abs_1))/size(a_abs_1,1));
RMS_a_abs_2 = sqrt(sum(a_abs_2.*conj(a_abs_2))/size(a_abs_2,1));
% Result_Table =
%[Max_d1;Max_d2;Max_a_abs_1;Max_a_abs_2;RMS_d1;RMS_d2;RMS_a_abs_1;RMS_a_abs_
%2]
figure(1)
plot(time,d1)
xlabel ('Time(s)')
ylabel ('Relative Displacement x1 (m)')
title('Time History for Relative Displacement corresponding to DOF#1')
grid on
figure(2)
plot(time,d2)
xlabel ('Time(s)')
ylabel ('Relative Displacement x2 (m)')
title('Time History for Relative Displacement corresponding to DOF#2')
grid on
figure(3)
plot(time,a_abs_1)
xlabel ('Time(s)')
ylabel ('Absolute Acceleration x1 (m/s2)')
title('Time History for Absolute Acceleration corresponding to DOF#1')
grid on
figure(4)
plot(time,a_abs_2)
xlabel ('Time(s)')
ylabel ('Absolute Acceleration x2 (m/s2)')
title('Time History for Absolute Acceleration corresponding to DOF#2')
grid on

You might also like