Heat Equation Sci Lab

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Heat simulation via Scilab programming

Mohammad Khatim Hasan, Jumat Sulaiman, and Samsul Arifin Abdul Karim

Citation: AIP Conference Proceedings 1605, 113 (2014); doi: 10.1063/1.4887574


View online: https://doi.org/10.1063/1.4887574
View Table of Contents: http://aip.scitation.org/toc/apc/1605/1
Published by the American Institute of Physics

Articles you may be interested in


Scilab software as an alternative low-cost computing in solving the linear equations problem
AIP Conference Proceedings 1813, 040005 (2017); 10.1063/1.4975970

Android-assisted physics mobile learning to improve senior high school students’ divergent thinking skills and
physics HOTS
AIP Conference Proceedings 1868, 070005 (2017); 10.1063/1.4995181

Development of single cell lithium ion battery model using Scilab/Xcos


AIP Conference Proceedings 1711, 060007 (2016); 10.1063/1.4941640
Heat Simulation via Scilab Programming
Mohammad Khatim Hasana , Jumat Sulaimanb and Samsul Arifin Abdul Karimc
a
Faculty of Information Science and Technology, Universiti Kebangsaan Malaysia, 43600 UKM Bangi, Selangor
b
School of Science and Technology, Universiti Malaysia Sabah, 88400 Kota Kinabalu, Sabah
c
Department of Fundamental and Applied Sciences, Universiti Teknologi Petronas, Bandar Seri Iskandar, Tronoh,
31750, Perak

Abstract. This paper discussed the used of an open source sofware called Scilab to develop a heat simulator. In this paper,
heat equation was used to simulate heat behavior in an object. The simulator was developed using finite difference method.
Numerical experiment output show that Scilab can produce a good heat behavior simulation with marvellous visual output
with only developing simple computer code.

Keywords: Heat simulation, finite difference method, differential equation, Scilab


PACS: 02.70.-c, 07.05.-t, 02.60.Lj, 44.10.+i

INTRODUCTION

Scilab software is a high-level programming language software. This software is an alternative to MATLAB,
Mathematica and MAPLE which was designed for math-based computing needs. The difference between Scilab
software with software such as MATLAB, Mathematica and MAPLE is Scilab is an open source software with no
annual license fees required. This software can be used to aid education and research.
In science and engineering, thermal behavior is often simulated using parabolic equations. This equation can
delegate any heat transfer process with initial and boundary temperature. Heat or diffusion equation is an example of
parabolic partial differential equation.
There are many scientific papers that discuss the solution of heat equation numerically. Veerapaneni and Biros
[1] for example has solved the problem one-dimensional heat equation with moving boundary conditions using
numerical methods using false spectral Chebyshev collocation method. In addition, Kumar [2] also introduced the
concept of modified numerical methods by simply choosing the appropriate value of the constant conductivity with
heat problems considered. Sahimi and Khatim [3] proposed a method called Reduced Iterative Alternating
Decomposition Explicit to solve parabolic problems. The method implements a temporary stage of solution.
Sulaiman et al [4] however, proposed Half-Sweep Iterative Alternating Decomposition Explicit method. The method
only considers half of the solution domain to be solved iteratively, while the other half solved directly. They [5] also
proposed Quarter-Sweep Iterative Alternating Decomposition Explicit method for parabolic problem. The method
only considers a quarter of the solution domain to be solved iteratively, while the rest solved directly.
In Introduction to Numerical Computation courses, students often have difficulties to imagine the role of
mathematics to study the behavior of heat transfer in a metal. This may be due to the focus of the program
developed in the course were displayed in numbers. To see visually, students should use the contour plots in Excel
software.
In this paper, we will discuss the development of a numerical program using Scilab. This program was developed
to facilitate students' appreciation on the capability of numerical methods in simulating the thermal behavior of a
metal rod and a rectangular metal plate.

FORMULATION AND SCILAB SOURCE CODE


In this paper, our experiences to develop Scilab program for simulating the behavior of heat transfer in a metal
rod and a rectangular plate is discussed. To simulate the behavior of heat transfer in a metal rod, the assumption
made was the problem can be represented by a one-dimensional heat equation given in equation

Proceedings of the 21st National Symposium on Mathematical Sciences (SKSM21)


AIP Conf. Proc. 1605, 113-118 (2014); doi: 10.1063/1.4887574
© 2014 AIP Publishing LLC 978-0-7354-1241-5/$30.00

