Finite Element Analysis

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

CE 5303- Introduction to Finite Elements

The University of Texas Arlington

Project No-1 Final Report

Submitted to the

Department of Civil Engineering

By

Shams Abbas Naqvi – 1001439914

Instructor- Arash Emami Saleh, Ph.D.

Date of Submission - 13th April 2020


Table of Contents
INTRODUCTION ............................................................................................................................................. 1
PROBLEM STATEMENT.................................................................................................................................. 2
MODEL DESCRIPTION .................................................................................................................................... 3
OBJECTIVES ................................................................................................................................................... 4
METHODOLOGY ............................................................................................................................................ 5
Assumptions:............................................................................................................................................. 5
Area of the tapered bar: ........................................................................................................................... 5
Find the Area (A) as a function of 𝒙. [𝑨𝒙 = 𝒂𝒙𝟐 + 𝒃𝒙 + 𝒄] ................................................................ 5
Discretization of Elements ........................................................................................................................ 6
Truss Elements with 2-nodes: ................................................................................................................... 6
Truss Elements with 3-nodes: ................................................................................................................. 12
EXACT SOLUTION ........................................................................................................................................ 18
CONCLUSION............................................................................................................................................... 19
REFERENCES ................................................................................................................................................ 20
APPENDIX .................................................................................................................................................... 21
MATLAB code for 2-node truss elements ............................................................................................... 21
MATLAB code for 3-nodes truss elements: ............................................................................................ 23
List of Figures
Fig 2.1 Tapered bar element………………………………………………………………………3
Fig 5.1. Discretization of the bar into one element………………………………………………..6
Fig 5.2. Discretization of the tapered bar with two elements……………………………………..8
Fig 5.3. Discretization of the tapered bar with three elements……………………………………8
Fig 5.4. Graphical representation of stress on one side and displacement on other…………10-11
Fig 5.5. Representing forces on a 3-node bar with single elements……………………………14
Fig 5.6. Graphical representation of stresses and displacements for 3- node truss elements...15-17
Fig 6.1. Exact solution of stress………………………………………………………………….18
Fig 6.1. Exact solution of stress………………………………………………………………….18
List of Symbols
A - cross-sectional area
E - modulus of elasticity
{f} - global-coordinate nodal force matrix
[F] - global-coordinate structure force matrix
[k] - global-coordinate element stiffness
L - length of a bar or beam element
σ - normal stress
ε - normal strain
p - Axial load applied to the bar
x - Distance from the fixed end
INTRODUCTION
This project has been assigned by Dr. Arash Saleh from the Civil Engineering department at the
University of Texas at Arlington. It is the part of the course CE 5303 (Introduction to finite element
method).
Advanced structural analysis is used to calculate the stresses and deflection of complex structures,
but the complex methodology used in finding the stresses cannot be used by a computer program
and manual calculations are generally not possible. Finite element method is also used to analyze
complex structures by developing stiffness matrix for each element. This data in the form of
matrices is easy to feed up in the computer making the calculations easy. In this project, we will
see how to calculate stresses and deflection of a non-prismatic bar element with traction force
using two nodes and three nodes truss elements.
These kinds of structures are highly used in the building industry due to their shape and aesthetic
appeal. Analysis of these bars is rather complicated and not widely investigated. A simple
advanced structural analysis is not possible for these kinds of structures hence finite element
analysis with truss analogy is required to deal with this problem.

1
PROBLEM STATEMENT
A bar with variable cross-section is subjected to a uniformly distributed axial load of p =2000
kg/m. The cross-sections at the support, mid-length and free end are, 60 x 60 cm2, 30 x 30 cm2 and
20 x 20 cm2 respectively. Assume that the cross-section varies quadratically in between these
points on all 4 sides (Hint: Obtain a quadratic formula that passes through the given areas).
Assume E= 2 x 106 kg/cm2 and L=5m.
(a) Determine the displacement along the member using truss elements with 2 nodes (linear
interpolation functions). What are the minimum number of elements for convergence? Show the
variation of displacement and stress along the member for at least 5 cases.
(b) Determine the displacement along the member using truss elements with 3 nodes (quadratic
interpolation functions). What are the minimum number of elements for convergence? Show the
variation of displacement and stress along the member for at least 5 cases.
(Hint: For convergence, let the stress distribution be your acceptance criteria).

