You are on page 1of 5

A two-dimensional FE truss program

4M020: Design Tools


Eindhoven University of Technology

1 Introduction
The Matlab program fem2d allows to model and analyze two-dimensional truss structures, where
trusses are homogeneous and linear elastic. Deformation and rotations must be small, i.e. the behav-
ior is geometrically linear.
Model geometry, topology (connectivity), geometrical and material parameters and boundary
conditions (prescribed displacements and point loads) must be available as input data. After reading
this input, fem2d checks it and initializes some variables. Input data are stored in a data base.
When the analysis is finished, output date are stored in the data base and various other data ar-
rays.
Save the file ’fem2d.tar’ in the directory ’fem’ and extract the tar-file. It is very convenient to
make a text-file e.g. ’com.txt’ to save some Matlab commands which you can copy into the Matlab
shell.
In the following section an example input is presented, with explanatory comments. The pro-
gram itself is explained in more detail in the last section.

2 Example input file


As an example, the two-bar truss structure, shown in the figure below, will be modelled, loaded and
analyzed.

1 2
x
1
F

Both trusses have different geometrical and material properties, which are given in the table below.

1
2

truss a b
cross-sectional area A 10 20 [mm2 ]
Young’s modulus E 200 150 [GPa]
Poisson’s ratio ν 0.3 0.3 [-]

Now lets see which Matlab commands do the job. Before starting, it might be wise to clear everything
and close all figures.

clear all; close all;

First we give the coordinates of the nodes in the array ”crd0”. Now we have to decide on the units and
in this example we choose to model everything in mm.

crd0 = [ 0 0; 100 0; 0 100/sqrt(3) ];

Then the connectivity of the elements is defined in the array ”lok”. This array has a row for each
element. The first column contains the element type, which is 9 for a truss. The second row is the
element group number. Typically elements with the same properties are placed in one and the same
group. Because our two elements indeed have different properties, they are placed in two different
groups. The third and fourth column contain the first and second node of the element.

lok = [ 9 1 1 2 ; 9 2 2 3 ];

Now we have to provide the geometrical and material properties in the array ”elda” (element data).
For each element group we have a row in ”elda”. The first column contains a zero (0), which is
not important for our use of fem2d. The second column contains the material identification number.
For linear elastic material, which we will use here and also further in other cases, this number is 11
(eleven). The third column contains the cross-sectional area (in mm2 ). The fourth and fifth column
are not used for our problems and always contain a zero (0). The sixth and seventh column contain
Young’s modulus and Poisson’s ratio. So for our example we have :

elda = [
0 11 10 0 0 200000 0.3
0 11 20 0 0 150000 0.3
];