113
డ௨ డమ ௨
డ௧
െ ߙ ቀడ௫ మ ቁ = 0 (1)

the solution domain R, (x, y) (0, a). Initial and boundary conditions given by ‫(ݑ‬0, ‫ݔ(݂ = )ݐ‬, ‫)ݐ‬, ‫ܾ(ݑ‬, ‫ݔ(݃ = )ݐ‬, ‫)ݐ‬,
and ‫ݔ(ݑ‬, 0) = ‫)ݔ(ݎ‬. The symbol Į in the heat equation is a constant thermal conductivity of a medium or object.
Consider a rod (Figure 1), which was heated at both ends with a constant temperature as shown in Figure 1.

Heated at a constant Heated at a constant


temperature temperature

FIGURE 1. Metal rods on two-dimensional view

To simulate the behavior of heat transfer numerically, the length of the rod should be represented by a number of
discrete points called nodal points. Representative rod with a nodal point (one-dimensional) described by Figure 2.

FIGURE 2. Metal rod is represented by the nodal points

The next step was to develop a numerical formulation for each nodal point. This formulation development can be
డ௨
done by using the finite difference approximation in equation (2) and (3). Note that, in equation (1) was estimated
డ௧
by the forward difference numerical approximation of the first order as given in equation (2).
డ௨ ௨೔ೖశభ ି௨೔ೖ
డ௧
= (2)
ο௧
డమ ௨
While, in equation (1) was estimated by a second order central difference as given in equation (3).
డ௫ మ

డమ ௨ ௨೔శభ ିଶ௨೔ೖ ା௨೔షభ

డ௫ మ
= (ο௫)మ
(3)

Substitution of equation (2)and (3)in equation (1)gives the equation (4).


డ௨ డమ ௨ ௨೔ೖశభ ି௨೔ೖ ೖ
௨೔శభ ିଶ௨೔ೖ ା௨೔షభ

డ௧
െ ߙ ቀడ௫ మ ቁ = െ ߙ൬ (ο௫) మ
൰ =0 (4)
ο௧

which can also be written as

‫ݑ‬௜௞ାଵ = ߛ‫ݑ‬௜ାଵ

+ (1 െ 2ߛ)‫ݑ‬௜௞ + ߛ‫ݑ‬௜ିଵ

(5)
ο௧
with ߛ = ߙ (ο௫)మ. Equation (5) is a numerical equation for each black nodal point in Figure 2. Scilab program

developed using equation (5) displayed in Source Code 1.


To develop a program that simulates the thermal behavior of a metal plate, we used a two-dimensional heat
equation. Two-dimensional heat equation is given by equation (6).
డ௨ డమ ௨ డమ ௨
డ௧
െ ߙ ቀడ௫ మ + డ௬ మ ቁ = 0 , (6)
with solution domain ܴ, (‫ݔ‬, ‫( א )ݕ‬0, ܽ) × (0, ܾ). Initial and boundary conditions given by
‫(ݑ‬0, ‫ݕ‬, ‫ݔ(݂ = )ݐ‬, ‫ݕ‬, ‫)ݐ‬, ‫ܾ(ݑ‬, ‫ݕ‬, ‫ݔ(݃ = )ݐ‬, ‫ݕ‬, ‫)ݐ‬, ‫ݔ(ݑ‬, 0, ‫ݔ(݌ = )ݐ‬, ‫ݕ‬, ‫)ݐ‬, ‫ݔ(ݑ‬, ܾ, ‫ݔ(ݍ = )ݐ‬, ‫ݕ‬, ‫ )ݐ‬and ‫ݔ(ݑ‬, ‫ݕ‬, 0) = ‫ݔ(ݎ‬, ‫)ݕ‬.
Constant Į in the heat equation is a constant thermal conductivity of a medium or object. Consider the two-
dimensional metal plate in Figure (3).

114
function [MasaSimulasi]=PensimulasiRodHaba1(HabaKiri,
HabaKanan, Tawal, PanjangRod, Masa_T, sela_masa, sela_jarak, eps,
alpha) colorbar(kecil,besar);
funcprot(0) T_new=T;
T=[]; Lamda=alpha*(sela_masa/(sela_jarak ^ 2));
Ralat=[]; if (Lamda>0.5) & (Lambda<0) then
GelungMaks=Masa_T/sela_masa; disp("Kaedah Tidak Stabil, sila masukkan sela_masa dan
MakNod=PanjangRod/sela_jarak; Jarak yang lain");
//syarat awal break;
for i=2:MakNod-1 end
T(i)=Tawal; counter=0;
end tic();
for j=1:2 for counter=1:GelungMaks
T(1,j)=HabaKiri; T=T_new;
T(MakNod,j)=HabaKanan; for i=2:MakNod-1
end T_new(i,1)= Lamda*T(i+1,1)+(1-
x=1:MakNod; 2*Lamda)*T(i,1)+Lamda*T(i-1,1)
y=1:2; T_new(i,2)=T_new(i,1);
show_window(); end
clf(); for j=1:2
f=gcf(); T(1,j)=HabaKiri;
f.color_map=jetcolormap(256); T(MakNod,j)=HabaKanan;
f.pixmap='on'; end
if HabaKiri<HabaKanan then z=T_new;
kecil=HabaKiri; Sgrayplot(x,y,z,strf="146",zminmax=[kecil,besar])
besar=HabaKanan; xtitle("Simulasi Haba")
else show_pixmap();
kecil=HabaKanan; MasaSimulasi=toc()
besar=HabaKiri; endfunction
end

Source Code 1. Scilab source code to simulate the thermal behavior of metal rods.

FIGURE 3. Rectangular Metal plate FIGURE 4. Metal plate represented by the nodal points

To simulate the behavior of heat transfer numerically, the metal plate should be represented by nodal points.
Representative of the metal plate with nodal points described by Figure 4. The next step is to develop a numerical
formulation for each nodal point. This formulation development can be done by using the finite difference
డ௨
approximation in equation (7), (8) and (9). Note, in equation (6) can be estimated by the forward difference
డ௧

numerical approximation of the first order as given in equation (7).


ೖశభ ೖ
డ௨ ௨೔,ೕ ି௨೔,ೕ
డ௧
= (7)
ο௧

115
డమ ௨
While, in equation (6) was estimated by second order central difference approximation as given in equation (8).
డ௫ మ
ೖ ೖ ೖ
డమ ௨ ௨೔శభ,ೕ ିଶ௨೔,ೕ ା௨೔షభ,ೕ
డ௫ మ
= (ο௫)మ
(8)
డమ ௨
in equation (6) was estimated by second order central difference approximation as given in equation (9).
డ௬ మ
ೖ ೖ ೖ
డమ ௨ ௨೔,ೕశభ ିଶ௨೔,ೕ ା௨೔,ೕషభ
డ௬ మ
= (ο௬)మ
(9)
Substitution of equation (7), (8) and (9) into equation (6) gives equation (10).
ೖశభ ೖ ೖ ೖ ೖ ೖ ೖ ೖ
డ௨ డమ ௨ డమ ௨ ௨೔,ೕ ି௨೔,ೕ ௨೔శభ,ೕ ିଶ௨೔,ೕ ା௨೔శభ,ೕ ௨೔,ೕశభ ିଶ௨೔,ೕ ା௨೔,ೕషభ
డ௧
െ ߙ ቀడ௫ మ + డ௬ మ ቁ = െ ߙ൬ (ο௫)మ
+ (ο௬)మ
൰ = 0, (10)
ο௧
which can also be written as
‫ݑ‬௜௞ାଵ = ߛଵ ‫ݑ‬௜ାଵ,௝
௞ ௞
+ ߛଵ ‫ݑ‬௜ିଵ,௝ + (1 െ 2ߛଵ െ 2ߛଶ )‫ݑ‬௜௞ + ߛଶ ‫ݑ‬௜,௝ାଵ
௞ ௞
+ ߛଶ ‫ݑ‬௜,௝ିଵ (11)
ο௧ ο௧
with ߛଵ = ߙ (ο௫)మ and ߛଶ = ߙ (ο௬)మ . Equation (11) was use to simulate heat for each black nodal points in Figure 4.
Scilab source code developed using equation (11) displayed in Source Code 2. For ease of programming, this paper
only analyzed the thermal behavior for ο‫ = ݔ‬ο‫ ݕ‬which implicates ߛଵ = ߛଶ = ߛ. In this experiment only ߛ = 0.05
was considered.

funcprot(0) show_window(); clf()


function [masa_komputasi]=PensimulasiHaba2D(dt, T_sempadan, f=gcf();
T_awal, Maks) f.color_map=jetcolormap(256);
T=[]; f.pixmap='on';
//sempadan bawah colorbar(0,100);
for i=1:20, T_new=T;
T(i,1)=T_sempadan; tic();
end for counter=1:Maks,
T=T_new;
//sempadan atas for i=2:19,
for i=1:20, for j=2:19,
T(i,20)=T_sempadan; T_new(i,j)=Lamda*(T(i-1,j)+T(i+1,j)+T(i,j-1)+T(i,j+1)-
end 4*T(i,j))+T(i,j);
end
//sempadan kiri end
for j=1:20, z=T_new;
T(1,j)=T_sempadan;
end x=1:20;
y=1:20;
//sempadan kanan Sgrayplot(x,y,z, strf="042",rect=[-5 2 25 40],
for j=1:20, zminmax=[0,100])
T(20,j)=T_sempadan; show_pixmap();
end end
//nilai awal masa_komputasi=toc();
for i=2:19, endfunction
for j=2:19,
T(i,j)=T_awal;
end
end

Source Code 2. Scilab source code to simulate the thermal behavior of the metal plate.

NUMERICAL EXPERIMENTS AND SIMULATIONS


In this paper, several numerical experiments were performed to see the simulations performance using both
programs. For Source Code 1, the input data is
i. Left heat = 100, Right heat = 500, initial temperature = 0, length = 10 cm rods, Simulation time = 10
seconds, interval = 0.01 sec, gap distance = 1 cm, epsilon = 0.01, alpha = 1.

116
ii. Left heat = 100, Right heat = 500, initial temperature = 150, length = 10 cm rods, Simulation time = 10
seconds, interval = 0.01 sec, gap distance = 1 cm, epsilon = 0.01, alpha = 1.
iii. Left heat = 300, Right heat = 500, initial temperature = 150, length = 10 cm rods, Simulation time = 10
seconds, interval = 0.01 sec, gap distance = 1 cm, epsilon = 0.01, alpha = 1.

Simulation results using Source Code 1 was displayed in Figure 5.

Computation Initial stage Final stage


time

Experiment i:
302.72

Experiment ii:
239.87

Experiment iii:
458.88

FIGURE 5. Simulation results for heat transfer in metal rod experiments


Three two-dimensional heat conduction problems solved using Source Code 2. Input data involved was
i. Temperature in all the border set to 100oC, the initial temperature is set to 20oC
ii. Temperature in all the border set to 100oC, the initial temperature is set to 50oC
iii. Temperature in all the border set to 100oC, the initial temperature is set to 40oC

Simulation results using Source Code 2 was displayed in Figure 6. Figures 5 and 6 clearly show Scilab can be used
to help students understand the thermal behavior of metal rods and plates. The resulting simulations convince
students the application of numerical methods to enable simulation of problems in science and technology.

CONCLUSIONS
Source code development using Scilab software can save development time especially if the output is a graphical
program. Generated graphics simulations can provide insight to students about thermal behavior of metal rods and
plates. These outputs convince students on the use of numerical methods in producing simulations to problems in
science and technology.

117
Computation Initial stage Final stage
time

Experiment i:
5625.18

Experiment ii:
18973.43

Experiment iii:
671.31

FIGURE 6. Simulation results for heat transfer in metal plate experiments

ACKNOWLEDGMENTS
We acknowledge the fund supported by Ministry of Education, FRGS/1/2013/ICT07/UKM/02/4.

REFERENCES
1. S. K. Veerapaneni and G. Biros, SIAM Journal of Scientific Computation 29(6), 2581-2606 (2007).
2. V. Kumar, “High Accurate Solver for Heat Equation using Modified Equation Approach” in International Conference of
Numerical Analysis and Applied Mathematics, AIP Conference Proceedings 1281, American Institute of Physics, Melville,
NY, 2010, pp. 562-565.
3. M. S. Sahimi and M. Khatim, Pertanika Journal of Science and Technology 9(1), 13-20 (2001).
4. J. Sulaiman, M. K. Hasan and M. Othman, “The Half-Sweep Iterative Alternating Decomposition Explicit (HSIADE)
Method for Diffusion Equation” in Computational and Information Sciences 2004, edited by J. Zhang et al. ,
Lecture Notes in Computer Science 3314, Springer Verlag, Berlin-Heidelberg, 2004, pp. 57-63.
5. J. Sulaiman, M. Othman and M. K. Hasan, International Journal of Computer Mathematics 81(12), 1559-1565 (2004)

118

You might also like