2
MODEL DESCRIPTION
Figure 2.1 depicts a tapered elastic bar subjected to a traction force over the length and attached to
a fixed support at one end. The cross-sectional area varies quadratically from Area 60 x 60 cm2 at
the fixed support at x = 0 to Area 20 x 20 cm2 at x = 5 m. The cross-section varies quadratically
on all four sides of the bar.

Fig 2.1 Tapered bar element


Modulus of elasticity of the bar (E) is assumed to be 2 x 106 kg/cm2 and Length (L) of the bar is
taken as 5 m. The traction force p is 2000 kg/m as shown in fig 2.1.

3
OBJECTIVES
A tapered bar subjected to a traction force along the length will be analyzed in order to predict the
distributions of stress and displacement in the bar. A comparison will be made between the exact
solution and discretized solution for the bar. The purpose is to understand how to discretize a
structure and divide a traction load into axial loads at different points to somehow reach a point
where we can have a solution which matches with the exact solution.
The outcome of the project is as follows.
• To understand how to discretize a complex structure into simple structures.
• To divide a traction loading along the length into axial loading at different nodes.
• To use two-node truss elements analysis to calculate the displacements and stresses.
• To use three-node truss elements to calculate the displacements and stresses.
• To develop an equation to calculate the cross-sectional area of the structure.
• To calculate the exact solution using the computer program MATLAB.
• To do the analysis of complex structures using finite element analysis.
• To compare the exact solution with the discretized solution and understand the concept of
finite element analysis.

4
METHODOLOGY
Assumptions:
The following assumptions are used in deriving the stiffness matrix of the bar elements:
a) The bar elements cannot sustain shear force or bending moment
b) Hooke’s law applies (axial load is related to axial strain).
c) Any effect of transverse movement is ignored.
d) There are no intermediate applied loads (all loads are applied at the nodes).

Area of the tapered bar:


As per the problem statement, the area of the bar is a quadratic function on all four sides. We
assume a quadratic function i.e. 𝑎𝑥 2 + 𝑏𝑥 + 𝑐. Which is varying along the length, where at 𝑥 = 0
area of the bar is 60 x 60 cm2 and at 𝑥 = 5𝑚 area of the bar is 20 x 20 cm2.

Find the Area (A) as a function of 𝒙. [𝑨(𝒙) = 𝒂𝒙𝟐 + 𝒃𝒙 + 𝒄]


a) At 𝑥 = 0
𝐴(0) = 𝐴1 = 0.36𝑚2
𝑆𝑜𝑙𝑣𝑖𝑛𝑔 𝑓𝑜𝑟 𝑎, 𝑏, 𝑐 𝑤𝑒 𝑜𝑏𝑡𝑎𝑖𝑛:
0.36 = 𝑎(0)2 + 𝑏(0) + 𝑐
𝑐 = 0.36

𝐿
b) At 𝑥 = 2 , where 𝐿 = 5𝑚
5
𝐴 ( ) = 𝐴2 = 0.09𝑚2
2
5 5
0.09 = 𝑎(2)2 + 𝑏(2) + 0.36
6.25𝑎 + 2.5𝑏 = −0.27 (1)

c) At 𝑥 = 𝐿 , where 𝐿 = 5𝑚
𝐴(5) = 𝐴3 = 0.04𝑚2
0.04 = 𝑎(5)2 + 𝑏(5) + 0.36
25𝑎 + 5𝑏 = −0.32 (2)

d) 𝑈𝑠𝑖𝑛𝑔 𝐸𝑞 𝑛 (1)𝑎𝑛𝑑 (2) 𝑆𝑜𝑙𝑣𝑖𝑛𝑔 𝑓𝑜𝑟 𝑎, 𝑏 𝑤𝑒 𝑜𝑏𝑡𝑎𝑖𝑛:


𝑎 = 0.0176
𝑏 = −0.152
𝑐 = 0.36
𝐴(𝑥) = 0.0176 𝑥 2 − 0.152𝑥 + 0.36

