Implements 2D versus time finite element thermal diffusion. Uses explicit algorithm for the time dimension.
-
19a
- Totally redefine approach. The main class is ThermalMesh with the temperature
stored in a 2D
numpy
array. savePGM
to write an image filesetBorderAdiabatic
to set no heat flow out of the side- Implemented Newton's Law of Cooling
iterate
using equation below
- Totally redefine approach. The main class is ThermalMesh with the temperature
stored in a 2D
-
19b
- Add heat input to certain nodes
- Add constant Temperature nodes
-
19c
- Clean up code and documentation
- Change image & animation code
-
20a
- Add explicity template to class. A template describes what a node is
or does. A template must be set before calculation can be done Examples are:
- .: a normal temperature evolving node
- Q: constant heat input to node
- T: constant termperature node
- P: a periodic boundary node
- A: an adiabatic border node
- Add explicity template to class. A template describes what a node is
or does. A template must be set before calculation can be done Examples are:
Heat is the transfer of thermal energy. Note that it is not the temperature of an object, or a property of an object, but a change or movement of thermal energy. The main mechanisms of heat transfer are conduction , convection , and radiation .
Heat is thermal energy associated with the temperature-dependent
motion of particles.
The macroscopic energy equation for infinitesimal volume used in
heat transfer analysis is
$$
\nabla \cdot \mathbf{q} = -c_p \rho \frac{\partial T}{\partial t} +
\sum_i{\dot s_i}
$$
where
specific heat capacity at constant pressure,
Fourier's law of thermal conduction is
$$
\mathbf{q} = -k \nabla T
$$
where
Working from the equation in Heat Transfer Physics , you can derive the Heat Equation
$$
\frac{\partial T}{\partial t} = \frac{k c_p}{\rho} \nabla^2 T = \alpha \nabla^2 T
$$
where
Material | Thermal Conductivity |
Heat Capacity |
Density | |
---|---|---|---|---|
- | ( |
( |
( |
( |
Aluminum | 240 | 900 | 2700 | 80 |
Steel | 35 | 480 | 7900 | 2.1 |
If there are sources or sinks of thermal energy, the heat equation becomes
$$
\rho c_p \frac{\partial T}{\partial t} - k \nabla^2 T = \dot{q_V}
$$
where
You can model the general heat loss by assuming Newton's Law of Cooling
$$
\frac{d T}{d t} = \beta (T - T_0)
$$
where
We want to apply the heat equation to simulate the time evolution of
the temperature of a plate, so we can write the equation as
$$
\frac{\partial T}{\partial t} = \alpha \nabla^2 T -\beta (T - T_0) + \dot q(x,y)
$$
where $\dot q(x,y) $ is where heat is flowing into (
Another possibility is that you can have the plate in contact with a constant temperature source, so the software ought to be able to handle that situation also.
Now make the times discrete, so $$ \begin{align} T^{i+1} &= T^i + \frac{\partial T}{\partial t} \vert_{t^i} \Delta t + \dot q(x,y) \Delta t \ & = T^i + \left ( \alpha \nabla^2 T^i -\beta (T^i - T_0) \right ) \Delta t + \dot q(x, y) \Delta t \end{align} $$
Next we need to make the spatial coordinates,
So the final result is $$ T_{j,k}^{i+1} = T_{j,k}^i + \frac{\alpha \Delta t}{{\Delta x}^2} \left({T_{j+1,k}^i + T_{j-1,k}^i + T_{j,k+1}^i + T_{j,k-1}^i - 4 T_{j,k}^i}\right)
- \beta \Delta t\left({T_{j,k}^i - T_0}\right)
- \Delta t ; \dot q_{j,k} $$
An important point to note is that ALL of the right side terms are at time
All we have to do now is program this!
From Python Heat Transfer I found here.
Use a 2D numpy
array for the spatial temperature on a plate. Hints:
-
To implement adiabatic edges (no heat flows off of the plate at the borders) add one row or column to the edge and give the values the same values as the last row or column. If there is no temperature difference at the the edge, heat won't flow that direction.
-
To increase efficiency you can use the
np.roll
to rotate the array in a direction. then you can do the sum$T_{i,j+1,k} + T_{i,j-1,k} + T_{i,j,k+1} + T_{i,j,k-1}$ by rolling and adding. Since we are going to have extra rows and columns on the edges, we do not have to worry about the temerature at the bottom affecting the temperature at the top, And similarly for the other three sides. The missing elements in the corners don't matter, so define a rectangular array.
BTW, if you want periodic boundary conditions, leave out the borders and the solution will smoothly roll across the boundaries.
In the figure, "B" are border rows and columns used to implement (or not) an adiabatic edge to the plate. The contents of the boxes labeled "C" are arbitrary; they are not used in the calculation. The python coordinates of the corner pixels are shown.
-
To add Heat Sources and Sinks, create both a template and a
heatSource
array the size of your array that adds (or subtracts) heat from particular cells. The non-zero values are the amount of heat added or subtracted from a given node. We are assuming the heat sources or sinks are constant with time. At each time step, the temperature of those cells is changed by the value$\dot q_{j,k} \Delta t$ . -
To implement constant temperature nodes, modify the template and create an array the size of the nodes array where the non-zero values are the fixed temperatures.