Nonlinear finite elements/Axial bar finite element solution

From testwiki
Jump to navigation Jump to search

Axially loaded bar: The Finite Element Solution

The finite element method is a type of Galerkin method that has the following advantages:

  1. The functions φi are found in a systematic manner.
  2. The functions φi are chosen such that they can be used for arbitrary domains.
  3. The functions φi are piecewise polynomials.
  4. The functions φi are non-zero only on a small part of the domain.

As a result, computations can be done in a modular manner that is suitable for computer implementation.

Discretization

The first step in the finite element approach is to divide the domain into elements and nodes, i.e., to create the finite element mesh.

Let us consider a simple situation and divide the rod into 3 elements and 4 nodes as shown in Figure 6.

File:DistAxialMesh.png
Figure 6. Finite element mesh and basis functions for the bar.

Shape functions

The functions φi have special characteristics in finite element methods and are generally written as Ni and are called basis functions, shape functions, or interpolation functions.

Therefore, we may write

Kij=0LdNjdxAEdNidxdxfj=0LNj๐ชdx+Nj๐‘น|x=L.

The finite element basis functions are chosen such that they have the following properties:

  1. The functions Ni are bounded and continuous.
  2. If there are n nodes, then there are n basis functions - one for each node. There are four basis functions for the mesh shown in Figure 6.
  3. Each function Ni is nonzero only on elements connected to node i.
  4. Ni is 1 at node i and zero at all other nodes.

Stiffness matrix

Let us compute the values of Kij for the three element mesh. We have

Kij=0LdNjdxAEdNidxdx=0x2dNjdxAEdNidxdx+x2x3dNjdxAEdNidxdx+x3LdNjdxAEdNidxdxΩ1dNjdxAEdNidxdx+Ω2dNjdxAEdNidxdx+Ω3dNjdxAEdNidxdx

The components of ๐Š are

K11=Ω1dN1dxAEdN1dxdx+Ω2dN1dxAEdN1dxdx+Ω3dN1dxAEdN1dxdxK12=Ω1dN2dxAEdN1dxdx+Ω2dN2dxAEdN1dxdx+Ω3dN2dxAEdN1dxdxK13=Ω1dN3dxAEdN1dxdx+Ω2dN3dxAEdN1dxdx+Ω3dN3dxAEdN1dxdxK14=Ω1dN4dxAEdN1dxdx+Ω2dN4dxAEdN1dxdx+Ω3dN4dxAEdN1dxdxK22=Ω1dN2dxAEdN2dxdx+Ω2dN2dxAEdN2dxdx+Ω3dN2dxAEdN2dxdxK23=Ω1dN3dxAEdN2dxdx+Ω2dN3dxAEdN2dxdx+Ω3dN3dxAEdN2dxdxK24=Ω1dN4dxAEdN2dxdx+Ω2dN4dxAEdN2dxdx+Ω3dN4dxAEdN2dxdxK33=Ω1dN3dxAEdN3dxdx+Ω2dN3dxAEdN3dxdx+Ω3dN3dxAEdN3dxdxK34=Ω1dN4dxAEdN3dxdx+Ω2dN4dxAEdN3dxdx+Ω3dN4dxAEdN3dxdxK44=Ω1dN4dxAEdN4dxdx+Ω2dN4dxAEdN4dxdx+Ω3dN4dxAEdN4dxdx.

The matrix ๐Š is symmetric, so we don't need to explicitly compute the other terms.

From Figure 6, we see that N1 is zero in elements 3 and 4, N2 is zero in element 4, N3 is zero in element 1, and N4 is zero in elements 1 and 2. The same holds for dNi/dx.

Therefore, the coefficients of the ๐Š matrix become

K11=Ω1dN1dxAEdN1dxdx;K12=Ω1dN2dxAEdN1dxdx;K13=0;K14=0K22=Ω1dN2dxAEdN2dxdx+Ω2dN2dxAEdN2dxdx;K23=Ω2dN3dxAEdN2dxdx;K24=0K33=Ω2dN3dxAEdN3dxdx+Ω3dN3dxAEdN3dxdx;K34=Ω3dN4dxAEdN3dxdxK44=Ω3dN4dxAEdN4dxdx.