5
Discretization of Elements
As shown in the figure 4.1. the tapered bar with varying cross-section is divided into one element
with the same cross-section area throughout the length of the bar. This will give us an
approximation of the data of the load applied and the displacement of the bar as compared to the
exact solution.

Fig 5.1. Discretization of the bar into one element.

Similarly, the bar will be further divided into several elements with different cross-section area
based upon the length and we will obtain a solution which will coincide with the graph of the exact
solution. An example will be shown in two node truss elements on how the structure will be divided
into various elements.
The purpose of discretization is to understand the use of finite element analysis on how a complex
structure can be divided into different parts and its analysis can be carried out using two-node truss
elements and three-node truss elements which will be further discussed in detail.

Truss Elements with 2-nodes:


In this method, we will discretize our bar into elements with the different cross-sectional area but
constant throughout their respective lengths. Furthermore, we will create a function which will
which divide our traction force into axial load acting at different nodes of the discretize bar
element. This process of dividing the element and the load will help us to reach a point where our
section will match exactly with the exact solution of the tapered bar. By this method, we can find
out the displacement at every point in the bar as well as the stress at each point.
A truss element is a member which incorporates the following assumptions.
1) Stresses are transferred only in the direction normal to the cross-section.
2) The stress is constant over the cross-section.

6
3)The cross-section area remains constant during deformations.
Now considering the same bar in fig 4.1 where we have discretized the area into a single bar
element upon which a traction force of 2000 kg/m is acting throughout.
Consider the length as L with constant cross-section area A in fig 5.1.
First, we need to define a displacement function for our element since it is a 2-node truss element
we will assume a linear displacement function.
𝑢 = 𝑎1 + 𝑎2 𝑥

𝑢(0) = 𝑢1 = 𝑎1

𝑢(𝐿) = 𝑢2 = 𝑎1 + 𝑎2 𝐿
𝑢2 − 𝑢1
𝑎2 =
𝐿
1−𝑥 𝑥
𝑢(𝑥) = ( ) 𝑢1 + ( )𝑢2
𝐿 𝑙
1−𝑥 𝑥
𝑁1 = , 𝑁2 =
𝐿 𝐿
Now with this shape function, we can calculate the force acting at each node because this function
is independent of each other. When N1=1, N2=0 and similarly vice versa.
𝐴𝐸 1 −1
For the bar element we know that the stiffness matrix [𝑘] = [ ]
𝐿 −1 1
As we know from spring element the force in the bar is represented as,

𝑓 = [𝑘]𝑢̂
Which for two nodes can be written as,
𝑓1𝑥 𝐴𝐸 1 −1 𝑢1
{ }= 𝐿 [ ]{ } (3)
𝑓2𝑥 −1 1 𝑢2
After getting the equation and the shape functions our objective is to convert the traction force into
axial force which can be done by using the equation below,

{𝑓𝑠 } = ∬𝑠1 [𝑁𝑠 ]𝑇 {𝑇̂𝑠 }𝑑𝑆 (4)

Where,
[𝑁𝑠 ]𝑇 = 𝑡𝑟𝑎𝑛𝑠𝑝𝑜𝑠𝑒 𝑜𝑓 𝑡ℎ𝑒 𝑠ℎ𝑎𝑝𝑒 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛

{𝑇̂𝑠 } = 𝑡𝑟𝑎𝑐𝑡𝑖𝑜𝑛 𝑓𝑜𝑟𝑐𝑒

Using equation (3) & (4) we can calculate the forces acting at each node,

7
𝑥
𝐿 1−
𝑓1𝑥
𝑓 = { } = {𝑓𝑠 } = ∬ [𝑁𝑠 ]𝑇 {𝑇̂𝑠 }𝑑𝑆 = ∫ { 𝑥 𝐿} {𝑇̂𝑠 } 𝑑𝑥
𝑓2𝑥 𝑠1 0
𝐿
Using the above equation, we can easily convert the traction force into axial loads at the two points
for single element.
Now once you know the displacement the stress will be
𝑢 𝐸 𝐸
𝜎 = 𝜖 ∗ 𝐸 = 𝐸[𝐵1 𝐵2 ] [𝑢1 ] = − 𝑢1 + 𝑢2
2 𝐿 𝐿

