sábado, 30 de setembro de 2023

2D steady-state heat diffusion using Python

Ordinary Differential Equations (ODEs) and Partial Differential Equations (PDEs) are part of a diverse range of physical phenomena. In engineering, they can be found in problems involving vibration, fluid mechanics, heat transfer, among others.

Simplifying the Energy Equation [1] for a steady-state 2D heat diffusion gives us the following PDE, which can be solved analitically:

\[\frac{\partial^{2}T(x, y)}{\partial x^{2}}+\frac{\partial^{2}T(x, y)}{\partial y^{2}}=0\]

Consider a rectangular plate with thermal conductivity given by "k", with length equal to "a", width equal to "b" and assume the following boundary conditions:

\[\left\{\begin{matrix}
 \\T(0,\space y)=0
 \\T(a,\space y)=0
 \\T(x,\space 0)=0
 \\-k\frac{\partial T(x,\space b)}{\partial y}=q_{in}\space if \space 0<x<\tfrac{a}{2}
\\-k\frac{\partial T(x, \space b)}{\partial y}=q_{out}\space if \space \tfrac{a}{2}<x<a
\end{matrix}\right.\]

Solving the PDE by the method of separation of variables and applying the Sturm-Liouville problem will lead to the following final solution considering the boundary conditions aforementioned:

\[T(x,\space y)=\sum_{n=1}^{\infty}C_{n}\sin \left ( \frac{n\pi x}{a} \right )\sinh\left ( \frac{n \pi y}{b} \right )\]

Where:

\[C_{n}=\frac{2}{n\pi\cosh\left ( \frac{n\pi x}{a} \right )}\left [ \int_{0}^{\frac{a}{2}}-q_{in}\sin\left (\frac{n\pi x}{a} \right )dx+\int_{\frac{a}{2}}^{a}-q_{out}\sin\left ( \frac{n\pi x}{a} \right )dx \right ]\]

Nowadays no one would dare to solve it by using a pen and a paper. Instead, we can take advantage of the computers to calculate approximate solutions using a certain number of iterations in the summation.

One great exercise I made in the past when learning Python was to implement this solution using this very friendly programming language. You can check the code in my repository on GitHub.

The boundary conditions considered in this solution result in this very cool temperature distribution presented in Figure 1.

 

Figure 1 - Temperature distribution of the plate.

More Python codes solving engineering problems related to heat transfer and fluid mechanics are going to show up in this blog. Stay tuned.

[1] Prof. Suman Chakraborty, Energy Equation. Department of Mechanical Engineering, IIT Kharagpur. Available at: <https://www.youtube.com/watch?v=k4zlxfUeNbE>. Accessed: 01 October 2023.

Nenhum comentário:

Postar um comentário