We can simplify our calculation further by letting Nke be the shape functions over an element e. For example, the shape functions over element 2 are N12 and N22 where the local nodes 1 and 2 correspond to global nodes 2 and 3, respectively. Then we can write,

K11=Ω1dN11dxAEdN11dxdx;K12=Ω1dN21dxAEdN11dxdx;K13=0;K14=0K22=Ω1dN21dxAEdN21dxdx+Ω2dN12dxAEdN12dxdx;K23=Ω2dN22dxAEdN12dxdx;K24=0K33=Ω2dN22dxAEdN22dxdx+Ω3dN13dxAEdN13dxdx;K34=Ω3dN23dxAEdN13dxdxK44=Ω3dN23dxAEdN23dxdx.

Let Kkle be the part of the value of Kij that is contributed by element e. The indices kl are local and the indices ij are global. Then,

K11=K111;K12=K121;K13=0;K14=0K22=K221+K112;K23=K122;K24=0K33=K222+K113;K34=K123K44=K223

We can therefore see that if we compute the stiffness matrices over each element and assemble them in an appropriate manner, we can get the global stiffness matrix ๐Š.

Stiffness matrix for two-noded elements

For our problem, if we consider an element e with two nodes, the local hat shape functions have the form

N1e(๐ฑ)=๐ฑ2๐ฑhe;N2e(๐ฑ)=๐ฑ๐ฑ1he

where he is the length of the element.

Then, the components of the element stiffness matrix are

K11e=x1x2dN1edxAEdN1edxdx=x1x2(1he)AE(1he)dx=AEheK12e=x1x2dN2edxAEdN1edxdx=x1x2(1he)AE(1he)dx=AEheK22e=x1x2dN2edxAEdN2edxdx=x1x2(1he)AE(1he)dx=AEhe

In matrix form,

๐Še=AEhe[1111]

The components of the global stiffness matrix are

K11=AEh1;K12=AEh1;K13=0;K14=0K22=AEh1+AEh2;K23=AEh2;K24=0K33=AEh2+AEh3;K34=AEh3K44=AEh3

In matrix form,

๐Š=AE[1h11h1001h1+1h21h201h2+1h31h3Symm.1h3]

Load vector

Similarly, for the load vector ๐Ÿ, we have

fj=0LNj๐ชdx+Nj๐‘น|x=L=Ω1Nj๐ชdx+Ω2Nj๐ชdx+Ω3Nj๐ชdx+Nj๐‘น|x=L

The components of the load vector are

f1=Ω1N1๐ชdx+Ω2N1๐ชdx+Ω3N1๐ชdx+N1๐‘น|x=Lf2=Ω1N2๐ชdx+Ω2N2๐ชdx+Ω3N2๐ชdx+N2๐‘น|x=Lf3=Ω1N3๐ชdx+Ω2N3๐ชdx+Ω3N3๐ชdx+N3๐‘น|x=Lf4=Ω1N4๐ชdx+Ω2N4๐ชdx+Ω3N4๐ชdx+N4๐‘น|x=L

Once again, since N1 is zero in elements 2 and 3, N2 is zero in element 3, N3 is zero in element 1, and N4 is zero in elements 1 and 2, we have

f1=Ω1N1๐ชdx+N1๐‘น|x=Lf2=Ω1N2๐ชdx+Ω2N2๐ชdx+N2๐‘น|x=Lf3=Ω2N3๐ชdx+Ω3N3๐ชdx+N3๐‘น|x=Lf4=Ω3N4๐ชdx+N4๐‘น|x=L

Now, the boundary ๐ฑ=L is at node 4 which is attached to element 3. The only non-zero shape function at this node is N4. Therefore, we have

f1=Ω1N1๐ชdxf2=Ω1N2๐ชdx+Ω2N2๐ชdxf3=Ω2N3๐ชdx+Ω3N3๐ชdxf4=Ω3N4๐ชdx+N4๐‘น|x=L

In terms of element shape functions, the above equations can be written as

f1=Ω1N11๐ชdx=f11f2=Ω1N21๐ชdx+Ω2N12๐ชdx=f21+f12f3=Ω2N22๐ชdx+Ω3N13๐ชdx=f22+f13f4=Ω3N23๐ชdx+N23๐‘น|x=L=f23+๐‘น