Fig 5.2. Discretization of the tapered bar with two elements

Fig 5.3. Discretization of the tapered bar with three elements

8
In figure 5.2. and figure 5.3. it can be clearly seen how to discretize the element and with the help
of the shape function the traction force can be converted into axial load using equation (6). A
MATLAB code has been created for this whole process which gives us the values of the stress and
displacement.

9
10
Fig 5.4. Graphical representation of stress on one side and displacement on other.
The following graphs are plotted using the software MATLAB. These values are for single
element, five elements, twenty-five elements, fifty elements and hundred elements respectively
based on the ascending order starting from the top. You can easily make out from this graphical
representation that, more the number of elements you divide your structure into, your solution will
be more likely towards the exact solution.

11
Truss Elements with 3-nodes:
Similar process as 2-node truss element should be followed in 3-nodes as well. First, we will
discretize the bar with elements of different cross section area along different length. Now we will
distribute the forces in these elements but as there will be three nodes instead of two nodes the
load from the traction force will be distributed at three nodes. We can call it as local three nodes
of global two nodes of the element.
In the problem statement it is mentioned that the 3-node will be a quadratic interpolation function.
Due to the quadratic function and introduction of one extra node at the center of two existing nodes
from 2-nodes elements. The convergence with the exact solution will be faster and better results
can be obtained with a smaller number of elements.
To obtain the shape function of the element the following process should be followed.

𝑢(𝑥) = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2

𝑁1 = 1 𝑤ℎ𝑒𝑛 𝑥 = 0

𝑁1 = 0 𝑤ℎ𝑒𝑛 𝑥 = 𝐿/2 , 𝐿

𝑇ℎ𝑖𝑠 𝑔𝑖𝑣𝑒𝑠 𝑢𝑠 𝑁1 = 2/𝐿2 ∗ (𝑥 − 𝐿/2) ∗ (𝑥 − 𝐿) = 1 − 3𝑥/𝐿 + 2𝑥 2 /𝐿2

𝑁2 = 1 𝑤ℎ𝑒𝑛 𝑥 = 𝐿/2

𝑁2 = 0 𝑤ℎ𝑒𝑛 𝑥 = 0, 𝐿

𝑇ℎ𝑖𝑠 𝑔𝑖𝑣𝑒𝑠 𝑢𝑠 𝑁2 = −4/𝐿2 ∗ 𝑥 ∗ (𝑥 − 𝐿) = 4𝑥/𝐿 − 4𝑥 2 /𝐿2

𝑁3 = 1 𝑤ℎ𝑒𝑛 𝑥 = 𝐿

𝑁3 = 0 𝑤ℎ𝑒𝑛 𝑥 = 0, 𝐿/2

𝑇ℎ𝑖𝑠 𝑔𝑖𝑣𝑒𝑠 𝑢𝑠 𝑁3 = 2/𝐿2 ∗ 𝑥 ∗ (𝑥 − 𝐿/2) = −𝑥/𝐿 + 2𝑥 2 /𝐿2


So, like two nodes even this shape functions are independent of each other when N1=1, N2=N3=0.
Through this shape function we can obtain an independent solution for each node. This will help
us to find stresses at each node.
Now to find the stress, we need to calculate the forces at each node and to calculate the forces we
require a [k] matrix. To use the formula,

𝑓 = [𝑘]𝑢̂
Procedure to obtain the [k] matrix for 3-nodes elements,

𝑢(𝑥) = 𝑁1𝑢1 + 𝑁2𝑢2 + 𝑁3𝑢3

12
𝑢1
𝑑𝑢(𝑥)
But, 𝜀 = 𝑑𝑥
= [𝑁1 𝑁2 𝑁3] [𝑢2 ]
𝑢3
Hence by differentiating,
3 4
𝑁1 = − + 2 𝑥
𝐿 𝐿
4 8
𝑁2 = − 𝑥
𝐿 𝐿2
1 4
𝑁3 = − + 2 𝑥
𝐿 𝐿
3 4 4 8 1 4
[𝐵] = [− + 𝑥 − 𝑥 − + 2 𝑥]
𝐿 𝐿2 𝐿 𝐿2 𝐿 𝐿
Now by Hooke’s law we know that,

