You are on page 1of 14

A Finite Element Solution of the Beam Equation via

MATLAB

Abstract
A beam is a structural element that primarily resists loads applied laterally to the its axis. Its
deflection is primarily bending type. Here the loads applied create reaction forces at the
beam's support points. The total effect of all the forces acting is produced as shear forces and
bending moments within the beam, that in turn induce internal stresses, sheer stresses and
deflections of the beam.
In this work, we will study the most critical conditions for a beam with one end fixed and
four different end conditions with Uniformly Distributed Load (UDL) applied throughout the
known length with assumed cross sectional area in terms of stresses.

Introduction
Beam equations have historical importance, as they have been the focus of attention for
prominent scientists. Practical applications of the beam equations are evident in mechanical
structures built under the premise of beam theory. The importance of beam theory has been
outlined in the literature over the years. Examples include the construction of high-rise
buildings, bridges across the rivers, air craft and heavy motor vehicles. In these structures,
beams are used as the basis of supporting structures or as the main-frame foundation in axles.
Without a proper knowledge of beam theory, the successful manufacture of such structures
would be unfeasible and unsafe.
The Finite-Difference Method is the most direct approach to discretizing partial differential
equations. By considering a point in space where we can take the continuum representation of
the equations and replace it with a set of discrete equations, called finite-difference equations.
The finite-difference method is typically defined on a regular grid and this fact can be used
for very efficient solution methods. The method is therefore not usually used for irregular CAD
geometries, but more often for rectangular or block-shaped models. That’s why it is very
efficiently used in terms of structural analysis.
Elements are interconnected by points called nodes. Nodes will have nodal (vector)
displacements or degrees of freedom which may include translations, rotations, and for
special applications, higher order derivatives of displacements.

1|Page
Governing Equations

Now basic types of end conditions can be: - (1) Fixed support, (2) Simple support, (3) Free end,
(4) Spring support, (5) Guided Support.

The differential equation that governs the deflection y of a simply supported beam under
uniformly distributed load (Figure 1) is given by,

𝑑 𝑦 𝑞𝑥(𝐿 − 𝑥)
=
𝑑𝑥 2𝐸𝐼

2|Page
Results
The results were obtained for a beam with one end fixed and 4 different other end conditions.
In this way, there are 4 cases such as: 1. Free end, 2. Fixed- guided, 3. Fixed- simply support
and 4. Fixed-spring supported. The results were obtained for various cases of deflections and
stresses with respect to length.

Case- 1: Both ends free:

Fig 1: Deflection Fig 2: Shear Stress

3|Page
Fig 3: Axial Stress

4|Page
Case- 2: One end fixed and one end guided:

Fig 4: Deflection Fig 5: Shear Stress

Fig 6: Axial Stress

5|Page
Case- 3:One end fixed and one end simple supported:

Fig 7: Deflection Fig 8: Shear Stress

Fig 9: Axial Stress

6|Page
Case- 4: One end fixed and one end spring guided:

Fig 10: Deflection Fig 11: Shear Stress

Fig 12: Axial Stress

7|Page
Conclusion

The primary goal of this project was to develop a user interactive interface to determine the
behavior of different beams under different loading conditions. The developed graphic user
interface (GUI) by using MATLAB platform, certainly meets the goals of the project by
allowing the user to input necessary conditions to get desired output without any manual
calculations. The GUI provides the deflection profiles, shear force and bending moment
diagrams of different beams subjected to different loading conditions. Overall 46 cases of beams
with different loading conditions are analyzed by the developed GUI. Based on obtained
maximum values of deflection, shear force and bending moment following conditions can be
checked:
1. A beam can be designed to meet the serviceability criteria for deflections to prevent crack
formation.
2. Based on shear values, a beam critical in shear can be designed to prevent shear failure
due to excessive shear stresses developed.
3. Moments at different points in a beam and its variation along the length can be used to
design a beam for adequate reinforcement.

8|Page
Appendix
Code for Case- 1: Both ends free:

clear;clc;close all; tic

L = 1;
I = 25e-6;
E = 200e9;
EI = E*I;

w0 = 4000;
n=1003;
dx=.001
X = -.001:0.001:1.001;

f = zeros(n,1);
Kstiff = zeros(n,n);
y = zeros(n,1);
M = zeros(n,1);
V = zeros(n,1);
sigma = zeros(n,1);
tau = zeros(n,1);

