Documente Academic
Documente Profesional
Documente Cultură
2014
Contents
Contents............................................................................................................................2
Matlab CODE..................................................................................................................3
Results...............................................................................................................................7
Square cross-sectional area results......................................................................10
Circular cross-sectional area results....................................................................12
Discussion and conclusion.............................................................................................14
Appendix........................................................................................................................15
Matrix analysis of a truss.............................................................................................15
References......................................................................................................................19
Matlab CODE
The following code was developed in order to solve the truss problem. The mode how
the data is entered is well explained in appendix. The appendix (partially presented) and
the program were developed by me as a course monitor in Brazil to aid a professor in
the lecture of FEA in Solid Mechanics II. It was only necessary to modify the entering
data as the program calculates for every truss if the data is correctly entered.
clear all
clc
num_nos = 3;
coord = [0 0;0 .3;.4 0];
num_elem = 3;
incid = [1 2;1 3;2 3];
mat = [200E9];
num_load = 1;
load = [3 2 -5000];
prop_geo = [1.11E-4];
num_restr = 3;
restr = [1 1; 2 1; 2 2];
counter = 1;
Kglobal = zeros(num_nos*2);
for n=1:num_elem
incidz = incid(n,:); % Gets the incidence of element n
% Gets the coordinate of the element nodes 1
Co1 = coord(incidz(1),:);
Co2 = coord(incidz(2),:);
% Calculate the length of the bar by the Pythagorean relationship.
L = sqrt((Co2(1)-Co1(1))^2+(Co2(2)-Co1(2))^2);
% calculates the cosine and sine bars.
s = (Co2(2) - Co1(2))/L;
c = (Co2(1) - Co1(1))/L;
c2 = c^2;
s2 = s^2;
cs = c*s;
% Calculate the element stiffness matrix n
% mat (1) refers to the Young's modulus, prop_geo (1) the crosssectional area.
Ke = mat(1)*prop_geo/L*[c2 cs -c2 -cs; cs s2 -cs -s2; -c2 -cs c2
cs; -cs -s2 cs s2];
of
% Gets the Degrees of Freedom for the element. To find the degree
% freedom for each element was used the node logic * 2 Y and node * 21
% X
DOF = [incidz(1)*2-1 incidz(1)*2 incidz(2)*2-1 incidz(2)*2];
% Algorithm to add the element stiffness matrix in the global
matrix
for n=1:4
for m=1:4
Kglobal(DOF(m),DOF(n)) = Kglobal(DOF(m),DOF(n)) +
Ke(m,n);
end
end
end
Kglobal1 = Kglobal;
%verifica onde os deslocamentos so iguais a zero, e os guarda no
%vetor constrDOF
for n=1:num_restr
if restr(n,2) == 1
constrDOF(n)=restr(n,1)*2-1;
end
if restr(n,2) == 2
constrDOF(n)=restr(n,1)*2;
end
end
constrDOF = constrDOF';
%Elimina as constrDOFs e colunas onde os deslocamentos so iguais a
zero,
%obtidos no vetor constrDOF.
Kglobal1(constrDOF,:) = [];
Kglobal1(:,constrDOF) = [];
Load = zeros(num_nos*2,1);
% Allocate the forces in the load vector according to your DOF
for n=1:num_load
if load(n,2) == 1
Load(load(n,1)*2-1) = load(n,3);
end
if load(n,2) == 2
Load(load(n,1)*2) = load(n,3);
end
end
Load;
% excludes constrDOFs in which we have the Load Vector support
reactions.
Load(constrDOF,:) = [];
U = Kglobal1\Load;
% Set a counter to be used in the next loop.
j=1;
n=1;
4
% adds the offsets equal to zeros missing from the vector displacement
%
% Initially the vector U just have different load of zero.
% It creates an auxiliary variable U1.
for i=1:(num_nos*2+1)
if j<(num_restr+1) j~=(num_restr);
if i== constrDOF(j)
U1(i)=0;
j = j+1;
else
U1(i)=U(n);
n=n+1;
end
end
if j>=(num_restr+1) && n~=(num_nos*2-num_restr+1);
U1(i+1)=U(n);
n=n+1;
end
end
U=U1';
% Calculate the overall loading vector for the simple multiplication
% global matrix with the vector global displacement
FRg = Kglobal*U;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Solver END%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% DOFs numbering
NodalDOFNumbers = zeros(num_nos,3);
for n=1:num_nos
NodalDOFNumbers(n,1) = n;
NodalDOFNumbers(n,2) = 2*n-1;
NodalDOFNumbers(n,3) = 2*n;
end
%% Post-processing
disp('================================================================
==');
fprintf(1,'Generated output file ResultsAssignment.out\n');
disp('================================================================
==');
%% Output file
OutFileName = sprintf('ResultsAssignment.out');
OutFile
= fopen(OutFileName, 'w');
fprintf(OutFile, '*Displacements\n%6d\n', num_nos);
for i = 1 : num_nos
displa = [U(NodalDOFNumbers(i,[2 3]))' 0];
fprintf(OutFile, '%5d %6.4e %6.4e %6.4e\n', i, displa);
end
if restr(i, 2) == 2
fprintf(OutFile, '%5d RY = %e\n', restr(i, 1), FRg(ElemEqs));
end
end
6
fclose(OutFile);
Results
The results shown in the ResultsAssignment.out file is as it shows:
*Displacements (m)
3
1 0.0000e+000 0.0000e+000 0.0000e+000
2 0.0000e+000 0.0000e+000 0.0000e+000
3 -1.2012e-004 -4.7297e-004 0.0000e+000
*Reactions
3
1 RX =
2 RX =
2 RY =
(N)
6.666667e+003
-6.666667e+003
5.000000e+003
*Element strain
3
1 0.000000e+000
2 -3.003003e-004
3 3.753754e-004
*Element stress (Pa)
3
1 0.000000e+000
2 -6.006006e+007
3 7.507508e+007
The results obtained via CREO is shown below. Me and some friends simulated the
truss in DMU. So they are the same images;
Figure: Structure
*values shown in the images are just representative, the values used were:
a=10.54mm, R=5.94mm and E=200GPa.
9
Figure: Displacement in X
Figure: Displacement in Y
10
Figure: Reactions in X
Figure: Reactions in Y
11
Figure: Displacement in X
12
Figure: Displacement in Y
Figure: Reactions in X
13
Figure: Reactions in Y
hand, CREO uses beams as elements to simulate. It is possible to observe that CREO
simulation produces different results when using different cross-section areas. Note that
in the MATLAB algorithm the shape of cross-section area isnt even taken in
consideration; It only gets the value of the area to do the calculation. The simulation of
the same truss was carried with ALGOR simulate and produced EXACLTY the same
results obtained in the calculation by the MATLAB algorithm. This is explained by the
fact that ALGOR uses the same calculation process as MATLAB.
Appendix
Matrix analysis of a truss
The model of the following input variables is just a suggestion. Set the following
variables beforehand can help when writing the program.
example:
data:
E1 = E2 = E3 = 200x103 MPa, P = 1000N
The areas of horizontal and vertical bars is 1mm2 area while the inclined 1,414 mm2.
The lengths in the figure are in millimeters;
15
Figure 1: Truss
We can define the beginning, the number of nodes of the truss and number of elements.
For this case:
The red numbers indicate the element and black indicate the node.
Num_nodes = 4;
Then define the coordinates of us and put in a matrix.
coord =
16
100
2 0 21
3 21 0
4 21 21
The first column represents the node, the second and third represent the coordinates x
and y.
It is necessary to define the geometric properties of the materials and the bars. As the 6
bars have the same material, will be a simple vector. In prop_geo vector placed the areas
of bars.
Mat =
17
200E3
Prop_geo =
11
21
31
41
5 1,414
6 1,414
Num_loads = 1;
One should tell the program where this load is located. If this lattice power is being
applied to the node 4, the DOF 2.
In the matrix, the first column indicates the node, the second the DOF and the third
magnitude.
Loads =
4 2 -1000
References
Bittencourt , Marco - Analise Computacional de Estruturas, com aplicao do
mtodo de elementos finitos.
19