𝜎 = 𝐸𝜀 = 𝐸[𝐵][𝑢]

Now to develop the [K] matrix we know that,

[𝐾]𝐿 = ∫ [𝐵]𝑇 [𝐷][𝐵]𝑑𝑣, 𝑤ℎ𝑒𝑟𝑒 [𝐷] 𝑖𝑛 𝑜𝑢𝑟 𝑐𝑎𝑠𝑒 𝑖𝑠 𝑡ℎ𝑒 𝑚𝑜𝑑𝑢𝑙𝑢𝑠 𝑜𝑓 𝑒𝑙𝑎𝑠𝑡𝑖𝑐𝑖𝑡𝑦 (𝐸).

For 3- nodded truss elements we keep the area as constant


𝐿 𝐿
𝐴𝐸 7 −8 1
[𝐾]𝐿 = 𝐴 ∫[𝐵] 𝑇 [𝐷][𝐵]𝑑𝑥
= 𝐴 𝐸 ∫[𝐵]𝑇 [𝐵]𝑑𝑥 = [−8 16 −8]
3𝐿
0 0 1 −8 7
Now as we have developed the [K] matrix further process is to divide the traction force on these
three nodes to divide the forces we use the exact same procedure as 2-nodes element. The
following process is followed.

𝑓1 𝐿

[𝑓2 ] = ∫[𝑁]𝑇 ∗ 𝑝 ∗ 𝑑𝑥
𝑓3 0

Where 𝑝 = {𝑇̂𝑠 } = 𝑡𝑟𝑎𝑐𝑡𝑖𝑜𝑛 𝑓𝑜𝑟𝑐𝑒

𝑓1 𝐿 1 − 3𝑥/𝐿 + 2𝑥 2 /𝐿2

[𝑓2 ] = ∫ [ 4𝑥/𝐿 − 4𝑥 2 /𝐿2 ] ∗ 𝑝 ∗ 𝑑𝑥


𝑓3 0 −𝑥/𝐿 + 2𝑥 2 /𝐿2
After Integration we obtained the values as,

13
𝑓1 0.166𝑝𝑙
[𝑓2 ] = [0.666𝑝𝑙 ]
𝑓3 0.166𝑝𝑙

As per the calculation we can conclude that these forces will be distributed at the nodes which is
shown in the fig 5.5. 16.6% of the force will be distributed on node 1 and node 3 and the remaining
66.66% will act on the node 3.

Fig 5.5. Representing forces on a 3-node bar with single elements


The final step is to calculate the stresses at each node for that we use the exact same formula as 2-
node elements.
𝑢1
𝜎 = 𝜖 ∗ 𝐸 = 𝐸[𝐵1 𝐵2 𝐵3 ] [𝑢2 ]
𝑢3

14
15
16
Fig 5.6. Graphical representation of stresses and displacements for 3- node truss elements
The following graphs are plotted using the software MATLAB. These values are for single
element, five elements, twenty-five elements, fifty elements and hundred elements respectively
based on the ascending order starting from the top. You can easily make out from this graphical
representation that, more the number of elements you divide your structure into, your solution will
be more likely towards the exact solution

17
EXACT SOLUTION

Stress Function:
𝑘𝑔
Distributed Force (P) = 2000 𝑚2

Area = 𝐴(𝑥) = 0.0176𝑥 2 − 0.152𝑥 + 0.36


2000𝑥−10000 𝑘𝑔
∴ 𝑆𝑡𝑟𝑒𝑠𝑠 𝐹𝑢𝑛𝑐𝑡𝑖𝑜𝑛 = 0.0176𝑥 2 −0.152𝑥+0.36 𝑚2

The value of x ranging from 0 to 5 meters.

Fig 6.1. Exact solution of stress


Displacement Function:
𝑥
𝑃(𝑥)
𝑢=∫ 𝑑𝑥
0 𝐴(𝑥)𝐸
𝑥
1 2000(𝑥) − 10000
𝑢= ∫
2 ∗ 10 0 0.0176𝑥 2 − 0.152𝑥 + 0.36
10

