Development of a Sustainable Universal Python Code for Accurate 2D Heat Transfer Conduction Simulations in Educational Environment
Abstract
:1. Introduction
2. Literature Review
3. Proposed Theoretical Derivation
3.1. Numerical Solution
- Energy Balance Equation:
- 2.
- Fourier’s Law of Heat Conduction:
- 3.
- Derivation of Equation (2):
3.2. Analytical Solution
- x and y are coordinate points with reference to nodes;
- W is the width of the boundary condition;
- L is the length of the boundary condition.
- is the dimensionless temperature variable;
- x and y are in meters (m);
- L and W are in meters (m).
- Txy is the temperature at a specific node;
- T1 is the reference temperature (usually the initial temperature or the temperature at one boundary);
- T2 is the temperature at the other boundary;
- θ is the dimensionless temperature at the node of interest.
4. Proposed Work
4.1. Comparison between Analytical and Numerical Solution
4.2. Mesh Size Optimization
- W = 1;
- L = 1;
- T1 = 500 °C;
- T2 = 300 °C.
4.3. Manipulation of Equations Based on Orientation of Nodes
4.4. Utilization of Excel to Produce Irregular Shapes
4.5. Execution of Python Script
- Convert the Excel file into a readable 2D array for Python.
- Have a timer that starts once the script is executed and stops after the Gauss–Seidel iterations have been completed.
- Find all of the indexes of where the respective nodes in Table 6 are located in the 2D array converted from the Excel file.
- Repeatedly perform the specified equations for the respective nodes that have been identified.
- Use a Gauss–seidel iteration to obtain the results for 2D steady-state conduction heat transfer of irregular shapes with various boundary conditions.
- Produce the contour plot of the results obtained to show the heat spread within the irregular shape at steady-state.
- The flowchart which elaborates on the entire process of the Python script used is shown below in Figure 8. The Python script used can be found in Appendix A.
4.6. Use of Ansys to Validate Python Simulation
5. Measured Results
5.1. Validation Test between Analytical and Numerical Solution
- W = 1;
- L = 1;
- T1 = 500 °C;
- T2 = 300 °C;
- Mesh size is 5 × 5.
T(x,y) in °C | ||
---|---|---|
(0,0) | (0.25,0) | (0.5,0) |
(0,0.25) | 486.4 | 480.9 |
(0,0.5) | 463.6 | 450 |
(0,0.75) | 413.6 | 391.9 |
5.2. Mesh Size Testing Results
5.3. 2D Heat Transfer of Irregular Shapes Test
5.4. Limitations
6. Conclusions
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
Appendix A
References
- Qdot Systems. Boundary Conditions for the Heat Conduction Equation. Available online: https://qdotsystems.com.au/boundary-conditions-for-the-heat-conduction-equation/ (accessed on 23 May 2023).
- Dardashti, B.N.; Sedighi, M.R. Numerical Solution of Heat Transfer for Single and Multi-Metal Pan. Appl. Mech. Mater. 2011, 148–149, 227–231. [Google Scholar] [CrossRef]
- Silva, D. Heatrapy Source Code, Version 2.0.3. Available online: https://github.com/djsilva99/heatrapy/wiki (accessed on 3 June 2023).
- Harris, C.R.; Millman, K.J.; Van Der Walt, S.J.; Gommers, R.; Virtanen, P.; Cournapeau, D.; Wieser, E.; Taylor, J.; Berg, S.; Smith, N.J.; et al. Array programming with NumPy. Nature 2020, 585, 357–362. [Google Scholar] [CrossRef] [PubMed]
- Virtanen, P.; Gommers, R.; Oliphant, T.E.; Haberland, M.; Reddy, T.; Cournapeau, D.; Burovski, E.; Peterson, P.; Weckesser, W.; Bright, J.; et al. SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nat. Methods 2020, 17, 261–272. [Google Scholar] [CrossRef] [PubMed]
- Hunter, J.D. Matplotlib: A 2D graphics environment. Comput. Sci. Eng. 2007, 9, 90–95. [Google Scholar] [CrossRef]
- ANSYS Inc. Ansys GRANTA EduPack Software, Version 2023 R2. Available online: https://www.ansys.com/products/materials/granta-edupack (accessed on 10 October 2023).
- Cengel, Y.A.; Boles, M.A. Thermodynamics an Engineering Approach, 8th ed.; McGraw Hill: New York, NY, USA, 2015. [Google Scholar]
- Chisăliţă, G.-A.; Kapalo, P. Steady state two-dimensional heat conduction in a square cross section, by using Microsoft Excel® for numerical modeling. Rev. Romana Ing. Civila 2022, 13, 10–25. [Google Scholar] [CrossRef]
- Roy, A.K.; Kumar, K. 2D heat conduction on a flat plate with Ti6Al4V alloy under steady state conduction: A numerical analysis. Mater. Today Proc. 2021, 46, 896–902. [Google Scholar] [CrossRef]
- Incropera, F.P.; DeWitt, D.P.; Bergman, T.L.; Lavine, A.S. Fundamentals of Heat and Mass Transfer, 6th ed.; Wiley: Hoboken, NJ, USA, 2006. [Google Scholar]
- Tamma, K.K.; Namburu, R.R.; Ramesh, K.S. Computational Techniques for Heat Transfer and Fluid Flow Problems; Springer: Berlin/Heidelberg, Germany, 2004. [Google Scholar]
- Bartosik, A.S. Numerical Heat Transfer and Fluid Flow: New Advances. Energies 2023, 16, 5528. [Google Scholar] [CrossRef]
- Srinivasacharya, D.; Reddy, K.S. (Eds.) Numerical Heat Transfer and Fluid Flow: Select Proceedings of NHTFF 2018; Springer: Berlin/Heidelberg, Germany, 2019. [Google Scholar]
- Kok, C.L.; Chia, K.J.; Siek, L. A 87 dB SNR and THD+N 0.03% HiFi Grade Audio Preamplifier. Electronics 2024, 13, 118. [Google Scholar] [CrossRef]
- Versteeg, H.K.; Malalasekera, W. An Introduction to Computational Fluid Dynamics: The Finite Volume Method; Pearson Education: London, UK, 2007. [Google Scholar]
- Anderson, J.D. Computational Fluid Dynamics: The Basics with Applications; McGraw-Hill: New York, NY, USA, 1995. [Google Scholar]
- Bird, R.B.; Stewart, W.E.; Lightfoot, E.N. Transport Phenomena; John Wiley & Sons: Hoboken, NJ, USA, 2006. [Google Scholar]
- Langtangen, H.P. A Primer on Scientific Programming with Python; Springer: Berlin/Heidelberg, Germany, 2016. [Google Scholar]
- Oliphant, T.E. A Guide to NumPy; Trelgol Publishing: Provo, UT, USA, 2006. [Google Scholar]
- Downey, A.B. Think Python: How to Think like a Computer Scientist; O’Reilly Media: Sebastopol, CA, USA, 2012. [Google Scholar]
- Venkataraman, P. Applied Optimization with MATLAB Programming; John Wiley & Sons: Hoboken, NJ, USA, 2009. [Google Scholar]
- Farlow, S.J. Partial Differential Equations for Scientists and Engineers; John Wiley & Sons: Hoboken, NJ, USA, 1993. [Google Scholar]
- Burden, R.L.; Faires, J.D. Numerical Analysis; Brooks/Cole: Pacific Grove, CA, USA, 2010. [Google Scholar]
- Mitchell, A.R.; Griffiths, D.F. The Finite Difference Method in Partial Differential Equations; John Wiley & Sons: Hoboken, NJ, USA, 1980. [Google Scholar]
- Press, W.H.; Teukolsky, S.A.; Vetterling, W.T.; Flannery, B.P. Numerical Recipes: The Art of Scientific Computing; Cambridge University Press: Cambridge, UK, 2007. [Google Scholar]
- Duffy, D.G. Advanced Engineering Mathematics with MATLAB; CRC Press: Boca Raton, FL, USA, 2013. [Google Scholar]
- Lewis, R.W.; Nithiarasu, P.; Seetharamu, K.N. Fundamentals of the Finite Element Method for Heat and Fluid Flow; John Wiley & Sons: Hoboken, NJ, USA, 2004. [Google Scholar]
- Forsythe, G.E.; Malcolm, M.A.; Moler, C.B. Computer Methods for Mathematical Computations; Prentice-Hall: Saddle River, NJ, USA, 1977. [Google Scholar]
- Rubinstein, R.Y.; Kroese, D.P. Simulation and the Monte Carlo Method; John Wiley & Sons: Hoboken, NJ, USA, 2016. [Google Scholar]
- Lagaris, I.E.; Likas, A.; Fotiadis, D.I. Artificial neural networks for solving ordinary and partial differential equations. IEEE Trans. Neural Netw. 1998, 9, 987–1000. [Google Scholar] [CrossRef] [PubMed]
- Osaci, M. Numerical Simulation Methods of Electromagnetic Field in Higher Education: Didactic Application with Graphical Interface for FDTD Method. Int. J. Mod. Educ. Comput. Sci. 2018, 10, 1–10. [Google Scholar] [CrossRef]
- Suleman, M.; Gas, P. Analytical, Experimental and Computational Analysis of Heat Released from a Hot Mug of Tea Coupled with Convection, Conduction, and Radiation Thermal Energy Modes. Int. J. Heat Technol. 2024, 42, 359–372. [Google Scholar] [CrossRef]
- Kok, C.L.; Ho, C.K.; Tan, F.K.; Koh, Y.Y. Machine Learning-Based Feature Extraction and Classification of EMG Signals for Intuitive Prosthetic Control. Appl. Sci. 2024, 14, 5784. [Google Scholar] [CrossRef]
- Aung, K.H.H.; Kok, C.L.; Koh, Y.Y.; Teo, T.H. An Embedded Machine Learning Fault Detection System for Electric Fan Drive. Electronics 2024, 13, 493. [Google Scholar] [CrossRef]
- Chen, J.; Teo, T.H.; Kok, C.L.; Koh, Y.Y. A Novel Single-Word Speech Recognition on Embedded Systems Using a Convolution Neuron Network with Improved Out-of-Distribution Detection. Electronics 2024, 13, 530. [Google Scholar] [CrossRef]
- Kok, C.L.; Dai, Y.; Lee, T.K.; Koh, Y.Y.; Teo, T.H.; Chai, J.P. A Novel Low-Cost Capacitance Sensor Solution for Real-Time Bubble Monitoring in Medical Infusion Devices. Electronics 2024, 13, 1111. [Google Scholar] [CrossRef]
- Kok, C.L.; Ho, C.K.; Dai, Y.; Lee, T.K.; Koh, Y.Y.; Chai, J.P. A Novel and Self-Calibrating Weighing Sensor with Intelligent Peristaltic Pump Control for Real-Time Closed-Loop Infusion Monitoring in IoT-Enabled Sustainable Medical Devices. Electronics 2024, 13, 1724. [Google Scholar] [CrossRef]
Metal Name | Symbol | Thickness |
---|---|---|
Copper | Cu | 8 (mm) |
Aluminum | Al | 6.5 (mm) |
Stainless Steel | SSt | 2 (mm) |
Titanium | Ti | 2 (mm) |
Grey Cast Iron | GCI | 10 (mm) |
Carbon Steel | CSt | 10 (mm) |
Iron | Fe | 10 (mm) |
Node Type | Configuration | Finite-Difference Equation for |
---|---|---|
Interior node | ||
Node at an internal corner with convection | ||
Node at a plane surface with convection | ||
Node at an external corner with convection | ||
Node at a plane surface with insulation OR surface of symmetry |
Orientation | Diagram | Equation |
---|---|---|
North-West | ||
South-West | ||
North-East | ||
South-East |
Orientation | Diagram | Equation |
---|---|---|
East | ||
South | ||
West | ||
North |
Orientation | Diagram | Equation |
---|---|---|
North-East | ||
South-East | ||
North-West | ||
South-West |
Orientation | Diagram | Equation |
---|---|---|
East | ||
South | ||
West | ||
North |
Value Keyed into Cell | Orientation | Node Type |
---|---|---|
1 | - | Interior node |
2 | North-West | Internal corner nodes with convection |
3 | South-West | |
4 | North-East | |
5 | South-East | |
6 | East | Node at a plane surface with convection |
7 | South | |
8 | West | |
9 | North | |
10 | North-East | Node at an external corner with convection |
11 | South-East | |
12 | North-West | |
13 | South-West | |
14 | East | Node at a plane surface with insulation |
15 | South | |
16 | West | |
17 | North | |
18 | - | Null nodes that are unused |
T(x,y) in °C | ||
---|---|---|
(0,0) | (0.25,0) | (0.5,0) |
(0,0.25) | 485.7 | 480.4 |
(0,0.5) | 462.5 | 450 |
(0,0.75) | 414.3 | 394.6 |
T(x,y) in °C | ||||||||
---|---|---|---|---|---|---|---|---|
Excel (Analytical Solution) | Python (Numerical Solution) | Difference/(%) (Excel—Python Values) | ||||||
(0,0) | (0.25,0) | (0.5,0) | (0,0) | (0.25,0) | (0.5,0) | (0,0) | (0.25,0) | (0.5,0) |
(0,0.25) | 486.4 | 480.9 | (0,0.25) | 485.7 | 480.4 | (0,0.25) | 0.7/(0.14%) | 0.5/(0.10%) |
(0,0.5) | 463.6 | 450 | (0,0.5) | 462.5 | 450 | (0,0.5) | 1.1/(0.24%) | 0/(0.0%) |
(0,0.75) | 413.6 | 391.9 | (0,0.75) | 414.3 | 394.6 | (0,0.75) | −0.7/(−0.17%) | −2.7/(−0.69%) |
Mesh Size | Iterations Needed | Time Taken (s) |
---|---|---|
9 | 169 | 0.0327 |
17 | 613 | 0.262 |
33 | 2171 | 3.63 |
65 | 7537 | 50.0 |
129 | 25,547 | 684 |
257 | 83,781 | 8998 |
513 | 261,485 | 112,748 |
Node Test Conducted | Results (Python Script vs. Ansys) |
---|---|
Interior node | |
Internal corner node with convection | |
Plane node with convection | |
External corner node with convection | |
Insulated node OR surface of symmetry |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Kok, C.L.; Ho, C.K.; Taufik, A.S.B.M.; Koh, Y.Y.; Teo, T.H. Development of a Sustainable Universal Python Code for Accurate 2D Heat Transfer Conduction Simulations in Educational Environment. Appl. Sci. 2024, 14, 7159. https://doi.org/10.3390/app14167159
Kok CL, Ho CK, Taufik ASBM, Koh YY, Teo TH. Development of a Sustainable Universal Python Code for Accurate 2D Heat Transfer Conduction Simulations in Educational Environment. Applied Sciences. 2024; 14(16):7159. https://doi.org/10.3390/app14167159
Chicago/Turabian StyleKok, Chiang Liang, Chee Kit Ho, Abbas Syihan Bin Muhammad Taufik, Yit Yan Koh, and Tee Hui Teo. 2024. "Development of a Sustainable Universal Python Code for Accurate 2D Heat Transfer Conduction Simulations in Educational Environment" Applied Sciences 14, no. 16: 7159. https://doi.org/10.3390/app14167159