mat lab beam deflection

15
Numerically Calculating Beam Deflections Shaun Salisbury January 17, 2011 Contents 1 Introduction 2 2 Review : Solving a Set of Linear Equations 2 3 One Dimension Spring Elements 2 3.1 Multiple Connected Spring Elements ................................ 3 3.2 Spring Example ............................................ 4 3.3 Summary of Method ......................................... 5 4 Beam Elements 6 4.1 Beam Example ............................................ 6 A Matlab Code 10 1

Upload: pavan-kishore

Post on 11-May-2017

228 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Mat Lab Beam Deflection

Numerically Calculating Beam Deflections

Shaun Salisbury

January 17, 2011

Contents

1 Introduction 2

2 Review : Solving a Set of Linear Equations 2

3 One Dimension Spring Elements 23.1 Multiple Connected Spring Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33.2 Spring Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43.3 Summary of Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4 Beam Elements 64.1 Beam Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

A Matlab Code 10

1

Page 2: Mat Lab Beam Deflection

1 Introduction

Beam deflections could be calculated by direct integration but it becomes cumbersome for more complexbeams, especially if the problem is statically indeterminate. In this handout we will employ a method basedon techniques from finite element analysis but since we will limit ourselves to point loads and constantcross-sections between joints, the solution will be exact.

2 Review : Solving a Set of Linear Equations

A set of linear equations can be written in matrix form as shown below where K is a square matrix ofconstants, u is the vector of unknowns and F is a vector of constants.

Ku = F (1)

In order to solve the equations we require:

1. as many equations as unknowns

2. all the equations to be independent (none of the rows of K can be made from linear combinations ofsome of the other rows, i.e. K is not a singular matrix)

Checking the first condition is straightforward; K must be square and the number of rows in K, u, andF must be the same. Checking the second condition is easy if you are using Matlab by computing thedeterminant (det(K)) and ensuring it doesn’t equal zero. Provided the above conditions are satisfied, wecan compute the unknowns with Matlab using:

u=K\F

You could instead use u=inv(K)*F, but Matlab advises against it since it is slower.

3 One Dimension Spring Elements

To gain an understanding of the process, we will consider simple one-dimensional springs. Each element hastwo nodes, each which have one degree of freedom—displacement, u.

f1 f2

ke

u2u1

Figure 1: Spring element.

We can write the forces acting on the element, f1 and f2, in terms of the displacements, u1 and u2 andthe stiffness ke.

ke(u1 − u2) = f1 (2)

ke(−u2 + u1) = f2 (3)

2

Page 3: Mat Lab Beam Deflection

or in the form ku = f : [ke −ke−ke ke

] [u1u2

]=

[f1f2

](4)

The k matrix is called the stiffness matrix and the f matrix is the force matrix. If you look at k, yousee that it is singular (the equations are not independent)! We actually have only one independent equationwhich means at least one displacement must be specified. The physical reason for this is that one sideneeds to be fixed otherwise the whole spring will move (rigid body motion). The specified displacements arecalled boundary conditions.

For the displacements which are not specified, a force must be specified at that joint otherwise you cannotsolve the equation. If one specifies a boundary condition at a joint then you cannot also specify the force atthat joint too. The force and displacement are related by the stiffness and are not independent.

3.1 Multiple Connected Spring Elements

Now let’s consider two springs connected together which have stiffnesses k1 and k2. There are three externalforces F1, F2, and F3.

F1 F2

k1

u2u1

F3

u3

k2

Figure 2: Multiple spring elements.

We can write the equations for each element:[k1 −k1−k1 k1

] [u1u2

]=

[f1,1f2,1

](5)[

k2 −k2−k2 k2

] [u2u3

]=

[f2,2f3,2

](6)

Using the equations of equilibrium at each node we can relate the internal forces, f , to the external forces,F .

f1,1 = F1 (7)

f3,2 = F3 (8)

f2,1 + f2,2 = F2 (9)

We can now combine both sets of matrices via the common node u2 and the equilibrium equations: k1 −k1 0−k1 k1 + k2 −k2

0 −k2 k2

u1u2u3

=

F1

F2

F3

(10)

3

Page 4: Mat Lab Beam Deflection

The process of combining the stiffness matrices is called assembly. We calculate the stiffness matrix foreach element and then add it to the total stiffness matrix starting at the first node. k1 −k1 0