Integrating this value in MATLAB we got the


following functions,
V = Exact solution for displacement
expr = log(11*(5-x)^2 - 95*(5-x) + 225)/352000 -
(3*35^(1/2)atan((22*35^(1/2)(5-x))/175 -
(19*35^(1/2))/35))/6160000
fplot (expr)
Exact solution for stress
syms x
expr=((10000-2000*x)./(0.0176*(x^2)-0.152*x+0.36)) Fig 6.2. Exact solution (Displacement)
fplot((expr),[0,5])

18
CONCLUSION
Comparing both the graphical solution that we have obtained from MATLAB we can conclude
that more the number of elements you divide your structure into you are more likely to get an exact
solution. Now it depends on yours engineering judgement how you will discretize your structure.
Looking at the figures above in fig 5.5. and fig 5.6. it can be observed as we divide the structure
into 25 elements, we can get a solution matching to that of exact solution. But if you further divide
your elements you will get more convergence with the exact solution.
If you compare about the divergence of the graphs with the exact solution. The 2-node will
converge with higher number of elements. Since in 3-nodes we are already dividing the elements
to one extra node. Looking at the graph this can be easily stated that 3-node converges at a much
faster rate with the exact solution as compared to 2-node elements

19
REFERENCES
1) Daryl L. Logan (2016). A First Course in the Finite Element Method. Sixth Edition. Cengage
Learning
2) https://www.mathworks.com/
3) Lectures’ notes

