Sunteți pe pagina 1din 19

Faculty of Technology

Department of Mechanical Engineering


DE MONTFORT UNIVERSITY

Module: ENGD 3016


Student: Lucas dos Santos Almeida
P-number: 13175018
Course: Mechanical Engineering
Lecturer: Warren Manning

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;

% Calculate the overall loading vector for the simple multiplication


% repeat operations to find out the bar L to calculate
% strains and stresses
for n=1:num_elem
incidz = incid(n,:);
Co1 = coord(incidz(1),:);
Co2 = coord(incidz(2),:);
L = sqrt((Co2(1)-Co1(1))^2+(Co2(2)-Co1(2))^2);
s = (Co2(2) - Co1(2))/L;
c = (Co2(1) - Co1(1))/L;

% strain is calculated using the equation given in the literature.


% U (incidz (1) * 2-1) and U (incidz (1) * 2) return the% respective
deformations of degrees of freedom of each element
Strain(n) = (1/L)*[-c -s c s]*[U(incidz(1)*2-1) U(incidz(1)*2)
U(incidz(2)*2-1) U(incidz(2)*2)]';
end
Strain = Strain';
% To calculate the normal stress simply multiplies the Young's modulus
% by deformation
Stress = Strain*mat(1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%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

%% Numbers of free and restricted dofs


TotalNumFreeDOFs = num_nos*2 - num_restr;
TotalNumRestrDOFs = num_restr;

%% 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

fprintf(OutFile, '\n*Reactions\n%5d\n', TotalNumRestrDOFs);


for i = 1 : TotalNumRestrDOFs
ElemEqs = NodalDOFNumbers(restr(i, 1),restr(i, 2)+1);
if restr(i, 2) == 1
fprintf(OutFile, '%5d RX = %e\n', restr(i, 1), FRg(ElemEqs));
end

if restr(i, 2) == 2
fprintf(OutFile, '%5d RY = %e\n', restr(i, 1), FRg(ElemEqs));
end

end
6

fprintf(OutFile, '\n*Element strain\n%6d\n', num_elem);


for i = 1 : num_elem
fprintf(OutFile, '%5d %e\n', i, Strain(i));
end
fprintf(OutFile, '\n*Element stress\n%6d\n', num_elem);
for i = 1 : num_elem
fprintf(OutFile, '%5d %e\n', i, Stress(i));
end

fclose(OutFile);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

Figure: Constraints definition

Figure: Circular beam section


definition*

Figure: Square beam section


definition*

Figure: Material definition*

*values shown in the images are just representative, the values used were:
a=10.54mm, R=5.94mm and E=200GPa.
9

Square cross-sectional area results

Figure: Displacement in X

Figure: Displacement in Y

10

Figure: Reactions in X

Figure: Reactions in Y

11

Figure: Stress results

Circular cross-sectional area results

Figure: Displacement in X

12

Figure: Displacement in Y

Figure: Reactions in X

13

Figure: Reactions in Y

Figure: Stress results

Discussion and conclusion


After all the calculation done by the programs MATLAB and CREO, it is no
time for discussion. The results generated by both programs indicate a good
convergence. The difference is mainly explained by the considerations taken by the
methods of calculations. MATLAB program uses the matrix analysis of a truss using
only bars. This means that this program does not considerate bending. On the other
14

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:

Figure 2: Nodes and defined elements.

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.

We now define the elements. In this example are 6 bars.


Num_elem = 6;
You must set the cost of each element, that is, tell the program where they are situated.
For example, the element 1 is connected at node 1 and node 2, while the element 3 is
connected node 3 and node 4. The first column represents the number of the element.
INCID =
112
123
334
424
523
614

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

We see that movement is restricted in the lattice 4 degrees of freedom. Node 1 is


restricted in x and y, the node 2 in x and y as well.
Num_restr = 4;
We must create a matrix with restrictions. In the first column put what is the node where
the restriction is. In the second place which is the degree of freedom has been restricted.
The number 1 represents the degree of freedom in x and number 2 represents the degree
of freedom in y. If this trellis, node 1 and node 2 are restricted in DOF 1 and 2 (x and y).
Is then:
restr =
11
12
21
22
Then remains to define the shipments of the trellis. It creates a vector with the number
of shipments. In this case, there is a force.
18

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

S-ar putea să vă placă și