−k1 k1 00 0 0

+

0 0 00 k2 −k20 −k2 k2

=

k1 −k1 0−k1 k1 + k2 −k2

0 −k2 k2

(11)

If we had 3 spring elements (4 nodes) connected sequentially, the total stiffness matrix would be:k1 −k1 0 0−k1 k1 + k2 −k2 0

0 −k2 k2 + k3 −k30 0 −k3 k3

(12)

Again the total stiffness matrix is singular and so we need to specify at least one displacement and theneither a displacement or a force (external) must be specified for each of the other nodes. Loads are simplyput in the force vector at the row corresponding to the node:F1

F2

F3

(13)

Incorporating displacement boundary conditions requires a bit more consideration since we wish to usematrices in Matlab to solve the equations. This is best illustrated in an example.

3.2 Spring Example

Consider the two spring arrangement with k1 = 10 N/mm and k2 = 20 N/mm. The displacement of thefirst node is 3 mm. The external force on node 2 is 50 N and on node 3 is 100 N.

Our total stiffness matrix is: 10 −10 0−10 30 −20

0 −20 20

(14)

The total equation with the loads incorporated is: 10 −10 0−10 30 −20

0 −20 20

u1u2u3

=

F1

50100

(15)

To incorporate the boundary condition, we would eliminate the top equation and rewrite the other twoequations as: [

−10 30 −200 −20 20

] 3u2u3

=

[50100

](16)

but we can move u1 to the right side of the equation since it is known:[−10 30 −20

0 −20 20

] [u2u3

]=

[50− (−10)3100− 0(3)

](17)

Deleting rows is annoying in programs like Matlab so more often the row with the known displacementis left in but simplified to: 1 0

0 30 −200 −20 20

u1u2u3

=

350− (−10)3100− 0(3)

=

380100

(18)

Solving in Matlab gives:

4

Page 5: Mat Lab Beam Deflection

u1 = 3, u2 = 18, u3 = 23.

We can get the all the external forces by multiplying the total stiffness matrix by the displacements: 1 0−10 30 −20

0 −20 20

31823

=

F1

F2

F3

=

−15050100

(19)

We can also get the internal forces for each element now that we have all the displacements from thestiffness matrix for each individual element.[

10 −10−10 10

] [318

]=

[f1,1f2,1

]=

[−150150

](20)

[20 −20−20 20

] [1823

]=

[f2,2f3,2

]=

[−100100

](21)

3.3 Summary of Method

1. Calculate the stiffness matrix for each element.

2. Assemble the element stiffness matrix in the total stiffness matrix.

3. Put known external loads in appropriate location of load vector.

4. Incorporate boundary conditions (known deflections) in stiffness matrix and load vector.

5. Solve for unknown displacements.

6. If desired, calculate the external and internal forces from the displacements.

5

Page 6: Mat Lab Beam Deflection

4 Beam Elements

The same procedure is used for beam elements, but beams have two types of loads—shear force and moment,and two degrees of freedom at each joint—displacement and slope.

y1

y2

θ1

θ2

M1

R1

M2

R2

x

Figure 3: Beam element.

Assuming that the modulus of elasticity, E, and second moment of area, I, are constant over the beamelement of length L, the equations for the slope, θ, and the displacement, y, for the beam element come fromdirect integration:

θ(x) = θ1 +1

EI

(−M1x+

1

2R1x

2

)(22)

y(x) = y1 + θ1x+1

EI

(−1

2M1x

2 +1

6R1x

3

)(23)

We can again write the forces and moments in terms of the degrees of freedom which gives the matrixequation for the element.

EI

L3

12 6L −12 6L6 4L2 −6L 2L2

−12 −6L 12 −6L6L 2L2 −6L 4L2

y1θ1y2θ2

=

R1

M1

R2

M2

(24)

This equation is in the exact same form Ku = F as before (the EI/L3 term is only factored out forclarity). Analysis of the stiffness matrix shows that now two degrees of freedom must be specified andone of them must be a displacement (again to prevent rigid body motion). The solution steps are thesame as for spring elements as the following example will illustrate.

6

Page 7: Mat Lab Beam Deflection

4.1 Beam Example

