You are on page 1of 78

Finite element dynamic analysis

using MATLAB
Also for CEP

Truss, Beam and Frame Elements


Dr. Asif Khan
Faculty of Mechanical Engineering GIK Institute Topi

1/78
Contents

1. Introduction to Finite Element Method


2. Static and Modal Analysis of Structure
2.1 Truss element
2.2 Beam element
2.3 Frame element
3. Summary

2/86
Example: Simple Spring (Static Analysis)
k1  1000 N / m

P=100N
1 2 3

k 2  2000 N / m

f11 f 21 f 22 f 32
F1 2 2 2
FBD
F3
1 1 3 3
F2
Step 1: element equations
1 2

 k1  k1   u1   f 1   k 2  u2   f 22 
1
 k2
 k k  u    f 1   k   
k 2  u3   f 32 
 1 1  2   2   2
Step 2: assemble global stiffness matrix
1  k1  k1 0  u1   f 1 
1 2 0 0 0  u1   0 
 u    f 1  0 k    
 k
 1 k1 0  2   2   2  k 2  u2    f 22 
 0 0 0 u3   0  0  k 2 k 2  u3   f 32 
3/86
1 + 2  k1  k1 0  u1   f 11   F1 
 k k  k       K u  F 
 1 1 2  k 2  u2    f 21  f 22    F2 
 0  k2 k 2  u3   f 32   F3  where
K : global stiffness matrix
Step 3: apply boundary conditions => u1=0 u : global displacement vector
F  : global force vector
 k1  k1 0   0   F1 
 k k  k    
 1 1 2  k 2  u2    0  k1  k 2  k 2  u2   0 
 k   
 0  k2 k 2  u3   P   2 k 2  u3   P 

Step 4: solve
1 1
u2  k1  k 2  k 2   0  1000  2000  2000  0  0.10
      
u3    k 2 k 2   P    2000 2000  100 0.15

Step 5: post process


F1  k1u1  k1u 2  1000(0)  1000(0.1)  100

All finite element methods go through the above process 4/86


Equation of motion of structure
Dynamics of a single element: the work of external forces is absorbed by the work of
internal, inertial and viscous forces for any small kinematically admissible motion
work done
work done work done by concentrated force  work done work done work done 
by body force by surface traction      
              n  byinternal
   force by inertial force by viscous force 
         
 
Ve
 u F dV    u Fs  dS 
T
Se
T
 u  p 
i 1
T
i i

T T T
       u  u   u kd u  dV
Ve  
 
 

Displacement-nodal dof relation: u  N de , u    N d e , u  N de 

 N d e    B d e 
Strain-displacement relation:    S u  S 

Stress-strain relation:    C    C  d e 


 B 

u : displacement field vector


de  : nodal degree of freedom vector
 N  : shape function matrix
S  : differential operator matrix
C  : stiffness matrix
5/86
Substitute all relation into the dynamic equation of element
 n 
T
 de 
 
Ve
T
B dV de  
B  C 

Ve
T
  V
  N   N dV de 
T
  
kd  N   N dV de 
Ve
T

T
 N  F dV  N  Fs  dS 
Se
  pi   0

 e
i 1 

Equation of motion of element

   
 M e  de  Ce  d e   Ke  de    fext 

Element mass and stiffness matrices


T

 M e     N   N dV
T
e 
 K   B  C 
B dV

Assemble each elemental system matrix for global system matrix


 
M  d  C  d  K d   F 

Static Analysis : no mass, no damping


 K d   F  6/86
Structural Vibration
Vibration: Mechanical oscillations about an equilibrium point. The
oscillations may be periodic such as the motion of a pendulum or mass-
spring system

7/86
Free vibration: simple harmonic motion
Free body diagram of static equilibrium: fig. (b)
k static  W

Newton’s second law: fig. (d)


F y
 my k static  ky  W  my

Equation of motion
my  ky  0 y  n2 y  0

k
where n2  : circular natural frequency(rad/sec)
m

General solution: y (t )  c1 sin nt  c2 cos nt

Initial conditions: y (0)  y0 , y (0)  0

y (t )  y0 cos nt

period (T ): time for one cycle (sec)


frequency (f ): number of cycle per second ( Hz  cycle / sec)
1
f 
T
 rad   rad   cycle  8/86
  2 f      2  f 
 sec   cycle   sec 
Multiple Degrees of Freedom
Equations of motion: coupled system
m1x1  2kx1  kx2  0
m2 x2  kx1  2kx2  0

Matrix form of equations of motion


 m1 0   x1   2k k   x1  0
           
 0 m2   x2    k 2k   x2  0

M x  K x  0


M  : mass matrix, K  : stiffness matrix

How to solve?
2k k
x1  x1  x2  0
From EOM: m1 m1 or in matrix form x  M 1 K x  0
k 2k
x2  x1  x2  0
m2 m2

x1 (t )  X1 sin(t   ) X 
Assume solution: or in matrix form x   X  sin(t   )  Xsin(t   )
1
x2 (t )  X 2 sin(t   )  2
9/86
Substitute assumed solution into EOM:
2k k
 2 X1 sin(t   )  X1 sin(t   )  X 2 sin(t   )  0
m1 m1
k 2k
 2 X 2 sin(t   )  X 1 sin(t   )  X 2 sin(t   )  0
m2 m2
 2k k 
 
2  X1   m1 m1   X1  0 
      
 X 2   k 2 k   X 2  0 
 
 m2 m2 

1
or  2 x  M  K x  0 or  2 M x  K x  0

Eigenvalue problem: Generalized eigenvalue problem:


 
A x   x  A    I  x  0 A x   B x
1
A   M  K ,    2 A   K , B   M ,    2

How to solve eigenvalue problem?


Eigenvalue (natural frequency): 1  12 , 2  22
 
det A    I   0  Characteristic equation
Eigenvector (mode shape): X1,X 2 

General solution: x  c1 X1sin(1t  1)  c2 X2 sin(2t  2 )


10/86
c1, c2 ,1,2 are determined by initial conditions
Modal analysis
Modal analysis: find natural frequencies and corresponding mode shapes of structure

Undamped free vibration system: 


M  d  K d   0

Assumed solution form: d (t )  eit where  : mode shape (eigenvector)


 : natural frequency (eigenvalue)

General solution of the given system is a linear combination of each mode

d (t )  c1 1ei1t  c2 2ei2t    cn n eint where c1 ,c2 ,...,cn are determined by initial conditions

Substitute assumed solution into equation of motion:  M   K e 
2 i t
0

For nontrivial solution,  2



M    K  must be singular

 2 M   K    M   K   0 : Eigenvalue problem

11/86
2. Truss Element

12/86
1D truss element
1D truss (bar element): only axial displacement exist, no moment
y

L
u1 u2
x
① ②
u  L x x
Displacement-nodal dof relation: u   N d    N u1  where  N   
 2  L L 

du  d  d
Strain-displacement relation: x        u     N d   B d 
dx  dx   dx 
 1 1 
  B   
 L L 

Stress-strain relation:  x  E x     C    E  B d 

13/86
1D truss element

Element mass and stiffness matrices

L x
L
T L
L   L  x x   AL  2 1 
  
T
 M e     N   N  dV   N   N   Adx   A   dx   
0 0  x  L L  6 1 2 
 L 
T L EA L  1 EA  1 1
  
T
 K e    B  C  B
   dV   B 
   E  B  Adx    1 1
 Adx   
0 L2 0  1  L  1 1 

14/86
Plane truss element
V2
Nodal degree of freedom for element coordinate
v2 u2
de   u1 v1 u2 v2 T
Nodal degree of freedom for global coordinate U2

d   U1 V1 U 2 V2T V1
Coordinate transformation u1
v1
 u1   cos sin  0 0  U1  U1
    
 v1    sin  cos 0 0   V1 

     T d  de   T d 
