Chapter 4
Analysis of 2D trusses
4.1 Introduction
This chapter deals with the static analysis of two dimensional trusses, which are basically bars oriented in two dimensional cartesian systems. A transformation of coordinate basis is necessary to translate the local element matrices (stiness matrix, force vector) into the structural (global) coordinate system. Trusses support compressive and tensile forces only, as in bars. All forces are applied at the nodes. After the presentation of the element formulation, some examples are solved by MATLAB codes.
4.2 2D trusses
In gure 4.1 we consider a typical 2D truss in global x y plane. The local system of coordinates x y denes the local displacements u1 , u2 . The element possesses two degrees of freedom in the local setting, u
T
= [u1
u2 ]
(4.1)
while in the global coordinate system, the element is dened by four degrees of freedom uT = [u1 u2 u3 u4 ] (4.2) The relation between both local and global displacements is given by u1 = u1 cos() + u2 sin() u2 = u3 cos() + u4 sin() (4.3) (4.4)
A.J.M. Ferreira, MATLAB Codes for Finite Element Analysis: Solids and Structures, Solid Mechanics and Its Applications 157, c Springer Science+Business Media B.V. 2009
51
52
4 Analysis of 2D trusses u4 x u2 u3
u2 u1 y x u1
Fig. 4.1 2D truss element: local and global degrees of freedom
where is the angle between local axis x and global axis x, or in matrix form as u = Lu being matrix L dened as L= l m0 0 0 0 l m (4.5)
(4.6)
The l, m elements of matrix L can be dened by the nodal coordinates as l= x2 x1 ; Le m= y2 y1 Le (4.7)
being Le the length of the element, Le = (x2 x1 )2 + (y2 y1 )2 (4.8)
4.3 Stiness matrix
In the local coordinate system, the stiness matrix of the 2D truss element is given by the bar stiness, as before: K = EA 1 1 Le 1 1 (4.9)
4.5 First 2D truss problem
53
In the local coordinate system, the strain energy of this element is given by Ue = Replacing u = Lu in (4.10) we obtain Ue = 1 T T u [L K L]u 2 (4.11) 1 T u Ku 2 (4.10)
It is now possible to express the global stiness matrix as K = LT K L or l2 lm EA K= Le l2 lm lm m2 lm m2 l2 lm l2 lm lm m2 lm m2 (4.12)
(4.13)
4.4 Stresses at the element
In the local coordinate system, the stresses are dened as = E . Taking into account the denition of strain in the bar, we obtain =E E u2 u1 = [1 Le Le 1] u1 u2 = E [1 1]u Le (4.14)
By transformation of local to global coordinates, we obtain stresses as function of the displacements as = E [1 Le 1]Lu = E [l Le m l m]u (4.15)
4.5 First 2D truss problem
In a rst 2D truss problem, illustrated in gure 4.2, we consider a downward point force (10,000) applied at node 1. The modulus of elasticity is E = 30e6 and all elements are supposed to have constant cross-section area A = 2. The supports are located in nodes 2 and 4. The numbering of degrees of freedom is illustrated in gure 4.3.
54
4 Analysis of 2D trusses
10
2 E = 30e6, A = 2
1 3 y 10000 x 10
Fig. 4.2 First 2D truss problem, problem4.m
4 3
6 5
1 2 x 8
Fig. 4.3 First 2D truss problem: degrees of freedom
4.5 First 2D truss problem
55
The code (problem4.m) listing is as: %................................................................ % MATLAB codes for Finite Element Analysis % problem4.m % antonio ferreira 2008 % clear memory clear all % E; modulus of elasticity % A: area of cross section % L: length of bar E=30e6; A=2; EA=E*A; % generation of coordinates and connectivities numberElements=3; numberNodes=4; elementNodes=[1 2;1 3;1 4]; nodeCoordinates=[ 0 0;0 120;120 120;120 0]; xx=nodeCoordinates(:,1); yy=nodeCoordinates(:,2); % for % % % structure: displacements: displacement vector force : force vector stiffness: stiffness matrix
GDof=2*numberNodes; % GDof: total number of degrees of freedom displacements=zeros(GDof,1); force=zeros(GDof,1); % applied load at node 2 force(2)=-10000.0; % computation of the system stiffness matrix [stiffness]=... formStiffness2Dtruss(GDof,numberElements,... elementNodes,numberNodes,nodeCoordinates,xx,yy,EA); % boundary conditions and solution prescribedDof=[3:8];
56
4 Analysis of 2D trusses
% solution displacements=solution(GDof,prescribedDof,stiffness,force); % drawing displacements us=1:2:2*numberNodes-1; vs=2:2:2*numberNodes; figure L=xx(2)-xx(1); %L=node(2,1)-node(1,1); XX=displacements(us);YY=displacements(vs); dispNorm=max(sqrt(XX.^2+YY.^2)); scaleFact=15000*dispNorm; clf hold on drawingMesh(nodeCoordinates+scaleFact*[XX YY],elementNodes,L2, k.-); drawingMesh(nodeCoordinates,elementNodes,L2,k.--); % stresses at elements stresses2Dtruss(numberElements,elementNodes,... xx,yy,displacements,E) % output displacements/reactions outputDisplacementsReactions(displacements,stiffness,... GDof,prescribedDof) Note that this code calls some new functions. The rst function (formStiness2Dtruss.m) computes the stiness matrix of the 2D truss two-node element.
function [stiffness]=... formStiffness2Dtruss(GDof,numberElements,... elementNodes,numberNodes,nodeCoordinates,xx,yy,EA);
stiffness=zeros(GDof); % computation of the system stiffness matrix for e=1:numberElements; % elementDof: element degrees of freedom (Dof) indice=elementNodes(e,:) ;
4.5 First 2D truss problem
57
elementDof=[ indice(1)*2-1 indice(1)*2 indice(2)*2-1 indice(2)*2] ; xa=xx(indice(2))-xx(indice(1)); ya=yy(indice(2))-yy(indice(1)); length_element=sqrt(xa*xa+ya*ya); C=xa/length_element; S=ya/length_element; k1=EA/length_element*... [C*C C*S -C*C -C*S; C*S S*S -C*S -S*S; -C*C -C*S C*C C*S;-C*S -S*S C*S S*S]; stiffness(elementDof,elementDof)=... stiffness(elementDof,elementDof)+k1; end The function (stresses2Dtruss.m) computes stresses of the 2D truss elements.
function stresses2Dtruss(numberElements,elementNodes,... xx,yy,displacements,E)
% stresses at elements for e=1:numberElements indice=elementNodes(e,:); elementDof=[ indice(1)*2-1 indice(1)*2 indice(2)*2-1 indice(2)*2] ; xa=xx(indice(2))-xx(indice(1)); ya=yy(indice(2))-yy(indice(1)); length_element=sqrt(xa*xa+ya*ya); C=xa/length_element; S=ya/length_element; sigma(e)=E/length_element* ... [-C -S C S]*displacements(elementDof); end disp(stresses) sigma The code problem4.m is therefore easier to read by using functions that can also be used for other 2D truss problems. Displacements, reactions and stresses are in full agreement with analytical results by Logan [11].
58
4 Analysis of 2D trusses
Displacements ans = 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 reactions ans = 1.0e+03 * 0.0030 0.0040 0.0050 0.0060 stresses ans = 1.0e+03 * 3.9645 1.4645 -1.0355 The deformation of the structure is illustrated in gure 4.4. We use a drawing routine drawingMesh for the purpose. This routine needs the input of nodal coordinates and elements connectivities and draws either undeformed and deformed meshes. 0 7.9289 2.0711 2.0711 0.0041 -0.0159 0 0 0 0 0 0
4.6 A second truss problem
The next problem is illustrated in gure 4.5. The degrees of freedom are illustrated in gure 4.6. The MATLAB code is problem5.m. The analytical solution of this problem is presented in [11]. The results of this code agree well with the analytical solution, although the analytical solution considered only half of the structure.
4.6 A second truss problem Fig. 4.4 Deformed shape of 2D truss
120 100 80 60 40 20 0 0 20 40 60 80 100 120
59
E = 70GPa, A = 3e4 m2 50kN 2 4 3 1 5 1 y x
Fig. 4.5 A second truss problem, problem5.m
100kN 4 9 8 6 7 11 6
50kN
3m 5
2 3m
10 3m
%................................................................ % MATLAB codes for Finite Element Analysis % problem5.m % antonio ferreira 2008
60
4 Analysis of 2D trusses
11
12
y x
10
Fig. 4.6 A second truss problem: degrees of freedom
% clear memory clear all % E; modulus of elasticity % A: area of cross section % L: length of bar E=70000; A=300; EA=E*A; % generation of coordinates and connectivities elementNodes=[ 1 2;1 3;2 3;2 4;1 4;3 4;3 6;4 5;4 6;3 5;5 6]; nodeCoordinates=[ 0 0;0 3000;3000 0;3000 3000;6000 0;6000 3000]; numberElements=size(elementNodes,1); numberNodes=size(nodeCoordinates,1); xx=nodeCoordinates(:,1); yy=nodeCoordinates(:,2); % for structure: % displacements: displacement vector % force : force vector % stiffness: stiffness matrix GDof=2*numberNodes; U=zeros(GDof,1); force=zeros(GDof,1); % applied load at node 2
4.6 A second truss problem
61
force(4)=-50000; force(8)=-100000; force(12)=-50000; % computation of the system stiffness matrix [stiffness]=... formStiffness2Dtruss(GDof,numberElements,... elementNodes,numberNodes,nodeCoordinates,xx,yy,EA); % boundary conditions and solution prescribedDof=[1 2 10]; % solution displacements=solution(GDof,prescribedDof,stiffness,force); us=1:2:2*numberNodes-1; vs=2:2:2*numberNodes; % drawing displacements figure L=xx(2)-xx(1); %L=node(2,1)-node(1,1); XX=displacements(us);YY=displacements(vs); dispNorm=max(sqrt(XX.^2+YY.^2)); scaleFact=2*dispNorm; clf hold on drawingMesh(nodeCoordinates+scaleFact*[XX YY],... elementNodes,L2,k.-); drawingMesh(nodeCoordinates,elementNodes,L2,k.--); % output displacements/reactions outputDisplacementsReactions(displacements,stiffness,... GDof,prescribedDof) % stresses at elements stresses2Dtruss(numberElements,elementNodes,... xx,yy,displacements,E)
62
4 Analysis of 2D trusses
Results are the following: Displacements ans = 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 11.0000 12.0000 reactions ans = 1.0e+05 * 0.0000 0.0000 0.0001 stresses ans = -210.9015 122.4318 62.5575 -44.2349 -173.1447 -88.4697 62.5575 -173.1447 -44.2349 122.4318 -210.9015 >> 0.0000 1.0000 1.0000 0 0 7.1429 -9.0386 5.2471 -16.2965 5.2471 -20.0881 10.4942 0 3.3513 -9.0386
4.7 An example of 2D truss with spring Fig. 4.7 Deformed shape, problem 5
3500 3000 2500 2000 1500 1000 500 0 500 1000 0 1000 2000 3000 4000 5000
63
6000
2 1 25kN 3 y x 4 10m 2 5m 45 1
E = 210GPa A = 500m2 k3 = 2000kN/m
Fig. 4.8 Mixing 2D truss elements with spring elements, problem6.m
The deformed shape of this problem is shown in gure 4.7.
4.7 An example of 2D truss with spring
In gure 4.8 we consider a structure that is built from two truss elements and one spring element. For the truss elements the modulus of elasticity is E = 210 GPa, and the cross-section area is A = 5e4 m2 . This problem is modeled with four points and three elements. Figure 4.9 illustrates the degrees of freedom according to our nite element discretization.
64
4 Analysis of 2D trusses
4 3 6 5 y x 7
Fig. 4.9 Mixing 2D truss elements with spring elements: degrees of freedom
2 1
The listing of the code (problem6.m) is presented.
%................................................................ % % % % % MATLAB codes for Finite Element Analysis problem6.m ref: D. Logan, A first couse in the finite element method, third Edition, mixing trusses with springs antonio ferreira 2008
% clear memory clear all % E; modulus of elasticity % A: area of cross section % L: length of bar E=210000; A=500; EA=E*A; % generation of coordinates and connectivities nodeCoordinates=[0 0;-5000*cos(pi/4) 5000*sin(pi/4); -10000 0]; elementNodes=[ 1 2;1 3;1 4]; numberElements=size(elementNodes,1); numberNodes=size(nodeCoordinates,1)+1; % spring added xx=nodeCoordinates(:,1); yy=nodeCoordinates(:,2);
4.7 An example of 2D truss with spring
65
% for structure: % displacements: displacement vector % force : force vector % stiffness: stiffness matrix GDof=2*numberNodes; U=zeros(GDof,1); force=zeros(GDof,1); stiffness=zeros(GDof); % applied load at node 2 force(2)=-25000; % computation of the system stiffness matrix for e=1:numberElements-1; % elementDof: element degrees of freedom (Dof) indice=elementNodes(e,:) ; elementDof=[ indice(1)*2-1 indice(1)*2 indice(2)*2-1 indice(2)*2] ; xa=xx(indice(2))-xx(indice(1)); ya=yy(indice(2))-yy(indice(1)); length_element=sqrt(xa*xa+ya*ya); C=xa/length_element; S=ya/length_element; k1=EA/length_element*... [C*C C*S -C*C -C*S; C*S S*S -C*S -S*S; -C*C -C*S C*C C*S;-C*S -S*S C*S S*S]; stiffness(elementDof,elementDof)=... stiffness(elementDof,elementDof)+k1; end % spring stiffness in global Dof stiffness([2 7],[2 7])= stiffness([2 7],[2 7])+2000*[1 -1;-1 1]; % boundary conditions and solution prescribedDof=[3:8]; % solution displacements=solution(GDof,prescribedDof,stiffness,force); % output displacements/reactions outputDisplacementsReactions(displacements,stiffness,... GDof,prescribedDof)
66
4 Analysis of 2D trusses
% stresses at elements for e=1:numberElements-1 indice=elementNodes(e,:); elementDof=[ indice(1)*2-1 indice(1)*2 indice(2)*2-1 indice(2)*2] ; xa=xx(indice(2))-xx(indice(1)); ya=yy(indice(2))-yy(indice(1)); length_element=sqrt(xa*xa+ya*ya); C=xa/length_element; S=ya/length_element; sigma(e)=E/length_element* ... [-C -S C S]*displacements(elementDof); end disp(stresses) sigma Note that the spring stiness is added to global degrees of freedom 2 and 7, corresponding to vertical displacements at nodes 1 and 4. Displacements, reactions and stresses are listed below. Displacements are exactly the same as the analytical solution [11]. Stresses in bars show that bar 1 is under tension and bar 2 is under compression. Displacements ans = 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 reactions ans = 1.0e+04 * 0.0003 0.0004 0.0005 -1.8103 1.8103 1.8103 -1.7241 -3.4483 0 0 0 0 0 0
4.7 An example of 2D truss with spring
67
0.0006 0.0007 0.0008 stresses ans = 51.2043 -36.2069 >>
0 0.6897 0