The above shows that the global load vector can also be assembled from the element load vectors if we use finite element shape functions.

Load vector for two-noded elements

Using the linear shape functions discussed earlier and replacing ๐ช with a๐ฑ, the components of the element load vector ๐Ÿe are

f1e=x1x2N1ea๐ฑdx=x1x2(x2xhe)a๐ฑdx=ahe(x2(x22x12)2x23x133)f2e=x1x2N2ea๐ฑdx=x1x2(xx1he)a๐ฑdx=ahe(x1(x22x12)2x23x133)

In matrix form, the element load vector is written

๐Ÿe=ahe[x2(x22x12)2x23x133x23x133x1(x22x12)2]

Therefore, the components of the global load vector are

f1=ah1(x2(x22x12)2x23x133)f2=ah1(x23x133x1(x22x12)2)+ah2(x3(x32x22)2x33x233)f3=ah2(x33x233x2(x32x22)2)+ah3(x4(x42x32)2x43x333)f4=ah3(x43x333x3(x42x32)2)+๐‘น

Displacement trial function

Recall that we assumed that the displacement can be written as

๐ฎh(๐ฑ)=a1φ1(๐ฑ)+a2φ2(๐ฑ)++anφn(๐ฑ)=i=1naiφi(๐ฑ).

If we use finite element shape functions, we can write the above as

๐ฎh(๐ฑ)=a1N1(๐ฑ)+a2N2(๐ฑ)++anNn(๐ฑ)=i=1naiNi(๐ฑ)

where n is the total number of nodes in the domain. Also, recall that the value of Ni is 1 at node i and zero elsewhere. Therefore, we have

u1:=๐ฎh(๐ฑ1)=a1N1(๐ฑ1)+a2N2(๐ฑ1)++anNn(๐ฑ1)=a1u2:=๐ฎh(๐ฑ2)=a1N1(๐ฑ2)+a2N2(๐ฑ2)++anNn(๐ฑ2)=a2un:=๐ฎh(๐ฑn)=a1N1(๐ฑn)+a2N2(๐ฑn)++anNn(๐ฑn)=an

Therefore, the trial function can be written as

๐ฎh(๐ฑ)=u1N1(๐ฑ)+u2N2(๐ฑ)++unNn(๐ฑ)=i=1nuiNi(๐ฑ)

where ui are the nodal displacements.

Finite element system of equations

If all the elements are assumed to be of the same length h, the finite element system of equations (๐Š๐š=๐Ÿ) can then be written as

AEh[1100121001210011][u1u2u3u4]=ah[(x2(x22x12)2x23x133)(x23x133x1(x22x12)2)+(x3(x32x22)2x33x233)(x33x233x2(x32x22)2)+(x4(x42x32)2x43x333)(x43x333x3(x42x32)2)+๐‘นha]

Essential boundary conditions

To solve this system of equations we have to apply the essential boundary condition ๐ฎ=0 at ๐ฑ=0. This is equivalent to setting u1=0. The reduced system of equations is

AEh[210121011][u2u3u4]=ah[(x23x133x1(x22x12)2)+(x3(x32x22)2x33x233)(x33x233x2(x32x22)2)+(x4(x42x32)2x43x333)(x43x333x3(x42x32)2)+๐‘นha]

This system of equations can be solved for u2, u3, and u4. Let us do that.

Assume that A, E, L, a, and R are all equal to 1. Then x1=0, x2=1/3, x3=2/3, x4=1, and h=1/3. The system of equations becomes

[210121011][u2u3u4]=[0.0370.0740.383][u1u2u3u4]=[0.00.4940.9511.333]

Computing element strains and stresses

From the above, it is clear that the displacement field within an element e is given by

๐ฎe=u1eN1e(๐ฑ)+u2eN2e(๐ฑ).

Therefore, the strain within an element is

εe=๐ฎex=u1eN1ex+u2eN2ex.

In matrix notation,

εe=๐e๐ฎe=[N1exN2ex][u1eu2e]=[1h1h][u1eu2e]

The stress in the element is given by

σe=Eεe.

For our discretization, the element stresses are

