CI221 Finite Element Notes

Embed Size (px)

Citation preview

  • 8/3/2019 CI221 Finite Element Notes

    1/50

    CI 221 Computational Methods

    Introduction to Finite Element Analysis

    Dr Andrew TM Phillips

    While intended to give an overview of this part of the course these notes are not a complete

    record and should not be treated as a substitute for attending lectures and tutorials.

    Copyright 2010. All rights reserved.

  • 8/3/2019 CI221 Finite Element Notes

    2/50

  • 8/3/2019 CI221 Finite Element Notes

    3/50

    Aim of this part of the course:

    The aim of this part of the course is to introduce the finite element method, and inves-

    tigate its application in particular in structural engineering. Emphasis is placed on theuse of Matlab and GSA in achieving this.

    No one believes the results of a computational model, except the person who put to-

    gether the model. Everyone believes the results of an experimental test, except the person

    who put together the experiment.

    Recommended reading

    The following suggested textbooks may be useful for students looking to do further read-

    ing on the subjects introduced in this part of the course.

    Kwon and Bang, The Finite Element Method Using MATLAB

    Ferreira, MATLAB Codes for Finite Element Analysis

    Zienkiewicz, Taylor and Zhu, The Finite Element Method: Its Basics and Funda-

    mentals

    Zienkiewicz and Morgan, Finite Elements and Approximation

    1

  • 8/3/2019 CI221 Finite Element Notes

    4/50

    1 Introduction

    The finite element method is a very powerful mathematical technique that has found

    significant application in structural engineering, as well as other fields of science andengineering.

    The first recognised use of the Finite Element Method as we know it is that of

    Turner et al.1 who used it to numerically model aircraft wings using a mesh of triangular

    elements. In introducing the finite element method we will first look at the Galerkin

    method of weighted residuals for approximating functions, before moving on to look at

    strong and weak function formulations.

    1.1 Galerkin method of weighted residuals

    Although the Galerkin method is not the only method of weighted residuals available for

    approximating functions we will investigate it, as we will see later on that it has particular

    relevance to the finite element method.

    Let us first consider the following differential governing equation:

    d2u

    dx2 u + x = 0 (1.1)

    In order to define the problem let us introduce a domain, 0 < x < 1, and let us also

    define boundary conditions, u(0) = 0, and u(1) = 0. This information can be rewritten

    in the form:

    d2udx2 u + x = 0, 0 < x < 1u(0) = 0, and u(1) = 0 (1.2)The first step for any method of weighted residuals is then to determine a trial function

    which contains unknown coefficients to be determined. Here we will select the trial

    function:

    1Turner et al., Stiffness and Deflection Analysis of Complex Structures, Journal of AeronauticalSciences 23(9):805-823,854, 1956

    2

  • 8/3/2019 CI221 Finite Element Notes

    5/50

    u = ax(1 x) (1.3)

    where u denotes an approximate solution for u, and a is the unknown coefficient. The trial

    function, u suggested has been chosen as it satisfies the boundary conditions specified

    for the governing differential equation (u(0) = 0, and u(1) = 0). It is observed that the

    goodness of fit of the approximate solution to the exact solution is dependent on the trial

    function. Having selected a a trial function we define a residual, R by substituting u into

    the governing differential equation:

    R =d2u

    dx2 u + x = 2a ax(1 x) + x (1.4)

    where because u will be different to the exact solution, the residual R will not be equal

    to zero for all values of x within the domain. Having defined the residual, R we can now

    combine this with a weighting function w in order to determine the value of the coefficient,

    a such that our chosen trial function provides the best fit that can be achieved compared

    to the exact solution. To do this we set the integration of the weighted residual over the

    domain to zero:

    10 wR dx = 10 w d2udx2 u + x dx=10

    w(2a ax(1 x) + x) dx = 0(1.5)

    For Galerkins method we set the weighting function based on the chosen trial function,

    such that:

    w =du

    da= x(1 x) (1.6)

    Hence for the chosen trial function, setting the integrated weighted residual over the

    domain to zero we have:

    10

    x(1 x)(2a ax(1 x) + x) dx = 0 (1.7)

    which can be solved to give a = 0.2272.

    3

  • 8/3/2019 CI221 Finite Element Notes

    6/50

    Although not discussed here the governing differential function can be solved exactly

    to give:

    u = x1

    (e1 e1)(ex

    ex

    ) (1.8)

    Hence we can plot the solution provided by our chosen trial function against our exact

    solution, as shown in Figure 1.1.

    0 0.2 0.4 0.6 0.8 10

    0.01

    0.02

    0.03

    0.04

    0.05

    0.06

    x

    u

    (solid

    red),u

    Figure 1.1: u, the exact solution (solid red) and u, the approximate solution (dash-dotblue) found using the Galerkin weighted residual method

    In order to improve the approximation we can change the trial function, and increase

    the number of independent coefficients. Hence another trial function could be:

    u = a1x(1

    x) + a2x2(1

    x) (1.9)

    where a1 and a2 are independent coefficients. This trial functions gives the residual:

    R =d2u

    dx2 u + x = a1(2 x + x2) + a2(2 6x + x2 + x3) + x (1.10)

    In order to find appropriate values for a1 and a2 we define the same number of weight-

    ing functions as we have unknowns. For the Galerkin method these are defined:

    4

  • 8/3/2019 CI221 Finite Element Notes

    7/50

    wi =u

    ai(1.11)

    So for the given trial function we have:

    w1 = x(1 x), w2 = x2(1 x) (1.12)

    Hence for the chosen trial function, we can define two weighted residuals, and set their

    integrals to zero over the domain:

    1

    0

    w1Rdx = 0,

    1

    0

    w2Rdx = 0 (1.13)

    giving simultaneous expressions, that in matrix form can be solved to give a1 = 0.1457

    and a2 = 0.1628:

    11/30 11/6011/60 1/7

    a1

    a2

    =

    1/121/20

    (1.14)

    Hence we can plot the solution provided by our 1st-order and 2nd-order chosen trialfunctions against our exact solution, as shown in Figure 1.2. It is observed that the

    2nd-order chosen trial function has a very high goodness of fit for the exact solution.

    1.2 Weak formulation of the Galerkin method

    When we were operating on the trial function previously we were using the strong form,

    where the evaluation of the integrated weighted residual relied on the highest order of

    derivative term in the residual having a non-zero value. This restricted our choice of trial

    functions to those where:

    2u

    x2= 0 (1.15)

    We can however apply integration by parts to the strong form, in order define the

    weak form:

    5

  • 8/3/2019 CI221 Finite Element Notes

    8/50

    0 0.2 0.4 0.6 0.8 10

    0.01

    0.02

    0.03

    0.04

    0.05

    0.06

    x

    u

    (solid

    red),

    u

    Figure 1.2: u, the exact solution (solid red), 1st-order approximate solution (dash-dot blue), and 2nd-order approximate solution (dotted black) found using the Galerkinweighted residual method

    10

    w

    d2u

    dx2 u + x

    dx =

    10

    dw

    dx

    du

    dx wu + wx

    dx +

    w

    du

    dx

    10

    = 0 (1.16)

    If we refer back the our original trial function for the governing differential equation

    it can be seen that we will arrive at the same value of a using the weak form as we did

    for the strong form:

    10

    (wu wu + wx)dx + [wu]10 = 0

    u = ax(1

    x), u = a

    2ax, w = x(1

    x), w = 1

    2x

    a = 0.2272

    (1.17)

    While for the originally chosen trial function this is not seen to have any immediate

    advantage, we can go on to introduce the concept of using piecewise continuous trial

    functions.

    6

  • 8/3/2019 CI221 Finite Element Notes

    9/50

    1.3 Piecewise continuous trial functions

    It is observed that regardless of whether a strong or weak formulation is adopted the

    accuracy of any approximate solutions depends on the chosen trial function. However

    selecting a trial function is not always an easy task. The is particularly true if the exact

    function varies widely over the problem domain, if the domain has a complex shape in

    two or three dimensions, or if the domain, or problem has a complex set of boundary

    conditions. The task can be made easier by selecting piecewise continuous trial functions.

    Consider piecewise linear functions in a one dimensional domain:

    i(x) = (x

    xi1)/hi for xi1

    x

    xi

    (xi+1 x)/hi+1 for xi x xi+10 for x < xi1, or x > xi+1

    (1.18)

    The piecewise linear functions can be represented graphically as shown in Figure 1.3.

    Figure 1.3: Piecewise linear functions

    Let us go on to define a piecewise linear trial function such that:

    u = a11(x) + a22(x) (1.19)

    where a1 and a2 are unknown coefficients and 1 and 2 are defined:

    1(x) =

    3x for 0 x 1/32 3x for 1/3 x 2/30 for 2/3 x 1

    (1.20)

    7

  • 8/3/2019 CI221 Finite Element Notes

    10/50

    2(x) =

    0 for 0 x 1/33x 1 for 1/3 x 2/33 3x for 2/3 x 1

    (1.21)

    The trial function, u can then be rewritten as:

    u =

    a1(3x) for 0 x 1/3a1(2 3x) + a2(3x 1) for 1/3 x 2/3a2(3 3x) for 2/3 x 1

    (1.22)

    and graphically represented as shown in Figure 1.4.

    Figure 1.4: Piecewise linear trial functions

    The Galerkin method gives the following weighting functions:

    w1 =

    3x for 0 x 1/32 3x for 1/3 x 2/30 for 2/3 x 1

    (1.23)

    w2 =

    0 for 0 x 1/33x 1 for 1/3 x 2/3

    3 3x for 2/3 x 1

    (1.24)

    The integrated weighted residuals over the domain are given:

    IwR1 =

    10

    (w1u w1u + w1x)dx = 0 (1.25)

    IwR2 = 1

    0

    (

    w1u

    w1u + w1x)dx = 0 (1.26)

    8

  • 8/3/2019 CI221 Finite Element Notes

    11/50

    where [wiu] is omitted recognising that w1(0) = w1(1) = w2(0) = w2(1) = 0.

    We can go on to evaluate the weighted integrals:

    IwR1 =1/30

    [3(3a) 3x(a1(3x)) + (3x)x] dx+2/31/3

    [3(3a1 + 3a2) (2 3x)(2a1 3a1x + 3a2x a2) + (2 3x)x] dx+12/3

    0 dx = 0

    (1.27)

    IwR2 = 1/3

    00 dx

    + 2/31/3 [3(3a1 + 3a2) (3x 1)(2a1 3a1x + 3a2x a2) + (3x 1)x] dx+12/3

    [3(3a2) (3 3x)(3a2 3a2x) + (3 3x)x] dx = 0(1.28)

    giving simultaneous equations, that in matrix form can be solved to give a1 = 0.0488 and

    a2 = 0.0569:

    6.2222 2.9444

    2.9444 6.2222 a1

    a2 = 0.1111

    0.2222 (1.29)Hence we can plot the solution provided by our piecewise linear trial functions against

    our exact solution, as shown in Figure 1.5. It is observed that although a good fit is not

    achieved with just two piecewise linear trial functions, a good fit could be achieved with

    the introduction of additional piecewise linear trial functions. While this will not be done

    here, it is clear that computationally the process could quickly be automated.

    Exercise: Download the Oasys GSA refresher tutorial from BlackBoard

    and remind yourself of how to put together simple truss and frame structures.

    GSA is based on the stiffness method and you should look in the help documents for

    the stiffness matrices used for bar and beam elements respectively. When we move on to

    the implementation of the finite element method for analysing structures we will first of

    all remind ourselves of the matrix stiffness method, which is covered in the second year

    structural mechanics course.

    9

  • 8/3/2019 CI221 Finite Element Notes

    12/50

    0 0.2 0.4 0.6 0.8 10

    0.01

    0.02

    0.03

    0.04

    0.05

    0.06

    x

    u

    (solid

    red),

    u

    Figure 1.5: u, the exact solution (solid red), u approximate solution (dash-dot blue) usingpiecewise linear trial functions

    10

  • 8/3/2019 CI221 Finite Element Notes

    13/50

    1.4 Galerkin Finite Element Formulation

    Having introduced the concepts of the Galerkin method, and piecewise continuous trial

    functions we can go on to introduce a more formal system of finite elements. Let us

    consider an individual finite element as shown in Figure 1.6.

    Figure 1.6: Individual finite element with nodes at xi and xi+1

    The element shown has two nodes at xi and xi+1 with nodal variables ui and ui+1

    at those nodes. We will assume that our unknown trial function is of the form:

    u = c1x + c2 (1.30)

    This trial function can be expressed in terms of the nodal variables (ui and ui+1),

    replacing c1 and c2 with the nodal variables:

    u(xi) = c1xi + c2 = ui

    u(xi+1) = c1xi+1 + c2 = ui+1(1.31)

    Thus solving simultaneously we obtain:

    c1 =ui+1 uixi+1 xi

    c2 =

    uixi+1

    ui+1xixi+1 xi

    (1.32)

    Substituting expressions for c1 and c2 back into our unknown trial function we have:

    u = N1(x)ui + N2(x)ui+1 (1.33)

    11

  • 8/3/2019 CI221 Finite Element Notes

    14/50

    where:

    N1(x) =xi+1 x

    hi, N2(x) =

    x xihi

    , hi = xi+1 xi (1.34)

    and N1 and N2 are referred to as linear shape functions.

    The shape functions are such that at node ni, the shape function Ni will have a value

    of 1, while at all other nodes it will have a value of zero. Thus the linear shape functions,

    N1 and N2 for a single element can be graphically represented as shown in Figure 1.7.

    Figure 1.7: Linear shape functions for a single finite element (e1), with two nodes (n1and n2)

    It is noted that in general:

    ni=1

    Ni(x) = 1 (1.35)

    We can go on to look at a system of four finite elements as shown in Figure 1.8 which

    we will use to find an approximation to the actual solution using the weak form of the

    governing differential we looked at previously:

    IwR =

    ni=1

    xi+1xi

    (wu wu + wx)dx + [uw]10 = 0 (1.36)

    For an individual element ei we maintain the relationship:

    u = N1(x)ui + N2(x)ui+1 (1.37)

    12

  • 8/3/2019 CI221 Finite Element Notes

    15/50

    Figure 1.8: Four finite elements (e1 to e4), with five nodes (n1 to n5) with linear shapefunctions

    where from the Galerkin method the weighting functions w1 and w2 are based on the

    shape functions N1 and N2:

    w1 = N1(x)

    w2 = N2(x)(1.38)

    and the integrated weighted residual for an individual element ei is:

    IwR(ei) =xi+1xi

    N1N2

    [N1N

    2]

    N1

    N2

    [N1N2]

    dx

    uiui+1

    + xi+1xi

    N1

    N2 x dx(1.39)

    Hence if we have a domain between 0 and 1, with nodes at x = 0, x = 0.25, x =

    0.5, x = 0.75 and x = 1, then we can derive the integrated weighted residual for each

    element in the form:

    IwR(ei) =

    1hi

    + hi3

    1hi

    + hi6

    1hi

    + hi6

    1hi

    + hi3

    ui

    ui+1

    +

    hi6

    (xi+1 + 2xi)hi6

    (2xi+1 + xi)

    (1.40)

    where hi = xi+1 xi

    13

  • 8/3/2019 CI221 Finite Element Notes

    16/50

    We can then write the integrated weighted residual for each element in matrix form:

    IwR(e1) = 4.08333 3.95833

    3.95833 4.08333

    u1

    u2 + 0.0104167

    0.0208333 (1.41)

    IwR(e2) =

    4.08333 3.958333.95833 4.08333

    u2u3

    +

    0.0416667

    0.0520833

    (1.42)

    IwR(e3) =

    4.08333 3.958333.95833 4.08333

    u3

    u4

    +

    0.0729167

    0.0833333

    (1.43)

    IwR(e4) = 4.08333 3.958333.95833 4.08333 u4u5 + 0.10416670.1145833 (1.44)

    which can be combined to give:

    IwR =

    4.08333 3.95833 0 0 03.95833 8.16667 3.95833 0 0

    0 3.95833 8.16667 3.95833 00 0 3.95833 8.16667 3.958330 0 0 3.95833 4.08333

    u1

    u2u3u4u5

    +

    0.0104167 u(0)0.0625

    0.125

    0.1875

    0.1145833 + u(1)

    = 0

    (1.45)

    where u(0) and u(1) are referred to as the Neumann boundary conditions. In practice we have

    what are referred to as the Dirichlet boundary conditions:

    u(0) = u1 = 0, u(1) = u5 = 0

    14

  • 8/3/2019 CI221 Finite Element Notes

    17/50

    Thus we can alter the integrated weighted residual relationship with the known boundary

    conditions:

    1 0 0 0 0

    3.95833 8.16667 3.95833 0 00 3.95833 8.16667 3.95833 00 0 3.95833 8.16667 3.958330 0 0 0 1

    u1u2u3u4u5

    =

    0

    0.06250.1250.1875

    0

    (1.46)

    giving:

    u1 = 0, u2 = 0.0352, u3 = 0.0569, u4 = 0.0505, u5 = 0

    We can substitute back into our unknown trial function for each element to give:

    u

    N1(x)u1 + N2(x)u2 = 0.1408x for 0 x 0.25N1(x)u2 + N2(x)u3 = 0.0352 + 0.0868(x 0.25) for 0.25 x 0.5

    N1(x)u3 + N2(x)u4 = 0.0569 0.0256(x 0.50) for 0.5 x 0.75N1(x)u4 + N2(x)u5 = 0.0505 0.2020(x 0.75) for 0.75 x 1

    (1.47)

    Hence we can plot the solution provided by the Galerkin finite element formulation against

    our exact solution, as shown in Figure 1.9. It is observed that although a reasonable fit is

    achieved with four elements, a better fit could be achieved with the introduction of additional

    elements. While this will not be done here, it is clear that computationally the process could

    quickly be automated. It should be noted in particular that although the residual (u u) iszero at the nodes, this is not the case in the length of the element.

    So we have demonstrated the application of the Galerkin finite element formulation to a

    particular governing differential relationship. It can be seen that the method is easily applied

    to a variety of physical phenomena. We shall look at the finite element method as applied in

    structural mechanics.

    15

  • 8/3/2019 CI221 Finite Element Notes

    18/50

    0 0.2 0.4 0.6 0.8 10

    0.01

    0.02

    0.03

    0.04

    0.05

    0.06

    x

    u

    (solid

    red),

    u

    Figure 1.9: u, the exact solution (solid red), u approximate solution (dash-dot blue) usingthe Galerkin finite element formulation

    16

  • 8/3/2019 CI221 Finite Element Notes

    19/50

    2 Structural Finite Elements

    2.1 Axial bar element

    Let us first consider a bar element, that is an element which only resists axial forces. At this

    stage we will also introduce a local coordinate system onto the bar such that at the first node,

    n1 we have = 1, and at the second node, n2 we have = +1, as shown in Figure 2.1.

    Figure 2.1: 1D bar element and associated linear shape functions

    If a force per unit length is applied to the bar as shown in Figure 2.2 we can go on to look

    at the strain energy and external work associated with axial deformation of the element.

    Figure 2.2: 1D bar element with an axial load per unit length, p applied

    The total strain energy can be expressed as:

    U =1

    2 +a

    axx A dx (2.1)

    17

  • 8/3/2019 CI221 Finite Element Notes

    20/50

    where A is the cross-sectional area of the bar (assumed to be constant). Taking the elastic

    modulus of the material to be E we have x = Ex and:

    U =

    1

    2 +a

    a EA

    2

    x dx (2.2)

    with x =dudx we have:

    U =1

    2

    +aa

    EA

    du

    dx

    2dx (2.3)

    The external work associated with the axial deformation of the element is:

    W =

    +aa

    p u dx (2.4)

    In the relative coordinate system the axial displacement function can be expressed as:

    u = N1()u1 + N2()u2 (2.5)

    which can be expressed in matrix form:

    u = N ue = [N1 N2]

    u1

    u2

    (2.6)

    The strain energy in terms of the relative coordinate system can be expressed:

    U =1

    2 +1

    1EA

    1

    a2du

    d2

    a d (2.7)

    dud is found from

    = J

    x where J is referred to as the Jacobian operator, or derivative

    transformation matrix between the global and the local coordinate systems.

    x= J1

    (2.8)

    In the case of a bar element J = x = a, and J1 = 1a In addition it is noted that x = a.

    18

  • 8/3/2019 CI221 Finite Element Notes

    21/50

    Given dud =dN1d

    dN2d

    u1u2

    = Nue the strain energy can be expressed:

    U =1

    2uTe

    +1

    1

    EA

    aNTN d ue (2.9)

    giving:

    U =1

    2uTe Keue (2.10)

    where Ke is the element stiffness matrix:

    Ke = EAa+11

    NTN d (2.11)

    For the bar element dN1d = 12 and dN2d = +12 and the element stiffness matrix is:

    Ke =EA

    a

    +11

    12+12

    [12 + 12 ]d =

    EA

    2a

    +1 11 +1

    =

    EA

    L

    +1 11 +1

    (2.12)

    The external work in terms of the relative coordinate system can be expressed:

    We =

    +11

    pua d = uTe a

    +11

    pNT d (2.13)

    giving:

    We = uTe fe (2.14)

    where fe is the matrix of nodal forces equivalent to the applied distributed load:

    fe = a

    +11

    pNT d =pL

    2

    1

    1

    (2.15)

    19

  • 8/3/2019 CI221 Finite Element Notes

    22/50

    For a system of elements, as illustrated in Figure 2.3 we can express the strain energy and

    work done by the external forces as:

    U =

    1

    2 uT

    n

    i=1

    Keu =

    1

    2 uT

    Ku (2.16)

    W = uTni=1

    fe = uTf (2.17)

    where K and f are the system stiffness and force matrices.

    Hence we have a global system expressed in matrix form:

    Ku = f (2.18)

    Figure 2.3: System of 1D bar elements

    2.1.1 Numerical integration

    Integrals arising from the computational implementation of the finite element method may

    be solved using numerical integration, for example Gauss quadrature. Considering a function

    f(x), x [1, +1] the integral I = +11 f(x) dx may be represented by the weighted sum of the

    values of f(x) at the Gauss points. The position and weightings of the Gauss points relate to

    the chosen number, as described in Table 1.

    Table 1: Gauss point positions and weightings

    n xi Wi1 0 2.0

    2 1/

    3 1.03 0 8/9

    3/5 5/9

    The technique is exact for 2n1 polynomials where n is the chosen number of Gauss points.

    20

  • 8/3/2019 CI221 Finite Element Notes

    23/50

    Exercise:

    The MATLAB code over the page, uses the finite element method to analyse

    the bar structure shown in Figure 2.4.

    Make notes next to the Matlab code and draw a flowchart on the blank page following,

    using pseudo-code to indicate your understanding of the Matlab code. Experiment with making

    changes to the code. In particular develop your understanding of how the stiffness and force

    matrices are constructed, and how the displacement matrix is derived.

    The Matlab code can also be downloaded from BlackBoard.

    Figure 2.4: Example Bar Structure

    21

  • 8/3/2019 CI221 Finite Element Notes

    24/50

    1 % Axial bar problem using the Finite Element Method by Andrew Phillips

    2 % adapted from Ferreira, MATLAB codes for Finite Element Analysis

    3

    4 clear all

    5 close all

    6

    7 % E, elastic modulus (N/mm2)

    8 % A, area of crosssection (mm2)9 % L, length of bar (mm)

    10

    11 E=2.05*105;

    12 A=pi*102;

    13 EA=E*A;

    14 L=900;

    15

    16 % information on the structure will be kept in a structure array

    17 s1 = struct();

    18

    19 % generating node coordinates and element connectivities

    20

    21 % setting the number of Elements

    22 s1.numElements = 3;

    23 % generating equally spaced nodes

    24 s1.nodeCoords = 0:L/s1.numElements:L;

    25 % setting coords in the x direction

    26 s1.nodeXCoord = s1.nodeCoords;

    27 % setting the number of Nodes

    28 s1.numNodes = size(s1.nodeCoords,2);

    29

    30 % assigning Nodes to Elements

    31 ii = 1:s1.numElements;

    32 s1.elementNodes(:,1) = ii;

    33 s1.elementNodes(:,2) = ii+1;

    34

    35 % degrees of freedom (1 at each node for a bar element)

    36 s1.globalDOF = s1.numNodes;

    37

    38 % setting up matrices (K, u, f)

    39 s1.stiffness = zeros(s1.globalDOF); % square matrix (n x n)

    40 s1.displacements = zeros(s1.globalDOF,1); % column matrix (n x 1);

    41 s1.force = zeros(s1.globalDOF,1); % column matrix (n x 1);

    42

    43 % applied loading (N)

    44 s1.force(2) = 1200;

    22

  • 8/3/2019 CI221 Finite Element Notes

    25/50

    45

    46 % deriving the system stiffness matrix

    47

    48 % element degrees of freedom

    49 for ee=1:s1.numElements

    50 elementDOF = s1.elementNodes(ee,:);

    51 nn = size(elementDOF,2);

    52 lengthElement = s1.nodeXCoord(elementDOF(2))s1.nodeXCoord(elementDOF(1));53 detJacobian = lengthElement/2;

    54 invJacobian = 1/detJacobian;

    55

    56 % using a single central Gauss point in each element (xi=0, W=2)

    57 xi=0; W=2;

    58 shape=struct();

    59 shape.shape=[1

    xi; 1+xi]/2;

    60 shape.naturalDerivatives=[1; 1]/2;61 Xderivatives=shape.naturalDerivatives *invJacobian;

    62

    63 % B matrix (derivates of the shape functions)

    64 B=zeros(1,nn); % single row

    65 B(1:nn) = Xderivatives;

    66

    67 % assembling the system stiffness matrix

    68 s1.stiffness(elementDOF,elementDOF)=s1.stiffness(elementDOF,elementDOF) ...

    69 +B'*

    B*

    W*

    detJacobian*

    EA;

    70 end

    71

    72 % prescribed global degrees of freedom

    73 s1.prescribedDOF = [1 4];

    74

    75 % solution

    76 activeDOF=setdiff([1:s1.globalDOF]', [s1.prescribedDOF]);

    77 U=s1.stiffness(activeDOF,activeDOF) \s1.force(activeDOF);78 s1.displacements(activeDOF)=U;

    79

    80 % output displacements and reactions

    81 disp('Displacements')

    82 [(1:s1.globalDOF)' s1.displacements]

    83

    84 F=s1.stiffness*s1.displacements;

    85 reactions=F(s1.prescribedDOF);

    86 disp('Reactions')

    87 [s1.prescribedDOF' reactions]

    23

  • 8/3/2019 CI221 Finite Element Notes

    26/50

    Blank page for pseudo-code flowchart for the bar structure example.

    24

  • 8/3/2019 CI221 Finite Element Notes

    27/50

    2.1.2 Rotational transformation

    In introducing the finite element formulation for an axial bar element we implicitly dealt with

    transformation between a global (x) and a relative () coordinate system in one-dimension. If

    we are to use bar elements in two-dimensional or three-dimensional problems we must also be

    able to deal with transforming between the relative coordinate system, and a x, y or x,y ,z

    coordinate system. We will limit ourselves here to transforming between the one-dimensional

    relative () system and a two-dimensional global (x, y) system.

    Referring to the global system of equations:

    Ku = f (2.19)

    We can recall the system of equations for an individual bar element:

    Keue = fe EAL

    +1 11 +1

    u1

    u2

    =

    f1

    f2

    (2.20)

    It is noted that in the above equation u1 and u2 are one-dimensional deformation values at

    nodes n1 and n2, and f1 and f2 are the associated applied forces. Going to a two-dimensional

    coordinate system ue

    and fe

    will expand to 4

    1 matrices and the element stiffness matrix Ke

    will expand to a 4 4 matrix:

    Keue = fe EAL

    +1 0 1 00 0 0 0

    1 0 +1 00 0 0 0

    ux1

    uy1

    ux2

    uy2

    =

    fx1

    fy1

    fx2

    fy2

    (2.21)

    It is observed that Ke is similar to second order strain and stress tensors that we have

    encountered before. As such it transforms in the same way as every second order tensor. That

    is if we have an element at an angle in the x, y system as shown in Figure 2.5 we can transform

    the element stiffness matrix in the relative system into the element stiffness matrix in the global

    system, required in order to allow us for a structural system to combine all of the element

    stiffness matrices to give us a system stiffness matrix.

    25

  • 8/3/2019 CI221 Finite Element Notes

    28/50

    Figure 2.5: Bar element at an angle with respect to the x, y coordinate system

    KGe = LTe K eLe (2.22)

    K

    Ge =

    cos sin 0 0sin cos 0 0

    0 0 cos

    sin

    0 0 sin cos

    EA

    Le

    +1 0 1 00 0 0 0

    1 0 +1 0

    0 0 0 0

    cos sin 0 0

    sin cos 0 00 0 cos sin

    0 0 sin cos

    (2.23)

    KGe = EALe

    cos2 cos sin cos2 cos sin cos sin sin2 cos sin sin2 cos2 cos sin cos2 cos sin

    cos sin sin2 cos sin sin2

    (2.24)

    where KGe is the element stiffness matrix in the global system, K e is the element stiffness matrixin the relative system, Le is the directional cosine matrix, and Le is the length.

    26

  • 8/3/2019 CI221 Finite Element Notes

    29/50

    Truss Example

    We can now adapt the Matlab code developed for our first bar element example

    in order to analyse the truss system shown in Figure 2.6.

    Figure 2.6: Example Truss Structure

    You should check the results that you find using Oasys GSA. You should find a close matchbetween the stiffness method and the finite element method when using bar elements, as imple-

    mented here.

    27

  • 8/3/2019 CI221 Finite Element Notes

    30/50

    1 % Axial bar truss problem using the Finite Element Method by Andrew Phillips

    2 % adapted from Ferreira, MATLAB codes for Finite Element Analysis

    3

    4 clear all

    5 close all

    6

    7 % E, elastic modulus (N/mm2)

    8 % A, area of crosssection (mm2)9 % L, length of bar (mm)

    10

    11 E=2.05*105;

    12 A=pi*102;

    13 EA=E*A;

    14

    15 % information on the structure will be kept in a structure array

    16 s1 = struct();

    17

    18 % generating node coordinates and element connectivities

    19

    20 % generating the node coordinates (6 nodes)

    21 s1.nodeCoords = [0 0; 0 3000; 3000 0; 3000 3000; 6000 0; 6000 3000];

    22 % setting coords in the x and y directions

    23 s1.nodeXCoord = s1.nodeCoords(:,1);

    24 s1.nodeYCoord = s1.nodeCoords(:,2);

    25 % setting the number of Nodes

    26 s1.numNodes = size(s1.nodeCoords,1);

    27

    28 % assigning Nodes to Elements (11 elements)

    29 s1.elementNodes = [1 2; 1 3; 2 3; 2 4; 1 4; 3 4; 3 6; 4 5; 4 6; 3 5; 5 6];

    30 % setting the number of Elements

    31 s1.numElements = size(s1.elementNodes,1);

    32

    33 % degrees of freedom (2 at each node for a bar element in 2D space)

    34 s1.globalDOF = s1.numNodes.*2;

    35

    36 % setting up matrices (K, u, f)

    37 s1.stiffness = zeros(s1.globalDOF); % square matrix (n x n)

    38 s1.displacements = zeros(s1.globalDOF,1); % column matrix (n x 1);

    39 s1.force = zeros(s1.globalDOF,1); % column matrix (n x 1);

    40

    41 % applied loading (N)

    42 s1.force(4) = 50000; % node 2, DOF 243 s1.force(8) = 100000; % node 4, DOF 244 s1.force(12) = 50000; % node 6, DOF 2

    28

  • 8/3/2019 CI221 Finite Element Notes

    31/50

    45

    46 % deriving the system stiffness matrix

    47

    48 % element degrees of freedom

    49 for ee=1:s1.numElements

    50 indice = s1.elementNodes(ee,:);

    51 % assigns Global DOF to the element

    52 elementDOF = [indice(1)*21 indice(1)*2 indice(2)*21 indice(2)*2];53 % length of each element in the x and y directions

    54 xa = s1.nodeXCoord(indice(2))s1.nodeXCoord(indice(1));55 ya = s1.nodeYCoord(indice(2))s1.nodeYCoord(indice(1));56 lengthElement = sqrt(xa.2+ya.2);

    57 thetaElement = atan(ya/xa);

    58 % Ke in the relative system

    59 Ke Relative = [1 0

    1 0 ; 0 0 0 0 ;

    1 0 1 0 ; 0 0 0 0 ] ;

    60 % Setting up the transformation to the global system

    61 C = cos(thetaElement);

    62 S = sin(thetaElement);

    63 L element = [C S 0 0; S C 0 0; 0 0 C S; 0 0 S C];64 % Ke in the global system

    65 Ke Global = EA./lengthElement.*(L element'*Ke Relative*L element);

    66 % assembling the system stiffness matrix

    67 s1.stiffness(elementDOF,elementDOF) =...

    68 s1.stiffness(elementDOF,elementDOF)+Ke Global;

    69 end

    70

    71 % prescribed global degrees of freedom

    72 s1.prescribedDOF = [1 2 10];

    73

    74 % solution

    75 activeDOF=setdiff([1:s1.globalDOF]', [s1.prescribedDOF]);

    76 U=s1.stiffness(activeDOF,activeDOF) \s1.force(activeDOF);77 s1.displacements(activeDOF)=U;

    78

    79 % output

    80 fprintf('Solution\n\n')81

    82 % output displacements and reactions

    83 disp('Displacements:')

    84 for n=1:s1.globalDOF

    85 fprintf('Global DOF %02d, %+1.4e \n',n,s1.displacements(n));86 end

    87 fprintf('\n');88

    29

  • 8/3/2019 CI221 Finite Element Notes

    32/50

    89 F=s1.stiffness*s1.displacements;

    90 reactions=F(s1.prescribedDOF);

    91 disp('Reactions:')

    92 for n=1:size(s1.prescribedDOF,2);

    93 fprintf('Global DOF %02d, %+1.4e

    \n',s1.prescribedDOF(n),reactions(n));

    94 end

    95 fprintf('\n');96

    97 % output axial strains

    98 for n=1:s1.numElements

    99 indice = s1.elementNodes(n,:);

    100 xa = s1.nodeXCoord(indice(2))s1.nodeXCoord(indice(1));101 ya = s1.nodeYCoord(indice(2))s1.nodeYCoord(indice(1));102 s1.originallengthElement(n) = sqrt(xa.2+ya.2);

    103 xanew = (s1.nodeXCoord(indice(2)) + s1.displacements(indice(2)*2

    1))...

    104 (s1.nodeXCoord(indice(1))+ s1.displacements(indice(1)*21));105 yanew = (s1.nodeYCoord(indice(2)) + s1.displacements(indice(2)*2))...

    106 (s1.nodeYCoord(indice(1))+ s1.displacements(indice(1)*2));107 s1.finallengthElement(n) = sqrt(xanew.2+yanew.2);

    108 s1.strainsElement(n) = (s1.finallengthElement(n)s1.originallengthElement(n)) ...109 ./s1.originallengthElement(n);

    110 end

    111

    112 disp('Strains:')

    113 for n=1:s1.numElements

    114 fprintf('Element %02d, %+1.4e \n',n,s1.strainsElement(n));115 end

    116 fprintf('\n');117

    118 % output axial stresses

    119 s1.stressesElement = E.*s1.strainsElement;

    120 disp('Stresses:')

    121 for n=1:s1.numElements

    122 fprintf('Element %02d, %+1.4e \n',n,s1.stressesElement(n));123 end

    124 fprintf('\n');

    30

  • 8/3/2019 CI221 Finite Element Notes

    33/50

    2.2 Euler-Bernoulli beam element

    The Euler-Bernoulli beam element is based on standard or engineering beam bending theory.

    The assumptions used in formulating standard beam bending theory are:

    Plane sections remain plane after deformation.

    Plane sections remain perpendicular to the neutral axis after deformation.

    These assumptions are illustrated in Figure 2.7.

    Figure 2.7: Euler-Bernoulli Beam Bending

    Based on Figure 2.7 and the standard definition of strain we have the relationship:

    11(x2) =du1dx1

    =d

    dx1

    x2du2

    dx1

    = x2d

    2u2dx21

    = x2

    Where is the curvature. The curvature of the beam is taken as:

    =1

    R=

    d

    ds=

    d2u2dx21

    31

  • 8/3/2019 CI221 Finite Element Notes

    34/50

    Where R is the radius of curvature, and ds is the distance along the curve as illustrated in

    Figure 2.8, which for small deflections can be considered equal to dx1.

    Figure 2.8: Beam curvature

    With regards to a finite element formulation for a two noded element we can specify two

    degrees of freedom at each node, as shown in Figure 2.9.

    Figure 2.9: Degrees of freedom for a two noded Euler-Bernoulli beam element

    We can define four shape functions as illustrated in Figure 2.10 and given:

    N1() = +1

    4(1 )2(2 + ) (2.25)

    N2() = +1

    8L(1 )2(1 + ) (2.26)

    N3() = +1

    4(1 + )2(2 ) (2.27)

    N4() = 18

    L(1 + )2(1 ) (2.28)

    32

  • 8/3/2019 CI221 Finite Element Notes

    35/50

    1 0.5 0 0.5 10.4

    0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    N

    N1

    N2

    N

    3N

    4

    Figure 2.10: Hermite cubic shape functions for an Euler-Bernoulli beam element

    The adopted hermite shape functions are said to have C1 continuity, whereas our original

    linear shape functions had C0 continuity. That is to say that C1 shape functions are continuous

    across nodes for the first derivative, while C0 shape functions are continuous for the value only.

    It is noted that N2() and N4() do not reach values of 1 or zero at the relevant nodes. However

    these shape functions relate to the angle of rotation, , or the slope at each of the nodes, = du2dx1 .

    Thus the relationship is true for dN2d and dN4d as shown in Figure 2.11 and given:

    dN2d

    =1

    4(1 2 + 32) (2.29)

    dN4d

    =1

    4(1 + 2 + 32) (2.30)

    The strain energy associated with bending of the element can be obtained as:

    U =1

    2

    V

    E211 dV (2.31)

    Where dV = dAdx1, thus:

    U =1

    2

    +aa

    EI

    2u2x21

    2dx1 =

    1

    2

    +11

    EI

    a4

    2u2x21

    2a d (2.32)

    33

  • 8/3/2019 CI221 Finite Element Notes

    36/50

    1 0.5 0 0.5 10.4

    0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    dN

    dN2

    dN4

    Figure 2.11: dN2 and dN4 for an Euler-Bernoulli beam element

    From the chain rule it is found that d2u2d2

    = 1a2

    d2u2dx2

    1

    = 4L2

    d2u2dx2

    1

    . In addition it is noted that

    x = a = L2 .

    Given d2u2d2

    = d2Nd2

    ue = Nue the strain energy can be expressed:

    U =

    1

    2 uT

    e

    EI

    a3 +11 NTN due (2.33)giving

    U =1

    2uTe Keue (2.34)

    where Ke is the element stiffness matrix:

    Ke =EA

    a3

    +11

    NTN d (2.35)

    and:

    N =1

    L

    6

    L3 1 6

    L3 + 1

    (2.36)

    Using the Hermite shape functions the element stiffness matrix is found as:

    34

  • 8/3/2019 CI221 Finite Element Notes

    37/50

    Ke =EI

    L3

    12 6L 12 6L6L 4L2 6L 2L212 6L 12 6L

    6L 2L2

    6L 4L2

    (2.37)

    It is observed that this is the same as the matrix derived using a virtual work approach,

    therefore an exact match should be found between the stiffness method and the finite element

    method when using Euler-Bernoulli beam elements as formulated here.

    If we apply a uniform load to the element as shown in Figure 2.12 we can state the work

    done by the external forces in deforming the element as:

    W = +aa

    pu dx = uTe a+11

    pNT d (2.38)

    Figure 2.12: Uniformly distributed loading for an Euler-Bernoulli beam element

    The vector of nodal forces and moments is then found as:

    fe = a

    +11

    pNT d = pL

    1/2

    L/12

    1/2

    L/12

    (2.39)

    It is observed that these have the same magnitude as the fixed end reactions and moments

    for a uniformly loaded fixed end beam, which you will have encountered when using the stiffness

    method.

    35

  • 8/3/2019 CI221 Finite Element Notes

    38/50

    Euler Bernoulli Beam Example

    The Matlab code below can be used to model the simply supported and fixed

    end beams shown in Figure 2.13 using Euler-Bernoulli beam elements.

    Adapt the code for the different boundary conditions, and perform a convergence study

    (increasing the number of elements, and recording the predicted deflection at midspan) to find

    the number of Euler-Bernoulli beam elements required to find the analytical midspan deflections.

    You will recall that these are

    max = 5pL4

    384EI

    for a simply supported beam, and

    max = pL4

    384EI

    for a fixed end beam.

    Note the effect that using the nodal force vector has on the reported reaction values. Plot

    the nodal displacements for 2, 4, 8, 16, 32 and 64 elements for both the simply supported and

    fixed end beams and comment on what you think is a sensible mesh density with regards to

    accurately reproducing the displaced shapes of the beams.

    Figure 2.13: Example Truss Structure

    36

  • 8/3/2019 CI221 Finite Element Notes

    39/50

    1 % EulerBernoulli beam problem using the Finite Element Method2 % by Andrew Phillips

    3

    4 clear all

    5

    6 % comment to show successive plots on the same graph

    7 close all

    8

    9 % E, elastic modulus (N/mm2)

    10 % I, second moment of area of crosssection (mm4)11 % L, length of beam (mm)

    12

    13 E=2.05*105;

    14 I=8.249*107;

    15 EI=E*I;

    16 L=10000;

    17

    18 % information on the structure will be kept in a structure array

    19 s1 = struct();

    20

    21 % generating node coordinates and element connectivities

    22

    23 % setting the number of Elements

    24 % asking the user for the number of elements

    25 s1.numElements = input('How many elements do you wish to use? ');

    26 % generating equally spaced nodes

    27 s1.nodeCoords = 0:L/s1.numElements:L;

    28 % setting coords in the x direction

    29 s1.nodeXCoord = s1.nodeCoords;

    30 % setting the number of Nodes

    31 s1.numNodes = size(s1.nodeCoords,2);

    32

    33 % assigning Nodes to Elements

    34 ii = 1:s1.numElements;

    35 s1.elementNodes(:,1) = ii;

    36 s1.elementNodes(:,2) = ii+1;

    37

    38 % degrees of freedom (2 at each node for an EB beam element)

    39 s1.globalDOF = s1.numNodes.*2;

    40

    41 % setting up matrices (K, u, f)

    42 s1.stiffness = zeros(s1.globalDOF); % square matrix (n x n)

    43 s1.displacements = zeros(s1.globalDOF,1); % column matrix (n x 1);

    44 s1.force = zeros(s1.globalDOF,1); % column matrix (n x 1);

    37

  • 8/3/2019 CI221 Finite Element Notes

    40/50

    45

    46 % applied loading

    47 % load per unit length

    48 % (kN/m to N/mm)

    49 p =

    5;

    50

    51 % deriving the system stiffness matrix

    52

    53 % element degrees of freedom

    54 for ee=1:s1.numElements

    55 indice = s1.elementNodes(ee,:);

    56 % assigns Global DOF to the element

    57 elementDOF = [indice(1)*21 indice(1)*2 indice(2)*21 indice(2)*2];58 % length of the element

    59 lengthElement = s1.nodeXCoord(indice(2))

    s1.nodeXCoord(indice(1));

    60 Le = lengthElement;

    61 % Ke

    62 Ke = EI./(Le.3)*[...

    63 12 6.*Le 12 6.*Le;...64 6.*Le 4.*Le.2 6.*Le 2.*Le2;...65 12 6.*Le 12 6.*Le;...66 6.*Le 2.*Le.2 6.*Le 4.*Le.2];67 % fe

    68 fe = p.*[Le./2; Le.2./12; Le./2; Le.2./12];69 % assembling the system stiffness matrix

    70 s1.stiffness(elementDOF,elementDOF) =...

    71 s1.stiffness(elementDOF,elementDOF)+Ke;

    72 % assembling the nodal force vector

    73 s1.force(elementDOF)=s1.force(elementDOF)+fe;

    74 end

    75

    76 % prescribed global degrees of freedom

    77

    78 % simply supported

    79 s1.prescribedDOF = [1 s1.globalDOF

    1];

    80

    81 % fixed end

    82 % s1.prescribedDOF = [1 2 s1.globalDOF1 s1.globalDOF];83

    84 % solution

    85 activeDOF=setdiff([1:s1.globalDOF]', [s1.prescribedDOF]);

    86 U=s1.stiffness(activeDOF,activeDOF) \s1.force(activeDOF);87 s1.displacements(activeDOF)=U;

    88

    38

  • 8/3/2019 CI221 Finite Element Notes

    41/50

    89 % output

    90 fprintf('Solution\n\n')91

    92 % output displacements and reactions

    93 disp('Displacements:')

    94 for n=1:s1.globalDOF

    95 fprintf('Global DOF %02d, %+1.4e \n',n,s1.displacements(n));96 end

    97 fprintf('\n');98

    99 F=s1.stiffness*s1.displacements;

    100 reactions=F(s1.prescribedDOF);

    101 disp('Reactions:')

    102 for n=1:size(s1.prescribedDOF,2);

    103 fprintf('Global DOF %02d, %+1.4e

    \n',s1.prescribedDOF(n),reactions(n));

    104 end

    105 fprintf('\n');106

    107 % plot the vertical displacements

    108 fig1=figure(1);

    109 plot(s1.nodeXCoord,s1.displacements(1:2:s1.globalDOF), 'x r');110 grid on

    111 title('EulerBernoulli Beam Example');112 xlabel('Horizontal Distance');

    113 ylabel('Vertial Deflection');

    114 hold on

    39

  • 8/3/2019 CI221 Finite Element Notes

    42/50

    2.3 Timoshenko beam element

    Alternative beam bending theories to the standard beam bending theory exist, and the formu-

    lation of the Timonshenko beam element is an example of the application of one of these.

    Timoshenko beam bending theory can be considered as an extension of standard beam

    bending theory, in which deflections due to shear strains are also taken into account. The

    assumptions used in formulating Timoshenko beam theory are:

    Plane sections remain in plane after deformation.

    Plane sections need not remain perpendicular to the neutral axis.

    The first of these assumptions in particular will be looked at with regards to compatibility.

    The additional contribution to deformation due to considering shear strains is illustrated in

    Figure 2.14. The contribution of shear strains to deformation of a beam is seen to increase as

    the depth:span ratio increases.

    Figure 2.14: Timoshenko Beam Bending

    40

  • 8/3/2019 CI221 Finite Element Notes

    43/50

    It is seen in Figure 2.14 that the assumption of plane sections remaining in plane after

    deformation doesnt fit with what we know about the shear distribution within a section. This

    can to some extent be taken account of through the introduction of a shear correction coefficient,

    or shape factor, in our shear deformation relationship:

    12 =V

    GA(2.40)

    Where V is the shear force acting across the section in the x2 direction, G is the shear

    modulus, normally taken as E/2(1 + ) where is Poissons ratio, and A is the area of the

    cross-section. Various values of have been put forward for cross-sections of different shapes,

    although 5/6 is often used.

    The finite element formulation for a Timoshenko beam element is different to the formulationfor an Euler-Bernoulli beam element. Expressions for the curvature, , caused by bending

    moments, and the angle, , caused by shear forces can be written in matrix form as:

    =

    0 ddx1

    ddx1 1

    u2

    (2.41)

    Expressions for the bending moment, M, and the shear force, V can be written in matrix

    form as:

    M

    V

    =

    EI 0

    0 GA

    (2.42)

    We can define a Timoshenko beam element using the same degrees of freedom at each node

    as we had for the Euler-Bernoulli beam element, as shown in Figure 2.9. For the formulation

    presented here we will use linear shape functions.

    u2

    =

    12(1 ) 0 12(1 + ) 0

    0 12(1 ) 0 12(1 + )

    u2(n1)

    (n1)

    u2(n2)

    (n2)

    (2.43)

    We can define the B matrix as:

    41

  • 8/3/2019 CI221 Finite Element Notes

    44/50

    B = dN =

    0 ddx1

    ddx1 1

    12(1 ) 0 12(1 + ) 0

    0 12(1 ) 0 12(1 + )

    (2.44)

    The element stiffness matrix can then be defined as:

    Ke =

    V

    BTDB dV (2.45)

    where D =

    EI 0

    0 GA

    While the equivalent nodal force vector can be defined as:

    fe =

    V

    NTp dV (2.46)

    where p is a uniformly distributed load.

    It is observed that the expressions for Ke and fe are general relationships, such that we

    could have used them in the development of the axial bar element, and the Euler-Bernoulli

    beam element formulations. They are easy to implement using short blocks of code within a

    numerical program such as Matlab, and also form the basis of other structural and continuum

    finite element formulations that you will investigate in future years.

    42

  • 8/3/2019 CI221 Finite Element Notes

    45/50

    Timoshenko Beam Example

    The Matlab code below can be used to model the simply supported and fixed

    end beams shown in Figure 2.13 (for the Euler-Bernoulli beam element example)

    using Timoshenko beam elements.

    Instead of using the previous section you should calculate I and A values for a cross-section

    300mm in depth and 30mm in width. You may take as 5/6.

    As you did for the Euler-Bernoulli beam example adapt the code for the different boundary

    conditions, and perform a convergence study (increasing the number of elements, and recording

    the predicted deflection at midspan) to find the minimum number of Timoshenko beam elements

    required to find consistent values for the midspan deflection. You will see that the code makes

    use of numerical integration, with two gauss points per element used for the integration related

    to curvature, and a single gauss point used per element for the integration related to shear.

    Repeat the convergence study for beam depths of 100mm and 900mm.

    The analytical values for midspan deflection using the Timoshenko formulation are:

    max = 5pL4

    384EI pL

    2

    8GA(2.47)

    for a simply supported beam, and

    max = pL4

    384EI pL

    2

    8GA(2.48)

    for a fixed end beam.

    Repeat the exercise using Euler-Bernoulli beam elements for the new cross-sections and find

    the percentage increase in the midspan deflections found using Timoshenko beam elements.

    Discuss when you think the use of Timoshenko, as opposed to Euler-Bernoulli beam elements

    could be important.

    43

  • 8/3/2019 CI221 Finite Element Notes

    46/50

    1 % Axial bar problem using the Finite Element Method by Andrew Phillips

    2 % adapted from Ferreira, MATLAB codes for Finite Element Analysis

    3

    4 clear all

    5 close all

    6

    7 % E, elastic modulus (N/mm2)

    8 % A, area of crosssection (mm2)9 % I, second moment of area (mm4)

    10 % L, length of bar (mm)

    11

    12 E=2.05*105; %elastic (Young's) modulus

    13 G=E/(2*(1+0.3)); %shear modulus

    14 k=5/6; % shear correction factor%

    15 b=30;

    16 d=300;

    17 A=b*d;

    18 I=b*d3/12;

    19 EI=E*I; %curvature%

    20 kGA=k*G*A; %shear%

    21 L=10000;

    22

    23 % D matrix

    24 D=[EI 0; 0 kGA];

    25

    26 % information on the structure will be kept in a structure array

    27 s1 = struct();

    28

    29 % generating node coordinates and element connectivities

    30

    31 % setting the number of Elements

    32 % asking the user for the number of elements

    33 s1.numElements = input('How many elements do you wish to use? ');

    34 % generating equally spaced nodes

    35 s1.nodeCoords = 0:L/s1.numElements:L;

    36 % setting coords in the x direction

    37 s1.nodeXCoord = s1.nodeCoords;

    38 % setting the number of Nodes

    39 s1.numNodes = size(s1.nodeCoords,2);

    40

    41 % assigning Nodes to Elements

    42 ii = 1:s1.numElements;

    43 s1.elementNodes(:,1) = ii;

    44 s1.elementNodes(:,2) = ii+1;

    44

  • 8/3/2019 CI221 Finite Element Notes

    47/50

    45

    46 % degrees of freedom (2 at each node for a T beam element)

    47 s1.globalDOF = s1.numNodes.*2;

    48

    49 % setting up matrices (K, u, f)

    50 s1.stiffness = zeros(s1.globalDOF); % square matrix (n x n)

    51 s1.displacements = zeros(s1.globalDOF,1); % column matrix (n x 1);

    52 s1.force = zeros(s1.globalDOF,1); % column matrix (n x 1);

    53

    54 % applied loading

    55 % load per unit length

    56 % (kN/m to N/mm)

    57 p = 5;58

    59 % deriving the system stiffness matrix

    60

    61 % element degrees of freedom

    62 for ee=1:s1.numElements

    63 indice = s1.elementNodes(ee,:);

    64 % assigns Global DOF to the element

    65 elementDOF = [indice(1)*21 indice(1)*2 indice(2)*21 indice(2)*2];66 % length of the element

    67 lengthElement = s1.nodeXCoord(indice(2))s1.nodeXCoord(indice(1));68 Le = lengthElement;

    69 detJacobian = Le/2;

    70 invJacobian = 1/detJacobian;

    71

    72 % two point gauss integration

    73 xi=[+1/sqrt(3) 1/sqrt(3)]; W=[1 1];74

    75 for n=1:size(W,2)

    76

    77 shape=struct();

    78 shape.shape=[1xi(n); 1+xi(n)]/2;79 shape.naturalDerivatives=[

    1; 1]/2;

    80 Xderivatives=shape.naturalDerivatives *invJacobian;

    81

    82 %%%% theta contribution

    83 % B matrix (derivates of the shape functions)

    84 B=zeros(2,4);

    85 B(1,2) = Xderivatives(1);

    86 B(1,4) = Xderivatives(2);

    87 % assembling the system stiffness matrix

    88 s1.stiffness(elementDOF,elementDOF)=s1.stiffness(elementDOF,elementDOF) ...

    45

  • 8/3/2019 CI221 Finite Element Notes

    48/50

    89 +B'*B.*W(n).*detJacobian.*D(1,1);

    90 %%%%

    91

    92 % assembling the nodal force vector

    93 s1.force(elementDOF)=s1.force(elementDOF)+ ...

    94 p*[shape.shape(1) 0 shape.shape(2) 0]'.*W(n).*detJacobian;

    95

    96 end

    97

    98 % avoiding a problem described as 'shear locking'

    99 % one point gauss integration when looking at shear

    100 xi=[0]; W=[2];

    101 for n=1:size(W,2)

    102

    103 shape=struct();

    104 shape.shape=[1xi(n); 1+xi(n)]/2;105 shape.naturalDerivatives=[1; 1]/2;106 Xderivatives=shape.naturalDerivatives *invJacobian;

    107

    108 %%%% gamma contribution

    109 % B matrix (derivatives of shape functions and shape functions)

    110 B=zeros(2,4);

    111 B(2,1) = Xderivatives(1);112 B(2,3) = Xderivatives(2);113 B(2,2) = shape.shape(1);

    114 B(2,4) = shape.shape(2);

    115 % assembling the system stiffness matrix

    116 s1.stiffness(elementDOF,elementDOF)=s1.stiffness(elementDOF,elementDOF) ...

    117 +B'*B.*W(n).*detJacobian.*D(2,2);

    118 %%%%

    119

    120 end

    121 end

    122

    123 % prescribed global degrees of freedom

    124

    125 % simply supported

    126 s1.prescribedDOF = [1 s1.globalDOF1];127

    128 % fixed end

    129 % s1.prescribedDOF = [1 2 s1.globalDOF1 s1.globalDOF];130

    131 % solution

    132 activeDOF=setdiff([1:s1.globalDOF]', [s1.prescribedDOF]);

    46

  • 8/3/2019 CI221 Finite Element Notes

    49/50

    133 U=s1.stiffness(activeDOF,activeDOF) \s1.force(activeDOF);134 s1.displacements(activeDOF)=U;

    135

    136 % output

    137 fprintf('Solution

    \n

    \n')

    138

    139 % output displacements and reactions

    140 disp('Displacements:')

    141 for n=1:s1.globalDOF

    142 fprintf('Global DOF %02d, %+1.4e \n',n,s1.displacements(n));143 end

    144 fprintf('\n');145

    146 % midspan displacements

    147 disp('Midspan Displacement:')

    148 fprintf('%+1.4e \n\n',s1.displacements(s1.globalDOF/2));149

    150 F=s1.stiffness*s1.displacements;

    151 reactions=F(s1.prescribedDOF);

    152 disp('Reactions:')

    153 for n=1:size(s1.prescribedDOF,2);

    154 fprintf('Global DOF %02d, %+1.4e \n',s1.prescribedDOF(n),reactions(n));155 end

    156 fprintf('\n');157

    158 % plot the vertical displacements

    159 fig1=figure(1);

    160 plot(s1.nodeXCoord,s1.displacements(1:2:s1.globalDOF), 'x r');161 grid on

    162 title('Timoshenko Beam Example');

    163 xlabel('Horizontal Distance');

    164 ylabel('Vertial Deflection');

    165 hold on

    47

  • 8/3/2019 CI221 Finite Element Notes

    50/50