f = ones(n,1)*-w0*.001^4/EI;
for i = 3:n-2
Kstiff(i,i-2) = 1;
Kstiff(i,i-1) = -4;
Kstiff(i,i ) = 6;
Kstiff(i,i+1) = -4;
Kstiff(i,i+2) = 1;
end

Kstiff(2,2) = 1; % left y_1 = 0


f(2) = 0;

Kstiff(1,1) = 1;
Kstiff(1,3) = -1;
f(1) =0 ;

Kstiff( n-1 ,n-3) = -1; % right y_n = 0


Kstiff( n-1 ,n-2) = +3;
Kstiff( n-1 ,n-1) = -3;
Kstiff( n-1 ,n) = 1;
Kstiff(n,n-2) = 1; % right M_n = 0
Kstiff(n,n-1) = -2;
Kstiff(n,n) = 1;

y = Kstiff\f;
fprintf('Max displacement = %f \n',max(abs(y)));
for i=1:2

M(i) = EI*( y(i) -2*y(i+1) + y(i+2))/dx^2;


V(i) = EI*(-y(i) +3*y(i+1) -3*y(i+2) + y(i+3))/dx^3;

9|Page
end
for i=3:n-3

M(i) = EI*( y(i-1) -2*y(i) + y(i+1))/dx^2;


V(i) = EI*(-y(i-2) +3*y(i-1) -3*y(i) +y(i+1))/dx^3;
end
for i=n-2:n

M(i) = EI*( y(i-2) -2*y(i-1) + y(i))/dx^2;


V(i) = EI*(-y(i-3) +3*y(i-2) -3*y(i-1) + y(i))/dx^3;

end
for i=1:n
sigma(i)=M(i)*6;

end
for i=1:n
tau(i)=V(i)*(.25*.02*.02-y(i)*y(i))/(2*I);
end
plot(X,sigma*1e-3);

Code for Case- 2: One end fixed and one end guided:

clear;clc;close all; tic


L = 1; % length of beam
I = 25e-6; % moment of inertia
E = 200e9; % elastic modulus
EI = E*I;
% Input load data --------------------------------------------------
w0 = 4000;
n=1003;
k=2e6;
dx=.001
X = -.001:0.001:1.001;

% Memory allocation ------------------------------------------------


f = zeros(n,1); % load vector
Kstiff = zeros(n,n); % stiffness matrix
y = zeros(n,1);
M = zeros(n,1); % moment
V = zeros(n,1); % shear
sigma = zeros(n,1);
tau = zeros(n,1);

f = ones(n,1)*-w0*.001^4/EI; % load vector

for i = 3:n-2
Kstiff(i,i-2) = 1;
Kstiff(i,i-1) = -4;
Kstiff(i,i ) = 6;
Kstiff(i,i+1) = -4;
Kstiff(i,i+2) = 1;
end
%% =================================================================
% Boundary Conditions
Kstiff(2,2) = 1;

10 | P a g e
f(2) = 0;
% Left moment ------------------------------------------------------
Kstiff(1,1) = 1;
Kstiff(1,3) = -1;
f(1) =0 ;

Kstiff( n-1 ,n-3) = -1;


Kstiff( n-1 ,n-2) = +3;
Kstiff( n-1 ,n-1) = -3;
Kstiff( n-1 ,n) = 1;
f(n-1)=0;
Kstiff(n,n-2) = 1;
Kstiff(n,n) = -1;
f(n) =0 ;

y = Kstiff\f;

for i=1:2

M(i) = EI*( y(i) -2*y(i+1) + y(i+2))/dx^2;


V(i) = EI*(-y(i) +3*y(i+1) -3*y(i+2) + y(i+3))/dx^3;
end
for i=3:n-3

M(i) = EI*( y(i-1) -2*y(i) + y(i+1))/dx^2;


V(i) = EI*(-y(i-2) +3*y(i-1) -3*y(i) +y(i+1))/dx^3;
end
for i=n-2:n

M(i) = EI*( y(i-2) -2*y(i-1) + y(i))/dx^2;


V(i) = EI*(-y(i-3) +3*y(i-2) -3*y(i-1) + y(i))/dx^3;

end
for i=1:n
sigma(i)=M(i)*6;

end
for i=1:n
tau(i)=V(i)*(.25*.02*.02-y(i)*y(i))/(2*I);
end
plot(X,sigma*1e-3);

Code for Case- 3: One end fixed and one end simple supported:

