METU Mechanical Engineering Department ME 582 Finite...

18
1 METU Mechanical Engineering Department ME 582 Finite Element Analysis in Thermofluids Spring 2018 (Dr. Sert) Handout 3 – Examples of Chapter 2 Example 2.1: We’ll solve the following advection diffusion equation 2 2 = over 0≤≤1 with = 3, = 1, = 1. The DE is supported by the following EBCs (0) = 0 , (1) = 0 Let’s use Galerkin FEM on a mesh of 5 equal-sized elements as shown below Elemental stiffness matrices can be evaluated using the following equation as derived previously = ∫ ( 1 + 1 1 ) 1 −1 Each element has the length of = 0.2 and has the same Jacobian =ℎ /2 = 0.1. and are given as constants. Therefore [ ] will be the same for all elements. Using previously derived shape functions of 1 = 1 2 (1 − ) , 2 = 1 2 (1 + ) and their derivatives 1 =− 1 2 , 2 = 1 2 entries of the 2x2 [ ] matrix can be calculated as follows (no need to use GQ integration here. As an exercise you can try to evaluate the integrals using for example 2 point GQ) 11 = ∫[ 1 2 (1 − )(3) (− 1 2 )( 1 0.1 ) + (1) (− 1 2 )( 1 0.1 ) (− 1 2 )( 1 0.1 )] (0.1) 1 −1 = 3.5 e=1 x e=2 e=3 e=4 e=5 1 2 3 4 5 6

