You are on page 1of 46

Finite Elements Analysis of Trusses

Trusses Review of Statics


DEFINITION OF A TRUSS
A truss is an assembly of bars (in 2D or 3D) with the following properties:
All members are connected by pin joints (no moment transfer)
No member is continuous through a node
The external forces are only applied to the nodes (never on the members)
The external constraints are only applied at the nodes
No moment is applied to the structure

FUNDAMENTAL CONSEQUENCE
Each member in a truss is a two-force member
(we already know the direction of all internal forces)

Externally determinate trusses


QUESTION 1
Can we calculate all the external forces using equilibrium alone?

3 unknowns - 3 equations
YES

4 unknowns - 3 equations
NO

The answer depends on the nature of the external constraints (exactly the same
as for a continuous rigid body)
3

Statically determinate trusses


QUESTION 2
Can we calculate all the internal forces using equilibrium alone?

A TRUSS is STATICALLY DETERMINATE if # of equations = # of unknowns


# of equations = # of equilibrium conditions we can impose
= (# of nodes) X (# of equations per node)
= 2n (in 2 dimensions)
# of unknowns = (# of internal forces) + (# of external reactions)
= m+3 (in 2 dimensions)
# of equations = # of unknowns

2n = m+3 (in 2D)

n = number of nodes
MAXWELLS RULE
If a truss is statically determinate, then 2n= m+3 (in 2D)

m = number of members
4

Maxwells rule for static determinacy


MAXWELLS RULE

If a truss is statically determinate, then 2n=m+3 (in 2D)

2n = 2 X 4 = 8

2n = 2 X 4 = 8

m+3=5+3=8

m+3=6+3=9

2n = m+3

2n < m+3

Quiz #1
Is the following truss statically determinate?

(A) Yes

(B) No

Statically determinate trusses


Solution by method of joints
Dismember the truss and create a freebody
diagram for each member and pin.
The two forces exerted on each member are
equal, have the same line of action, and
opposite sense.
Forces exerted by a member on the pins or
joints at its ends are directed along the member
and equal and opposite.
Conditions of equilibrium on the pins provide 2n
equations for 2n unknowns. For a simple truss,
2n = m + 3. May solve for m member forces
and 3 reaction forces at the supports.

Conditions for equilibrium for the entire truss


provide 3 additional equations which are not
independent of the pin equations.

Statically determinate trusses


Solutions by the method of sections
When the force in only one member or the
forces in a very few members are desired, the
method of sections works well.
To determine the force in member BD, pass a
section through the truss as shown and
create a free body diagram for the left side.

With only three members cut by the section,


the equations for static equilibrium may be
applied to determine the unknown member
forces, including FBD.

How can we solve statically indeterminate trusses?


OUTLINE OF THE SOLUTION PROCEDURE FOR THE STIFFNESS METHOD
1. Analyze the deformation of one element in a local 1D coordinate system. Derive
its stiffness.
2. Express the stiffness of each element in a common (global) coordinate system.
3. Assemble the stiffness of each element to derive the overall stiffness of the truss
(i.e., the relationship between applied external loads and nodal displacements).
4. Account for boundary conditions and apply loads.
5. By linear algebra procedures, calculate the displacement of each node.
6. Solve for the reaction forces at the nodes where displacement BCs are specified.
7. Solve for internal forces (and hence stresses) in each element.

This method shares many common principles with Finite Elements Analysis; the extension from
trusses to continuum solids only require an alternative definition of the element stiffness.
9

Stiffness of a single truss element in local CS


d=

PL
EA

x = local element-based coordinate system

EA
( q '- q1 ')
L 2
EA
F1 ' = - F2 ' =
( q '- q2 ')
L 1
F2 ' =

We can combine these two equations in:

F1 ' EA 1 -1 q1 '
=


L
F
'
-1
1

q2 '
2

Stiffness matrix for a truss member in local coordinates


or alternatively:

{ F '} = k ' {q'}

EA 1 -1
k ' =

L -1 1
10

Stiffness of a single truss element in global CS


F1 ' EA 1 -1 q1 '
=


F2 ' L -1 1 q2 '

Y
X
x = local element-based coordinate system
(X,Y) = global truss-based coordinate system

Nodal Displacements
q1 ' = q1 cosq + q2 sin q
q2 ' = q3 cosq + q4 sin q
q1

q1 ' cosq sin q


q2
0
0
=

0
cosq sinq q3
q2 ' 0

Transformation matrix [L] q4

Nodal Forces
F1 = F1 'cos q
F2 = F1 'sin q
F3 = F2 'cosq
F4 = F2 'sin q

F1
cosq
F2 sin q
=
F3 0
F 0
4

0
0
cosq
sinq

F '
1
F2 '

[L]T = Transpose of [L]

11

Stiffness of a single truss element in global CS


I am now ready to express the stiffness of the truss element in global coordinates
F1
cosq
F2 sin q
=
F3 0
F 0
4

0
0
cosq
sinq

F '
1
F2 '

F1 ' EA 1 -1 q1 '
=


F2 ' L -1 1 q2 '

F1
cosq
F2 sin q
=
F3 0
F 0
4

0
0
cosq
sinq

EA 1 -1 cosq
L -1 1 0

q1 ' cosq
=
q2 ' 0

sinq
0

0
cosq

sin q
0

sin q

0
cosq

q1

0 q2

sinq q3
q
4

q1

q2

q3
q4

Stiffness matrix of truss element in global CS, [k]


T

k = L k ' L
Force-displacement relationship for a truss element in global coordinate system in 2D:

{ F } = k {q}
12

Stiffness of a single truss element in global CS


By performing the matrix multiplication, I finally find an explicit expression for [k]

cos 2 q

EA sinq cosq
k =
L - cos 2 q

- sinq cosq

sin q cosq
sin 2 q
- sinq cosq
- sin 2 q

- cos 2 q
- sinq cosq
cos 2 q
sin q cosq

- sin q cosq
- sin 2 q
sinq cosq
sin 2 q

Geometric formulas for the calculation of sines and cosines as a function of the nodal coordinates

13

Example Analysis of a 1-element truss


This single element truss has four global
degrees of freedom: Q1, Q2, Q3, Q4.
Because there is only one element, the
global degrees of freedom correspond to the
degrees of freedom of element e = 1, that is:
Q1 = q1, Q2 = q2, Q3 = q3, Q4 = q4
I want to calculate:
(i) The nodal displacements Qi
(ii) The reaction forces at the constraints.

The stiffness matrix for the truss is:

1
EA
K = k =
L

EA
=
2L

1/ 2 1/ 2 -1/ 2 -1/ 2

1/ 2 1/ 2 -1/ 2 -1/ 2
-1/ 2 -1/ 2 1/ 2 1/ 2

-1/ 2 -1/ 2 1/ 2 1/ 2
1 1 -1 -1

1 1 -1 -1
-1 -1 1 1
-1 -1 1 1

The displacement boundary conditions are:

Q1 = Q2 = Q4 = 0
The load boundary conditions are:

F3 = F

14

Example Analysis of a 1-element truss


The governing equation {F}=[K]{Q} then becomes:

EA
2L

1 1 -1 -1 0 R1

1 1 -1 -1 0 = R2


-1 -1 1 1 Q3 F
-1 -1 1 1 0 R4

where Ri are the unknown reaction forces and Q3 is the unknown displacement.
This easy problem can be conveniently solved in two steps:
(1) Eliminate the rows and columns of [K] corresponding to the degrees of freedom for which the
displacement is prescribed (1,2,4) and solve for the remaining displacements.

EA
2L

1 1 -1 -1 0

1 1 -1 -1 0 =


-1 -1 1 1 Q3
-1 -1 1 1 0

R1

R2

F
R4

EA
2LF
Q3 = F Q3 =
2L
EA

15

Example Analysis of a 1-element truss


(2) Now that {Q} is fully known, solve for the
unknown reaction forces using the rows that we
had previously eliminated.
Row 1:

EA
Q = R1 R1 = - F
2L 3

Row 2:

EA
Q = R2 R2 = - F
2L 3

Row3:

EA
Q = R4 R4 = F
2L 3

This completes the solution of the problem!

EA
2L

1 1 -1 -1 0

1 1 -1 -1 0 =


-1 -1 1 1 Q3
-1 -1 1 1 0

R1

R2

F
R4

16

Assembly procedure and analysis of arbitrary trusses


How do extend the previous analysis to multi-member trusses?
Lets see this through an example.
Sequence of steps
1.
2.
3.
4.

5.
6.
7.
8.

a =1m
E = 200 GPa (steel)

9.

Carefully number nodes, elements (members) and


global degrees of freedom
Derive the stiffness matrix for each member
Assemble the global stiffness matrix
Prescribe boundary conditions (loads and
displacements)
Write down the complete system of equations
Remove rows and columns corresponding to DOFs for
which the displacement is specified
Solve the matrix problem for the unknown nodal
displacements
By using the rows that were previously eliminated,
solve for the unknown reaction forces
Calculate the internal force (and stress) in each
member

A = 2 cm X 2 cm = 0.0004 m 2 for all 5 members


F = 10 kN
Note: the procedure is the same whether the truss is statically
determinate or indeterminate (either internally ox externally)

17

Assembly procedure and analysis of arbitrary trusses


STEP 1 Number nodes, elements and global degrees of freedom

{Q} =

Q1

Q2

Q3
Q4

Q5
Q6

Q7

Q8

x and y displacement at node 1


x and y displacement at node 2
x and y displacement at node 3

x and y displacement at node 4

Connectivity matrix

Qi = global degrees of freedom

Element, e

Node 1

Node 2

3
18

Assembly procedure and analysis of arbitrary trusses


STEP 2 Derive the stiffness matrix for each member

1
EA
k =
a

1
0
-1
0

2
EA
k =
a

0 0
0 1
0 0
0 -1

3
EA
k =
a

1
0
-1
0

4
EA
k =
a

0 0
0 1
0 0
0 -1

3
EA
k =
2 2a

0 -1 0

0 0 0
0 1 0
0 0 0
0 0

0 -1
0 0
0 1

0 -1 0

0 0 0
0 1 0
0 0 0
0 0

0 -1
0 0
0 1

1 1 -1 -1

1 1 -1 -1
-1 -1 1 1
-1 -1 1 1

q = 0o

q = 90o

q = 180o

q = 270o

q = 45o

Element, e

Node 1

Node 2

19

Assembly procedure and analysis of arbitrary trusses


STEP 3 Assemble the global stiffness matrix
1 2 3 4

1
EA
k =
a

1
0
-1
0

0 -1 0 1

0 0 0 2
0 1 0 3
0 0 0 4

Global DOFs

Element, e

Node 1

Node 2

EA/a

-EA/a

-EA/a

EA/a

4
5
6

7
8
1

20

Assembly procedure and analysis of arbitrary trusses


STEP 3 Assemble the global stiffness matrix
3 4 5 6

2
EA
k =
a

0 0
0 1
0 0
0 -1

0 0 3

0 -1 4
0 0 5
0 1 6

Global DOFs

Element, e

Node 1

Node 2

1
2
0

EA/a

-EA/a

-EA/a

EA/a

7
8
1

21

Assembly procedure and analysis of arbitrary trusses


STEP 3 Assemble the global stiffness matrix
5 6 7 8

3
EA
k =
a

1
0
-1
0

0 -1 0 5

0 0 0 6
0 1 0 7
0 0 0 8

Global DOFs

Element, e

Node 1

Node 2

1
2
3
4

EA/a

-EA/a

-EA/a

EA/a

22

Assembly procedure and analysis of arbitrary trusses


STEP 3 Assemble the global stiffness matrix
7 8 1 2

4
EA
k =
a

0 0
0 1
0 0
0 -1

0 0 7

0 -1 8
0 0 1
0 1 2

Global DOFs

Element, e

Node 1

Node 2

EA/a

-EA/a

2
3
4
5
6

-EA/a

EA/a

23

Assembly procedure and analysis of arbitrary trusses


STEP 3 Assemble the global stiffness matrix
1 2 5 6

3
EA
k =
2 2a

1 1 -1 -1 1

1 1 -1 -1 2
-1 -1 1 1 5
-1 -1 1 1 6

Global DOFs

Element, e

Node 1

Node 2

EA/2V2
a

EA/2V2
a

EA/2V2
a

EA/2V2
a

EA/2V2
a

EA/2V2
a

EA/2V2
a

EA/2V2
a

1
2
3
4

EA/2V2
a

EA/2V2
a

EA/2V2
a

EA/2V2
a

EA/2V2
a

EA/2V2
a

EA/2V2
a

EA/2V2
a

5
6

7
8

24

Assembly procedure and analysis of arbitrary trusses


STEP 3 Assemble the global stiffness matrix

The global stiffness matrix for the entire truss is then:

1+1/ 2 2

1/ 2 2

1/ 2 2

1+1/ 2 2

-1

-1

-1/ 2 2

-1/ 2 2

-1/ 2 2

-1/ 2 2

1
-1

3
-1

EA
K =
a

-1/ 2 2

-1/ 2 2

-1/ 2 2

-1/ 2 2

-1

1+1/ 2 2

1/ 2 2

1/ 2 2

1+1/ 2 2

-1

4
-1

5
6

-1

7
1

8
25

Assembly procedure and analysis of arbitrary trusses


STEP 3 Assemble the global stiffness matrix

By plugging in the numerical values, we get:

108

28

-80

-28

-28

28

108

-28

-28

-80

-80

80

80

-80

-28

108

28

-80

-28

-28

-80

28

108

-80

80

-80

80

K =
-28

106 N/m

26

Assembly procedure and analysis of arbitrary trusses


STEP 4 Prescribe boundary conditions

Displacement boundary conditions

Q1 = Q2 = Q4 = 0

Load boundary conditions

F6 = - F
F7 = F

27

Assembly procedure and analysis of arbitrary trusses


STEP 5 Write down the system of equations

108 28 -80 0 -28 -28 0


0

28
108
0
0
-28
-28
0
-80

-80 0
80
0
0
0
0
0
0

0
0
80
0
-80
0
0
6

10
-28
-28
0
0
108
28
-80
0

-28 -28 0 -80 28 108 0


0

0
0
0
0
-80
0
80
0

0 -80 0
0
0
0
0
80

0
0
Q3
0
Q5
Q6
Q7
Q8

R1

R2

0
R4
0

-F
F
0

where R1, R2, R4 are the unknown reaction forces.

28

Assembly procedure and analysis of arbitrary trusses


STEP 6 Remove rows and columns corresponding to the degrees of freedom
for which the displacement is specified

108 28 -80 0 -28 -28 0


0

28
108
0
0
-28
-28
0
-80

-80 0
80
0
0
0
0
0
0

0
0
80
0
-80
0
0
6

10
-28
-28
0
0
108
28
-80
0

-28 -28 0 -80 28 108 0


0

0
0
0
0
-80
0
80
0

0 -80 0
0
0
0
0
80

106

80 0
0
0
0
0 108 28 -80 0
0 28 108 0
0
0 -80 0
80 0
0
0
0
0 80

0
0
Q3
0
Q5
Q6
Q7
Q8

Q3

Q5
0


Q6 = -10,000

Q7 10,000
0

Q8

R1

R2

0
R4
0

-F
F
0

29

Assembly procedure and analysis of arbitrary trusses


STEP 7 Solve the matrix problem for {Q}

106

80 0
0
0
0
0 108 28 -80 0
0 28 108 0
0
0 -80 0
80 0
0
0
0
0 80

Q3

Q5
0


Q6 = -10,000

Q7 10,000
0

Q8

Q3 = 0 mm

Q5 = 0.6 mm

Q6 = -0.25 mm
Q = 0.73 mm
7
Q8 = 0 mm

At this point, we know the displacement of every node in the truss.

30

Assembly procedure and analysis of arbitrary trusses


STEP 8 By using the rows I had eliminated at step 6, solve for the reaction forces

6
10

R1

0
108 28 -80 0 -28 -28 0
0

R2

0
28 108 0
0 -28 -28 0 -80


0
0
-80 0
80
0
0
0
0
0

0
R4
0
0
0
80
0 -80 0
0

-28 -28 0
0 108 28 -80 0 0.0006

0
-28 -28 0 -80 28 108 0
0 -0.00025 -10,000

0
0
0
0 -80 0
80
0 0.00073 10,000

0 -80 0
0
0
0
0
80
0

from which I finally get:

R1 = -10 kN

R2 = -10 kN
R = 20 kN
4

31

Assembly procedure and analysis of arbitrary trusses


STEP 9 Calculate the internal force (and stress) in each member
In the local (primed) coordinate system, an element
undergoes the deformation q2-q1.
e
The corresponding strain in the element is: e =

The stress is given by:

s e = E ee e =

Ee
e

But remember that:

q'

=
L


q2 '

Hence the stress in the member is:

( q2 '- q1 ') =

q'
Ee
1
-1
1

e
q2 '

q1

q2

q3
q4

se =

Ee
- cosq
e

and the force in the member is:

q2 '- q1 '

T e = Aes e

- sin q

cosq

sin q

q1

q2

q3
q4

32

Assembly procedure and analysis of arbitrary trusses


STEP 9 Calculate the internal force (and stress) in each member
This procedure requires careful bookkeeping, as we need to
transition from local to global reference systems.
Example: Calculate the internal force in element #5.

q1

q2
=
q3
q4

Q1

Q2

0
=
m
Q5 0.00061
Q6 -0.00025

q 5 = 45o

cosq = sinq = 2 / 2

from the solution obtained at step 7


Local

Global

200 10

6
s5 =
-1/
2
-1/
2
1/
2
1/
2

0.00061 = 36 10 Pa = 36 MPa
2

-0.00025
9

T = A s = 0.0004 3610 N = 14.4 kN


5

Similarly, we obtain:

Element, e

Node 1

Node 2

s 1 = 0 MPa
2
s = -50 MPa
3
s = -25 MPa
s 4 = 0 MPa

T 1 = 0 kN
2
T = 20 kN
3
T = -10 kN
T 4 = 0 kN

33

MATLAB Program for Truss Analysis


Program TRUSS2D
Developed by Chadrupatla and Belegundu
Included in:
Chandrupatla and Belegundu, Introduction to Finite Elements in Engineering, Prentice Hall, 2002
Slightly modified by L Valdevit

34

Step 1 - Input file and numbering scheme


Next line is problem title
<< 2D TRUSS ANALYSIS >>
TRUSS EXAMPLE
NN NE NM NDIM NEN NDN
4 5 1 2 2 2
ND NL
3 2
Node# X Y
1 0 0
2 1 0
3 1 1
4 0 1
Elem# N1 N2 Mat# Area
1
1 2 1 0.0004
2
2 3 1 0.0004
3
3 4 1 0.0004
4
4 1 1 0.0004
5
1 3 1 0.0004
DOF# Displacement
1 0
2 0
4 0
DOF# Load
6 -10000
7 10000
MAT# E
1 200.E9
SCALING FACTOR FOR PLOTTING
100.
-------- LEGEND -------------NN = Number of nodes
NE = Number of truss elements
NM = Number of different materials
NDIM = Number of coordinates per node (2 fr 2D, 3 for 3D)
NEN = Number of nodes per element (2 for a truss)
NDN = Number of degrees of freedom per node (truss: 2 for 2D, 3 for 3D)
ND = # of DOFs along which displacement is specified
NL = # of DOFs along which load is applied
----------------------------------

35

Function InputData
Reads the input file and stores all values
function [] = InputData()
global NN NE NM NDIM NEN NDN
global ND NL NCH NPR NBW
global X NOC F AREA MAT S
global PM NU U STRESS REACT
global CNST
global TITLE FILE1 FILE2
global LINP LOUT
global NQ
global SF
FILE1 = input('Input Data File Name ','s');
LINP = fopen(FILE1,'r');
FILE2 = input('Output Data File Name ','s');
LOUT = fopen(FILE2,'w');
DUMMY = fgets(LINP);
TITLE = fgets(LINP);
DUMMY = fgets(LINP);
TMP = str2num(fgets(LINP));
[NN, NE, NM, NDIM, NEN, NDN] =
deal(TMP(1),TMP(2),TMP(3),TMP(4),TMP(5),TMP(6));
NQ = NDN * NN;
DUMMY = fgets(LINP);
TMP = str2num(fgets(LINP));
[ND, NL]= deal(TMP(1),TMP(2));
NPR=1; % E (Young's modulus)
%----- Coordinates ----DUMMY = fgets(LINP);
for I=1:NN
TMP = str2num(fgets(LINP));
[N, X(N,:)]=deal(TMP(1),TMP(2:1+NDIM));
end

%----- Connectivity ----DUMMY = fgets(LINP);


for I=1:NE
TMP = str2num(fgets(LINP));
[N,NOC(N,:), MAT(N,:), AREA(N,:)] = ...
deal(TMP(1),TMP(2:1+NEN), TMP(2+NEN), TMP(3+NEN));
end
%----- Specified Displacements ----DUMMY = fgets(LINP);
for I=1:ND
TMP = str2num(fgets(LINP));
[NU(I,:),U(I,:)] = deal(TMP(1), TMP(2));
end
%----- Component Loads ----DUMMY = fgets(LINP);
F = zeros(NQ,1);
for I=1:NL
TMP = str2num(fgets(LINP));
[N,F(N)]=deal(TMP(1),TMP(2));
end
%----- Material Properties ----DUMMY = fgets(LINP);
for I=1:NM
TMP = str2num(fgets(LINP));
[N, PM(N,:)] = deal(TMP(1), TMP(2:NPR+1));
end
%----- Scaling factor for plotting ----DUMMY = fgets(LINP);
SF = str2num(fgets(LINP));

fclose(LINP);

36

InputData
x

Nodal coordinate matrix

1
X =
1

1 2

2
3

NOC = 3 4

4
1

1 3

1
Material
MAT = 1

1
PM(1) = 200 E9 1

0
1

Line = Node #

Local
Node 2

Local
Node 1

Connectivity matrix

Line = Element #

0.0004

0.0004

AREA = 0.0004
Cross-section

0.0004

0.0004
Line = Element #

37

InputData
Displacement boundary conditions

1

NU = 2
4

0

U = 0
0

Applied Loads

F =
0

-10000
10000

Degree of freedom with displacement b.c.

Value of the displacement


of dof specified in NU

Line = Degree of Freedom

38

Function Stiffness
Assemble stiffness matrix for each element
%----- First initialize stiffness matrix
S = zeros(NQ,NQ);

%----- Stiffness Matrix ----for N = 1:NE


I1 = NOC(N, 1);
I2 = NOC(N, 2);
I3 = MAT(N);
X21 = X(I2, 1) - X(I1, 1);
Y21 = X(I2, 2) - X(I1, 2);
EL = sqrt(X21 * X21 + Y21 * Y21);
EAL = PM(I3, 1) * AREA(N) / EL;
CS = X21 / EL;
SN = Y21 / EL;
%----------- Element Stiffness Matrix SE()
SE(1, 1) = CS * CS * EAL;
SE(1, 2) = CS * SN * EAL;
SE(2, 1) = SE(1, 2);
SE(1, 3) = -CS * CS * EAL;
SE(3, 1) = SE(1, 3);
SE(1, 4) = -CS * SN * EAL;
SE(4, 1) = SE(1, 4);
SE(2, 2) = SN * SN * EAL;
SE(2, 3) = -CS * SN * EAL;
SE(3, 2) = SE(2, 3);
SE(2, 4) = -SN * SN * EAL;
SE(4, 2) = SE(2, 4);
SE(3, 3) = CS * CS * EAL;
SE(3, 4) = CS * SN * EAL;
SE(4, 3) = SE(3, 4);
SE(4, 4) = SN * SN * EAL;

Example for element #3 (N=3)

I1 = 3

I2 = 4

I3 = 1

Node 1

Node 2

Material

X21 = x(4) - x(3) = 0-1 = -1


Y21 = y(4) - y(3) = 1-1 = 0
Element length
EL = Sqrt((-1)2+(0)2) = 1
EA/L
EAL = 200E9 * 0.0004 / 1 = 80E6

1
X =
1

0
1

1 2

2
3

NOC = 3 4

4 1
1 3

Sine and Cosine of the angle


CS = X21 / EL = -1/1 = -1
SN = Y21 / EL = 0/1 = 0

80E6

0
SE =
-80E6

0 -80E6 0

0
0
0
0 80E6 0

0
0
0

39

Function Stiffness
Assemble the global stiffness matrix
1

80E6

0
SE =
-80E6

globX1=NOC(N,1)*2-1;
globY1=NOC(N,1)*2;
globX2=NOC(N,2)*2-1;
globY2=NOC(N,2)*2;

I1 = 3

I2 = 4

Node 1

Node 2

globX1 = 5
globY1 = 6
globX2 = 7
globY2 = 8

S(globX1,globX1) = S(globX1,globX1) + SE(1,1);


S(globX1,globY1) = S(globX1,globY1) + SE(1,2);
S(globX1,globX2) = S(globX1,globX2) + SE(1,3);
S(globX1,globY2) = S(globX1,globY2) + SE(1,4);
S(globY1,globY1) = S(globY1,globY1) + SE(2,2);
S(globY1,globX2) = S(globY1,globX2) + SE(2,3);
S(globY1,globY2) = S(globY1,globY2) + SE(2,4);
S(globX2,globX2) = S(globX2,globX2) + SE(3,3);
S(globX2,globY2) = S(globX2,globY2) + SE(3,4);
S(globY2,globY2) = S(globY2,globY2) + SE(4,4);
and the rest follows from the symmetry of SE;

S =

-
-

-
- 80E6 0 -80E6 0

0
0
0
0
- -80E6 0 80E6 0

0
0
0
0

- - -

0 -80E6 0

2
3

0
0
0 NOC =
3 4

0 80E6 0
4 1

0
0
0
1 3

Example for element #3 (N=3)

40

Function ModifyForBC
Impose displacement BCs with the penalty method
Removing lines and columns is easy to do by hand, but rather cumbersome computationally.
Changing a matrix (or a vector) dimension within a program is never an advisable operation.
The Penalty Method is a very convenient alternative that provides an approximate solution

Suppose we want to impose Q4 = a4 (e.g. 0).


If you add a large number C to S44 and Ca4 to
F4, the governing equation becomes:

S11

S41 S42

S81

S43

S44 + C S45

S46

S47

S18 Q1 F1

S48 Q4 F4 + Ca4
=


S88 Q8 F8

The fourth row yields the equation:

S41Q1 + S42Q2 + S43Q3 + (S44 + C)Q4 + S45Q5 + S46Q6 + S47Q7 + S48Q8 = F4 + Ca4
Divide by C:

S41
S
S
S
S
S
S
S
F
Q1 + 42 Q2 + 43 Q3 + ( 44 +1)Q4 + 45 Q5 + 46 Q6 + 47 Q7 + 48 Q8 = 4 + a4
C
C
C
C
C
C
C
C
C
If C is much larger than any Sij and Fj, this is approximately equivalent to:
which is the BC we want to impose.

Q4 = a4

Hence all I need to do to enforce a displacement BC to dof N is add to the diagonal stiffness term SNN a
large number C; if the prescribed displacement is different from 0, I will also need to add the term C.aN
to the force term FN. Typically C is chosen as 10,000 times the largest value of Sij
41

Function ModifyForBC
Impose displacement BCs with the penalty method
This is trivially implemented in the MATLAB code

%----- Decide Penalty Parameter CNST ----CNST = max(max(S))*10000;

%----- Modify for Boundary Conditions ----% --- Displacement BC --for I = 1:ND
N = NU(I);
S(N,N) = S(N,N) + CNST;
F(N) = F(N) + CNST * U(I);
end

1

NU = 2
4

0

U = 0
0

Degree of freedom with displacement b.c.

Value of the displacement


of dof specified in NU
42

Function Solver
Solve the matrix equation for Q using Gauss elimination
MATLAB has a built-in solver that uses the Gauss elimination.
This function is simply:

function []=Solver()
%--------Gauss Elimination and Back Substitution via the MATLAB \ function-------Q = S\F;
F = Q; %the displacements are renamed F to avoid introducing one more variable

43

Function StressCalc
Calculate the stress in each member
for I = 1:NE
I1 = NOC(I, 1);
I2 = NOC(I, 2);
I3 = MAT(I);
X21 = X(I2, 1) - X(I1, 1);
Y21 = X(I2, 2) - X(I1, 2);
EL = sqrt(X21 * X21 + Y21 * Y21);
CS = X21 / EL;
SN = Y21 / EL;
J2 = 2 * I1;
J1 = J2 - 1;
K2 = 2 * I2;
K1 = K2 - 1;
DLT = (F(K1) - F(J1)) * CS +
+ (F(K2) - F(J2)) * SN;
STRESS(I) = PM(I3, 1) * (DLT / EL);
end

1
X =
1

Example for element #3 (I=3)


I1 = 3

I2 = 4

I3 = 1

Node 1

Node 2

Material

X21 = x(4) - x(3) = 0-1 = -1


Y21 = y(4) - y(3) = 1-1 = 0
Element length
EL = Sqrt((-1)2+(0)2) = 1
EA/L
EAL = 200E9 * 0.0004 / 1 = 80E6

0
1

1 2

2 3
NOC = 3 4

4
1

1 3

Sine and Cosine of the angle


CS = X21 / EL = -1/1 = -1
SN = Y21 / EL = 0/1 = 0
Global DOFs corresponding to element #3
J2 = 6
J1 = 5
K2 = 8
K1 = 7
Elongation of element #3
DLT = (Q7-Q5)*CS+ (Q8-Q6)*SN
Stress in element #3
STRESS(3) = E*DTL/EL = -25 MPa (compression)

44

Function ReactionCalc
Calculate the external reaction forces
1

NU = 2
4

%----- Reaction Calculation ----for I = 1:ND


N = NU(I);
REACT(I) = CNST * (U(I) - F(N));
end

The reaction forces follow simply from the Penalty Method.


Lets look for R4 = F4
S11

S41 S42

S81

S43

S44 + C S45

S46

S47

Degree of freedom with displacement b.c.

0

U = 0
0

Value of the displacement


of dof specified in NU

S18 Q1 F1

S48 Q4 F4 + Ca4
=


S88 Q8 F8

The fourth equation is:

S41Q1 + S42Q2 + S43Q3 + (S44 + C)Q4 + S45Q5 + S46Q6 + S47Q7 + S48Q8 = F4 + Ca4
which can be solved for F4:

F4 = Ca4 - ( S41Q1 + S42Q2 + S43Q3 + (S44 + C)Q4 + S45Q5 + S46Q6 + S47Q7 + S48Q8 ) =

Ca4 - CQ4 = C ( a4 - Q4 )

45

Functions Output and Draw


Output for Input Data from file TRUSS2D_lv.INP
TRUSS EXAMPLE
Node# X-Displ
1
9.2350E-09
2
9.2350E-09
3
6.0359E-04
4
7.2859E-04
Elem# Stress
1
1.3235E-12
2 -5.0000E+07
3 -2.5000E+07
4 -0.0000E+00
5
3.5355E+07
DOF# Reaction
1 -1.0000E+04
2 -1.0000E+04
4
2.0000E+04

Y-Displ
9.2350E-09
-1.8470E-08
-2.5002E-04
9.2350E-09

46

You might also like