20
APPENDIX
MATLAB code for 2-node truss elements
el = input('How many elements do you have? : ');
L = 5;%Length of non-prismatic bar in mtrs
E = 2*10^6; %Modolus of Elasticity of the bar
tr = 2000; %traction force
syms x;
A(x) = 3600 - 1520*x + 176*x*x; %Area function of the bar
split = linspace(0, L, el+1);
%fprintf('Split: [%d]\n', split);
Area = zeros(1, el);
%fprintf('Area: [%d]\n', area);
for i = 1:length(split)-1
Area1 = A(split(i));
Area2 = A(split(i+1));
Area(1, i) = (Area1 + Area2)/2;
end
%fprintf('[%d]\n', area);
identity = [1 -1;-1 1];
k_global = zeros(el+1);
for i = 1:length(split)-1
local_k_matrix = (Area(1,i)*E)/(L/el);
local_k_matrix = local_k_matrix * identity;
k_global(i,i) = k_global(i,i) + local_k_matrix(1,1);
k_global(i,i+1) = local_k_matrix(1,2);
k_global(i+1,i) = local_k_matrix(2,1);
k_global(i+1,i+1) = local_k_matrix(2,2);
%fprintf('[%d]\n', local);
end
%fprintf('[%d]\n', global_stiff);
force = zeros(el+1,1);
nodal_force = (tr*L)/(el);
force(:,1) = nodal_force;
force(1,1) = nodal_force/2;
force(el+1,1) = nodal_force/2;
%fprintf('[%d]\n', force);
k_global = k_global(2:el+1, 2:el+1);
force = force(2:el+1, :);
U = inv(k_global)*force;
%fprintf('[%d]\n', U);
figure('Name', 'Displacement of the tapered bar due to
traction force ');
plot(split, [0,U'], 'b--o');

21
ylabel('Displacement of the bar at different nodes in
m','FontWeight','bold');
xlabel('Length of the tapered elastic bar in
m','FontWeight','bold');
title('Variation of displacement and length of the bar');
U = [0, U']';
stress = zeros(1,el);
for i = 1:length(stress)
stress(1,i) = E*[-el/L el/L]*U(i:i+1,:);
end

%fprintf('[%d]\n', sigma);
figure, stairs(split, [stress, stress(1,el)]);
title('Stress along the bar','FontWeight','bold');
xlabel('stress kg/cm^2','FontWeight','bold');
ylabel('Length of the bar m','FontWeight','bold');
hold on

%Plot Exact Solution


stress = (10000-2000*x)/(3600 - 1520*x + 176*x*x);
fplot(stress, 'g');
xlim([0 5]);
ylim([0 8]);
title('Exact solution');
xlabel('Distance from the fixed end in
m','FontWeight','bold');
ylabel('Stress along the bar in
kg/cm^2','FontWeight','bold');
hold off

22
MATLAB code for 3-nodes truss elements:
el = input('How many elements do you have? : ');
L = 5;%Length of non-prismatic bar in mtrs
E = 2*10^10; %Modolus of Elasticity of the bar
tr = 2000; %traction force
N=3;

% NE is the number of elements


% [ NE+1 ] is the total number of inter-element nodes
X = linspace(0, L, el+1); % one for every inter-element
node
Xmean = zeros([ 1, el ]); % one for every element
A = zeros([ 1, el ]); % one for every element
for i = 1:el
Xmean(i) = (X(i) + X(i+1))/2;
A(i) = 0.0176*Xmean(i)^2-0.152*Xmean(i)+0.36; % That’s the
equation we obtained earlier
end

I = [7 -8 1; -8 16 -8; 1 -8 7] ;
KG = zeros( 2*el+1 );
for i = 1:el % for every element
KL = ((E*A(i)) / (3*(L/el))*I ); % where L/NE is each
element’s length
KG(2*i-1:2*i+1, 2*i-1:2*i+1) = KG(2*i-1:2*i+1, 2*i-1:2*i+1)
+ KL;
end
% At this point we have calculated the global stiffness
matrix
R = L*tr; % we compute the total reaction at node 1
F = zeros([ 2*el+1, 1 ]); % we create a column matrix for
the nodal forces
F(1) = 0.16*tr*( L/(el) ) - R; % we compute the first value
of the F matrix F(2*NE+1) = 0.16*p*( L/(NE) ); % we compute
the last value of the F matrix
for i=2:2*el % for the rest values of the F matrix
if mod(i,2) == 0
F(i) = 0.6666*tr*( L/el );
else
F(i) = 0.3333*tr*( L/el );
end
end

23
% At this point we have calculated the global nodal forces
using the equivalent nodal forces method
U = zeros([ 2*el+1, 1 ]);
U(2:2*el+1) = KG(2:2*el+1, 2:2*el+1) \ F(2:2*el+1); % we
solve U = KG-1*F after “partitioning”
% At this point we have obtained our U matrix, which means
that we know each node’s displacement
% Notice that U(1)=0 because the first node is at the
support
% Now we will calculate the stress in each element
S = zeros([ 3*el, 1 ]); % three values for every element
for i=1:el % for every element
S(3*i-2) = E*( (-3/(L/el))*U(2*i-1) + (4/(L/el))*U(2*i)-
(1/(L/el))*U(2*i+1));
S(3*i-1) = E*( (-3/(L/el))*U(2*i-1) + (4/(L/el))*U(2*i)-
(1/(L/el))*U(2*i+1) + (2/(L/el))*U(2*i-1) -
(4/(L/el))*U(2*i) + (2/(L/el))*U(2*i+1) );
S(3*i) = E*( (-3/(L/el))*U(2*i-1) + (4/(L/el))*U(2*i)-
(1/(L/el))*U(2*i+1) + (4/(L/el))*U(2*i-1) -
(8/(L/el))*U(2*i) + (4/(L/el))*U(2*i+1) );
end

% Now we have calculated the Stress within each element


% The final step is to plot the graph of Stress vs Length
and the graph of Displacement vs. Length
Xplot = zeros([ 1, 3*el ]);
Xplot2 = zeros([1, 3*el-2]);
Xplot2(1) = (L/el)/2;
Xplot(1) = 0;
Xplot(3*el) = L;
for i = 2:3*el-2
if mod(i,3) == 0
Xplot2(i) = Xplot2(i-1);
else
Xplot2(i) = Xplot2(i-1) + (L/el) / 2;
end
end
Xplot(2:3*el-1) = Xplot2;
X2 = linspace(0,5,2*el+1);
subplot(2,1,1);
plot(Xplot,S)
title('Variation of Stress vs. Length');
xlabel('Length (m)');
ylabel('Stress (kg/m2)');
24
subplot(2,1,2)
plot(X2,U)
title('Variation of Displacement vs. Length');
xlabel('Length (m)');
ylabel('Displacement (m)');

25

You might also like