Heat transfer through a wall

This problem demonstrates the use of prescribed temperature on both sides of the wall.

Using

Theory

We shall consider a stationary heat transfer problem within a wall. The inner surface of the wall, \(x=0~m\), is heated to \(200~K\), the outer surface of the wall, \(x=10~m\), to \(300~K\).

The thermal equation for the uni-directional problem can be expressed as

\[\Delta T = \frac{\partial^2 T}{\partial r^2} = 0\]

where \(\Delta\) is the Laplace operator.

The analytic solution follows as

\[T(x) = T_i \left(1-\frac{x}{L}\right) + T_o \left(\frac{x}{L}\right)\]

This solution will be compared against the finite element solution in the last figure.

import matplotlib.pyplot as plt

import math
import sys
import numpy as np

from femedu.examples.Example import *

from femedu.domain import *
from femedu.mesher import PatchMesher
from femedu.elements.diffusion import Triangle
from femedu.materials import Thermal


class ExampleThermal02(Example):

    def problem(self):
        # ========== setting mesh parameters ==============

        Nx = 4  # number of elements through the wall
        Ny = 3  # number of elements parallel to the wall
        Lx = 10.00  # wall thickness in m
        Ly =  5.00  # wall thickness in m

        # ========== setting material parameters ==============

        params = dict(
            E=20000.,  # Young's modulus
            nu=0.250,  # Poisson's ratio
            t=1.00     # thickness of the plate
        )

        # ========== setting load parameters ==============

        qn = 1.00  # uniform flux normal to x=const

        # ========== setting analysis parameters ==============

        target_load_level = 1.00  # reference load
        max_steps = 2  # number of load steps: 2 -> [0.0, 1.0]

        # define a list of target load levels
        load_levels = np.linspace(0, target_load_level, max_steps)

        #
        # ==== Build the system model ====
        #

        model = System()

        # create nodes

        #  2 -------- 3
        #  |          |
        #  |          |
        #  |          |          |
        #  0 -------- 1

        pts = (
            ( 0,  0),  # 0
            (Lx,  0),  # 1
            ( 0, Ly),  # 2
            (Lx, Ly),  # 3
            (0.67*Lx, 0),   # 4
            (0.33*Lx, Ly),  # 5
        )

        mesher = PatchMesher(model, pts[0], pts[1], pts[3], pts[2], pts[4], None, pts[5], None)
        nodes, elements = mesher.triangleMesh(Nx, Ny, Triangle, Thermal(params))

        model.plot(factor=0.0,
                   title='Uni-directional diffusion',
                   show_reactions=0, show_bc=0, show_loads=0)

        model.report()

        # boundary condition(s)

        ## find nodes at y==0 and x==0

        for node in nodes:
            X = node.getPos()
            if math.isclose(X[0], 0.0):
                node.setDOF(['T'],[200.])    # prescribed temperature at x=0.0
            if math.isclose(X[0], Lx):
                node.setDOF(['T'],[300.])    # prescribed temperature at x=0.0

        # perform the analysis
        model.setLoadFactor(1.0)
        model.solve()

        model.report()

        model.valuePlot('T', show_mesh=True)

        # creating a path plot

        R_list = []
        T_list = []

        for node in nodes:
            X = node.getPos()
            T = node.getDisp('T')
            R_list.append(X[0])
            T_list.append(T)

        # the analytic solution for comparison
        x = np.linspace(0, Lx, 21)
        T = 200. * (1 - x/Lx) + 300. * x/Lx

        fig, axs = plt.subplots()
        axs.plot(x,T,'-b',label="analytic solution")
        axs.plot(R_list,T_list,'ro',label="FEM")
        axs.set_title('Nodal Temperature for ALL Nodes')
        axs.set_xlabel("X distance")
        axs.set_ylabel('T')
        axs.legend()
        axs.grid(True)
        plt.show()

Run the example by creating an instance of the problem and executing it by calling Example.run()

if __name__ == "__main__":
    ex = ExampleThermal02()
    ex.run()
  • Uni-directional diffusion
  • Contours of 'T'
  • Nodal Temperature for ALL Nodes
System Analysis Report
=======================