The beam shown below has two parts with different moments of inertia but with the same modulus. Theloading and boundary conditions are shown.

I=20mm4 I=60mm4

E=6000 MPaF=6 N

M=5 N.mm

60 mm 60 mm

40 mm

Figure 4: Beam example

We need to break the beam into 3 elements (4 nodes) because the force is not at the junction of the twobeam sections.

F=6 N

M=5 N.mm

1 2 3 4

L=40mm L=20mm L=60mm

I=20mm4 I=20mm4 I=60mm4

Nodes #:

E=6000 MPa

Figure 5: Beam example nodes.

The individual stiffness matrices are:22.5 450 −22.5 450450 12000 −450 6000−22.5 −450 22.5 −450450 6000 −450 12000

,

180 1800 −180 18001800 24000 −1800 12000−180 −1800 180 −18001800 12000 −1800 24000

,

20 600 −20 600600 24000 −600 12000−20 −600 20 −600600 12000 −600 24000

(25)

7

Page 8: Mat Lab Beam Deflection

The assembled equations are:

22.5 450 −22.5 450 0 0 0 0450 12000 −450 6000 0 0 0 0−22.5 −450 202.5 1350 −180 1800 0 0450 6000 1350 36000 −1800 12000 0 00 0 −180 −1800 200 −1200 −20 6000 0 1800 12000 −1200 48000 −600 120000 0 0 0 −20 −600 20 −6000 0 0 0 600 12000 −600 24000

y1θ1y2θ2y3θ3y4θ4

=

00−60000−50

(26)

Applying the boundary conditions (y1 = 0, θ1 = 0, y4 = 0):

1 0 0 0 0 0 0 00 1 0 0 0 0 0 00 0 202.5 1350 −180 1800 0 00 0 1350 36000 −1800 12000 0 00 0 −180 −1800 200 −1200 0 6000 0 1800 12000 −1200 48000 0 120000 0 0 0 0 0 1 00 0 0 0 600 12000 0 24000

y1θ1y2θ2y3θ3y4θ4

=

00−60000−50

(27)

Solving the equations gives:

y1θ1y2θ2y3θ3y4θ4

=

00

−0.3064−0.005404−0.309850.0042045

00.0035606

(28)

Keep in mind that the absolute maximum deflection and slope may occur between nodes. But sincewe know the exact equations (22, 23) we can get any point between the nodes. The Matlab program inthe appendix does just this and prints the maximum slope and deflection and the shear, moment, slope anddeflection graphs. The maximum absolute slope is 0.0103 and the maximum absolute deflection is 0.3319.The beam graphs are shown in figure 6.

8

Page 9: Mat Lab Beam Deflection

0 20 40 60 80 100 120-2

0

2

4

6S

hea

r

0 20 40 60 80 100 120-200

-100

0

100

Mom

ent

0 20 40 60 80 100 120-0.02

-0.01

0

0.01

Slo

pe

0 20 40 60 80 100 120-0.4

-0.2

0

0.2

0.4

Def

lect

ion

Figure 6: Beam example graphs.

9

Page 10: Mat Lab Beam Deflection

A Matlab Code

%*************************************************************************

%***

%*** Beam Shear, Moment, Slope, and Deflection

%*** S. Salisbury 2010

%***

%*************************************************************************

%This program uses finite element methods to calculate the shear,

%moment, slope and deflection distribution along a beam. Analysis is

%limited to beams with constant cross-sections between nodes and only

%concentrated forces and moments applied at the nodes. This permits

%fewer nodes to be used since the form of the equations are known.

%

%One must be consistent in units (i.e. pounds-inches-psi, N-mm-MPa).

%Slope is in radians and deflection is in the consistent units.

%*************************************************************************

%*************************************************************************

%***Enter Data...

%*************************************************************************

clc; clear; %clear the workspace and command window

%Modulus of Elasticity

E=6000;

%Properties for each beam element

BeamProp=[

%length, I

40, 20;

20, 20;

60, 60;

];

%Known node deflections

% need at least 1 if a slope is specified,

% otherwise need 2 if no slopes are specified

NodeDef=[

%node, deflection

1, 0;

4, 0;

];

%Known node slopes

% need at least 1 if only 1 deflection specified

NodeSlp=[

%node, slope

1, 0;

];

%Applied node forces

10