Boundary conditions are prescribed nodal displacements and/or prescribed nodal forces. Prescribed
nodal displacements are always needed to prevent rigid body motions.
Prescribed displacements are provided in the array ”pp”. For each prescribed displacement component
we have one row. The first column contains the node, the second column contains the direction (either
1 (= x = horizontal) or 2 (= y = vertical). The third column contains the value.
For our example we have :

pp = [ 1 1 0; 1 2 0; 3 1 0; 3 2 0; ];

The prescribed forces are given in the array ”pf”. Again each prescribed force component is placed
on a row, with the node in the first, the direction in the second and the value in the third column.
For our example :
3

pf = [ 2 2 -100 ];

That is about all. The input is complete and fem2d can be executed to analyze the behavior.

fem2d;

When the analysis is completed successfully, we want to see some results. First the nodal data, i.e.
displacements and reaction forces. They are available in the array’s ”MTp” and ”Mfi”. Rows contain
nodal data : displacement and forces in the first (1 = x = horizontal) and second (2 = y = vertical)
directions. Just type the next commands in the Matlab shell.

MTp
Mfi

Element data, like stress and strain, are available in the data base. This is a Matlab structure ”eda.eldaC”.
For element ”e” we find the date in the array ”eda(e).eldaC”. The relevant date can be found at the
following locations :

eda(e).eldaC(1) = sine of angle between axis and 1-direction


eda(e).eldaC(2) = cosine of angle between axis and 1-direction
eda(e).eldaC(3) = length
eda(e).eldaC(4) = cross-sectional area
eda(e).eldaC(6) = linear axial strain
eda(e).eldaC(7) = axial stress
eda(e).eldaC(11) = axial stretch ratio
eda(e).eldaC(12) = radial stretch ratio
eda(e).eldaC(18) = axial force

To see some results for our example just type the following in the Matlab shell :

eda(1).eldaC(6)
eda(1).eldaC(7)
eda(1).eldaC(18)
eda(2).eldaC(6)
eda(2).eldaC(7)
eda(2).eldaC(18)

These values can ofcourse be stored and printed in various ways.

The above input commands can also be put in one single input file, e.g. ”Ifem2d.m” :

clear all; close all;


crd0 = [ 0 0; 100 0; 0 100/sqrt(2) ];
lok = [ 9 1 1 2 ; 9 2 2 3 ];
elda = [ 0 11 10 0 0 200000 0.3; 0 11 20 0 0 150000 0.3 ];
pp = [ 1 1 0; 1 2 0; 3 1 0; 3 2 0; ];
pf = [ 2 2 -100 ];
4

3 The program ”fem2d”


The two-dimensional finite element program fem2d is not only suited to analyze truss structures. As
we only use it for this purpose, the following explanation is confined to this use. It is recommended
to look at the program listing, when reading the text.
The program starts with a check of input variables and initialization. This is done in separate
m-files.

prog=’fe2d’;
checkinputN;
daba;
lcase;
initialzero;

After that the loop over all elements ”ne” is started to make the system of equations.

for e=1:ne
...
end; % element loop ’e’

In this loop some data are extracted from the data base ”eda.elpa”, which contains the element param-
eters.

ety = element type


egr = element group
nenod = number of element nodes
nedof = number of element degrees of freedom
neip = number of element integration points

The last variable is irrelevant for the truss element.


Element nodal coordinates are also needed :

ec0 = initial element nodal coordinates


ec = current element nodal coordinates

After initialization of element matrix (”em”) and force column (”ef”) to zero, the element stiffness
matrix is made. Here we only show the part for the truss element (”ety = 9”).

[ML,V] = geomm(e,eda);
l0 = eda(e).elda0(3); A0 = eda(e).elda0(4); E0 = eda(e).elda0(8);
em = (A0/l0 * E0) * ML ;

The m-file ”geomm” is used to generate the array’s ”ML” and ”V”. From the data base we extract the
initial element length ”l0”, cross-sectional area ”A0” and Young’s modulus ”E0”.
The element stiffness matrix ”em” is assembled into the structural stiffness matrix ”sm”, using
information on the connectivity, which is stored in the array ”lokvg”, which finishes the element loop.
Now that we have the left hand structural stiffness matrix ”sm”, the right hand force column
”rs” must be made from the prescribed nodal forces, which are contained in the array ”fe”. The total
system of equations is reduced by partitioning, which means that prescribed nodal displacements are
taken into account. This is done with the m-file ”partit”. The reduced equation system is solved and
the solution is found in the column ”sol”.
5

sol = inv(sm)*rs;

From this solution array, the nodal displacements and new coordinates are extracted.
To calculated element strains and stresses, we have to go into an element loop for the second
time. Using the nodal displacements, various element values are calculated and stored in the data
base.

4 Mesh plotting function


Truss structures can be plotted in undeformed and deformed state with a Matlab function pmshN.m.
The call to the function looks like :

pmshN(option,lok,crd0,crd,eda)

We recognize the arrays ”lok”, ”crd0”, ”crd” and ”eda”, respectively the location (connectivity) ma-
trix, the coordinates in initial and current state and the element data base. The first argument is a
column array with some options :

option(1) = magfac : magnification factor


option(2) = inimsh : 1 -> plotting of initial mesh
option(3) = nodpnt : 1 -> plotting of nodal numbers
option(4) = elmnrs : 1 -> plotting of element numbers
option(5:10) = 0 : values are not relevant for trusses

So it will almost always be enough to use :

option = [1 0 0 0 0 0 0 0 0];
pmshN(option,lok,crd0,crd,eda);

You might also like