Nodes:
---------------------
  Node_231:
      x:    [0. 0.]
      u:    [0.]
  Node_232:
      x:    [3.775 0.   ]
      u:    [0.]
  Node_233:
      x:    [6.7 0. ]
      u:    [0.]
  Node_234:
      x:    [8.775 0.   ]
      u:    [0.]
  Node_235:
      x:    [10.  0.]
      u:    [0.]
  Node_236:
      x:    [0.         1.66666667]
      u:    [0.]
  Node_237:
      x:    [2.925      1.66666667]
      u:    [0.]
  Node_238:
      x:    [5.56666667 1.66666667]
      u:    [0.]
  Node_239:
      x:    [7.925      1.66666667]
      u:    [0.]
  Node_240:
      x:    [10.          1.66666667]
      u:    [0.]
  Node_241:
      x:    [0.         3.33333333]
      u:    [0.]
  Node_242:
      x:    [2.075      3.33333333]
      u:    [0.]
  Node_243:
      x:    [4.43333333 3.33333333]
      u:    [0.]
  Node_244:
      x:    [7.075      3.33333333]
      u:    [0.]
  Node_245:
      x:    [10.          3.33333333]
      u:    [0.]
  Node_246:
      x:    [0. 5.]
      u:    [0.]
  Node_247:
      x:    [1.225 5.   ]
      u:    [0.]
  Node_248:
      x:    [3.3 5. ]
      u:    [0.]
  Node_249:
      x:    [6.225 5.   ]
      u:    [0.]
  Node_250:
      x:    [10.  5.]
      u:    [0.]

