Example: One-dimensional heat flow

This example is from the CALFEM manual (exs2.py).

Purpose:

Analysis of one-dimensional heat flow.

Description:

Consider a wall built up of concrete and thermal insulation. The outdoor temperature is −17 ◦C and the temperature inside is 20 ◦C. At the inside of the thermal insulation there is a heat source yielding \(10 ~W/m^2\).

image0

The wall is subdivided into five elements and the one-dimensional spring (analogy) element spring1e is used. Equivalent spring stiffnesses are \(k_i = λ A/L\) for thermal conductivity and \(k_i = A/R\) for thermal surface resistance. Corresponding spring stiffnesses per \(m^2\) of the wall are:

\begin{align} k_1 &= 1/0.04 = 25.0 ~W/K \\ k_2 &= 1.7/0.070 = 24.3 ~W/K \\ k_3 &= 0.040/0.100 = 0.4 ~W/K \\ k_4 &= 1.7/0.100 = 17.0 ~W/K \\ k_5 &= 1/0.13 = 7.7 ~W/K \end{align}

A global system matrix K and a heat flow vector f are defined. The heat source inside the wall is considered by setting \(f_4 = 10\). The element matrices Ke are computed using spring1e, and the function assem assembles the global stiffness matrix.

The system of equations is solved using solveq with considerations to the boundary conditions in bc and bcVal. The prescribed temperatures are \(T_1 = −17 ~^{\circ}C\) and \(T_2 = 20~^{\circ}C\).

Necessary modules are first imported.

[1]:
import numpy as np
import calfem.core as cfc

Next, the element topology is defined

[2]:
Edof = np.array([
    [1,2],
    [2,3],
    [3,4],
    [4,5],
    [5,6]
])

Create stiffness matrix K and load vector f

[3]:
K = np.mat(np.zeros((6,6)))
f = np.mat(np.zeros((6,1)))
f[3] = 10.0

Define element properties (ep) and create element matrices for the different material layers.

[4]:
ep1 = 25.0
ep2 = 24.3
ep3 = 0.4
ep4 = 17.0
ep5 = 7.7

Element stiffness matrices

[5]:
Ke1 = cfc.spring1e(ep1)
Ke2 = cfc.spring1e(ep2)
Ke3 = cfc.spring1e(ep3)
Ke4 = cfc.spring1e(ep4)
Ke5 = cfc.spring1e(ep5)

Assemble all element matrices into the global stiffness matrix

[6]:
cfc.assem(Edof[0,:], K, Ke1)
cfc.assem(Edof[1,:], K, Ke2)
cfc.assem(Edof[2,:], K, Ke3)
cfc.assem(Edof[3,:], K, Ke4)
cfc.assem(Edof[4,:], K, Ke5)

print("Stiffness matrix K:")
print(K)
Stiffness matrix K:
[[ 25.  -25.    0.    0.    0.    0. ]
 [-25.   49.3 -24.3   0.    0.    0. ]
 [  0.  -24.3  24.7  -0.4   0.    0. ]
 [  0.    0.   -0.4  17.4 -17.    0. ]
 [  0.    0.    0.  -17.   24.7  -7.7]
 [  0.    0.    0.    0.   -7.7   7.7]]

Define the boundary conditions and solve the system of equations

[7]:
bc = np.array([1,6])
bc_val = np.array([-17.0, 20.0])
a,r = cfc.solveq(K, f, bc, bc_val)

print("Displacements a:")
print(a)

print("Reaction forces r:")
print(r)
Displacements a:
[[-17.        ]
 [-16.43842455]
 [-15.86067203]
 [ 19.23779344]
 [ 19.47540439]
 [ 20.        ]]
Reaction forces r:
[[-1.40393862e+01]
 [ 0.00000000e+00]
 [ 0.00000000e+00]
 [ 0.00000000e+00]
 [ 5.68434189e-14]
 [ 4.03938619e+00]]