Page 11: Mat Lab Beam Deflection

ForApp=[

%node, force

2, -6;

];

%Applied node moments

MomApp=[

%node, moment

4, -50;

];

%Number of results per beam element

Nres=10;

%*************************************************************************

% Start calculations...

%*************************************************************************

Nelem=length(BeamProp(:,1)); %number of beam elements

Nnode=Nelem+1; %number of joints

Ndof=Nnode*2; %number of degrees of freedom (1 deflection and

% 1 slope per node)

%Construct stiffness matrix

%*************************************************************************

K=zeros(Ndof);%initialize stiffness array

for i=1:Nelem %for each beam element...

L=BeamProp(i,1); %get the length

EI=E*BeamProp(i,2); %get the section properties

%stiffness of local element

Ksect=EI/L^3*[

12, 6*L, -12, 6*L;

6*L, 4*L^2, -6*L, 2*L^2;

-12, -6*L, 12, -6*L;

6*L, 2*L^2, -6*L, 4*L^2;

];

%assemble in global stiffness matrix

Loc=2*i-1; %location of element in global matrix

for j=0:3

for k=0:3

K(Loc+j,Loc+k)=K(Loc+j,Loc+k)+Ksect(j+1,k+1);

end

end

end

%Construct Load Vector

%*************************************************************************

F=zeros(Ndof,1); %initialize load vector

%Incorporate nodal forces

if isempty(ForApp)==0 %check that array not empty

for i=1:length(ForApp(:,1))

11

Page 12: Mat Lab Beam Deflection

F(ForApp(i,1)*2-1)=ForApp(i,2); %put in applied force

end

end

%Incorporate nodal moments

if isempty(MomApp)==0 %check that array not empty

for i=1:length(MomApp(:,1))

F(MomApp(i,1)*2)=MomApp(i,2); %put in applied moment

end

end

%Incoporate Boundary Conditions

%*************************************************************************

%deflections

for i=1:length(NodeDef(:,1)) %for each constraint...

Loc=NodeDef(i,1)*2-1; %get the column the constraint refers to

def=NodeDef(i,2); %get the deflection at this node

for j=1:Ndof %for each row...

if j~=Loc %if the row doesn’t correspond to the constraint

F(j)=F(j)-K(j,Loc)*def; %move the known to right side of eqn.

K(j,Loc)=0; %elminiate it from the left side

else %if row corresponds to the constraint...

F(j)=def; %set the value on right side to constraint

for k=1:Ndof %elminate this equation from left side of eqn.

if k==Loc

K(j,k)=1;

else

K(j,k)=0;

end

end

end

end

end

%slopes

if isempty(NodeSlp)==0

for i=1:length(NodeSlp(:,1)) %for each constraint...

Loc=NodeSlp(i,1)*2; %get the column the constraint refers to

def=NodeSlp(i,2); %get the deflection at this node

for j=1:Ndof %for each row...

if j~=Loc %if the row doesn’t correspond to the constraint

F(j)=F(j)-K(j,Loc)*def; %move known to right side of eqn.

K(j,Loc)=0; %elminiate it from the left side

else %if row corresponds to the constraint...

F(j)=def; %set the value on right side to constraint

for k=1:Ndof %elminate this equation from left side of eqn.

if k==Loc

K(j,k)=1;

else

K(j,k)=0;

end

end

12

Page 13: Mat Lab Beam Deflection

end

end

end

end

%Solve for deflection and slopes

%*************************************************************************

u=zeros(Ndof,1); %initialize dof vector

u=K\F; %solve

%Calculate shear(V) and moment(M) at the nodes

%*************************************************************************

% limitations on type of problem mean shear is constant along element

% and moment varies linearly

xVM=zeros(Ndof,1); %initialize distance along beam for V & M

V=zeros(Ndof,1); %initialize shear (2 per node)

M=zeros(Ndof,1); %initialize moment (2 per node)

for i=1:Nelem %for each beam element...

% get the element properties

L=BeamProp(i,1);

EI=E*BeamProp(i,2);

%stiffness of local element (as before)

Ksect=EI/L^3*[

12, 6*L, -12, 6*L;

6*L, 4*L^2, -6*L, 2*L^2;

-12, -6*L, 12, -6*L;

6*L, 2*L^2, -6*L, 4*L^2;

];

