Nonlinear finite elements/Axial bar finite element solution: Difference between revisions

From testwiki
Jump to navigation Jump to search
 
(No difference)

Latest revision as of 09:24, 13 February 2023

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