Transcript of METU Mechanical Engineering Department ME 582 Finite...

  • 1

    METU Mechanical Engineering Department ME 582 Finite Element Analysis in Thermofluids

    Spring 2018 (Dr. Sert) Handout 3 – Examples of Chapter 2

    Example 2.1:

    We’ll solve the following advection diffusion equation

    𝑢𝑑𝜙

    𝑑𝑥− 𝛼

    𝑑2𝜙

    𝑑𝑥2= 𝑓 over 0 ≤ 𝑥 ≤ 1

    with 𝑢 = 3, 𝛼 = 1, 𝑓 = 1. The DE is supported by the following EBCs

    𝑇(0) = 0 , 𝑇(1) = 0

    Let’s use Galerkin FEM on a mesh of 5 equal-sized elements as shown below

    Elemental stiffness matrices can be evaluated using the following equation as derived previously

    𝐾𝑖𝑗𝑒 = ∫ ( 𝑆𝑖

    𝑒 𝑢 𝑑𝑆𝑗

    𝑒

    𝑑𝜉 1

    𝐽𝑒+ 𝛼

    𝑑𝑆𝑖𝑒

    𝑑𝜉 1

    𝐽𝑒 𝑑𝑆𝑗

    𝑒

    𝑑𝜉 1

    𝐽𝑒) 𝐽𝑒 𝑑𝜉

    1

    −1

    Each element has the length of ℎ𝑒 = 0.2 and has the same Jacobian 𝐽𝑒 = ℎ𝑒/2 = 0.1. 𝑢 and 𝛼 are

    given as constants. Therefore [𝐾𝑒] will be the same for all elements. Using previously derived shape

    functions of

    𝑆1𝑒 =

    1

    2(1 − 𝜉) , 𝑆2

    𝑒 =1

    2(1 + 𝜉)

    and their derivatives

    𝑑𝑆1𝑒

    𝑑𝜉= −

    1

    2 ,

    𝑑𝑆2𝑒

    𝑑𝜉=1

    2

    entries of the 2x2 [𝐾𝑒] matrix can be calculated as follows (no need to use GQ integration here. As an

    exercise you can try to evaluate the integrals using for example 2 point GQ)

    𝐾11𝑒 = ∫ [

    1

    2(1 − 𝜉)(3) (−

    1

    2) (

    1

    0.1) + (1) (−

    1

    2) (

    1

    0.1) (−

    1

    2) (

    1

    0.1)] (0.1) 𝑑𝜉

    1

    −1

    = 3.5

    e=1

    x

    e=2 e=3 e=4 e=5

    1 2 3 4 5 6

  • 2

    𝐾12𝑒 = ∫ [

    1

    2(1 − 𝜉)(3) (

    1

    2) (

    1

    0.1) + (1) (−

    1

    2) (

    1

    0.1) (1

    2) (

    1

    0.1)] (0.1) 𝑑𝜉

    1

    −1

    = −3.5

    𝐾21𝑒 = ∫ [

    1

    2(1 + 𝜉)(3) (−

    1

    2) (

    1

    0.1) + (1) (

    1

    2) (

    1

    0.1) (−

    1

    2) (

    1

    0.1)] (0.1) 𝑑𝜉

    1

    −1

    = −6.5

    𝐾22𝑒 = ∫ [

    1

    2(1 + 𝜉)(3) (

    1

    2) (

    1

    0.1) + (1) (

    1

    2) (

    1

    0.1) (1

    2) (

    1

    0.1)] (0.1) 𝑑𝜉

    1

    −1

    = 6.5

    Therefore, for all elements

    𝐾𝑒 = [3.5 −3.5−6.5 6.5

    ]

    Entries of the elemental force vector are given by

    𝐹𝑖𝑒 = ∫ 𝑆𝑖

    𝑒 𝑓 𝐽𝑒 𝑑𝜉

    1

    −1

    Function 𝑓 is constant and the same for each element. Therefore, elemental force vectors will also be

    the same for all elements. Their components can be evaluated as

    𝐹1𝑒 = ∫

    1

    2(1 − 𝜉) (1) (0.1) 𝑑𝜉

    1

    −1

    = 0.1

    𝐹2𝑒 = ∫

    1

    2(1 + 𝜉) (1) (0.1) 𝑑𝜉

    1

    −1

    = 0.1

    Combining these two entries we get

    𝐹𝑒 = {0.10.1}

    Local to global mapping of the mesh is given by

    𝐿𝑡𝑜𝐺 =

    [ 1 22 33 44 55 6]

    Using the assembly rule, following 6x6 global system can be assembled

    [ 3.5 −3.5 0 0 0 0−6.5 6.5 + 3.5 −3.5 0 0 00 −6.5 6.5 + 3.5 −3.5 0 00 0 −6.5 6.5 + 3.5 −3.5 00 0 0 −6.5 6.5 + 3.5 −3.50 0 0 0 −6.5 6.5 ]

    {

    𝜙1𝜙2𝜙3𝜙4𝜙5𝜙6}

    =

    {

    0.10.1 + 0.10.1 + 0.10.1 + 0.10.1 + 0.10.1 }

    +

    {

    𝐵10000𝐵6}

  • 3

    Due to the EBCs provided at 𝑥 = 0 and 𝑥 = 1, 𝜙1 and 𝜙6 are actually known and we can perform

    reduction as explained in the previous section to remove the first and last equation resulting in the

    following 4x4 system.

    [

    10 −3.5 0 0−6.5 10 −3.5 00 −6.5 10 −3.50 0 −6.5 10

    ]{

    𝜙2𝜙3𝜙4𝜙5

    } = {

    0.20.20.20.2

    }

    Note that the reduction of the system did not result any change in the right hand side vector, because

    of the special zero EBCs. Solving this system, we get the following nodal unknowns as

    {

    𝜙2𝜙3𝜙4𝜙5

    } = {

    0.05310.09460.11460.0945

    }

    Exact solution can be found using MATLAB as follows.

    dsolve('3*Dy-D2y=1', 'y(0)=0', 'y(1)=0')

    which can be simplified using MATLAB’s simplify command to get

    𝜙𝑒𝑥𝑎𝑐𝑡 = −𝑒3𝑥 − 𝑥𝑒3 + 𝑥 − 1

    3(𝑒3 − 1)

    Comparison of FEM and exact solutions is given below. Except the boundary nodes, nodal values are

    not exact, but they are close to the exact solution.

  • 4

    Example 2.2:

    Remember that one disadvantage of variational solutions we performed in the previous chapter was

    the dependency of approximation function selection on the boundary conditions. To appreciate that

    this is not the case for FEM, let’s solve the previous problem with the following different EBCs

    𝜙(0) = 1 , 𝜙(1) = 10

    Change in BCs will not bring any change to the elemental system calculation or to the assembly process.

    Therefore, the same 6x6 global system, given below, will be obtained.

    [ 3.5 −3.5 0 0 0 0−6.5 10 −3.5 0 0 00 −6.5 10 −3.5 0 00 0 −6.5 10 −3.5 00 0 0 −6.5 10 −3.50 0 0 0 −6.5 6.5 ]

    {

    𝜙1𝜙2𝜙3𝜙4𝜙5𝜙6}

    =

    {

    0.10.20.20.20.20.1}

    +

    {

    𝐵10000𝐵6}

    𝜙1 and 𝜙6 are known. Therefore, let’s reduce the system to a 4x4 system by deleting the first and the

    last rows and columns. In the meantime, the right hand side vector will also change.

    [

    10 −3.5 0 0−6.5 10 −3.5 00 −6.5 10 −3.50 0 −6.5 10

    ]{

    𝜙2𝜙3𝜙4𝜙5

    } = {

    0.2 − (−6.5)(1)0.20.2

    0.2 − (−3.5)(10)

    }

    The solution is

    {

    𝜙2𝜙3𝜙4𝜙5

    } = {

    1.41892.13963.42115.7437

    }

    Comparison of FEM and exact solutions is as follows.

  • 5

    Example 2.3:

    To experiment with NBCs, let’s solve the same problem with the following BCs

    𝜙(0) = 0 , 𝑑𝜙

    𝑑𝑥|𝑥=1

    = −1

    The 6x6 global system is again the same as before. Reduction will be applied for the EBC. After deleting

    the first row and the first column we’ll be left with the following 5x5 system

    [ 10 −3.5 0 0 0−6.5 10 −3.5 0 00 −6.5 10 −3.5 00 0 −6.5 10 −3.50 0 0 −6.5 6.5 ]

    {

    𝜙2𝜙3𝜙4𝜙5𝜙6}

    =

    {

    0.20.20.20.20.1}

    +

    {

    0000𝐵6}

    First derivative is given at 𝑥 = 1. This is related to 𝐵6 of the last equation.

    𝐵6 = (𝑆𝑉)𝑥=1 = (𝛼𝑑𝜙

    𝑑𝑥𝑛𝑥)

    𝑥=1= −1

    Warning: Do not include the effect of 𝛼 and 𝑛𝑥 . In this case they are both equal to one, but in general

    this is not the case.

    Use this 𝐵6 value in the reduced global system and solve it to get

    Now this is a solvable system with 5 equations and 5 unknowns. The solution gives the following nodal

    values

    {

    𝜙2𝜙3𝜙4𝜙5𝜙6}

    =

    {

    0.04940.08410.09130.0475−0.0910}

    FEM solution is very close to the exact one. At the right boundary, where NBC is specified, the value of

    𝜙6 is not exact, athough it looks so on the graph. The exact value at the right boundary is -0.089, but

    we calculated it to be -0.091. As a general rule, unknown nodal values at the NBC boundaries cannot

    be calculated as exact.

  • 6

    Example 2.4:

    To experiment with MBCs, let’s solve the same problem with the following BCs

    (𝜙 + 2𝑑𝜙

    𝑑𝑥)|𝑥=0

    = 5 , 𝜙(1) = −10

    The 6x6 global system is the same as before. We apply reduction for the EBC given at 𝑥 = 1 to get the

    following 5x5 reduced system.

    [ 3.5 −3.5 0 0 0−6.5 10 −3.5 0 00 −6.5 10 −3.5 00 0 −6.5 10 −3.50 0 0 −6.5 10 ]

    {

    𝜙1𝜙2𝜙3𝜙4𝜙5}

    =

    {

    0.10.20.20.2

    0.2 − (−3.5)(−10)}

    +

    {

    𝐵10000 }

    SV at the first node is

    𝐵1 = (𝑆𝑉)1 = (𝛼𝑑𝜙

    𝑑𝑥𝑛𝑥)

    𝑥=0= (−

    𝑑𝜙

    𝑑𝑥)𝑥=0

    Let’s write the given MBC in the standard 𝑆𝑉 = 𝛽 𝑃𝑉 + 𝛾 form

    𝐵1 = 0.5𝜙1 − 2.5

    And use it in the right hand side of the global system

    [ 3.5 −3.5 0 0 0−6.5 10 −3.5 0 00 −6.5 10 −3.5 00 0 −6.5 10 −3.50 0 0 −6.5 10 ]

    {

    𝜙1𝜙2𝜙3𝜙4𝜙5}

    =

    {

    0.10.20.20.2−34.8}

    +

    {

    0.5𝜙1 − 2.5

    0000 }

    Transfer 0.5𝜙1 from the right hand side to the left hand side

    [ 3.5 − 0.5 −3.5 0 0 0−6.5 10 −3.5 0 00 −6.5 10 −3.5 00 0 −6.5 10 −3.50 0 0 −6.5 10 ]

    {

    𝜙1𝜙2𝜙3𝜙4𝜙5}

    =

    {

    −2.40.20.20.2−34.8}

    And solve this system to get

    {

    𝜙2𝜙3𝜙4𝜙5𝜙6}

    =

    {

    10.16449.39817.91775.1113−0.1576}

    Comparison of exact and approximate solutions is given below. As seen clearly, at the MBC boundary

    FEM solution deviates from the exact solution. More elements are required for a better solution.

  • 7

    Example 2.5:

    Let’s solve Example 2.3 again using the following mesh of 2 equi-sized quadratic elements.

    Elemental stiffness matrices can be evaluated using the same equation that we used previously for

    linear elements

    𝐾𝑖𝑗𝑒 = ∫ ( 𝑆𝑖

    𝑒 𝑢 𝑑𝑆𝑗

    𝑒

    𝑑𝜉 1

    𝐽𝑒+ 𝛼

    𝑑𝑆𝑖𝑒

    𝑑𝜉 1

    𝐽𝑒 𝑑𝑆𝑗

    𝑒

    𝑑𝜉 1

    𝐽𝑒) 𝐽𝑒 𝑑𝜉

    1

    −1

    Both elements has a length of ℎ𝑒 = 0.5 and a Jacobian of 𝐽𝑒 = ℎ𝑒/2 = 1/4. Similar to the previous

    solution [𝐾𝑒] will be the same for both elements. Using the shape functions of quadratic elements,

    entries of the 3x3 [𝐾𝑒] can be calculated as

    𝐾11𝑒 = ∫ (

    1

    2𝜉(𝜉 − 1)(3) (

    1

    2(2𝜉 − 1)) (4) + (1) (

    1

    2(2𝜉 − 1)) (4) (

    1

    2(2𝜉 − 1)) (4)) (

    1

    4) 𝑑𝜉

    1

    −1

    =19

    6

    𝐾12𝑒 = ∫ (

    1

    2𝜉(𝜉 − 1)(3)(−2𝜉) (4) + (1) (

    1

    2(2𝜉 − 1)) (4)(−2𝜉) (4)) (

    1

    4) 𝑑𝜉

    1

    −1

    = −10

    3

    𝐾13𝑒 = ∫ (

    1

    2𝜉(𝜉 − 1)(3) (

    1

    2(2𝜉 + 1)) (4) + (1) (

    1

    2(2𝜉 − 1)) (4) (

    1

    2(2𝜉 + 1)) (4)) (

    1

    4) 𝑑𝜉

    1

    −1

    =1

    6

    e=1

    𝑥

    e=2

    1 2 3 4 5

  • 8

    𝐾21𝑒 = ∫ ((1 − 𝜉2)(3) (

    1

    2(2𝜉 − 1)) (4) + (1) (−2𝜉) (4) (

    1

    2(2𝜉 − 1)) (4)) (

    1

    4) 𝑑𝜉

    1

    −1

    = −22

    3

    𝐾22𝑒 = ∫((1 − 𝜉2)(3)(−2𝜉) (4) + (1) (−2𝜉) (4)(−2𝜉) (4)) (

    1

    4) 𝑑𝜉

    1

    −1

    =32

    3

    𝐾23𝑒 = ∫ ((1 − 𝜉2)(3) (

    1

    2(2𝜉 + 1)) (4) + (1) (−2𝜉) (4) (

    1

    2(2𝜉 + 1)) (4)) (

    1

    4) 𝑑𝜉

    1

    −1

    = −10

    3

    𝐾31𝑒 = ∫ (

    1

    2𝜉(𝜉 + 1)(3) (

    1

    2(2𝜉 − 1)) (4) + (1) (

    1

    2(2𝜉 + 1)) (4) (

    1

    2(2𝜉 − 1)) (4)) (

    1

    4) 𝑑𝜉

    1

    −1

    =7

    6

    𝐾32𝑒 = ∫ (

    1

    2𝜉(𝜉 + 1)(3)(−2𝜉) (4) + (1) (

    1

    2(2𝜉 + 1)) (4)(−2𝜉) (4)) (

    1

    4) 𝑑𝜉

    1

    −1

    = −22

    3

    𝐾33𝑒 = ∫ (

    1

    2𝜉(𝜉 + 1)(3) (

    1

    2(2𝜉 + 1)) (4) + (1) (

    1

    2(2𝜉 + 1)) (4) (

    1

    2(2𝜉 + 1)) (4)) (

    1

    4) 𝑑𝜉

    1

    −1

    =37

    6

    Therefore, for both elements

    𝐾𝑒 = [

    19/6 −10/3 1/6−22/3 32/3 −10/37/6 −22/3 37/6

    ]

    Remembering the following general form of the elemental force vector

    𝐹𝑖𝑒 = ∫ 𝑆𝑖

    𝑒 𝑓 𝐽𝑒 𝑑𝜉

    1

    −1

    and noticing that the source function 𝑓 is constant and the same for each element, elemental force

    vectors will also be the same for both elements. Its entries can be evaluated as

    𝐹1𝑒 = ∫

    1

    2𝜉(𝜉 − 1) (1) (

    1

    4) 𝑑𝜉

    1

    −1

    = 1

    12

    𝐹2𝑒 = ∫(1 − 𝜉2) (1) (

    1

    4) 𝑑𝜉

    1

    −1

    = 1

    3

    𝐹3𝑒 = ∫

    1

    2𝜉(𝜉 + 1) (1) (

    1

    4) 𝑑𝜉

    1

    −1

    = 1

    12

    Combining these three entries we get

    𝐹𝑒 = {

    1/121/31/12

    }

  • 9

    Local to global mapping of the mesh is 𝐿𝑡𝑜𝐺 = [1 2 33 4 5

    ]

    Using the assembly rule, global system can be obtained as

    [ 19

    6 −

    10

    3

    1

    6 0 0

    −22

    3

    32

    3 −

    10

    3 0 0

    7

    6 −

    22

    3 37

    6+19

    6 −

    10

    3

    1

    6

    0 0 −22

    3

    32

    3 −

    10

    3

    0 0 7

    6 −

    22

    3

    37

    6 ]

    {

    𝑇1 𝑇2 𝑇3 𝑇4 𝑇5}

    =

    {

    1

    121

    31

    12+1

    121

    31

    12 }

    +

    {

    𝐵1 0 0 0 𝐵5}

    𝜙1 = 0 is given as an EBC. Applying reduction for the first equation and using 𝐵5 = −1 we are left with

    the following 4x4 system

    [ 32

    3 −

    10

    3 0 0

    −22

    3

    56

    6 −

    10

    3

    1

    6

    0 −22

    3

    32

    3 −

    10

    3

    0 7

    6 −

    22

    3

    37

    6 ]

    {

    𝜙2 𝜙3 𝜙4 𝜙5}

    =

    {

    13⁄

    16⁄

    13⁄

    112⁄ }

    +

    {

    0 0 0 −1}

    Solving this system we get {

    𝜙2𝜙3𝜙4𝜙5

    } = {

    0.05910.08900.0648−0.0884

    }

    The following figure compares the GFEM solution with the approximate solution. The solution

    obtained in Example 2.3 with 5 linear elements is also given. As seen, the linear solution with 5

    elements and the quadratic solution with 2 elements provide a comparable performance.

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-0.1

    -0.05

    0

    0.05

    0.1

    x

    T

    Comparison of Linear and Quadratic GFEM Solutions

    Exact

    Linear GFEM

    Quadratic GFEM

  • 10

    Example 2.6:

    Let’s work on a different, more physical problem, which has a different DE. Consider the following steady, heat transfer problem in a 1D fin with constant circular cross-section. 𝑇∞ = 25 ℃ , ℎ = 100 W/m

    2K 𝑘 = 140 W/mK 𝐷 = 0.1 m (fin diameter) 𝐿 = 1 m (fin length) At 𝑥 = 0 𝑇 = 100 ℃

    At 𝑥 = 𝐿 𝑘𝐴𝑐 (𝑑𝑇

    𝑑𝑥) + ℎ𝐴𝑐(𝑇 − 𝑇∞) = 0

    The governing DE is

    −𝑑

    𝑑𝑥(𝑘𝐴𝑐

    𝑑𝑇

    𝑑𝑥) + ℎ𝑃(𝑇 − 𝑇∞) = 0

    where 𝐴𝑐 = 𝜋𝐷

    2/4 is the cross-sectional area and 𝑃 = 𝜋𝐷 is the perimeter of the fin. Warning: 𝑘𝐴𝑐 is constant. We can divide the whole equation by 𝑘𝐴𝑐, but we prefer not to this because if we keep the equation in the given form, the secondary variable will have a more physical meaning, i.e. amount of heat passing through the boundary. Also studying the ODE in this form is better because it can be extended to cases where 𝑘 and/or 𝐴𝑐 is not constant, as we’ll see in the next example. Note that the minus sign in front of the first term is there for a purpose. It’ll disappear after integration by parts. Let’s obtain the temperature distribution 𝑇(𝑥) on the fin using GFEM using a mesh of 4 linear elements of the same length. Compared to the previous examples, now the DE is not the advection-diffusion equation. We need to obtain its weak form.

    Residual: 𝑅(𝑥) = −𝑑

    𝑑𝑥(𝑘𝐴𝑐

    𝑑𝑇

    𝑑𝑥) + ℎ𝑃(𝑇 − 𝑇∞)

    Weighted integral statement: ∫𝑤𝑅 𝑑𝑥

    Ω

    = ∫ [−𝑤𝑑

    𝑑𝑥(𝑘𝐴𝑐

    𝑑𝑇

    𝑑𝑥) + 𝑤ℎ𝑃(𝑇 − 𝑇∞)] 𝑑𝑥

    Ω

    = 0

    Apply int. by parts: ∫ [𝑘𝐴𝑐𝑑𝑤

    𝑑𝑥

    𝑑𝑇

    𝑑𝑥+ ℎ𝑃𝑤𝑇] 𝑑𝑥

    Ω

    = ∫𝑤ℎ𝑃𝑇∞ 𝑑𝑥

    Ω

    + (𝑤 𝑆𝑉)0 + (𝑤 𝑆𝑉)𝐿

    where the secondary variable is the following term, which is conductive heat transfer rate in Watts.

    𝑆𝑉 = 𝑘𝐴𝑐𝑑𝑇

    𝑑𝑥𝑛𝑥

    Primary variable of the problem is the temperature, 𝑇. We wrote the 𝑇∞ term on the right hand side because it is known. We can get 𝐾𝑖𝑗

    𝑒 and 𝐹𝑖𝑒 entries of the elemental system by replacing the unknown

    𝑇 with 𝑆𝑗 and the weight function 𝑤 with 𝑆𝑖.

    𝐾𝑖𝑗𝑒 = ∫ [𝑘𝐴𝑐

    𝑑𝑆𝑖𝑑𝑥

    𝑑𝑆𝑗

    𝑑𝑥+ ℎ𝑃𝑆𝑖𝑆𝑗] 𝑑𝑥

    Ωe

    , 𝐹𝑖𝑒 = ∫ 𝑆𝑖ℎ𝑃𝑇∞ 𝑑𝑥

    Ωe

    𝑥

  • 11

    To be able to use the master element and the shape functions defined using the 𝜉 coordinate, let’s change the variable of integration from 𝑥 to 𝜉.

    𝐾𝑖𝑗𝑒 = ∫ (𝑘𝐴𝑐

    𝑑𝑆𝑖𝑒

    𝑑𝜉

    1

    𝐽𝑒 𝑑𝑆𝑗

    𝑒

    𝑑𝜉

    1

    𝐽𝑒+ ℎ𝑃𝑆𝑖

    𝑒𝑆𝑗𝑒) 𝐽𝑒𝑑𝜉

    1

    −1

    , 𝐹𝑖𝑒 = ∫ 𝑆𝑖ℎ𝑃𝑇∞ 𝐽

    𝑒𝑑𝜉1

    −1

    where the shape functions are now functions of 𝜉 and 𝐽𝑒 = ℎ𝑒/2 is the Jacobian of element 𝑒. To get

    this form,

    we converted each 𝑑𝑆𝑒

    𝑑𝑥 to

    𝑑𝑆𝑒

    𝑑𝜉

    1

    𝐽𝑒, i.e. we included an extra

    1

    𝐽𝑒,

    we changed the integral limits to [-1,1],

    we changed the last 𝑑𝑥 to 𝐽𝑒𝑑𝜉.

    𝑘, ℎ, 𝐴𝑐 and 𝑃 are the same for all elements. Also element lengths and therefore 𝐽𝑒’s are the same for

    all elements. It means that [𝐾𝑒]’s and {𝐹𝑒}’s are the same for all elements. Substituting the shape function details and other numerical values, we can calculate (using GQ integration or not) the following

    [𝐾𝑒] = [7.0162 −3.0892−3.0892 7.0162

    ] , {𝐹𝑒} = {98.174898.1748

    }

    Important: As seen, [𝐾𝑒] is symmetric. Actually it can be seen from the 𝐾𝑖𝑗

    𝑒 equation. As we

    interchange the indices 𝑖 and 𝑗, nothing changes in the integrand. In earlier examples, there was no such symmetry because of the existence of the first derivative term in the DE. Assembled 5x5 system is

    [ 7.0162 −3.0892 0 0 0−3.0892 14.0324 −3.0892 0 0

    0 −3.0892 14.0324 −3.0892 00 0 −3.0892 14.0324 −3.08920 0 0 −3.0892 7.0162 ]

    {

    𝑇1𝑇2𝑇3𝑇4𝑇5}

    =

    {

    98.1748196.3495196.3495196.349598.1748 }

    +

    {

    𝐵1000𝐵5}

    𝑇1 is given as 100

    oC. Apply reduction for this and get rid of the first equation.

    [

    14.0324 −3.0892 0 0−3.0892 14.0324 −3.0892 0

    0 −3.0892 14.0324 −3.08920 0 −3.0892 7.0162

    ]{

    𝑇2𝑇3𝑇4𝑇5

    } = {

    196.3495196.3495196.349598.1748

    } + {

    0 − (−3.0892)(100)00𝐵5

    }

    MBC is provided at the last node as

    𝐵5 = (𝑘𝐴𝑐𝑑𝑇

    𝑑𝑥𝑛𝑥)

    𝐿= 𝑘𝐴𝑐

    𝑑𝑇

    𝑑𝑥|𝐿= −ℎ𝐴𝑐(𝑇5 − 𝑇∞)

    Put this in the standard form of

    𝐵5 = (𝑆𝑉)5 = 𝛽𝑇5 + 𝛾 where 𝛽 = −ℎ𝐴𝑐 = −0.7854 and 𝛾 = ℎ𝐴𝑐𝑇∞ = 19.6350. Use these in the reduced system

  • 12

    [

    14.0324 −3.0892 0 0−3.0892 14.0324 −3.0892 0

    0 −3.0892 14.0324 −3.08920 0 −3.0892 7.0162 + 0.7854

    ]{

    𝑇2𝑇3𝑇4𝑇5

    } = {

    196.3495196.3495196.349598.1748

    } + {

    308.9200

    19.6350

    }

    Solving this system, we get

    {

    𝑇2𝑇3𝑇4𝑇5

    } = {

    42.401929.045825.975725.3864

    } ℃

    Comparison of the known exact solution and the FEM solution is as follows.

    As a post processing calculation the amount of heat that goes through the fin base (𝑥 = 0), which is

    important in evaluating the fin’s performance, can be calculated. The value we want is given by

    𝑄𝑏𝑎𝑠𝑒 = (𝑘𝐴𝑐𝑑𝜃

    𝑑𝑥𝑛𝑥)

    𝑥=0

    where 𝑛𝑥 = −1 at the left boundary of the domain. 𝑄𝑏𝑎𝑠𝑒 is nothing but the SV at node 1, i.e. 𝐵1. It

    can be calculated in two different ways. First one is to use the first equation of the original 5x5 system

    that we had before reduction. Substituting the already calculated temperature values we can obtain

    𝐵1.

    𝑄𝑏𝑎𝑠𝑒 = 𝐵1 = (7.0162)(100) + (−3.0892)(42.4019) = 570.6 W

    In an alternative way we can use the calculated nodal temperatures to determine the slope of

    temperature at the fin base and use it to calculate 𝑄𝑏𝑎𝑠𝑒. Over the first element the temperature varies

    linearly as seen above and the slope of this linear variation is

    𝑑𝑇

    𝑑𝑥|𝑥=0

    = 𝑇2 − 𝑇1ℎ𝑒

    =42.4019 − 100

    0.25= −230.4 K/m

    Multiplying this slope with 𝑘𝐴𝑐𝑛𝑥 will give the required 𝑄𝑏𝑎𝑠𝑒

    𝑄𝑏𝑎𝑠𝑒 = (𝑘𝐴𝑐𝑑𝑇

    𝑑𝑥𝑛𝑥)

    𝑥=0= (140) (

    𝜋 0.12

    4)(−230.4)(−1) = 253.3 W

  • 13

    Important: The two values calculated are quite different. The reason of this is the extra derivative

    approximation involved in the second approach. Differentiation is always a risky operation that

    amplifies the already existing errors. Here, the calculated temperature values already have some error

    in them, and these errors amplify when we approximate the first derivative at the fin base. Although

    the first approach gives a better estimate (exact value of 𝑄𝑏𝑎𝑠𝑒 is 440.8 W), the second approach is

    usually used in an FEM code due to practical reasons. As expected, as the mesh is refined, the values

    estimated by the two approaches converge to the same value, which is the exact value. This can be

    seen below

    𝑵𝑬 𝑸𝒃𝒂𝒔𝒆 calculated with the second approach (W)

    4 253.3

    10 344.6

    100 429.3

    1000 439.6

    𝑄𝑏𝑎𝑠𝑒 is positive, meaning that heat is coming into the domain at the base of the fin. Because we

    included 𝑛𝑥 in the SV definition, regardless of which boundary we calculate 𝑄 at (fin base or fin tip), a

    positive value means “heat is coming in”, and a negative value means “heat is going out”.

    Example 2.7:

    Let’s modify the previous fin problem a bit, by making the diameter of the fin variable. It is larger at the base and decreases linearly towards the tip. 𝐿 = 1 m

    𝐷𝑏𝑎𝑠𝑒 = 0.1 m , 𝐷𝑡𝑖𝑝 = 0.05 m

    𝐷(𝑥) = −0.05𝑥 + 0.1 Governing DE is the same as before, but now the cross sectional area and the perimeter of the fin are not constant. They are functions of 𝑥. 𝐾𝑖𝑗

    𝑒 and 𝐹𝑖𝑒 integrals are expressed same as before, also given

    below.

    𝐾𝑖𝑗𝑒 = ∫ (𝑘𝐴𝑐

    𝑑𝑆𝑖𝑒

    𝑑𝜉

    1

    𝐽𝑒 𝑑𝑆𝑗

    𝑒

    𝑑𝜉

    1

    𝐽𝑒+ ℎ𝑃𝑆𝑖

    𝑒𝑆𝑗𝑒) 𝐽𝑒𝑑𝜉

    1

    −1

    , 𝐹𝑖𝑒 = ∫ 𝑆𝑖ℎ𝑃𝑇∞ 𝐽

    𝑒𝑑𝜉1

    −1

    Important: Now [𝐾𝑒] and {𝐹𝑒} of each element is different because 𝐴𝑐 and 𝑃 changes from element

    to element. To evaluate the above integrals we need to write 𝐴𝑐 and 𝑃 as functions of 𝜉.

    𝐴𝑐 =𝜋𝐷2

    4=𝜋

    4(−0.05𝑥 + 0.1)2, 𝑃 = 𝜋𝐷 = 𝜋(−0.05𝑥 + 0.1)

    For element “e”, 𝑥 − 𝜉 relation is given by

    𝑥 =ℎ𝑒

    2𝜉 +

    𝑥1𝑒 + 𝑥2

    𝑒

    2

    𝑥

  • 14

    which needs to be substituted in the 𝐴𝑐 and 𝑃 expressions to get

    𝐴𝑐 =𝜋𝐷2

    4=𝜋

    4[−0.05(

    ℎ𝑒

    2𝜉 +

    𝑥1𝑒 + 𝑥2

    𝑒

    2) + 0.1]

    2

    , 𝑃 = 𝜋𝐷 = 𝜋 [−0.05(ℎ𝑒

    2𝜉 +

    𝑥1𝑒 + 𝑥2

    𝑒

    2) + 0.1]

    As you see, things can get pretty involved and it becomes very difficult to perform a hand solution. But

    this will not create any difficulty in a FEM code that makes use of GQ integration, as we’ll see later.

    Example 2.8:

    Let’s solve Example 2.1, DE of which is given below, using the Finite Difference Method (FDM) and

    compare the solution with the FEM solution.

    3𝑑𝜙

    𝑑𝑥−𝑑2𝜙

    𝑑𝑥2= 1 𝑇(0) = 0 , 𝑇(1) = 0

    FDM has no concept of elements, but it has nodes. We’ll perform a 6 node solution using a node

    spacing of Δ𝑥 = 1/5 = 0.2.

    Let’s write the ODE for an inner node 𝑖, with neighbors 𝑖 − 1 and 𝑖 + 1.

    Node 𝑖: 3𝑑𝜙

    𝑑𝑥|𝑖−𝑑2𝜙

    𝑑𝑥2|𝑖

    = 1

    The first and the second derivatives can be approximated in many different ways, such as backward,

    central and forward. Also approximations of various orders, such as first-order or second-order can be

    used. We’ll use the following second-order central approximations

    𝑑𝜙

    𝑑𝑥|𝑖≅𝜙𝑖+1 − 𝜙𝑖−1

    2Δ𝑥 ,

    𝑑2𝜙

    𝑑𝑥2|𝑖

    ≅𝜙𝑖+1 − 2𝜙𝑖 + 𝜙𝑖−1

    (Δ𝑥)2

    Substitute these into the ODE to get

    Node 𝑖: 3 (𝜙𝑖+1 − 𝜙𝑖−1

    2Δ𝑥) − (

    𝜙𝑖+1 − 2𝜙𝑖 + 𝜙𝑖−1(Δ𝑥)2

    ) = 1

    Use Δ𝑥 = 0.2 and arrange into

    Node 𝑖: 32.5𝜙𝑖−1 + 50𝜙𝑖 + 17.5𝜙𝑖+1 = 1

    To see the similarity of this equation with that obtained earlier by FEM, multiply the equation by

    Δ𝑥 = 0.2

    Node 𝑖: 6.5𝜙𝑖−1 + 10𝜙𝑖 + 3.5𝜙𝑖+1 = 0.2

    This is exactly the same equation as those obtained for the inner nodes of the FE solution. Look at the

    global system obtained in Example 2.1 to see it.

    x

    1 2 3 4 5 6

    Δ𝑥

  • 15

    Important: Therefore, our FEM solution is practically the same as using FDM with second-order central

    derivative approximations. But FDM seems to be much simpler than FEM. So why should anyone prefer

    FEM? For this 1D problem, FEM has no advantage over FDM. FDM is just OK here. But FDM cannot be

    extended to 2D and 3D problems over complicated geometries, where unstructured grids are required.

    On the other hand, FEM is naturally suitable for those problems.

    Important: Here we worked only on the inner nodes. For the boundary nodes, derivatives need to be

    approximated not as central, but as a one-sided, such as forward differencing for node 1, and backward

    differencing for node 6.

    Example 2.9:

    Let’s solve Example 2.6, DE of which is given below, using the Finite Volume Method (FVM) and

    compare the solution with the FEM solution.

    −𝑑

    𝑑𝑥(𝑘𝑑𝑇

    𝑑𝑥) +

    ℎ𝑃

    𝐴𝑐(𝑇 − 𝑇∞) = 0 , 0 < 𝑥 < 𝐿

    Note that both terms are divided by 𝐴𝑐, because this form is more suitable to FVM. A FVM mesh has

    cells and nodes. Cells are similar to the elements of FEM. Nodes are where we store the discrete

    unknown values, and typically they are at the midpoints of the cells. Following mesh has 4 cells and 4

    nodes. Different than FEM or FDM, there are no nodes at the boundaries. In FVM one can use other

    storage schemes too.

    Consider each cell to have a length of Δ𝑥 = 𝐿/4.

    FVM uses integral form of the given DE. We integrate the DE over cell 𝑖.

    Cell 𝑖 ∶ −∫𝑑

    𝑑𝑥(𝑘𝑑𝑇

    𝑑𝑥) 𝑑∀

    Ω𝑖

    +∫ℎ𝑃

    𝐴𝑐(𝑇 − 𝑇∞) 𝑑∀

    Ω𝑖

    = 0

    where Ω𝑖 denotes the domain (line segment in 1D) of cell 𝑖 and 𝑑∀ is used for volume integration (line

    integral in 1D). FVM is based on the accounting of incoming and outgoing amounts of the conserved

    quantity at the faces of a cell. To see it this way we apply Gauss divergence theorem to the first integral

    and convert it from a volume integral to an area integral

    Cell 𝑖 ∶ −∫ 𝑘𝑑𝑇

    𝑑𝑥 𝑛𝑥 𝑑𝐴

    𝐴𝑖

    +∫ℎ𝑃

    𝐴𝑐(𝑇 − 𝑇∞) 𝑑∀

    Ω𝑖

    = 0

    where 𝐴𝑖 is the boundary (faces) of cell 𝑖 , which are just the two end points in 1D. 𝑛𝑥 is the 𝑥

    component of the unit outward normal at the boundaries, same as the one we used in the SV

    expression in FEM. In 1D, area integral is not really an integral, but the sum of the integrand evaluated

    at the two end points of cell 𝑖.

    Cell 1 Cell 2 Cell 3 Cell 4

    x

    1 2 3 4

  • 16

    Cell 𝑖 ∶ − [(𝑘𝑑𝑇

    𝑑𝑥𝑛𝑥𝐴𝑐)

    𝑙𝑒𝑓𝑡+ (𝑘𝐴𝑐

    𝑑𝑇

    𝑑𝑥𝑛𝑥𝐴𝑐)

    𝑟𝑖𝑔ℎ𝑡] + ∫

    ℎ𝑃

    𝐴𝑐(𝑇 − 𝑇∞) 𝑑∀

    Ω𝑖

    = 0

    where “left” and “right” are the left and right end points (faces) of cell 𝑖. The volume integral over cell

    𝑖 can be approximated as

    ∫ℎ𝑃

    𝐴𝑐(𝑇 − 𝑇∞) 𝑑∀

    Ω𝑖

    ≅ℎ𝑃

    𝐴𝑐(𝑇𝑖 − 𝑇∞)𝐴𝑐Δ𝑥 = ℎ𝑃(𝑇𝑖 − 𝑇∞)Δ𝑥

    which is obtained by considering the nodal value 𝑇𝑖 (stored at the center of cell 𝑖) to be constant over

    cell 𝑖 , which has a volume of 𝐴𝑐Δ𝑥 . Also using 𝑛𝑥𝑙𝑒𝑓𝑡 = −1 and 𝑛𝑥𝑟𝑖𝑔ℎ𝑡 = 1 , equation of cell 𝑖

    becomes

    Cell 𝑖 ∶ − [(−𝑘𝑑𝑇

    𝑑𝑥𝐴𝑐)

    𝑙𝑒𝑓𝑡+ (𝑘

    𝑑𝑇

    𝑑𝑥𝐴𝑐)

    𝑟𝑖𝑔ℎ𝑡] + ℎ𝑃(𝑇𝑖 − 𝑇∞)Δ𝑥 = 0

    This is an energy balance equation. It considers the balance of heat coming into the cell from its left

    face, the heat going out of the cell from its right face and the convective heat going out of the cell to

    the surroundings. This “physical accounting” character of FVM is what makes it natural and easy to

    understand for engineers.

    The main approximation in FVM is to approximate 𝑑𝑇

    𝑑𝑥 at the right and left faces of the cell. For an inner

    cell (not located at a boundary), they can be approximated using the nodal values of 𝑇𝑖, 𝑇𝑖+1 and 𝑇𝑖−1

    as follows

    𝑑𝑇

    𝑑𝑥|𝑙𝑒𝑓𝑡

    ≅𝑇𝑖 − 𝑇𝑖−1Δ𝑥

    , 𝑑𝑇

    𝑑𝑥|𝑟𝑖𝑔ℎ𝑡

    ≅𝑇𝑖+1 − 𝑇𝑖Δ𝑥

    which are second-order central approximations around the faces. Substitute these into the equation

    of cell 𝑖.

    Cell 𝑖 ∶ − [−𝑘𝑇𝑖 − 𝑇𝑖−1Δ𝑥

    𝐴𝑐 + 𝑘𝑇𝑖+1 − 𝑇𝑖Δ𝑥

    𝐴𝑐] + ℎ𝑃(𝑇𝑖 − 𝑇∞)Δ𝑥 = 0

    By putting the known values in and arranging we get

    −4.3982𝑇𝑖−1 + 16.6504𝑇𝑖 − 4.3982𝑇𝑖+1 = 196.3495

    Compared with the inner node equations obtained in Example 2.6, the right hand side value is the

    same, but the coefficients of the unknowns are different. FVM and FEM discretizations are not identical

    for this problem. The difference seems to be due to the discretization of the convective cooling term.

    Note that FDM will give the same result as FVM, when the second derivative of the DE is approximated

    in a second-order central way.

    To complete the FVM discretization and obtain a solution, we need to work on the boundary cells,

    which will not be done here.

    Cell i

    i-1 i i+1

    Left Right

  • 17

    Example 2.10:

    (Reference: Reddy’s book) We’ll perform an ℎ -convergence study by solving the following pure

    diffusion problem (Poisson equation)

    −𝑑2𝜙

    𝑑𝑥2= 2 , 0 < 𝑥 < 1 with 𝜙(0) = 𝜙(1) = 0

    The exact solution is 𝜙𝑒𝑥 = 𝑥(1 − 𝑥).

    Solutions with 2, 3 and 4 linear elements with constant element size for each case are shown below.

    Nodal values are exact, even for the 2 element mesh. But inside the elements there are deviations

    from the exact solution. To calculate how much these deviations contribute to the 𝐿2 and energy norm

    errors, let’s express the FE solutions as follows

    For 2 elements ∶ 𝜙𝑎𝑝𝑝 = {ℎ2(𝑥/ℎ)

    ℎ2(2 − 𝑥/ℎ) for 0 ≤ 𝑥 ≤ ℎ for ℎ ≤ 𝑥 ≤ 2ℎ

    For 3 elements ∶ 𝜙𝑎𝑝𝑝 = {

    2ℎ2(𝑥/ℎ)

    2ℎ2(2 − 𝑥/ℎ) + 2ℎ2(𝑥/ℎ − 1)

    2ℎ2(3 − 𝑥/ℎ)

    for 0 ≤ 𝑥 ≤ ℎ for ℎ ≤ 𝑥 ≤ 2ℎ for 2ℎ ≤ 𝑥 ≤ 3ℎ

  • 18

    For 4 elements ∶ 𝜙𝑎𝑝𝑝 =

    {

    3ℎ

    2(𝑥/ℎ)

    3ℎ2(2 − 𝑥/ℎ) + 4ℎ2(𝑥/ℎ − 1)

    4ℎ2(3 − 𝑥/ℎ) + 3ℎ2(𝑥/ℎ − 2)

    3ℎ2(4 − 𝑥/ℎ)

    for 0 ≤ 𝑥 ≤ ℎ for ℎ ≤ 𝑥 ≤ 2ℎ for 2ℎ ≤ 𝑥 ≤ 3ℎfor 3ℎ ≤ 𝑥 ≤ 4ℎ

    where ℎ = 1/2, 1/3 and 1/4 for 2, 3, and 4 element solutions, respectively. Knowing the exact

    solution, we can calculate the integrals of the error norms and obtain the following results

    ℎ 𝐿2 norm error Energy norm error

    1/2 0.04564 0.2887

    1/3 0.02028 0.1925

    1/4 0.01141 0.1443

    Following is the log-log plot of these values. Although not easy to see on the graph, slopes of the 𝐿2

    and energy norm error lines are 2 and 1, as discussed before.

    Exercise: Repeat the above ℎ-convergence study using quadratic elements and see if you can get the

    rate of convergences predicted by the theory.

    Slope of 1

    Slope of 2