Loc=2*i; %location in the V & M matrices

%calculate shear and moment at left and right end of element

for k=0:3

V(Loc)=V(Loc)+Ksect(1,k+1)*u(Loc-1+k);

M(Loc)=M(Loc)-Ksect(2,k+1)*u(Loc-1+k);

V(Loc+1)=V(Loc+1)-Ksect(3,k+1)*u(Loc-1+k);

M(Loc+1)=M(Loc+1)+Ksect(4,k+1)*u(Loc-1+k);

end

%distance

xVM(Loc+1)=xVM(Loc)+L;

xVM(Loc+2)=xVM(Loc+1);

end

%Print out nodal results

%*************************************************************************

disp(’**Nodal Results**’)

%Column titles

S=sprintf(’%4s’,’Node’);

S=strcat(S,sprintf(’ %12s’,’Distance’));

S=strcat(S,sprintf(’ %12s’,’Deflection’));

S=strcat(S,sprintf(’ %12s’,’Slope’));

13

Page 14: Mat Lab Beam Deflection

% total force and moment at nodes

S=strcat(S,sprintf(’ %12s’,’Force’));

S=strcat(S,sprintf(’ %12s’,’Moment’));

% Shear.2 and Moment.2 are at left side of beam element

% Shear.1 and Moment.1 are at right side of beam element

S=strcat(S,sprintf(’ %12s’,’Shear.2’));

S=strcat(S,sprintf(’ %12s’,’Shear.1’));

S=strcat(S,sprintf(’ %12s’,’Moment.2’));

S=strcat(S,sprintf(’ %12s\n’,’Moment.1’));

disp(S)

%Column Data

for i=1:Nnode

S=sprintf(’%4d’,i);

S=strcat(S,sprintf(’ %12.3g’,xVM(i*2-1)));

S=strcat(S,sprintf(’ %12.3g’,u(i*2-1)));

S=strcat(S,sprintf(’ %12.3g’,u(i*2)));

S=strcat(S,sprintf(’ %12.3g’,V(i*2-1)+ V(i*2)));

S=strcat(S,sprintf(’ %12.3g’,M(i*2-1)+ M(i*2)));

S=strcat(S,sprintf(’ %12.3g’,V(i*2-1)));

S=strcat(S,sprintf(’ %12.3g’,V(i*2)));

S=strcat(S,sprintf(’ %12.3g’,M(i*2-1)));

S=strcat(S,sprintf(’ %12.3g\n’,M(i*2)));

disp(S)

end

%Calculate slope(slp) and deflection(y) at increments along elements

%*************************************************************************

% limitations on type of problem allow use of formulae

% from direct integration rather than many sub-elements

xG=0; %global distance from left end of beam to left end of element

xR=zeros(Nelem*Nres,1); %initialize global distance vector for results

slp=zeros(Nelem*Nres,1); %initialize slope vector

y=zeros(Nelem*Nres,1); %initialize deflection vector

for i=1:Nelem %for each beam element...

% get the element properties

L=BeamProp(i,1);

EI=E*BeamProp(i,2);

%calculate the distance, slope and deflection

for j=1:Nres %for each point along element...

xL=L/(Nres-1)*(j-1); %local distance from element left side

xR((i-1)*Nres+j)=xG+xL; %global distance

slp((i-1)*Nres+j)=u(2*i)+(V(2*i)*xL^2/2+M(2*i)*xL)/EI;

y((i-1)*Nres+j)=u(2*i-1)+u(2*i)*xL+ ...

(V(2*i)*xL^3/6+M(2*i)*xL^2/2)/EI;

end

xG=xG+L;

end

14

Page 15: Mat Lab Beam Deflection

disp(sprintf(’Maximum absolute deflection: %12.4f’,...

max(max(y),abs(min(y)))));

disp(sprintf(’Maximum absolute slope: %12.4f’,...

max(max(slp),abs(min(slp)))));

%Plot out the data

%*************************************************************************

subplot(4,1,1)

area(xVM,V)

ylabel(’Shear’)

subplot(4,1,2)

area(xVM,M)

ylabel(’Moment’)

subplot(4,1,3)

area(xR,slp)

ylabel(’Slope’)

subplot(4,1,4)

area(xR,y)

ylabel(’Deflection’)

15