Assignment 2
Assignment 2
The section
has a width of 40 cm, height of 20. The modulus elasticity of the material is given as
E=2.1x 1011 Pa. Compare the result with that of ANSYS.
Solution
The beam has two elements and three nodes shown as follow.
1 2 3
1 2
When the two element matrix are assembled and we get the global matrix
12 6 −12 6
3 2 3 𝟎 𝟎
𝐿1 𝐿1 𝐿1 𝐿2 2
6 4 6 2
2 − 𝟎 𝟎
𝐿1 𝐿1 𝐿1 2 𝐿1
−12 −6 12 12 −6 6 −12 6
3 2 3 + 3 2 + 2 3
𝐿1 𝐿1 𝐿1 𝐿2 𝐿1 𝐿2 𝐿2 𝐿2 2
[𝑲](𝑮) = 𝑬𝑰 6 2 −6 6 4 4 6 2 …… (1)
2 + + −
𝐿1 2 𝐿1 𝐿1 𝐿2 2 𝐿1 𝐿2 𝐿2 2 𝐿2
−12 −6 12 −6
𝟎 𝟎
𝐿2 3 𝐿2 2 𝐿2 3 𝐿2 2
6 2 6 4
[ 𝟎 𝟎
𝐿2 2 𝐿2
−
𝐿2 2 𝐿2 ]
Then the force vector is defined as follows.
{𝑭}=[K]G {𝒅}
12 6 −12 6
𝑭𝟏𝒚 3 2
𝐿1 3
𝟎 𝟎
𝐿1 𝐿1 𝐿2 2
6 4 6 2 𝑽𝟏
𝑴𝟏 2 𝐿1
− 2 𝐿1
𝟎 𝟎
𝐿1 𝐿1
−12 −6 12 12 −6
+
6 −12 6 𝜽𝟏
3 2 3 + 3 2 2 3 2
𝑭𝟐𝒚 𝐿1 𝐿1 𝐿1 𝐿2 𝐿1 𝐿2 𝐿2 𝐿2 𝑽𝟐
= 𝑬𝑰 6 2 −6 6 4 4 6 2 ……………..(2)
+ +𝐿 − 𝜽𝟐
𝑴𝟐 𝐿1 2 𝐿1 𝐿1 2 𝐿2 2 𝐿1 2 𝐿2 2 𝐿2
−12 −6 12 −6 𝑽𝟑
𝑭𝟑𝒚 𝟎 𝟎
𝐿2 3 𝐿2 2 𝐿2 3 𝐿2 2 {𝜽𝟑 }
6 2 6 4
{ 𝑴𝟑 } 𝟎 𝟎 −
[ 𝐿2 2 𝐿2 𝐿2 2 𝐿2 ]
Boundary conditions
At node-1 V1=Ө1=0, and at node-2 and 3 F2y = -P, M2=0, M3=0 F3y=0
Substituting these values in the above equation (1) and we will have:
12 6 −12 6
𝐿1 3 𝐿1 2 𝐿1 3
𝟎 𝟎
𝐿2 2
6 4 6 2
𝑭𝟏𝒚 − 𝟎 𝟎
𝐿1 2 𝐿1 𝐿1 2 𝐿1 𝟎
𝑴𝟏 −12 −6 12 12 −6 6 −12 6 𝟎
+ +
−𝑷 𝐿1 3 𝐿1 2 𝐿1 3 𝐿2 3 𝐿1 2 𝐿2 2 𝐿2 3 𝐿2 2 𝑽𝟐
𝟎 = 𝑬𝑰 6 2 −6 6 4 4 6 2 𝜽𝟐 …………… (3)
+ +𝐿 −
𝟎 𝐿1 2 𝐿1 𝐿1 2 𝐿2 2 𝐿1 2 𝐿2 2 𝐿2 𝑽𝟑
−12 −6 12 −6 {𝜽𝟑 }
{ 𝟎 } 𝟎 𝟎
𝐿2 3 𝐿2 2 𝐿2 3 𝐿2 2
6 2 6 4
𝟎 𝟎 −
[ 𝐿2 2 𝐿2 𝐿2 2 𝐿2 ]
To find the reaction force and moment at point -1, we can use the static equilibrium
equations.
∑ 𝐹𝑦=0 , F1y=P
∑ 𝑀=0 , M1=3m*10*103N=30000N.m
Therefore the stress at point -1 is
𝑀𝑦
𝜎𝑥 = Where M=30000N.m y=0.2/2=0.1m and I=2.6667*10-4m4
𝐼
𝟑𝟎𝟎𝟎𝟎∗𝟎.𝟏
𝝈𝒙 = 𝟐.𝟔𝟔𝟔𝟕∗𝟏𝟎−𝟒 = 11.248Mpa
Nodal solutions
a) Displacement vector sum
PRINT U NODAL SOLUTION PER NODE
NODE UX UY UZ USUM
1 0.0000 0.0000 0.0000 0.0000
2 0.0000 -0.32687E-03 0.0000 0.32687E-03
3 0.0000 -0.62821E-03 0.0000 0.62821E-03
b) Rotational deflection
PRINT ROT NODAL SOLUTION PER NODE
NODE FX FY FZ
1 -10000.
2 10000.
TOTAL VALUES
VALUE 0.0000 0.50932E-10 0.0000
NODE MX MY MZ
1 -0.61126E-12-0.19058E-12 -30000.
2 0.61126E-12 0.19058E-12
TOTAL VALUES
VALUE 0.31302E-26 0.53011E-27 -30000.
Elemental solutions
a) 1st principal stress
PRINT S PRIN ELEMENT SOLUTION PER ELEMENT
ELEMENT = 1 SECTION ID = 1
ELEMENT NODE = 1
ELEMENT NODE = 2
ELEMENT = 2 SECTION ID = 1
ELEMENT NODE = 2
F1
Where:
A = 0.040 m2 I= 5 x10-4 m2
Material is steel with E=2.1x 1011 Pa.
𝐹1 = 35𝐾𝑁, 𝐹2 = 50𝐾𝑁, 𝐹3 = 75𝐾𝑁 𝑎𝑛𝑑 𝐿 = 2𝑚 is given for our group
Method 1: By using MATLAB Software
%Q#1 (For Group 1 members)
%_________________________________
% Problem description
% Find the deflection of a frame structure which is made of three beams.
% The length of beams: 10m, 10m and 6+6+4+5+3=24m(if L=4).
% The cross-section of beams equals 0.040m^2
% The elastic modulus is 2.1x10^11 pa.
% The frame is subjected to a concenterated load of
% 40, 60 & 60kN at the longest beam and the two short members are fixed.
% SOLUTION:
%_______________________________
% Variable descriptions
% x and y = global x and y coordiates of each node
% kk = system stiffness matrix
% ff = system force vector
% index = a vector containing system dofs associated with each element
% bcdof = a vector containing dofs associated with boundary conditions
% bcval = a vector containing boundary condition values associated
% with the dofs in 'bcdof'
%_______________________________________________________________________
clear all,clc
nel=7; % number of elements
nnel=2; % number of nodes per element
ndof=3; % number of dofs per node
nnode=(nnel-1)*nel+1; % total number of nodes in system
sdof=nnode*ndof; % total system dofs
x(1)=0; y(1)=0; % x, y coord. values of node 1 in terms of the global axis
n1=[x(1);y(1)];
x(2)=0; y(2)=8; % x, y coord. values of node 2 in terms of the global axis
n2=[x(2);y(2)];
x(3)=6; y(3)=8; % x, y coord. values of node 3 in terms of the global axis
n3=[x(3);y(3)];
x(4)=10; y(4)=8; % x, y coord. values of node 4 in terms of the global axis
n4=[x(4); y(4)];
x(5)=13; y(5)=8; % x, y coord. values of node 5 in terms of the global axis
n5=[x(5); y(5)];
x(6)=18; y(6)=8; % x, y coord. values of node 6 in terms of the global axis
n6=[x(6); y(6)];
x(7)=24; y(7)=8; % x, y coord. values of node 7 in terms of the global axis
n7=[x(7); y(7)];
x(8)=24; y(8)=0; % x, y coord. values of node 8 in terms of the global axis
n8=[x(8); y(8)];
el=2.1*(10^11); % elastic modulus
area=0.04; % cross-sectional area
xi=5*(10^-4); % moment of inertia of cross-section
bcdof(1)=1; % transverse deflection at node 1 is constrained
bcval(1)=0; % whose described value is 0
bcdof(2)=2; % axial displacement at node 1 is constrained
bcval(2)=0; % whose described value is 0
bcdof(3)=3; % slope at node 1 is constrained
bcval(3)=0; % whose described value is 0
bcdof(4)=22; % transverse deflection at node 8 is constrained
bcval(22)=0; % whose described value is 0
bcdof(5)=23; % axial displacement at node 8 is constrained
bcval(23)=0; % whose described value is 0
bcdof(6)=24; % slope at node 8 is constrained
bcval(24)=0; % whose described value is 0
ff=zeros(sdof,1); % initialization of system force vector
kk=zeros(sdof,sdof); % initialization of system matrix
index=zeros(nel*ndof,1); % initialization of index vector
ff(10)=-40000; % load applied at node 4 in the negative y direction
ff(13)=-60000; % load applied at node 5 in the negative y direction
ff(16)=-60000; % load applied at node 6 in the negative y direction
nodes=[1 3;2 3;3 4;4 5;5 6;6 7;6 8;];
for iel=1:nel % loop for the total number of elements
nd(1)=nodes(iel,1); % starting node number for element 'iel'
nd(2)=nodes(iel,2); % ending node number for element 'iel'
index=feeldof(nd,nnel,ndof); % extract system dofs for the element
x1=x(nd(1)); y1=y(nd(1)); % x and y coordinate values of 'node1'
x2=x(nd(2)); y2=y(nd(2)); % x and y coordinate values of 'node2'
leng=sqrt((x2-x1)^2+(y2-y1)^2); % length of element 'iel'
if (x2-x1)==0 % compute the angle between the local and global axes
if y2>y1
beta=pi/2;
else
beta=-pi/2;
end
else
beta=atan((y2-y1)/(x2-x1));
end
k=frameel(el,xi,leng,area,beta); % compute element stiffness matrix
kk=feasmbl1(kk,k,index); % assemble each element matrix into system matrix
end
[kk,ff]=feaplyc2(kk,ff,bcdof,bcval); % apply the boundary conditions
fsol=kk\ff; % solve the matrix equation and print
% nodal connectivity
% solution display loop:
% in the result desplayed we have four columns
% first column is for node numbers
% second column is for deflection u (x - direction)
% third column is for deflection v (y - direction)
% fourth column is for rotation theta (z - axis rotation)
% so, each node will have its own coresponding deflection in both x and y
% axis in meter and rotation about z-axis in radians.
store=zeros(nnode,4); % intiation of result desplay matirix
for i=1:nnode % loop that starts from 1 to total number of node
store(i,1)=i;
store(i,2)=fsol(3*i-2);
store(i,3)=fsol(3*i-1);
store(i,4)=fsol(3*i);
end
num=1:1:sdof;
disp ('deformation results are:')
store=[num' fsol]
function [index]=feeldof(nd,nnel,ndof)
%----------------------------------------------------------
% Purpose:
% Compute system dofs associated with each element
% Synopsis:
% [index]=feeldof(nd,nnel,ndof)
% Variable Description:
% index - system dof vector associated with element "iel"
% iel - element number whose system dofs are to be determined
% nnel - number of nodes per element
% ndof - number of dofs per node
%-----------------------------------------------------------
edof = nnel*ndof;
k=0;
for i=1:nnel
start = (nd(i)-1)*ndof;
for j=1:ndof
k=k+1;
index(k)=start+j;
end
end
function [k]=frameel(el,xi,leng,area,beta)
%--------------------------------------------------------------
% Purpose:
% Stiffness and mass matrices for the 2-d frame element
% nodal dof {u_1 v_1 theta_1 u_2 v_2 theta_2}
% Synopsis:
% [k,m]=feframe2(el,xi,leng,area,rho,beta,ipt)
% Variable Description:
% k - element stiffness matrix (size of 6x6)
% m - element mass matrix (size of 6x6)
% el - elastic modulus
% xi - second moment of inertia of cross-section
% leng - element length
% area - area of beam cross-section
% beta - angle between the local and global axes ipt = 1: consistent mass
matrix
% is positive if the local axis is in the ccw direction from
% the global axis
%---------------------------------------------------------------------
% stiffness matrix at the local axis
a=el*area/leng;
c=el*xi/(leng^3);
kl=[a 0 0 -a 0 0;...
0 12*c 6*leng*c 0 -12* c 6*leng*c;...
0 6*leng*c 4*leng^2*c 0 -6*leng*c 2*leng^2*c; ...
-a 0 0 a 0 0;...
0 -12*c -6*leng*c 0 12*c -6*leng*c;...
0 6*leng*c 2*leng^2*c 0 -6*leng*c 4*leng^2*c];
% coordinate transformation matrix
r=[ cos(beta) sin(beta) 0 0 0 0;...
-sin(beta) cos(beta) 0 0 0 0;...
0 0 1 0 0 0;...
0 0 0 cos(beta) sin(beta) 0;...
0 0 0 -sin(beta) cos(beta) 0;...
0 0 0 0 0 1];
% stiffness matrix at the global axis
k=r'*kl*r;
function [kk]=feasmbl1(kk,k,index)
%----------------------------------------------------------
% Purpose:
% Assembly of element matrices into the system matrix
% Synopsis:
% [kk]=feasmbl1(kk,k,index)
% Variable Description:
% kk - system matrix
% k - element matri
% index - d.o.f. vector associated with an element
%-----------------------------------------------------------
edof = length(index);
for i=1:edof
ii=index(i);
for j=1:edof
jj=index(j);
kk(ii,jj)=kk(ii,jj)+k(i,j);
end
end
function [kk,ff]=feaplyc2(kk,ff,bcdof,bcval)
%----------------------------------------------------------
% Purpose:
% Apply constraints to matrix equation [kk]{x}={ff}
% Synopsis:
% [kk,ff]=feaplybc(kk,ff,bcdof,bcval)
% Variable Description:
% kk - system matrix before applying constraints
% ff - system vector before applying constraints
% bcdof - a vector containging constrained d.o.f
% bcval - a vector containing contained value
% For example, there are constraints at d.o.f=2 and 10
% and their constrained values are 0.0 and 2.5,
% respectively. Then, bcdof(1)=2 and bcdof(2)=10; and
% bcval(1)=1.0 and bcval(2)=2.5.
%-----------------------------------------------------------
n=length(bcdof);
sdof=size(kk);
for i=1:n
c=bcdof(i);
for j=1:sdof
kk(c,j)=0;
end
kk(c,c)=1;
ff(c)=bcval(i);
disp=zeros(sdof,1);
stress=zeros(nel,3);
eldisp=zeros(ndof,1);
for i=1:(nnel*ndof)
eldisp(i)=eldisp(index(i));
end
elforce=k*eldisp;
stress(iel)=sqrt(elforce(1)^2+elforce(2)^2)/area;
num=1:1:sdof;
eldisp1=[num;disp]
numm=1:1:nel;
stresses=[numm stress]
store=[num eldisp]
end
end
end
end
end
NODE UX UY UZ USUM
1 0.0000 0.0000 0.0000 0.0000
2 -0.32451E-01 0.24193E-01 0.0000 0.40477E-01
3 -0.32451E-01 0.41619E-01 0.0000 0.52775E-01
4 -0.32470E-01-0.64584E-03 0.0000 0.32477E-01
5 -0.32498E-01-0.42023E-01 0.0000 0.53123E-01
6 -0.32545E-01-0.24595E-01 0.0000 0.40794E-01
7 -0.32545E-01 0.36853E-01 0.0000 0.49167E-01
8 0.0000 0.0000 0.0000 0.0000
Elemental solutions
i. Moments and loads
NODE FX FY FZ
1 78945. 62783. 0.0000
8 -78945. 97217. 0.0000
TOTAL VALUES
VALUE 0.24884E-08 0.16000E+06 0.0000
Nodal loads
PRINT F SUMMED NODAL LOADS
NODE FX FY FZ
1 -78945. -62783.
4 35000.
5 50000.
6 75000.
8 78945. -97217.
TOTAL VALUES
VALUE -0.24884E-08-0.12224E-08 0.0000
Structural moment solutions at Reaction
PRINT M REACTION SOLUTIONS PER NODE
NODE MX MY MZ
1 -0.42579E-12-0.73991E-12-0.12526E+06
8 0.19520E-12 0.34697E-12 16484.
TOTAL VALUES
VALUE -0.23058E-12-0.39294E-12-0.10878E+06
Nodal moments
PRINT M SUMMED NODAL LOADS
NODE MX MY MZ
1 0.42579E-12 0.73991E-12 0.12526E+06
2 -0.25132E-11 0.24445E-11
4 0.11637E-11-0.49783E-11
5 0.16624E-11 0.66099E-12
6 -0.54350E-12 0.14798E-11
8 -0.19520E-12-0.34697E-12 -16484.
TOTAL VALUES
VALUE -0.88352E-27 0.20195E-27 0.10878E+06
ELEMENT = 1 SECTION ID = 1
ELEMENT NODE = 1
Max= 0.33767E-05
Min= -0.26615E-04
ELEMENT NODE = 2
Max= 0.33767E-05
Min= -0.26615E-04
ELEMENT = 2 SECTION ID = 1
ELEMENT NODE = 2
Max= 0.55983E-20
Min= -0.55983E-20
ELEMENT NODE = 3
Max= 0.55983E-20
Min= -0.55983E-20
ELEMENT = 3 SECTION ID = 1
ELEMENT NODE = 2
Max= 0.45280E-03
Min= -0.47160E-03
ELEMENT NODE = 4
Max= 0.45280E-03
Min= -0.47160E-03
ELEMENT = 4 SECTION ID = 1
ELEMENT NODE = 4
Max= 0.25096E-03
Min= -0.26976E-03
ELEMENT NODE = 5
SEC NODE E1 E2 E3 EINT EEQV
1 0.25096E-03 0.0000 0.0000 0.25096E-03 0.25096E-03
3 0.0000 0.0000 -0.93991E-05 0.93991E-05 0.93991E-05
13 0.0000 0.0000 -0.93991E-05 0.93991E-05 0.93991E-05
11 0.25096E-03 0.0000 0.0000 0.25096E-03 0.25096E-03
5 0.0000 0.0000 -0.26976E-03 0.26976E-03 0.26976E-03
15 0.0000 0.0000 -0.26976E-03 0.26976E-03 0.26976E-03
23 0.0000 0.0000 -0.93991E-05 0.93991E-05 0.93991E-05
21 0.25096E-03 0.0000 0.0000 0.25096E-03 0.25096E-03
25 0.0000 0.0000 -0.26976E-03 0.26976E-03 0.26976E-03
Max= 0.25096E-03
Min= -0.26976E-03
ELEMENT = 5 SECTION ID = 1
ELEMENT NODE = 5
Max= 0.15502E-03
Min= -0.17382E-03
ELEMENT NODE = 6
Max= 0.15502E-03
Min= -0.17382E-03
ELEMENT = 6 SECTION ID = 1
ELEMENT NODE = 6
Max= 0.11197E-19
Min= -0.11197E-19
ELEMENT NODE = 7
Max= 0.11197E-19
Min= -0.11197E-19
ELEMENT = 7 SECTION ID = 1
ELEMENT NODE = 6
Max= 0.37983E-04
Min= -0.67781E-04
ELEMENT NODE = 8
Min= -0.67781E-04
ELEMENT = 1 SECTION ID = 1
ELEMENT NODE = 1
ELEMENT NODE = 2
ELEMENT = 2 SECTION ID = 1
ELEMENT NODE = 2
ELEMENT NODE = 3
ELEMENT = 3 SECTION ID = 1
ELEMENT NODE = 2
ELEMENT NODE = 4
ELEMENT NODE = 4
ELEMENT NODE = 5
ELEMENT = 5 SECTION ID = 1
ELEMENT NODE = 5
ELEMENT NODE = 6
ELEMENT = 6 SECTION ID = 1
ELEMENT NODE = 6
ELEMENT NODE = 7
ELEMENT = 7 SECTION ID = 1
ELEMENT NODE = 6
ELEMENT NODE = 8
Conclusion
The comparison of the results by ANSYS and MATLAB software according to the above results
can concluded as follow
The solutions obtained by MATLAB are a little bit different from that of ANSYS
solution. Thus, the MATLAB solutions are lower than ANSYS solutions. This indicates
that if we increase mesh number on the ANSYS, the solution will approach to that of
MATLAB solution.
Therefore, the variation between MATLAB and ANSYS solutions are due to
discretization error. The fact that number of discretization element (mesh number)
increases, the answer will approach to the accurate solution.
Fine discretization gives more accurate solutions and the reverse is true that of coarse
discretization.