clear;clc;close all; tic

L = 1;
I = 25e-6;
E = 200e9;
EI = E*I;

w0 = 4000;
n=1003;
11 | P a g e
dx=.001
X = -.001:0.001:1.001;

f = zeros(n,1);
Kstiff = zeros(n,n);
y = zeros(n,1);
M = zeros(n,1);
V = zeros(n,1);
sigma = zeros(n,1);
tau = zeros(n,1);

f = ones(n,1)*-w0*.001^4/EI;

for i = 3:n-2
Kstiff(i,i-2) = 1;
Kstiff(i,i-1) = -4;
Kstiff(i,i ) = 6;
Kstiff(i,i+1) = -4;
Kstiff(i,i+2) = 1;
end

Kstiff(2,2) = 1;
f(2) = 0;

Kstiff(1,1) = 1;
Kstiff(1,3) = -1;
f(1) =0 ;

Kstiff( n-1 ,n-1) = 1;


f(n-1) = 0;
Kstiff(n,n-2) = 1;
Kstiff(n,n-1) = -2;
Kstiff(n,n) = 1;

y = Kstiff\f;

for i=1:2

M(i) = EI*( y(i) -2*y(i+1) + y(i+2))/dx^2;


V(i) = EI*(-y(i) +3*y(i+1) -3*y(i+2) + y(i+3))/dx^3;
end
for i=3:n-3

M(i) = EI*( y(i-1) -2*y(i) + y(i+1))/dx^2;


V(i) = EI*(-y(i-2) +3*y(i-1) -3*y(i) +y(i+1))/dx^3;
end
for i=n-2:n

M(i) = EI*( y(i-2) -2*y(i-1) + y(i))/dx^2;


V(i) = EI*(-y(i-3) +3*y(i-2) -3*y(i-1) + y(i))/dx^3;

end
for i=1:n
sigma(i)=M(i)*6;

12 | P a g e
end
for i=1:n
tau(i)=V(i)*(.25*.02*.02-y(i)*y(i))/(2*I); %thickness=.02m
plot(X,y*1e3);

Code for Case- 4: One end fixed and one end spring guided:

L = 1;
I = 25e-6;
E = 200e9;
EI = E*I;
w0 = 4000;
n=1003;
k=2e6; %spring constant
dx=.001
X = -.001:0.001:1.001;

f = zeros(n,1);
Kstiff = zeros(n,n);
y = zeros(n,1);
M = zeros(n,1);
V = zeros(n,1);
sigma = zeros(n,1);
tau = zeros(n,1);

f = ones(n,1)*-w0*.001^4/EI;

for i = 3:n-2
Kstiff(i,i-2) = 1;
Kstiff(i,i-1) = -4;
Kstiff(i,i ) = 6;
Kstiff(i,i+1) = -4;
Kstiff(i,i+2) = 1;
end

Kstiff(2,2) = 1;
f(2) = 0;

Kstiff(1,1) = 1;
Kstiff(1,3) = -1;
f(1) =0 ;

Kstiff( n-1 ,n-3) = -1;


Kstiff( n-1 ,n-2) = +3;
Kstiff( n-1 ,n-1) = -3-(k*.001^3/(E*I));
Kstiff( n-1 ,n) = 1;
Kstiff(n,n-2) = 1;
Kstiff(n,n-1) = -2+(k*.001^2/(E*I));
Kstiff(n,n) = 1;

y = Kstiff\f; % deflection
;

13 | P a g e
for i=1:2

M(i) = EI*( y(i) -2*y(i+1) + y(i+2))/dx^2;


V(i) = EI*(-y(i) +3*y(i+1) -3*y(i+2) + y(i+3))/dx^3;
end
for i=3:n-3

M(i) = EI*( y(i-1) -2*y(i) + y(i+1))/dx^2;


V(i) = EI*(-y(i-2) +3*y(i-1) -3*y(i) +y(i+1))/dx^3;
end
for i=n-2:n

M(i) = EI*( y(i-2) -2*y(i-1) + y(i))/dx^2;


V(i) = EI*(-y(i-3) +3*y(i-2) -3*y(i-1) + y(i))/dx^3;

end
for i=1:n
sigma(i)=M(i)*6;

end
for i=1:n
tau(i)=V(i)*(.25*.02*.02-y(i)*y(i))/(2*I);
end
plot(X,y*1e3);

14 | P a g e

You might also like