σ1=1.48σ2=1.37σ3=1.15

A plot of this solution is shown in Figure 7.

File:AxialBarFemDisp.png
Figure 7(a). FEM vs exact solutions for displacements of an axially loaded bar.
File:AxialBarFemSig.png
Figure 7(b). FEM vs exact solutions for stresses in an axially loaded bar.

Matlab code

The finite element code (Matlab) used to compute this solution is given below.

    function AxialBarFEM
      
      A = 1.0;
      L = 1.0;
      E = 1.0;
      a = 1.0;
      R = 1.0;
    
      e = 3;
      h = L/e;
      n = e+1;
      for i=1:n
        node(i) = (i-1)*h;
      end
      for i=1:e
        elem(i,:) = [i i+1];
      end
     
      K = zeros(n);
      f = zeros(n,1);
      for i=1:e
        node1 = elem(i,1);
        node2 = elem(i,2);
        Ke = elementStiffness(A, E, h);
        fe = elementLoad(node(node1),node(node2), a, h);
        K(node1:node2,node1:node2) = K(node1:node2,node1:node2) + Ke;
        f(node1:node2) = f(node1:node2) + fe;
      end
    
      f(n) = f(n) + R;
   
      Kred = K(2:n,2:n);
      fred = f(2:n);
   
      d = inv(Kred)*fred;
   
      dsol = [0 d'];
   
      fsol = K*dsol';
      sum(fsol)
    
      figure;
      p0 = plotDisp(E, A, L, R, a);
      p1 = plot(node, dsol, 'ro--', 'LineWidth', 3); hold on;
      legend([p0 p1],'Exact','FEM');
   
      for i=1:e
        node1 = elem(i,1);
        node2 = elem(i,2);
        u1 = dsol(node1);
        u2 = dsol(node2);
        [eps(i), sig(i)] = elementStrainStress(u1, u2, E, h);
      end
 
      figure;
      p0 = plotStress(E, A, L, R, a);
      for i=1:e
        node1 = node(elem(i,1));
        node2 = node(elem(i,2));
        p1 = plot([node1 node2], [sig(i) sig(i)], 'r-','LineWidth',3); hold on;
      end
      legend([p0 p1],'Exact','FEM');

    function [p] = plotDisp(E, A, L, R, a)

      dx = 0.01;
      nseg = L/dx;
      for i=1:nseg+1
        x(i) = (i-1)*dx;
        u(i) = (1/(6*A*E))*(-a*x(i)^3 + (6*R + 3*a*L^2)*x(i));
      end
      p = plot(x, u, 'LineWidth', 3); hold on;
      xlabel('x', 'FontName', 'palatino', 'FontSize', 18);
      ylabel('u(x)', 'FontName', 'palatino', 'FontSize', 18);
      set(gca, 'LineWidth', 3, 'FontName', 'palatino', 'FontSize', 18);

    function [p] = plotStress(E, A, L, R, a)

      dx = 0.01;
      nseg = L/dx;
      for i=1:nseg+1
        x(i) = (i-1)*dx;
        sig(i) = (1/(2*A))*(-a*x(i)^2 + (2*R + a*L^2));
      end
      p = plot(x, sig, 'LineWidth', 3); hold on;
      xlabel('x', 'FontName', 'palatino', 'FontSize', 18);
      ylabel('\sigma(x)', 'FontName', 'palatino', 'FontSize', 18);
      set(gca, 'LineWidth', 3, 'FontName', 'palatino', 'FontSize', 18);

    function [Ke] = elementStiffness(A, E, h)

      Ke = (A*E/h)*[[1 -1];[-1 1]];
 
    function [fe] = elementLoad(node1, node2, a, h)

      x1 = node1;
      x2 = node2;

      fe1 = a*x2/(2*h)*(x2^2-x1^2) - a/(3*h)*(x2^3-x1^3);
      fe2 = -a*x1/(2*h)*(x2^2-x1^2) + a/(3*h)*(x2^3-x1^3);
      fe = [fe1;fe2];

    function [eps, sig] = elementStrainStress(u1, u2, E, h)

      B = [-1/h 1/h];
      u = [u1; u2];
      eps = B*u
      sig = E*eps;


Template:Subpage navbar