Sei sulla pagina 1di 8

Table of Contents

Central Difference Method ...................................................................................................


Dynamic Amplification function ............................................................................................
Response Spectrum .............................................................................................................
Eigenvalues Problem ...........................................................................................................
Rayleigh Damping and MDOF ..............................................................................................
Logarithmic Decrement ........................................................................................................
IRF ...................................................................................................................................
Newmark Explicit Beta ........................................................................................................
Duhamel Integral ................................................................................................................
Newmark Implicit Beta method .............................................................................................

1
1
2
3
4
6
6
6
7
7

Central Difference Method

a = input(sprintf('Type 1 for Second Central Difference Method,\nor any other key f


if a==1 %Second central difference method
x(1) = x_0;
x_dot(1) = x_dot_0;
x_ddot(1) = x_ddot_0;
m_term = delta_t^2/(2*m);
for ii = 1:numTimeSteps-1

x(ii+1) = m_term * (F(ii) - c*x_dot(ii) - k*x(ii)) + x(ii) + delta_t*x_dot(ii);


x_dot(ii+1) = 2 * (x(ii+1) - x(ii))/delta_t - x_dot(ii);
x_ddot(ii+1) =1/m * (F(ii+1) - c * x_dot(ii+1) - k*x(ii)+1);
end
else %central difference method with two time steps from past
%use the central difference equations for x_dot and x_dotdot to
%calculate the relative displacement at time step -1
x_minus1 = x_0 - delta_t * x_dot_0 + delta_t^2 / 2 * x_ddot_0;
%assign the intial absolute displacement to the solution vector
x(1) = x_0;
end

Dynamic Amplification function


% calculate dynamic parameters
omega = sqrt(k/m);
period = 2 * pi / omega;
freq = 1 / period;
ccrit = 2 * m * omega;
zeta = c / ccrit;

period_damped = 1 / sqrt(1-zeta^2) * period;


freq_damped = 1 / period_damped;
phase = atan(c * Omega / ( k - m * Omega^2 ));
eta = Omega / omega;
V1 = 1 / sqrt(( 1- ( eta^2 ))^2 + ( 2*zeta*eta )^2 );

Response Spectrum
[filename, pathname] = uigetfile('*.*');
filename = fullfile(pathname, filename);
%
fid = fopen(filename,'r'); % input of base accelerations in [m/s^2]
THM = fscanf(fid,'%g %g',[2 inf]);
THM=THM';
%
t=double(THM(:,1));
y=double(THM(:,2));
%
tmx=max(t);
tmi=min(t);
n = length(y);
%
out1 = sprintf('\n %d samples \n',n);
disp(out1);
%
dt=(tmx-tmi)/(n-1);
sr=1./dt;
%
out1 = sprintf(' SR = %g samples/sec
dt = %g sec \n',sr,dt);
disp(out1);
%
f_start = 1 ; % starting frequency (Hz)
f_end = 20 ; % end frequency (Hz)
delta_f = 1 ; % frequency increment (Hz)
freq_num = round((f_end - f_start + 1) / delta_f);
fprintf('Start frequency = %f [Hz]\n', f_start);
fprintf('End frequency = %f [Hz]\n', f_end);
fprintf('Frequency increment = %f [Hz]\n', delta_f);

%
zeta = input('Enter the damping coefficient zeta [% of critical damping]: ') / 100;
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate the response spectrum %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S_pv = zeros(freq_num,1);
S_d = zeros(freq_num,1);
S_a = zeros(freq_num,1);
frequencies = zeros(freq_num,1);

disp(' ');
disp(' Calculating response..... ');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% YOUR TASK: Calculate the response spectrum %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for freq_count = 1:freq_num
freq = (freq_count-1)*delta_f;
omega= 2*pi*freq;
fprintf('Current freuency = %f [Hz]\n', freq);
x= zeros(n,1);
for ii = 1:n
for jj = 1:ii
sin_val = sin(omega*dt*(ii-jj));
exp_val = exp(-zeta*omega*dt*(ii-jj));
x(ii) = x(ii)+y(jj)*exp_val*sin_val;
end
end
S_pv(freq_count) = max(abs(x));
S_d(freq_count) = S_pv(freq_count)/omega;
S_a(freq_count) = S_pv(freq_count)*omega;
frequencies(freq_count) = freq;
clear('x');
end

Eigenvalues Problem
M = [m, m*h/2;m*h/2, 2*m*h^2/3];
K = [2*k, k*h; k*h, k*h^2];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% solve the generalized eigenvalue problem%
%
YOUR TASK !!!%
% solution should be called [eigenvectors, eigenvalues]
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[eigenvectors,eigenvalues] = eig(K,M);
nat_freq_eigenval= sqrt(eigenvalues)/(2*pi);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% solve the problem with the characteristic equation%
%
YOUR TASK !!!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
polynom = [(M(1,1)*M(2,2)-M(2,1)*M(2,2))...
(K(2,1)*M(1,2)+K(1,2)*M(2,1)-K(1,1)*M(2,2)-K(2,2)*M(1,1))...
(K(1,1)*K(2,2)-K(1,2)*K(2,1))];

omega_square = roots(polynom);
nat_freq_poly = sqrt(omega_square) / (2*pi);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% solution from lecture%
%
YOUR TASK !!!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f_1 = sqrt(6*k/(5*m))/ (2*pi);

Rayleigh Damping and MDOF


M = [m_1 0 ; 0 m_2];
K = [(k_1+k_2) -k_2 ; -k_2 k_2];
size_M = size(M);
size_K = size(K);
numdof = size_M(1);
% calculate the natural frequency of the system
[modeshape, eigenvalue] = eig(K,M);
omega = eigenvalue.^0.5;
f_nat = omega./ (2*pi);
% print the eigenfrequencies
disp(' ');
for ii=1:numdof
fprintf('Natural frequency f_%i = %f [Hz]\n',ii, f_nat(ii,ii));
end
zeta_1 = .004;
zeta_2 = .004;
zeta_vec = [zeta_1 ; zeta_2];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate the Rayleigh coefficients alpha and beta
% and the damping matrix and print it
% This is your task!!!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
alphabeta = [omega(1,1), 1/omega(1,1);omega(2,2), 1/omega(2,2)]\(0.5.*zeta_vec);
alpha = alphabeta(1);
beta = alphabeta(2);
% Damping Matrix
C = alpha.*M+beta.*K;

% calculate critical time steps


tDelta_critical = 2 / max(max(omega));
fprintf('\nThe critical time step for the central difference method is: %f [s]\n',t
% get the analysis time
tStop = 30;
% time length [s]
tDelta = 0.01; % time step [s]
numTimeSteps = ceil(tStop/tDelta);
Omega = [(2*pi*3) ; (2*pi*1.5)]; % frequencies [rad/s]

Famplitude = [1000 ; 100]; % Force amplitudes [N]


% Generate the vector time that contains the time for all time steps
time = 0:tDelta:numTimeSteps*tDelta;
% Create three matrices to store the solution for all time steps and one
% to store the force
X = zeros(numdof,numTimeSteps+1);
X_dot = X;
X_dotdot = X;
F = X;
% Assume initial displacemens, velocites and accelerations to be zero and
% therefore leave X(0), X_dot(0) and X_dotdot(0) unchanged.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate the integration constants
% This is your task!!!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a0 = 1/tDelta^2;
a1 = 1/(2*tDelta);
a2 = 2*a0;
a3 = 1/a2;
% built the effective mass matrix
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Build the effective mass matrix
% This is your task!!!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Meff = a0.*M+a1*C;
% caclulate constants to save computation time
const1 = K-a2*M;
const2 = a0*M-a1*C;
% Solve the first time step outside the loop, because we need X_t0-1
X_t0minus1 = X(:,1) -tDelta * X_dot(:,1) + a3 * X_dotdot(:,1);
F(:,1) = Famplitude .* sin(Omega*time(1));
Feff = F(:,1) - const1*X(:,1) - const2*X_t0minus1;
X(:,2) = Meff\Feff;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Calculate the structural response for all time steps!
% This is your task!!!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for ii=2:numTimeSteps
if ii<numTimeSteps/4
F(:,ii) = Famplitude.*sin(Omega*time(ii));
else
F(:,ii) = 0;
end
Feff = F(:,ii) - const1*X(:,ii) - const2*X(:,ii-1);

X(:,ii+1) = Meff\Feff ;
X_dot(:,ii) = a1*(X_dot(:,ii-1)+X_dot(:,ii+1));
X_dotdot(:,ii) = a0*(X(:,ii+1)-2*X(:,ii)+X(:,ii-1));
end

Logarithmic Decrement
%%%%%% This is your task ! %%%%%%
omega_0 = sqrt(k/m);
freq = omega_0/(2*pi);
period = 1/freq;
log_decrement =zeta*omega_0*period;

IRF
calculate dynamic parameters
omega = sqrt(k/m);
ccrit = 2 * m * omega;
zeta = c/ccrit;
%calculating time period
%T=Time period
T=2*pi/omega;
t=(0:T/20:n*T);
H=(1/(m*omega))*sin(omega*t);
H_damped= exp(-zeta*omega*t)/(m*sqrt(1-zeta^2)*omega)...
.*sin(sqrt(1-zeta^2)*omega*t);

Newmark Explicit Beta


%choose the parameters for the Newmark algorithm
a=input(sprintf('type 1 for beta=0.25 explicit method: '));
if a==1
multi1=(4*m/delta_t^2)+(2*c/delta_t)+k;
for ii = 1:numTimeSteps-1
multi2=(4*x(ii)/delta_t^2)+(4*x_dot(ii)/delta_t)+x_ddot(ii);
multi3=(2*x(ii)/delta_t)+x_dot(ii);
x(ii+1)=(F(ii+1)+(m*multi2)+(c*multi3))/multi1;
x_dot(ii+1)=(2*(x(ii+1)-x(ii))/delta_t)-x_dot(ii);
x_ddot(ii+1)=(F(ii+1)-c*x_dot(ii+1)-k*x(ii+1))/m;
end
else %beta=1/6
multi1=(6*m/delta_t^2)+(3*c/delta_t)+k;
for ii = 1:numTimeSteps-1
multi2=(6*x(ii)/delta_t^2)+(6*x_dot(ii)/delta_t)+2*x_ddot(ii);
multi3=(3*x(ii)/delta_t)+2*x_dot(ii)+(0.5*delta_t*x_ddot(ii));

x(ii+1)=(F(ii+1)+(m*multi2)+(c*multi3))/multi1;
x_dot(ii+1)=(2*(x(ii+1)-x(ii))/delta_t)-x_dot(ii);
x_ddot(ii+1)=(F(ii+1)-c*x_dot(ii+1)-k*x(ii+1))/m;
end
end

Duhamel Integral
if (1)
% this case uses the general discretized Duhamel integral
for ii=1:numTimeSteps
for jj= 1:ii
exp_val=exp(-zeta*omega*delta_t*(ii-jj));
sin_val=sin(omega_damped*delta_t*(ii-jj));
x(ii)=x(ii)+F(jj)*exp_val* sin_val;
end
x(ii)=x(ii)*(omega*delta_t)/(k*eta);
end
else
% this case uses the discretized Duhamel integral for base excitation
for jj= 1:ii
exp_val=exp(-zeta*omega*delta_t*(ii-jj));
sin_val=sin(omega_damped*delta_t*(11-jj));
x(ii)=x(ii)+x_b(jj)*exp_val* sin_val;
end
x(ii)=x(ii)*(omega*delta_t)/(k*eta);
end

Newmark Implicit Beta method


%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
gamma=1/2;
beta=1/6;
for ii=2:numTimeSteps
x_0=x(ii-1);
x_dot_0=x_dot(ii-1);
x_ddot_0=(F(ii-1)-c*x_ddot(ii-1)-k*x(ii-1))/m;

x_1=x(ii);
x_ddot_1=x_ddot_0;
diff=1;
fprintf('Time step = %f \n', ii);
while diff>1e-8
x_dot_1=x_dot_0+(1-gamma)*delta_t*x_ddot_0+gamma *delta_t*x_ddot_1;
x_new=x_0+delta_t*x_dot_0+(0.5-beta)*delta_t^2*x_ddot_0+beta*delta_t^2*x_dd
x_ddot_1=(F(ii)-c*x_dot_1-k*x_new)/m;

diff = abs(x_new -x_1);


x_1 =x_new;
fprintf('diff = %f \n' , diff);
end
x(ii)=x_1;
x_dot(ii)=x_dot_1;
x_ddot(ii)=x_ddot_1;
end

Published with MATLAB R2013b

Potrebbero piacerti anche