u2   0 0 cos  sin   U 2   
 1 1

 v2  cos   
 V2   2  B d e )T B d e dV
 sin  T
  0 0  Ref) U   dV  (C 
2
1 1
Strain energy of truss  de T 
T T T
B  C  B dV d e   d e   K e  d e 
1 0 1 0 2 2
 0 
EA  0 0 0 1 1 1
 K e  
L  1 0 1 0
U de T  K e  de   d T T T  Ke  T d   dT  Ke  d
2 2 2
  T
 0 0 0 0    K e   T   K e  T   element stiffness matrix for global coordinate

2

0 1 0

Similarly obtained from kinetic energy of truss
 AL  0 2 0 1
 M e   6  1 0 2 0
due to inertia for y-dir.  M e   T T  M e  T   element mass matrix
 
  for global coordinate
 0 1 0 2 
15/86
Finite element code of plane truss using
MATLAB
Input data:truss_in.m
Materials, node and element definition
1. Input data Boundary conditions, loads

 Node data
 Element data Solve:truss_sol.m
 Area
 Material data Evaluate results:truss_out.m

 Boundary conditions
 External load no
Is this satisfy
2. Output data design requirement?

 Static Analysis
yes
 Nodal displacement
Present results
 Element stress
 Modal Analysis Flow chart of 2D-truss problem
 Natural frequency
16/86
 Mode shape
Truss ex1
Find natural frequency and mode shape of the given truss structure
Aluminum: E=70GPa, A=0.002m2, rho=2700Kg/m3

2 3

(2)
1m (1)

(3) 4
1
1m
1 MN

17/86
0. Truss main program : truss.m %--------------------------------------------------------------
% < Solution Procedure >
% %--------------------------------------------------------------
% Truss program truss_sol
%
clear all; close all; %--------------------------------------------------------------
% < Postprocess >
%-------------------------------------------------------------- %--------------------------------------------------------------
% < Input Truss information > if Atype==1
%-------------------------------------------------------------- truss_out_static
truss_ex1 elseif Atype==2
%truss_ex2 truss_out_modal %truss_ex1, 2
%truss_ex3 %truss_out1 %truss_ex3, 4, 5
%truss_ex4 %truss_movie
%truss_ex5 end

%--------------------------------------------------------------
% < Choose Static or Modal Analysis >
%--------------------------------------------------------------
fprintf('\n\n* < Press 1 or 2 to choose analysis type >')
fprintf('\n => Static Analysis = 1') See truss/truss.m
fprintf('\n Modal Analysis = 2\n')
Atype=input(' Analysis type ? ');

18/86
%
1. Input Data : truss_ex1.m % Area of the cross-section 2 3
% %
% INPUT FOR 2D-PLANE TRUSS PROBLEM A=0.002;
% SI unit %
% Information of truss element % Young's Modulus
(2)
% %
1m (1)
ndof=2; % degree of freedom for each node E=70E9;
npe=2; % node per element %
nmode=2; % number of mode extracted % mass density
% Node data % 4
(3)
% NODE=[#1 #2 #3] rho=2700; 1
% #1: node number %
% #2: x-coordinate % Input boundary conditions 1m
% #3: y-coordinate % BC=[#1 #2 #3] 1 MN
NODE=[ % #1: node number
10 0 % #2: x-constraint (0:free, 1:fixed)
20 1 % #3: y-constraint (0:free, 1:fixed) Example 1
31 1 BC=zeros(nnode,3);
4 1 0]; for i=1:nnode, BC(i,1)=i;, end
nnode=length(NODE); % total number of node %
% BC(2,2)=1; BC(2,3)=1;
% Element data BC(3,2)=1; BC(3,3)=1;
% ELEM=[#1 #2 #3] BC(4,2)=1; BC(4,3)=1;
% #1: element number %%%%%%%%%%%%%%%%%% See
% #2: node number 1 % External loads
% #3: node number 2 % F=[#1 #2 #3]
truss/truss_ex1.m
% % #1: node number
ELEM=[ % #2: x-directional load
112 % #3: y-directional load
213 F=zeros(nnode,3);
3 1 4]; for i=1:nnode, F(i,1)=i;, end
nelem=length(ELEM); % total number of elements F(1,3)=-1E6; 19/86
1. Input Data : truss_ex1.m 2 3
%%%%%%%%%%%%%%%%%%%%%%%%
% Plot truss structure
%%%%%%%%%%%%%%%%%%%%%%%%
figure(1) (2)
plot(NODE(:,2),NODE(:,3),'ro'), hold on 1m (1)
text(NODE(:,2)+0.02*max(NODE(:,2)),NODE(:,3),int2str(NODE(:,1)));
for i=1:nelem
x1=NODE(ELEM(i,2),2); 4
y1=NODE(ELEM(i,2),3); (3)
1
x2=NODE(ELEM(i,3),2);
y2=NODE(ELEM(i,3),3); 1m
1 MN
X=[x1,x2]; Y = [y1,y2];
original shape of the structure
figure(1) 1 2 3
plot(X,Y)
0.9
text((x1+x2)/2,(y1+y2)/2,int2str(ELEM(i,1)));
end 0.8
title('original shape of the structure'), axis equal 0.7
hold off
0.6

0.5 1 2

0.4

0.3

0.2

0.1

0 1 3 4
0 0.2 0.4 0.6 0.8 1

20/86
2. Solve : truss_sol.m %
% Apply boundary conditions
% %
% Construct system matrix and solve 2D-plane truss problem lambda=1e6*GK(1,1);
% Global mass and stiffness matrices for i=1:nnode, for j=1:ndof
% if BC(i,j+1)==1
GK=zeros(ndof*nnode,ndof*nnode); ii=ndof*(i-1)+j;
GM=zeros(ndof*nnode,ndof*nnode); GK(:,ndof*(i-1)+j)=0; GK(ndof*(i-1)+j,:)=0;
GF=zeros(ndof*nnode,1); GK(ii,ii)=lambda;
for l=1:nelem GM(:,ndof*(i-1)+j)=0; GM(ndof*(i-1)+j,:)=0;
% GM(ii,ii)=1;
% Element stiffness matrix end, end,end
% if Atype==1
dx=NODE(ELEM(l,3),2)-NODE(ELEM(l,2),2); %
dy=NODE(ELEM(l,3),3)-NODE(ELEM(l,2),3); % Solve static truss problem
L=sqrt(dx^2+dy^2); % element length %
Ca=dx/L; Sa=dy/L; % cos & sin (alpha) GU=inv(GK)*GF;
elseif Atype==2
T=[Ca Sa 0 0;-Sa Ca 0 0;0 0 Ca Sa;0 0 -Sa Ca]; % transform matrix %
SKE1=E*A/L*[1 0 -1 0;0 0 0 0;-1 0 1 0;0 0 0 0]; % element stiffness matrix % Solve eigenvalue problem
SME1=rho*A*L/6*[2 0 1 0;0 2 0 1;1 0 2 0;0 1 0 2]; %
SKE=T'*SKE1*T; % element stiffness matrix [eig_vec1,eig_val1]=eig(GK,GM);
SME=T'*SME1*T; % element mass matrix %
% Sort Eigenvectors and Eigenvalues
% Assemble global stiffness matrix %
for i=1:npe [eig_val2,index]=sort(diag(eig_val1));
for j=1:npe eig_vec2=eig_vec1(:,index);
ii=ndof*ELEM(l,i+1)-ndof+1; jj=ndof*ELEM(l,j+1)-ndof+1;
GK(ii:ii+ndof-1,jj:jj+ndof-1)=GK(ii:ii+ndof-1,jj:jj+ndof-1) ... % extract required modes
+SKE(ndof*i-ndof+1:ndof*i,ndof*j-ndof+1:ndof*j); eigval=eig_val2(1:nmode,1);
eigvec=eig_vec2(:,1:nmode);
GM(ii:ii+ndof-1,jj:jj+ndof-1)=GM(ii:ii+ndof-1,jj:jj+ndof-1) ... % natural frequency
+SME(ndof*i-ndof+1:ndof*i,ndof*j-ndof+1:ndof*j); omega=sqrt(eigval)/2/pi %Hz
end end
GF(ndof*(i-1)+j,1)=F(i,j+1);
end, end 21/86
3. Post process (static) : truss_out_static.m
% Displacement: U[#1,#2,#3]
% #1: node number
% #2: x-directional displacement deformed and undeformed shape

% #3: y-directional displacement undeformed shape


0.9
for i=1:nnode deformed shape
0.8
U(i,1)=i;
for j=1:ndof 0.7

U(i,j+1)=GU(ndof*(i-1)+j); 0.6

end, end 0.5 1 2

% 0.4
% Plot deformed shape 0.3
%
0.2
figure(2)
0.1
mag=20;
for i=1:nelem 0 3

x1=NODE(ELEM(i,2),2); -0.1
-0.2 0 0.2 0.4 0.6 0.8 1 1.2
y1=NODE(ELEM(i,2),3);
x2=NODE(ELEM(i,3),2);
y2=NODE(ELEM(i,3),3);
X=[x1,x2]; Y = [y1,y2]; Deformed and undeformed shape
dx1=NODE(ELEM(i,2),2)+mag*U(ELEM(i,2),2);
dy1=NODE(ELEM(i,2),3)+mag*U(ELEM(i,2),3);
dx2=NODE(ELEM(i,3),2)+mag*U(ELEM(i,3),2);
dy2=NODE(ELEM(i,3),3)+mag*U(ELEM(i,3),3);
dX=[dx1,dx2]; dY = [dy1,dy2];

figure(2)
plot(X,Y,'-b',dX,dY,'-r'),hold on
legend('undeformed shape','deformed shape')
text((x1+x2)/2,(y1+y2)/2,int2str(ELEM(i,1)));
end 22/86
title('deformed and undeformed shape'), axis equal, hold off
stress at each truss
% 400
% Computation of axial stress
% Axial stress: sigma[#1,#2] 300
% #1: node number
% #2: axial stress
200
%

stress (MPa)
for l=1:nelem
100
sigma(l,1)=l;
%
% Element stiffness matrix 0

%
dx=NODE(ELEM(l,3),2)-NODE(ELEM(l,2),2); -100

dy=NODE(ELEM(l,3),3)-NODE(ELEM(l,2),3);
L=sqrt(dx^2+dy^2); % element length -200
1 2 3
Ca=dx/L; Sa=dy/L; % cos & sin (alpha) element number
T1=[-Ca -Sa Ca Sa]; % transform matrix
for i=1:2*ndof
DU(1,1)=U(ELEM(l,2),2); Stresses of each element
DU(2,1)=U(ELEM(l,2),3);
DU(3,1)=U(ELEM(l,3),2);
DU(4,1)=U(ELEM(l,3),3); >> load disp.dat
end >> disp
sigma(l,2)=E/L*T1*DU/1e6; % element stiffness matrix disp =
end 1.0000 0.0015 -0.0057
figure(3) 2.0000 0 0
bar(sigma(:,2)) 3.0000 0 0
xlabel('element number') 4.0000 0 0
ylabel('stress (MPa)') >> load sigma.dat
title('stress at each truss') >> sigma
sigma =
save disp.dat U -ascii 1.0000 396.4466
save sigma.dat sigma -ascii 2.0000 146.4466
3.0000 -103.5534
23/86
4. Post process (modal) : truss_out_modal.m 1
1
% Displacement: U[#1,#2,#3] undeformed shape

% #1: node number deformed shape

% #2: x-directional displacement


% #3: y-directional displacement 0.5

for mm=1:nmode
GU(:,1)=eigvec(:,mm);
for i=1:nnode
U(i,1)=i; 0

for j=1:ndof
U(i,j+1)=GU(ndof*(i-1)+j);
end -0.5
end -0.5 0 0.5 1

% Plot deformed shape


mag=1; % magnification factor mode1
for i=1:nelem 2
x1=NODE(ELEM(i,2),2); y1=NODE(ELEM(i,2),3); 1
undeformed shape
x2=NODE(ELEM(i,3),2); y2=NODE(ELEM(i,3),3); deformed shape

X=[x1,x2]; Y = [y1,y2];
0.5
dx1=NODE(ELEM(i,2),2)+mag*U(ELEM(i,2),2);
dy1=NODE(ELEM(i,2),3)+mag*U(ELEM(i,2),3);
dx2=NODE(ELEM(i,3),2)+mag*U(ELEM(i,3),2);
dy2=NODE(ELEM(i,3),3)+mag*U(ELEM(i,3),3); 0

dX=[dx1,dx2]; dY = [dy1,dy2];

figure(mm+1)
plot(X,Y,'-b',dX,dY,'-r'),hold on -0.5
-0.5 0 0.5 1

end
title(mm); % mode number
legend('undeformed shape','deformed shape') mode2
hold off 24/86
end
5. Post process : truss_movie.m
% Free response of each mode shape
mm=1; % mode number
GU(:,1)=eigvec(:,mm);
for i=1:nnode
U(i,1)=i;
for j=1:ndof, U(i,j+1)=GU(ndof*(i-1)+j); end
end
% Plot deformed shape
for kk=1:100
for i=1:nelem
x1=NODE(ELEM(i,2),2); y1=NODE(ELEM(i,2),3);
x2=NODE(ELEM(i,3),2); y2=NODE(ELEM(i,3),3);
X=[x1,x2]; Y = [y1,y2];
mode1
mag=sin(pi/12*(kk-1));
dx1=NODE(ELEM(i,2),2)+mag*U(ELEM(i,2),2);
dy1=NODE(ELEM(i,2),3)+mag*U(ELEM(i,2),3);
dx2=NODE(ELEM(i,3),2)+mag*U(ELEM(i,3),2);
dy2=NODE(ELEM(i,3),3)+mag*U(ELEM(i,3),3);
dX=[dx1,dx2]; dY = [dy1,dy2];

figure(mm+1)
plot(X,Y,'-b',dX,dY,'-r'),hold on
end
title('modal vibration')
hold off
axis([0 13 -1 4])
F1(kk)=getframe;
end
movie(F1) mode2
%movie2avi(F1,'temp.avi') 25/86
Truss ex1
Provide ANSYS solution Using workbench ( )

2 3

(2)
1m (1)

(3) 4
1
1m
1 MN

26/86
Truss ex2
Find natural frequency and mode shape of the given truss structure
Aluminum: E=70GPa, A=0.002m2, rho=2700Kg/m3, P=1MN

L=1m

27/86
%
1. Input Data : truss_ex2.m % Area of the cross-section
% %
% INPUT FOR 2D-PLANE TRUSS PROBLEM A=0.002;
% SI unit %
% Information of truss element % Young's Modulus
% %
ndof=2; % degree of freedom for each node E=70E9; L=1m
npe=2; % node per element %
nmode=2; % number of mode extracted % mass density
% Node data %
% NODE=[#1 #2 #3] rho=2700;
% #1: node number %
% #2: x-coordinate % Input boundary conditions
% #3: y-coordinate % BC=[#1 #2 #3]
NODE=[ % #1: node number
10 0 % #2: x-constraint (0:free, 1:fixed)
21 0 % #3: y-constraint (0:free, 1:fixed)
3 0.5 0.866]; BC=zeros(nnode,3);
nnode=length(NODE); % total number of node for i=1:nnode, BC(i,1)=i;, end
% %
% Element data BC(1,2)=1;
% ELEM=[#1 #2 #3] BC(2,3)=1;
% #1: element number BC(3,2)=1; BC(3,3)=1;
% #2: node number 1 %%%%%%%%%%%%%%%%%%
% #3: node number 2 % External loads
% % F=[#1 #2 #3]
ELEM=[ % #1: node number
112 % #2: x-directional load
213 % #3: y-directional load
3 2 3]; F=zeros(nnode,3);
nelem=length(ELEM); % total number of elements for i=1:nnode, F(i,1)=i;, end
F(2,2)=1E6; 28/86
Truss ex2 (Static Analysis)
deformed and undeformed shape stress at each truss
400
undeformed shape
0.8
deformed shape
350
0.7
300
0.6
250
0.5

stress (MPa)
2 3 200
0.4

150
0.3

100
0.2

0.1 50

0 1 0
0 0.2 0.4 0.6 0.8 1 1 2 3
element number

Deformed and undeformed shape Stresses of each element


>> disp >> sigmasigma = 1.0000 399.9947
disp = 1.0000 0 0 2.0000 0
2.0000 0.0057 0 3.0000 200.0062
3.0000 0 0

29/86
Truss ex2 (Modal Analysis)
1 2
0.9 0.9
undeformed shape undeformed shape
0.8 deformed shape 0.8 deformed shape

0.7 0.7

0.6 0.6

0.5 0.5

0.4 0.4

0.3 0.3

0.2 0.2

0.1 0.1

0 0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6

mode1 mode2

30/86
Exercise: Truss ex3
Find first six natural frequencies and mode shapes of the given truss structure
Aluminum: E=70GPa, A=0.002m2, rho=2700Kg/m3
100kN 200kN
1m 1m

1m

31/86
Truss ex3 (Static analysis)
deformed and undeformed shape stress at each truss
1.2 250
undeformed shape
deformed shape 200
1 3 6
150
0.8
100

0.6
50

stress (MPa)
2 4 5
0.4 0

-50
0.2

-100
0 1
-150
-0.2
-200

-0.4 -250
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 1 2 3 4 5 6
element number

Deformed and undeformed shape Stresses of each element


>> dispdisp = 1.0000e+000 0 0 >> sigmasigma = 1.0000e+000 -2.5000e+002
2.0000e+000 -3.5714e-003 -9.6323e-003 2.0000e+000 2.1213e+002
3.0000e+000 0 0 3.0000e+000 1.0000e+002
4.0000e+000 1.4286e-003 -1.0347e-002 4.0000e+000 -5.0000e+001
5.0000e+000 2.8571e-003 -2.0102e-002 5.0000e+000 -1.4142e+002
6.0000e+000 1.0000e+002

32/86
Truss ex3 (Modal analysis)
original shape of the structure
Mode shapes
1.2
1 2
1 3 3 4 6 5 1.5 1.5
1 1
0.8
0.5 0.5
0.6 0 0
2 4 5
-0.5 -0.5
0.4 0 0.5 1 1.5 2 2.5 0 0.5 1 1.5 2 2.5
3 4
0.2
1.5 1.5
1 1
0 1 1 2
0.5 0.5
-0.2 0 0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 -0.5 -0.5
0 0.5 1 1.5 2 2.5 0 0.5 1 1.5 2 2.5
5 6
1.5 1.5
1 1
0.5 0.5
0 0
-0.5 -0.5
0 0.5 1 1.5 2 2.5 0 0.5 1 1.5 2 2.5

33/86
Exercise: Truss ex4
Find first six natural frequencies and mode shapes of the given truss structure
Aluminum: E=70GPa, A=0.002m2, rho=2700Kg/m3

2m

2m 2m

500kN

34/86
Truss ex4 (Static analysis)
deformed and undeformed shape stress at each truss
150
undeformed shape
2 deformed shape

7 100

1.5

50
1

stress (MPa)
3 4 5 6
0
0.5

-50
0 1 2

-100
-0.5

-150
0 0.5 1 1.5 2 2.5 3 3.5 4 1 2 3 4 5 6 7
element number

Deformed and undeformed shape Stresses of each element


>> load disp.dat >> load sigma.dat
2.0000e+000 2.0620e-003 -1.3095e-002 1.0000e+000 7.2171e+001
3.0000e+000 4.1241e-003 0 2.0000e+000 7.2171e+001
4.0000e+000 4.1241e-003 -7.1430e-003 3.0000e+000 -1.4434e+002
5.0000e+000 -1.3959e-018 -7.1430e-003 4.0000e+000 1.4434e+002
5.0000e+000 1.4434e+002
>> disp 6.0000e+000 -1.4434e+002
disp = 7.0000e+000 -1.4434e+002
1.0000e+000 0 0 >> sigma
sigma =
35/86
Truss ex4 (Modal analysis)
original shape of the structure

Mode shapes
2

4 7 5
1 2
1.5 3 3
2 2
1
3 4 5 6 1 1
0 0
0.5
-1 -1
0 1 2 3 4 5 0 1 2 3 4 5
0 1 1 2 2 3 3 4
3 3
-0.5 2 2
1 1
0 0.5 1 1.5 2 2.5 3 3.5 4
0 0
-1 -1
0 1 2 3 4 5 0 1 2 3 4 5
5 6
3 3
2 2
1 1
0 0
-1 -1
0 1 2 3 4 5 0 1 2 3 4 5

36/86
Exercise: Truss ex5
Find first six natural frequencies and mode shapes of the given truss structure
Steel: E=200GPa, A=0.0025m2, rho=7850Kg/m3

100kN 300kN

37/86
Truss ex5 (Static analysis)
deformed and undeformed shape stress at each truss
6 150
undeformed shape
5 deformed shape
100

4
50
3 6

stress (MPa)
2 0
2 3 5 7 9
1
-50
0 1 4 8

-100
-1

-2 -150

-3
-200
0 2 4 6 8 10 12 1 2 3 4 5 6 7 8 9
element number

Deformed and undeformed shape Stresses of each element


>> load sigma.dat
>> load disp.dat >> sigma
>> disp sigma =
disp = 1.0000e+000 8.8889e+001
1.0000e+000 0 0 2.0000e+000 -1.1111e+002
2.0000e+000 1.7778e-003 -1.1069e-002 3.0000e+000 4.0000e+001
3.0000e+000 4.3796e-003 -1.0469e-002 4.0000e+000 8.8889e+001
4.0000e+000 3.5556e-003 -1.3420e-002 5.0000e+000 4.4444e+001
5.0000e+000 1.8907e-003 -1.2020e-002 6.0000e+000 -1.2444e+002
6.0000e+000 6.0444e-003 0 7.0000e+000 9.3333e+001
8.0000e+000 1.2444e+002
9.0000e+000 -1.5556e+002 38/86
Truss ex5
original shape of the structure
6
Mode shapes
5

4 1 2
4 4
3 3 6 5

2
2 2
2 3 5 7 9
1 0 0

0 1 1 2 4 4 8 6 -2 -2
0 5 10 0 5 10
-1 3 4
4 4
-2
2 2
-3
0 2 4 6 8 10 12 0 0

-2 -2
0 5 10 0 5 10
5 6
4 4

2 2

0 0

-2 -2
0 5 10 0 5 10

39/86
3. Beam Element

40/86
Beam element
Nodal degree of freedom: deflection(v), rotation() y
v(x) 2
T
d   v1 1 v2  2 
1
v1 v2
Hermite shape function:
v  c1  c2 x  c3 x 2  c4 x 3 x
① ②
Boundary conditions: at node 1 (x  0) at node 2 (x  Le )
v(0)  c1  v1 v( Le )  c1  c2 Le  c3 L2e  c4 L3e  v1  1Le  c3 L2e  c4 L3e  v2
dv(0) dv ( Le )
 c2  1  1  2c3 Le  3c4 L2e   2
dx dx
3 (  21 ) 2 1
c3   2 (v1  v2 )  2 , c4  2 (v1  v2 )  2 (1   2 )
Le Le Le Le
3x 2 2 x 3 x 2 x 2 x3 3x 2 2 x 3  x2 x3
Shape function: v( x)  (1   ) v1  Le (   )1  (  ) v 2  Le (  3 ) 2
L2e L3e Le L2e L3e L2e L3e L2e Le

v  N1v1  N 21  N 3v2  N 4 2

3x 2 2 x3 x 2x2 x3 3x 2 2 x 3  x 2 x3
N1  (1   ), N 2  Le (   ), N 3  (  ), N 4  Le (  3)
L2e L3e Le L2e L3e L2e L3e L2e Le

41/86
Beam element

Element mass matrix


 156 22 Le 54 13Le 
 
L  ALe  22 Le 4 L2e 13Le 3L2e 

T
 M e    N   N   Adx  M e  
0 420  54 13Le 156 22 Le 

 13L 3L2e 22 Le 2 
4 Le 
 e

Element stiffness matrix


L  12 6 Le 12 6 Le 

T
 K e    B  EI B dx  2 
0 EI  6 Le 4 Le 6 Le 2 L2e 
 K e   3 
B    N1'' N 2'' N3'' N 4''  Le  12 6 Le 12 6 Le 
  
6L 2 2 
EI : bending rigidity  e 2 Le 6 Le 4 Le 

42/86
Finite element code of beam using MATLAB
1. Input data Input data:beam_in.m
Materials, node and element definition
 Node data Boundary conditions, loads

 Element data
 Area, Solve:beam_sol.m
 Second moment of area (Izz)
 Material data Evaluate results:beam_out.m

 Boundary conditions
 External load Is this satisfy no
2. Output data design requirement?

 Static Analysis
yes
 Nodal displacement
Present results
 Modal Analysis
 Natural frequency Flow chart of beam problem
 Mode shape
43/86
beam ex1
Find static deflection, first three natural frequencies and mode shapes of the given
cantilevered beam.
Steel: E=100GPa, rho=1000 Kg/m3

500N
Cross section

20cm

1m
20cm

A  0.02  0.02  4e  4m 2
bh3 0.02(0.02)3
I zz    1.3333e  8m 4
12 12

44/86
0. Beam main program : beam.m %--------------------------------------------------------------
% < Solution Procedure >
% %--------------------------------------------------------------
% Beam program beam_sol
% SI unit
% %--------------------------------------------------------------
clear all; close all; % < Postprocess >
%--------------------------------------------------------------
%-------------------------------------------------------------- if Atype==1
% < Input Beam information > beam_out_static
%-------------------------------------------------------------- elseif Atype==2
beam_ex1 beam_out_modal
%beam_ex2 %beam_movie
end
%--------------------------------------------------------------
% < Choose Static or Modal Analysis >
%--------------------------------------------------------------
fprintf('\n\n* < Press 1 or 2 to choose analysis type >')
fprintf('\n => Static Analysis = 1')
fprintf('\n Modal Analysis = 2\n')
Atype=input(' Analysis type ? '); See beam/beam.m

45/86
%
1. Input Data : beam_ex1.m % Area of the cross-section
% % 500N
% INPUT FOR 2D-PLANE TRUSS PROBLEM A=4e-4;
% SI unit Izz=1.3333e-8;
% Information of truss element %
% % Young's Modulus 1m
ndof=2; % degree of freedom for each node %
npe=2; % node per element E=100E9;%
nmode=3; % number of mode extracted % mass density 20cm
% Node data %
% NODE=[#1 #2 #3] rho=1000;
% #1: node number 20cm
%
% #2: x-coordinate % Input boundary conditions
% #3: y-coordinate % BC=[#1 #2 #3]
nelem=3; % number of element
original shape of the structure
% #1: node number
nnode=nelem+1; % total number of node % #2: x-constraint (0:free, 1:fixed) 0.3

BEAML=1; % length of beam % #3: z-rotation (0:free, 1:fixed) 0.2


NODE=zeros(nnode,3); BC=zeros(nnode,3); 0.1
for i=1:nnode for i=1:nnode, BC(i,1)=i;, end
NODE(i,1)=i; BC(1,2)=1; BC(1,3)=1;
0 1 1 2 2 3 3 4

NODE(i,2)=BEAML/nelem*(i-1); %%%%%%%%%%%%%%%%%% -0.1

end % External loads -0.2

% % F=[#1 #2 #3] -0.3


% Element data % #1: node number
% ELEM=[#1 #2 #3] % #2: y-directional load, shear load 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

% #1: element number % #3: z-rotation, moment


% #2: node number 1 %
% #3: node number 2 F=zeros(nnode,3);
% for i=1:nnode, F(i,1)=i;, end
for i=1:nelem %
ELEM(i,1)=i; ELEM(i,2)=i; ELEM(i,3)=i+1; F(nnode,2)=-500;
end 46/86
2. Solve : beam_sol.m
%
% Construct system matrix and solve beam problem
% Global mass and stiffness matrices
%
GK=zeros(ndof*nnode,ndof*nnode);
GM=zeros(ndof*nnode,ndof*nnode);
GF=zeros(ndof*nnode,1);
for l=1:nelem
L=NODE(ELEM(l,3),2)-NODE(ELEM(l,2),2); % element length
% element stiffness matrix
SKE=zeros(4,4);
SKE(1,1)=12*E*Izz/L^3; SKE(1,2)=6*E*Izz/L^2; SKE(1,3)=-12*E*Izz/L^3; SKE(1,4)=6*E*Izz/L^2;
SKE(2,1)=6*E*Izz/L^2; SKE(2,2)=4*E*Izz/L; SKE(2,3)=-6*E*Izz/L^2; SKE(2,4)=2*E*Izz/L;
SKE(3,1)=-12*E*Izz/L^3; SKE(3,2)=-6*E*Izz/L^2; SKE(3,3)=12*E*Izz/L^3; SKE(3,4)=-6*E*Izz/L^2;
SKE(4,1)=6*E*Izz/L^2; SKE(4,2)=2*E*Izz/L; SKE(4,3)=-6*E*Izz/L^2; SKE(4,4)=4*E*Izz/L;

% element mass matrix


SME=zeros(4,4);
SME(1,1)=rho*A*L/420*156; SME(1,2)=rho*A*L/420*22*L; SME(1,3)=rho*A*L/420*54; SME(1,4)=-rho*A*L/420*13*L;
SME(2,1)=rho*A*L/420*22*L; SME(2,2)=rho*A*L/420*4*L^2; SME(2,3)=rho*A*L/420*13*L; SME(2,4)=-rho*A*L/420*3*L^2;
SME(3,1)=rho*A*L/420*54; SME(3,2)=rho*A*L/420*13*L; SME(3,3)=rho*A*L/420*156; SME(3,4)=-rho*A*L/420*22*L;
SME(4,1)=-rho*A*L/420*13*L; SME(4,2)=-rho*A*L/420*3*L^2; SME(4,3)=-rho*A*L/420*22*L; SME(4,4)=rho*A*L/420*4*L^2;

% Assembe global stiffness matrix


for i=1:npe
for j=1:npe
ii=ndof*ELEM(l,i+1)-ndof+1; jj=ndof*ELEM(l,j+1)-ndof+1;
GK(ii:ii+ndof-1,jj:jj+ndof-1)=GK(ii:ii+ndof-1,jj:jj+ndof-1) ...
+SKE(ndof*i-ndof+1:ndof*i,ndof*j-ndof+1:ndof*j);
GM(ii:ii+ndof-1,jj:jj+ndof-1)=GM(ii:ii+ndof-1,jj:jj+ndof-1) ...
+SME(ndof*i-ndof+1:ndof*i,ndof*j-ndof+1:ndof*j);
end, end, end 47/86
if Atype==1
2. Solve : beam_sol.m %
% Solve static beam problem
(same as truss) %
% GU=inv(GK)*GF;
% Apply boundary conditions
% elseif Atype==2
lambda=1e6*GK(1,1); %
for i=1:nnode, for j=1:ndof % Solve eigenvalue problem
if BC(i,j+1)==1 %
ii=ndof*(i-1)+j; [eig_vec1,eig_val1]=eig(GK,GM);
GK(:,ndof*(i-1)+j)=0; GK(ndof*(i-1)+j,:)=0;
GK(ii,ii)=lambda; %
% Sort Eigenvectors and Eigenvalues
GM(:,ndof*(i-1)+j)=0; GM(ndof*(i-1)+j,:)=0; %
GM(ii,ii)=1; [eig_val2,index]=sort(diag(eig_val1));
end eig_vec2=eig_vec1(:,index);
GF(ndof*(i-1)+j,1)=F(i,j+1);
end,end % extract required modes
eigval=eig_val2(1:nmode,1);
eigvec=eig_vec2(:,1:nmode);
% natural frequency
omega=sqrt(eigval)/2/pi %Hz
end

48/86
figure(2)
3. Post process (static) : beam_out_static.m plot(X,Y,'-b',dX,dY,'-r'),hold on
% legend('undeformed shape','deformed shape')
% Post process of beam structures text((x1+x2)/2,(y1+y2)/2,int2str(ELEM(i,1)));
% end
% Displacement: U[#1,#2,#3] title('deformed and undeformed shape'), axis equal
% #1: node number hold off
% #2: y-directional displacement save disp.dat U -ascii
% #3: z-directional rotation
%
for i=1:nnode
U(i,1)=i;
for j=1:ndof deformed and undeformed shape

U(i,j+1)=GU(ndof*(i-1)+j); 0.3 undeformed shape

end, end 0.2


deformed shape

%
% Plot deformed shape 0.1

% 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
figure(2)
mag=1; -0.1

for i=1:nelem -0.2


x1=NODE(ELEM(i,2),2);
y1=NODE(ELEM(i,2),3); -0.3

x2=NODE(ELEM(i,3),2); -0.4
y2=NODE(ELEM(i,3),3);
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
X=[x1,x2]; Y = [y1,y2];

dx1=NODE(ELEM(i,2),2);
dy1=NODE(ELEM(i,2),3)+mag*U(ELEM(i,2),2);
dx2=NODE(ELEM(i,3),2);
dy2=NODE(ELEM(i,3),3)+mag*U(ELEM(i,3),2);
dX=[dx1,dx2]; dY = [dy1,dy2];
49/86
beam ex1 (Static analysis)
Number of elements: 1 Number of elements: 2 Number of elements: 4
deformed and undeformed shape deformed and undeformed shape deformed and undeformed shape
0.3 undeformed shape 0.3 0.3
undeformed shape undeformed shape
deformed shape deformed shape deformed shape
0.2 0.2 0.2

0.1 0.1 0.1

0 1 0 1 2 0 1 2 3 4

-0.1 -0.1 -0.1

-0.2 -0.2 -0.2

-0.3 -0.3 -0.3

-0.4 -0.4 -0.4

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

disp = disp = >> disp


2.0000 -0.1250 -0.1875 1.0000 0 0 1.0000 0 0
2.0000 -0.0391 -0.1406 2.0000 -0.0107 -0.0820
1.0000 0 0 3.0000 -0.1250 -0.1875 3.0000 -0.0391 -0.1406
4.0000 -0.0791 -0.1758
5.0000 -0.1250 -0.1875
disp =

 When shear force is applied: Since the Hermite shape


function is a cubic polynomial and matches the shape of the
exact solution, the displacement value at the node point is
accurate regardless of the number of elements.
50/86
4. Post process (modal) : beam_out_modal.m
%
% Post process of beam structures
for mm=1:nmode
GU(:,1)=eigvec(:,mm);
for i=1:nnode
U(i,1)=i;
for j=1:ndof, U(i,j+1)=GU(ndof*(i-1)+j);
end, end
% Plot deformed shape
mag=1; % magnification factor
for i=1:nelem
x1=NODE(ELEM(i,2),2); y1=NODE(ELEM(i,2),3);
x2=NODE(ELEM(i,3),2); y2=NODE(ELEM(i,3),3);
X=[x1,x2]; Y = [y1,y2];

dx1=NODE(ELEM(i,2),2);
dy1=NODE(ELEM(i,2),3)+mag*U(ELEM(i,2),2);
dx2=NODE(ELEM(i,3),2);
dy2=NODE(ELEM(i,3),3)+mag*U(ELEM(i,3),2);
dX=[dx1,dx2]; dY = [dy1,dy2];

figure(2)
subplot(3,1,mm),plot(X,Y,'-b',dX,dY,'-r'), hold on, axis([0 1 -4 4])
end
title(mm); % mode number
hold off
end

51/86
beam ex1 (modal analysis)
original shape of the structure Number of element: 3
1
4
0.3
2
0
0.2
-2
-4
0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
2
4
0 1 1 2 2 3 3 4
2
0
-0.1
-2
-4
-0.2 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
3
4
-0.3
2
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 -2
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Number
3 10 20 Number of element: 10
of elements:
1
4
2
0

Convergence -2
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
of frequency 4
2

2
0
-2
Unlike static analysis, it is necessary to -4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

increase the number of elements to obtain an


3
4
2

accurate solution due to the effect of inertial 0


-2
52/86
force. -4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Exercise: beam ex2
Find static deflection, first three natural frequencies and mode shapes of the given
clamped-clamped beam using 4, 8, 16 elements
Steel: E=100GPa, rho=1000 Kg/m3

5kN Cross section

20cm

1m
20cm

A  0.02  0.02  4e  4m 2
bh3 0.02(0.02)3
I zz    1.3333e  8m 4
12 12

53/86
beam ex2 (Static analysis)
Number of elements: 4 Number of elements: 8 Number of elements: 16
deformed and undeformed shape deformed and undeformed shape deformed and undeformed shape

undeformed shape undeformed shape undeformed shape


0.3 deformed shape 0.3 deformed shape 0.3 deformed shape

0.2 0.2 0.2

0.1 0.1 0.1

0 1 2 3 4 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

-0.1 -0.1 -0.1

-0.2 -0.2 -0.2

-0.3 -0.3 -0.3

-0.4 -0.4 -0.4


0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

54/86
beam ex2 (Modal analysis)
Number of element: 4 Number of element: 8
1 1
4 4
2 2
0 0
-2 -2
-4 -4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
2 2
4 4
2 2
0 0
-2 -2
-4 -4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
3 3
4 4
2 2
0 0
-2 -2
-4 -4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Number of element: 16
Number 4
1

4 8 16
of elements:
2
0
-2
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
2
4
Convergence 2
0

of frequency -2
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
3
4
2
0
-2
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
55/86
Exercise: beam ex3
Find static deflection, first three natural frequencies and mode shapes of the given
simply supported beam using 4, 8, 16 elements
Steel: E=100GPa, rho=1000 Kg/m3

5kN m Cross section

20cm

1m
20cm

A  0.02  0.02  4e  4m 2
bh3 0.02(0.02)3
I zz    1.3333e  8m 4
12 12

56/86
beam ex3 (Static analysis)
Number of elements: 4 Number of elements: 8 Number of elements: 16
deformed and undeformed shape
deformed and undeformed shape deformed and undeformed shape
undeformed shape
undeformed shape undeformed shape
0.3 deformed shape
deformed shape 0.3 deformed shape
0.3

0.2
0.2 0.2

0.1
0.1 0.1

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
0 1 2 3 4 0 1 2 3 4 5 6 7 8

-0.1
-0.1 -0.1

-0.2
-0.2 -0.2

-0.3
-0.3 -0.3

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

57/86
beam ex3 (Modal analysis)
Number of element: 4 1 Number of element: 8 1
4 4
2 2
0 0
-2 -2
-4 -4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
2 2
4 4
2 2
0 0
-2 -2
-4 -4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
3 3
4 4
2 2
0 0
-2 -2
-4 -4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Number of element: 16 1
Number 4

4 8 16 2

of elements: -2
0

-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
2
4

Convergence 2
0

of frequency
-2
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
3
4
2
0
-2
-4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 58/86
4. Frame Element

59/86
Frame element
Nodal degree of freedom: axial displacement(u), deflection(v), rotation()
Frame element = bar element + beam element v2

Nodal degree of freedom for element coordinate θ


u2
Y v1
de   u1 v1 1 u2 v2 2 T ② 2

Nodal degree of freedom for global coordinate θ u1

d   u1 v1 1 u2 v2  2 
T
① 1
x
Coordinate transformation

 u1   cos sin  0 0 0 0   u1 
    
 v1    sin  cos  0 0 0 0   v1 

1   0 0 1 0 0 0  1  de   T d 
   
u2   0 0 0 cos sin  0  u2 
 v2   0 0 0  sin  cos  0   v2 
    
 2 
   0 0 0 0 0 1  
 2 

60/86
Frame element
Element mass and stiffness matrices for local coordinate
 EA EA 
 0 0  0 0 
 Le Le 
 12 EI 6 EI 12 EI 6 EI 
140 0 0 70 0 0   0 0  
   L3e L2e L3e L2e 
 0 156 22 Le 0 54 13Le  
   0 6 EI 4 EI 6 EI 2 EI 
4 L2e 3L2e  0 
 ALe  0 22 Le 0 13Le  L2e Le L2e Le 
 M e   420  70 0 0 140 0 0   K e    EA 
 EA
 
 L 0 0 0 0 
 0 54 13Le 0 156 22 Le  e Le
   
 0 13Le 3L2e 0 22 Le 4 L2e   12 EI 6 EI 12 EI 6 EI 
 0   0  2 
 L3e L2e L3e Le 
 6 EI 2 EI 6 EI 4 EI 
 0 0  
 L2e Le L2e Le 

Element mass and stiffness matrices for global coordinate

 M e   T T  M e  T   K e   T T  K e  T 


   

61/86
Finite element code of frame using MATLAB
1. Input data
Input data:frame_in.m
 Node data Materials, node and element definition
Boundary conditions, loads
 Element data
 Area, Solve:frame_sol.m
 Second moment of area (Izz)
 Material data Evaluate results:frame_out.m
 Boundary conditions
 External load
Is this satisfy no
2. Output data design requirement?
 Static Analysis
yes
 Nodal displacement
 Modal Analysis Present results

 Natural frequency Flow chart of beam problem


 Mode shape
62/86
Frame ex1
Find static deflection, first six natural frequencies and mode shapes of the given
frame structure using 3, 15, 30 elements
Steel: E=200GPa, rho=7850 Kg/m3
Cross section
2m 3
2

5kN 30cm

1.5 m 10cm

A  0.01  0.03  3e  4m 2
bh3 0.01(0.03)3
I zz    2.25e  8m 4
1 4 12 12

63/86
0. Frame main program : frame.m %--------------------------------------------------------------
% < Solution Procedure >
% %--------------------------------------------------------------
% 2D-Frame program frame_sol
% SI unit
% %--------------------------------------------------------------
clear all; close all; % < Postprocess >
%--------------------------------------------------------------
%-------------------------------------------------------------- if Atype==1
% < Input Beam information > frame_out_static
%-------------------------------------------------------------- elseif Atype==2
frame_ex1 frame_out_modal
%frame_ex11 %frame_movie
%frame_ex2 end
%frame_ex22

%--------------------------------------------------------------
% < Choose Static or Modal Analysis >
%--------------------------------------------------------------
fprintf('\n\n* < Press 1 or 2 to choose analysis type >')
fprintf('\n => Static Analysis = 1') See frame/frame.m
fprintf('\n Modal Analysis = 2\n')
Atype=input(' Analysis type ? ');

64/86
%
1. Input Data : frame_ex1.m % Area of the cross-section
2m

% %
% INPUT FOR 2D-FRAME PROBLEM A=3e-4;
% SI unit Izz=2.25e-8; 1.5 m
% Information of truss element %
% % Young's Modulus
ndof=3; % degree of freedom for each node %
npe=2; % node per element E=200E9;%
nmode=6; % number of mode extracted % mass density
% Node data %
% NODE=[#1 #2 #3] rho=7850;
% #1: node number % 2
original shape of the structure

% #2: x-coordinate % Input boundary conditions


% #3: y-coordinate % BC=[#1 #2 #3 #4] 1.5 2 2 3

NODE=[ % #1: node number


10 0 % #2: x-constraint (0:free, 1:fixed) 1

2 0 1.5 % #3: y-constraint (0:free, 1:fixed) 1 3


3 2 1.5 % #4: z-rotation (0:free, 1:fixed) 0.5
4 2 0]; BC=zeros(nnode,4);
nnode=length(NODE); for i=1:nnode, BC(i,1)=i;, end 0 1 4
% BC(1,2)=1; BC(1,3)=1; BC(1,4)=1;
% Element data BC(4,2)=1; BC(4,3)=1; BC(4,4)=1; -0.5
% ELEM=[#1 #2 #3] %%%%%%%%%%%%%%%%%%
-0.5 0 0.5 1 1.5 2 2.5

% #1: element number % External loads


% #2: node number 1 % F=[#1 #2 #3 #4]
% #3: node number 2 % #1: node number
% % #2: x-directional load, shear load
ELEM=[ % #3: y-directional load, shear load
112 % #4: z-rotation, moment
223 F=zeros(nnode,4);
3 3 4]; for i=1:nnode, F(i,1)=i;, end
nelem=length(ELEM); F(2,2)=5000; 65/86
2. Solve : frame_sol.m
%
% Construct system matrix and solve 2D-frame problem
% Global mass and stiffness matrices
%
GK=zeros(ndof*nnode,ndof*nnode);
GM=zeros(ndof*nnode,ndof*nnode);
GF=zeros(ndof*nnode,1);
for l=1:nelem
%
% Element stiffness matrix
%
dx=NODE(ELEM(l,3),2)-NODE(ELEM(l,2),2);
dy=NODE(ELEM(l,3),3)-NODE(ELEM(l,2),3);
L=sqrt(dx^2+dy^2); % element length
Ca=dx/L; Sa=dy/L; % cos & sin (alpha)
% transformation matrix
T=[Ca Sa 0 0 0 0;
-Sa Ca 0 0 0 0;
0 0 1 0 0 0;
0 0 0 Ca Sa 0;
0 0 0 -Sa Ca 0;
0 0 0 0 0 1];

% element stiffness matrix


SKExy=zeros(6,6);
SKExy(1,1)=A*E/L; SKExy(1,4)=-A*E/L;
SKExy(2,2)=12*E*Izz/L^3; SKExy(2,3)=6*E*Izz/L^2; SKExy(2,5)=-12*E*Izz/L^3; SKExy(2,6)=6*E*Izz/L^2;
SKExy(3,2)=6*E*Izz/L^2; SKExy(3,3)=4*E*Izz/L; SKExy(3,5)=-6*E*Izz/L^2; SKExy(3,6)=2*E*Izz/L;
SKExy(4,1)=-A*E/L; SKExy(4,4)=A*E/L;
SKExy(5,2)=-12*E*Izz/L^3; SKExy(5,3)=-6*E*Izz/L^2; SKExy(5,5)=12*E*Izz/L^3; SKExy(5,6)=-6*E*Izz/L^2;
SKExy(6,2)=6*E*Izz/L^2; SKExy(6,3)=2*E*Izz/L; SKExy(6,5)=-6*E*Izz/L^2; SKExy(6,6)=4*E*Izz/L;
66/86
SKE=T'*SKExy*T;
2. Solve : frame_sol.m
% element mass matrix
SMExy=zeros(6,6);
SMExy(1,1)=rho*A*L/420*140; SMExy(1,4)=rho*A*L/420*70;
SMExy(2,2)=rho*A*L/420*156; SMExy(2,3)=rho*A*L/420*22*L; SMExy(2,5)=rho*A*L/420*54;
SMExy(2,6)=-rho*A*L/420*13*L;
SMExy(3,2)=rho*A*L/420*22*L; SMExy(3,3)=rho*A*L/420*4*L^2; SMExy(3,5)=rho*A*L/420*13*L;
SMExy(3,6)=-rho*A*L/420*3*L^2;
SMExy(4,1)=rho*A*L/420*70; SMExy(4,4)=rho*A*L/420*140;
SMExy(5,2)=rho*A*L/420*54; SMExy(5,3)=rho*A*L/420*13*L; SMExy(5,5)=rho*A*L/420*156;
SMExy(5,6)=-rho*A*L/420*22*L;
SMExy(6,2)=-rho*A*L/420*13*L; SMExy(6,3)=-rho*A*L/420*3*L^2; SMExy(6,5)=-rho*A*L/420*22*L;
SMExy(6,6)=rho*A*L/420*4*L^2;

SME=T'*SMExy*T;

% Assembe global stiffness matrix


for i=1:npe
for j=1:npe
ii=ndof*ELEM(l,i+1)-ndof+1; jj=ndof*ELEM(l,j+1)-ndof+1;
GK(ii:ii+ndof-1,jj:jj+ndof-1)=GK(ii:ii+ndof-1,jj:jj+ndof-1) ...
+SKE(ndof*i-ndof+1:ndof*i,ndof*j-ndof+1:ndof*j);
GM(ii:ii+ndof-1,jj:jj+ndof-1)=GM(ii:ii+ndof-1,jj:jj+ndof-1) ...
+SME(ndof*i-ndof+1:ndof*i,ndof*j-ndof+1:ndof*j);
end
end
end

67/86
2. Solve : frame_sol.m if Atype==1
%
% Solve static beam problem
(same as truss) %
% GU=inv(GK)*GF;
% Apply boundary conditions
% elseif Atype==2
lambda=1e6*GK(1,1); %
for i=1:nnode, for j=1:ndof % Solve eigenvalue problem
if BC(i,j+1)==1 %
ii=ndof*(i-1)+j; [eig_vec1,eig_val1]=eig(GK,GM);
GK(:,ndof*(i-1)+j)=0; GK(ndof*(i-1)+j,:)=0;
GK(ii,ii)=lambda; %
% Sort Eigenvectors and Eigenvalues
GM(:,ndof*(i-1)+j)=0; GM(ndof*(i-1)+j,:)=0; %
GM(ii,ii)=1; [eig_val2,index]=sort(diag(eig_val1));
end eig_vec2=eig_vec1(:,index);
GF(ndof*(i-1)+j,1)=F(i,j+1);
end,end % extract required modes
eigval=eig_val2(1:nmode,1);
eigvec=eig_vec2(:,1:nmode);
% natural frequency
omega=sqrt(eigval)/2/pi %Hz
end

68/86
figure(2)
3. Post process : frame_out_static.m plot(X,Y,'-b',dX,dY,'-r'),hold on
% Post process of 2D-plane frame structures legend('undeformed shape','deformed shape')
% Displacement: U[#1,#2,#3,#4] text((x1+x2)/2,(y1+y2)/2,int2str(ELEM(i,1)));
% #1: node number end
% #2: x-directional displacement title('deformed and undeformed shape'), axis equal
% #3: y-directional displacement hold off
% #4: z-directional rotation
for i=1:nnode save disp.dat U -ascii
U(i,1)=i;
for j=1:ndof
U(i,j+1)=GU(ndof*(i-1)+j);
end
end deformed and undeformed shape
1.6
% 11 12 13 14 15 16 17 18 19 20
% Plot deformed shape 1.4 10 21

% 1.2
9
undeformed shape
22

figure(2) 8 deformed shape 23


17
mag=1; 24

for i=1:nelem 0.8 6 25

x1=NODE(ELEM(i,2),2); 0.6
5 26

y1=NODE(ELEM(i,2),3); 4 27
0.4 3
x2=NODE(ELEM(i,3),2); 28

y2=NODE(ELEM(i,3),3); 0.2 2 29

X=[x1,x2]; Y = [y1,y2]; 0
1 30

0 0.5 1 1.5 2
dx1=NODE(ELEM(i,2),2)+mag*U(ELEM(i,2),2);
dy1=NODE(ELEM(i,2),3)+mag*U(ELEM(i,2),3);
dx2=NODE(ELEM(i,3),2)+mag*U(ELEM(i,3),2);
dy2=NODE(ELEM(i,3),3)+mag*U(ELEM(i,3),3);
dX=[dx1,dx2]; dY = [dy1,dy2];
69/86
frame ex1 (Static analysis)
Number of elements: 3 Number of elements: 15 Number of elements: 30
deformed and undeformed shape deformed and undeformed shape deformed and undeformed shape
1.6 1.6 1.6
undeformed shape undeformed shape
2 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
deformed shape deformed shape
1.4 1.4 1.4 10 21
5 11
9 22
1.2 1.2 1.2 undeformed shape
8 deformed shape 23
4 12
1 1 17 24

0.8 0.8 0.8 6 25


1 3 3 13
5 26
0.6 0.6 0.6
4 27
2 14
0.4 0.4 0.4 3 28

0.2 0.2 0.2 2 29


1 15
1 30
0 0 0

0 0.5 1 1.5 2 0 0.5 1 1.5 2 0 0.5 1 1.5 2

70/86
3. Post process (modal) : frame_out_modal.m
%
% Post process of beam structures
for mm=1:nmode
GU(:,1)=eigvec(:,mm);
for i=1:nnode
U(i,1)=i;
for j=1:ndof, U(i,j+1)=GU(ndof*(i-1)+j);
end, end
% Plot deformed shape
mag=1; % magnification factor
for i=1:nelem
x1=NODE(ELEM(i,2),2); y1=NODE(ELEM(i,2),3);
x2=NODE(ELEM(i,3),2); y2=NODE(ELEM(i,3),3);
X=[x1,x2]; Y = [y1,y2];

dx1=NODE(ELEM(i,2),2)+mag*U(ELEM(i,2),2);
dy1=NODE(ELEM(i,2),3)+mag*U(ELEM(i,2),3);
dx2=NODE(ELEM(i,3),2)+mag*U(ELEM(i,3),2);
dy2=NODE(ELEM(i,3),3)+mag*U(ELEM(i,3),3);
dX=[dx1,dx2]; dY = [dy1,dy2];

figure(2)
subplot(3,2,mm),plot(X,Y,'-b',dX,dY,'-r'), hold on, axis([-1 3 0 2])
end
title(mm); % mode number
hold off
end

71/86
Frame ex1(Modal analysis)
Number of element: 3 Number of element: 15
1 2 1 2
2 2
2 2

1 1 1 1

0 0 0 0
-1 0 1 2 3 -1 0 1 2 3 -1 0 1 2 3 -1 0 1 2 3
3 4 3 4
2 2
2 2

1 1 1 1

0 0 0 0
-1 0 1 2 3 -1 0 1 2 3 -1 0 1 2 3 -1 0 1 2 3
5 6 5 6
2 2
2 2

1 1 1 1

0 0 0 0
-1 0 1 2 3 -1 0 1 2 3 -1 0 1 2 3 -1 0 1 2 3

Number of element: 30
1 2

Number 2 2

3 15 30
of elements: 1 1

0 0
-1 0 1 2 3 -1 0 1 2 3
3 4

2 2

Convergence 1 1

of frequency 0
-1 0 1 2 3
0
-1 0 1 2 3
5 6

2 2

1 1

0 0
-1 0 1 2 3 -1 0 1 2 3
72/86
Exercise: Frame ex2
Find first six natural frequencies and mode shapes of the given frame structure
using 7, 21, 70 elements
Steel: E=200GPa, rho=7850 Kg/m3
Cross section

30cm
3m
3 kN m

10cm
5kN
A  0.01  0.03  3e  4m 2
3m bh3 0.01(0.03)3
I zz    2.25e  8m 4
12 12

1 2 3

4m 4m

73/86
frame ex2 (Static analysis)
Number of elements: 7 Number of elements: 21 Number of elements: 70
deformed and undeformed shape deformed and undeformed shape deformed and undeformed shape
7 7 7
undeformed shape undeformed shape undeformed shape
6 deformed shape 6 deformed shape 6 deformed shape
40 50
12 15 39 49
38 48
5 5 5 37 47
6 7 11 14 36 46
35 45
4 4 4 34 44
33 43
10 13 32 42
31 41
3 4 5 3 16 17 18 19 20 21 3 1051 52 53 54 55 56 57 58 59 602061 62 63 64 65 66 67 68 69 7030
3 6 9 9 19 29
8 18 28
2 2 2 7 17 27
6 16 26
1 2 3 2 5 8 5 15 25
1 1 1 4 14 24
3 13 23
1 4 7 2 12 22
1 11 21
0 0 0

-1 -1 -1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9

74/86
Exercise: Frame ex2 (Modal analysis)
original shape of the structure
Number of element: 7
6 7 8

5
6 7
Mode shapes
1 2
4
6 6
3 4 4 5 5 6
4 4
2 2 2
1 2 3 0 0
1
0 2 4 6 8 0 2 4 6 8
0 1 2 3 3 4
6 6
-1 0 1 2 3 4 5 6 7 8 9 4 4
2 2
0 0
0 2 4 6 8 0 2 4 6 8
5 6
6 6
4 4
2 2
0 0
0 2 4 6 8 0 2 4 6 8

75/86
Exercise: Frame ex2 (Modal analysis)
Number of elements: 21
6 15
original shape of the structure
18
Number of elements: 21
1 2

12 15 6 6
4 4
5 14 17
2 2
11 14
0 0
4 13 16
0 2 4 6 8 0 2 4 6 8
10 13 3 4

3 4 16 19 17 20 18 8 19 21 20 22 21 12 6 6
4 4
3 6 9
2 2
2 3 7 11 0 0
2 5 8 0 2 4 6 8 0 2 4 6 8
5 6
1 2 6 10
6 6
1 4 7
4 4
0 1 5 9 2 2
0 1 2 3 4 5 6 7 8 0 0
0 2 4 6 8 0 2 4 6 8

Number of elements: 70
Number 1 2

7 21 70 6 6

of elements: 4
2
4
2
0 0
0 2 4 6 8 0 2 4 6 8
3 4
6 6

Convergence
4 4
2 2
0 0

of frequency 0 2 4
5
6 8 0 2 4
6
6 8

6 6
4 4
2 2
0 0
0 2 4 6 8 0 2 4 6 8

76/86
Summary

 Static and modal analysis of structure using finite element method was

studied

2.1 how to construct mass and stiffness matrices of the structure

2.2 how to solve static problem using MATLAB

2.3 how to solve eigenvalue problem using MATLAB

2.4 how to analyze truss, beam and frame structure


77/86
CEP Activity

78/86

You might also like