Elements:
---------------------
  Triangle_347: nodes ( Node_231 Node_232 Node_236 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_348: nodes ( Node_237 Node_236 Node_232 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_349: nodes ( Node_232 Node_233 Node_237 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_350: nodes ( Node_238 Node_237 Node_233 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_351: nodes ( Node_233 Node_234 Node_238 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_352: nodes ( Node_239 Node_238 Node_234 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_353: nodes ( Node_234 Node_235 Node_239 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_354: nodes ( Node_240 Node_239 Node_235 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_355: nodes ( Node_236 Node_237 Node_241 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_356: nodes ( Node_242 Node_241 Node_237 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_357: nodes ( Node_237 Node_238 Node_242 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_358: nodes ( Node_243 Node_242 Node_238 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_359: nodes ( Node_238 Node_239 Node_243 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_360: nodes ( Node_244 Node_243 Node_239 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_361: nodes ( Node_239 Node_240 Node_244 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_362: nodes ( Node_245 Node_244 Node_240 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_363: nodes ( Node_241 Node_242 Node_246 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_364: nodes ( Node_247 Node_246 Node_242 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_365: nodes ( Node_242 Node_243 Node_247 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_366: nodes ( Node_248 Node_247 Node_243 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_367: nodes ( Node_243 Node_244 Node_248 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_368: nodes ( Node_249 Node_248 Node_244 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_369: nodes ( Node_244 Node_245 Node_249 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00
  Triangle_370: nodes ( Node_250 Node_249 Node_245 )
      material: Thermal
      grad phi: x=0.000e+00 y=0.000e+00
      flux:     x=0.000e+00 y=0.000e+00


System Analysis Report
=======================

Nodes:
---------------------
  Node_231:
      x:    [0. 0.]
      fix:  ['T']
      u:    [200.]
  Node_232:
      x:    [3.775 0.   ]
      u:    [237.75]
  Node_233:
      x:    [6.7 0. ]
      u:    [267.]
  Node_234:
      x:    [8.775 0.   ]
      u:    [287.75]
  Node_235:
      x:    [10.  0.]
      fix:  ['T']
      u:    [300.]
  Node_236:
      x:    [0.         1.66666667]
      fix:  ['T']
      u:    [200.]
  Node_237:
      x:    [2.925      1.66666667]
      u:    [229.25]
  Node_238:
      x:    [5.56666667 1.66666667]
      u:    [255.66666667]
  Node_239:
      x:    [7.925      1.66666667]
      u:    [279.25]
  Node_240:
      x:    [10.          1.66666667]
      fix:  ['T']
      u:    [300.]
  Node_241:
      x:    [0.         3.33333333]
      fix:  ['T']
      u:    [200.]
  Node_242:
      x:    [2.075      3.33333333]
      u:    [220.75]
  Node_243:
      x:    [4.43333333 3.33333333]
      u:    [244.33333333]
  Node_244:
      x:    [7.075      3.33333333]
      u:    [270.75]
  Node_245:
      x:    [10.          3.33333333]
      fix:  ['T']
      u:    [300.]
  Node_246:
      x:    [0. 5.]
      fix:  ['T']
      u:    [200.]
  Node_247:
      x:    [1.225 5.   ]
      u:    [212.25]
  Node_248:
      x:    [3.3 5. ]
      u:    [233.]
  Node_249:
      x:    [6.225 5.   ]
      u:    [262.25]
  Node_250:
      x:    [10.  5.]
      fix:  ['T']
      u:    [300.]

Elements:
---------------------
  Triangle_347: nodes ( Node_231 Node_232 Node_236 )
      material: Thermal
      grad phi: x=1.000e+01 y=0.000e+00
      flux:     x=-1.000e+01 y=-0.000e+00
  Triangle_348: nodes ( Node_237 Node_236 Node_232 )
      material: Thermal
      grad phi: x=1.000e+01 y=5.684e-14
      flux:     x=-1.000e+01 y=-5.684e-14
  Triangle_349: nodes ( Node_232 Node_233 Node_237 )
      material: Thermal
      grad phi: x=1.000e+01 y=2.842e-14
      flux:     x=-1.000e+01 y=-2.842e-14
  Triangle_350: nodes ( Node_238 Node_237 Node_233 )
      material: Thermal
      grad phi: x=1.000e+01 y=2.842e-14
      flux:     x=-1.000e+01 y=-2.842e-14
  Triangle_351: nodes ( Node_233 Node_234 Node_238 )
      material: Thermal
      grad phi: x=1.000e+01 y=2.842e-14
      flux:     x=-1.000e+01 y=-2.842e-14
  Triangle_352: nodes ( Node_239 Node_238 Node_234 )
      material: Thermal
      grad phi: x=1.000e+01 y=-2.842e-14
      flux:     x=-1.000e+01 y=2.842e-14
  Triangle_353: nodes ( Node_234 Node_235 Node_239 )
      material: Thermal
      grad phi: x=1.000e+01 y=-2.842e-14
      flux:     x=-1.000e+01 y=2.842e-14
  Triangle_354: nodes ( Node_240 Node_239 Node_235 )
      material: Thermal
      grad phi: x=1.000e+01 y=0.000e+00
      flux:     x=-1.000e+01 y=-0.000e+00
  Triangle_355: nodes ( Node_236 Node_237 Node_241 )
      material: Thermal
      grad phi: x=1.000e+01 y=0.000e+00
      flux:     x=-1.000e+01 y=-0.000e+00
  Triangle_356: nodes ( Node_242 Node_241 Node_237 )
      material: Thermal
      grad phi: x=1.000e+01 y=2.842e-14
      flux:     x=-1.000e+01 y=-2.842e-14
  Triangle_357: nodes ( Node_237 Node_238 Node_242 )
      material: Thermal
      grad phi: x=1.000e+01 y=0.000e+00
      flux:     x=-1.000e+01 y=-0.000e+00
  Triangle_358: nodes ( Node_243 Node_242 Node_238 )
      material: Thermal
      grad phi: x=1.000e+01 y=2.842e-14
      flux:     x=-1.000e+01 y=-2.842e-14
  Triangle_359: nodes ( Node_238 Node_239 Node_243 )
      material: Thermal
      grad phi: x=1.000e+01 y=0.000e+00
      flux:     x=-1.000e+01 y=-0.000e+00
  Triangle_360: nodes ( Node_244 Node_243 Node_239 )
      material: Thermal
      grad phi: x=1.000e+01 y=-1.137e-13
      flux:     x=-1.000e+01 y=1.137e-13
  Triangle_361: nodes ( Node_239 Node_240 Node_244 )
      material: Thermal
      grad phi: x=1.000e+01 y=-1.137e-13
      flux:     x=-1.000e+01 y=1.137e-13
  Triangle_362: nodes ( Node_245 Node_244 Node_240 )
      material: Thermal
      grad phi: x=1.000e+01 y=0.000e+00
      flux:     x=-1.000e+01 y=-0.000e+00
  Triangle_363: nodes ( Node_241 Node_242 Node_246 )
      material: Thermal
      grad phi: x=1.000e+01 y=0.000e+00
      flux:     x=-1.000e+01 y=-0.000e+00
  Triangle_364: nodes ( Node_247 Node_246 Node_242 )
      material: Thermal
      grad phi: x=1.000e+01 y=0.000e+00
      flux:     x=-1.000e+01 y=-0.000e+00
  Triangle_365: nodes ( Node_242 Node_243 Node_247 )
      material: Thermal
      grad phi: x=1.000e+01 y=-5.684e-14
      flux:     x=-1.000e+01 y=5.684e-14
  Triangle_366: nodes ( Node_248 Node_247 Node_243 )
      material: Thermal
      grad phi: x=1.000e+01 y=-2.842e-14
      flux:     x=-1.000e+01 y=2.842e-14
  Triangle_367: nodes ( Node_243 Node_244 Node_248 )
      material: Thermal
      grad phi: x=1.000e+01 y=-8.527e-14
      flux:     x=-1.000e+01 y=8.527e-14
  Triangle_368: nodes ( Node_249 Node_248 Node_244 )
      material: Thermal
      grad phi: x=1.000e+01 y=0.000e+00
      flux:     x=-1.000e+01 y=-0.000e+00
  Triangle_369: nodes ( Node_244 Node_245 Node_249 )
      material: Thermal
      grad phi: x=1.000e+01 y=2.842e-14
      flux:     x=-1.000e+01 y=-2.842e-14
  Triangle_370: nodes ( Node_250 Node_249 Node_245 )
      material: Thermal
      grad phi: x=1.000e+01 y=0.000e+00
      flux:     x=-1.000e+01 y=-0.000e+00

Total running time of the script: (0 minutes 0.302 seconds)

Gallery generated by Sphinx-Gallery