You are on page 1of 80

MAJOR PROJECT REPORT

ON
DEVELOPMENT OF A MATLAB APP USING FINITE DIFFERENT
SOLUTION FOR HEAT TRANSFER PROBLEMS

submitted in partial fulfillment of requirements for the award of the degree of


BACHELOR OF TECHNOLOGY
IN
MECHANICAL ENGINEERING
by
TURLAPATI SHIVA SRINIVASA RAHUL BHARADWAJ 17011A0325
VAMSHI MADHAV NYATHAWADA 17011A0338
GADE YASWANTH 17011A0342
NARAYANDAS ROHITH 18015A0319

Under the esteemed guidance of


DR. P. BHRAMARA
PROFESSOR OF MECHANICAL ENGINEERING

DEPARTMENT OF MECHANICAL ENGINEERING


JNTUH COLLEGE OF ENGINEERING HYDERABAD
KUKATPALLY- 500085
2021

DEPARTMENT OF MECHANICAL ENGINEERING


JNTUH COLLEGE OF ENGINEERING HYDERABAD
KUKATPALLY- 500085
2021

CERTIFICATE
This is to certify that the project entitled “Development Of A MATLAB
App Using Finite Different Solution For Heat Transfer Problems” a group
project submitted as a part of the curriculum of the requirements for the
Bachelor’s degree in Mechanical Engineering to JAWAHARLAL NEHRU
TECHNOLOGICAL UNIVERSITY, Hyderabad.

By:
TURLAPATI SHIVA SRINIVASA 17011A0325
RAHUL BHARADWAJ
VAMSHI MADHAV 17011A0338
NYATHAWADA
GADE YASWANTH 17011A0342
NARAYANDAS ROHITH 18015A0319

Project guide: Head of the department:


DR. P. BHRAMARA DR. A.V. S. S. K. S. GUPTA
Professor, JNTUHCEH Professor and Head of the department
Dept. of Mechanical Engineering Dept. of Mechanical Engineering
JNTUHCEH, Hyderabad JNTUHCEH, Hyderabad
Telangana, India Telangana, India
DEPARTMENT OF MECHANICAL ENGINEERING
JNTUH COLLEGE OF ENGINEERING HYDERABAD
KUKATPALLY- 500085
2021

DECLARATION BY CANDIDATE

We hereby declare that the project report entitled as DEVELOPMENT OF A


MATLAB APP USING FINITE DIFFERENT SOLUTION FOR HEAT
TRANSFER PROBLEMS is carried out by us during the year 2021 in partial
fulfilment of the requirements for the award of the degree of BACHELOR OF
TECHNOLOGY in MECHANICAL ENGINEERING at JAWAHARLAL
NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD COLLEGE
OF ENGINEERING HYDERABAD.
We have not submitted the same to any University/Institute for the award of any
degree or diploma.

TURLAPATI SHIVA SRINIVASA RAHUL BHARADWAJ (17011A0325)


VAMSHI MADHAV NYATHAWADA (17011A0338)
GADE YASWANTH (17011A0342)
NARAYANDAS ROHITH (18015A0319)
Acknowledgements
We write this acknowledgment with great honor, pride, and pleasure to express
our special thanks of gratitude to all people who enabled us either directly or
indirectly in doing this major project.

We wish to express our sincere thanks to our guide Dr. BHRAMARA


PANITAPU for her guidance, suggestions and inspiration in carrying out the
major project. Working under her supervision greatly contributed in improving
the quality of our work and developed our management skills.

We would also like to thank Dr. A.V.S.S.K.S GUPTA Professor and Head of
the Department of Mechanical Engineering for his motivation and support
extended.

We would also like to thank the Professor and Principal, Dr. A. PRABHU
KUMAR and all the staff members of JNTUHCEH and DEPARTMENT OF
MECHANICAL ENGINEERING for providing support and opportunity.
Abstract
Heat transmission is a regular occurrence in almost every engineering application.
We must evaluate the average heat transfer that occurs during a procedure in order
to attain good results. Heat transfer is a discipline of thermal engineering that
concerns the generation, use, conversion, and exchange of thermal energy (heat)
between physical systems. Thermal conduction, thermal convection, thermal
radiation, and energy transfer via phase shifts are all examples of heat transfer
methods. The Finite Difference Method is one of the simpler methods for
resolving heat transfer problems. The use of central differences in the solution of
partial differential equations is beneficial. If data values from the past and future
are available, the numerical derivative should be approximated by the central
difference method. Solving so many problems using such an easier method is also
a bit difficult. So, in order to avoid the difficulty, it is a necessity to have an
alternative which is fast and also solves the problem as per the given situation.
Computer programming can be utilised to create an application that assists us in
calculating all of the relevant parameters for the analysis. Because the central
difference method is based on matrix solving, it is best to use a programming
language that has simpler programs for solving specific matrices. MATLAB
provides a simple compiler for solving matrices because it treats each attribute
value as a matrix. So, if a computer programme exists to simplify the calculations
and allow professionals with expertise in other aspects of engineering to properly
calculate and estimate the required parameters, it would be extremely beneficial.
The goal of this project is to create such an app.
CONTENTS
1. INTRODUCTION…………...…………………………………………...1
1.1. Numerical Methods………………...……………………………...3
1.2. Analytical Methods…………………...…………………………...3
1.3. Experimental Methods…………………...………………………..3
1.4. Errors Involved in Numerical Methods……………...…………….4
2. FINITE DIFFERENCE METHOD………………..……………………..5
2.1. Higher Order Difference…………..………………………………6
2.2. Methods to Solve FDM Equations……………..………………….7
3. APPLICATION OF FDM IN HEAT TRANSFER…..…..……………..10
3.1. Plane Slab...…………………………..………………..…………10
3.2. Fins……………………..……………………………..………….11
3.3. Transient Heat Conduction………..…………………..………….12
3.4. Discretization of Boundary Conditions…..………..……………..14
4. INTRODUCTION TO MATLAB……………..…………..……………16
4.1. Main Features and Capabilities of MATLAB…..…..……………16
4.2. MATLAB System……………………..…….…………………...17
4.3. Advantages of MATLAB………….……..………………………18
4.4. Disadvantages of MATLAB…………..…………………………19
4.5. MATLAB App Designer……………….………………………..19
5. APP DEVELOPMENT USING FDM…….……………………………22
5.1. Algorithm…………………………….…………………………..22
5.2. Code Behind Temperature Distribution Plotter….………………24
5.3. Instructions to Install the App…………………….……………...35
5.4. Instructions to Use Temperature Distribution Plotter……………36
5.5. Advantages of Temperature Distribution Plotter………………...37
5.6. Drawbacks of Temperature Distribution Plotter…………………37
6. RESULTS AND COMPARISONS……………………………………..38
6.1. Plane Slab………………………………………………………...38
6.2. Fins………………………………………………………….……54
6.3. Transient Heat Conduction………………….……………………66
7. CONCLUSIONS………………………………………………………..70

REFERENCES……………………………………………………………..71
LIST OF FIGURES

FIG. NO. DESCRIPTION PAGE NO.

4.1 MATLAB System 18

4.2 Design View Window in App Designer 20

4.3 Code View Window in App Designer 20

5.1 Installation Window 35

5.2 Temperature Distribution Plotter App Interface 36

6.1 Discretization of Physical Domain for Problem 1 38

6.2 Input Values for Problem 1 42

6.3 Result for Problem 1 42

6.4 Discretization of Physical Domain for Problem 2 43

6.5 Input Values for Problem 2 48

6.6 Result for Problem 2 48

6.7 Discretization of Physical Domain for Problem 3 49

6.8 Input Values for Problem 3 53

6.9 Result for Problem 3 53

6.10 Discretization of Physical Domain for Problem 4 54

6.11 Input Values for Problem 4 59


6.12 Result for Problem 4 59

6.13 Discretization of Physical Domain for Problem 5 60

6.14 Input Values for Problem 5 65

6.15 Result for Problem 5 65

6.16 Discretization of Physical Domain for Problem 6 66

6.17 Input Values for Problem 6 69

6.18 Result for Problem 6 69

LIST OF TABLES

TABLE NO. DESCRIPTION PAGE NO.

Table 6.1 Solution obtained from FDM method and Analytical 41


method for Problem 1

Table 6.2 Solution obtained from FDM method and Analytical 47


method for Problem 2

Table 6.3 Solution obtained from FDM method and Analytical 52


method for Problem 3

Table 6.4 Solution obtained from FDM method and Analytical 58


method for Problem 4

Table 6.5 Solution obtained from FDM method and Analytical 64


method for Problem 5

Table 6.6 Solution obtained from FDM method and Analytical 68


method for Problem 6
LIST OF GRAPHS
GRAPH NO. DESCRIPTION PAGE NO.

Graph 6.1 Comparison of FDM Solution and Analytical 41


Solution for Problem 1

Graph 6.2 Comparison of FDM Solution and Analytical 47


Solution for Problem 2

Graph 6.3 Comparison of FDM Solution and Analytical 52


Solution for Problem 3

Graph 6.4 Comparison of FDM Solution and Analytical 58


Solution for Problem 4

Graph 6.5 Comparison of FDM Solution and Analytical 64


Solution for Problem 5

Graph 6.6 Comparison of FDM Solution and Analytical 68


Solution for Problem 6
1. INTRODUCTION
Heat transfer is a discipline of thermal engineering that concerns the
generation, use, conversion, and exchange of thermal energy (heat) between
physical systems. Heat transfer is classified into various mechanisms, such
as thermal conduction, thermal convection, thermal radiation, and transfer of
energy by phase changes. As opposed to functions of state, heat transfer is a
process function (or path function); thus, the amount of heat transferred in a
thermodynamic process that changes the state of a system depends on how that
process occurs, not just the net difference between the initial and final states of
the process. There are 4 fundamental modes of heat transfer.
• Advection
• Conduction
• Convection
• Radiation

Advection might be considered as a type of convection.


Conduction is the transfer of heat energy through collisions between
neighbouring atoms or molecules. The conductive heat transfer can be analysed
by the Fourier law. It states that the rate of the heat transfer through a material is
proportional to the negative gradient in the temperature to the area, at the right
angles to the gradient, through which the heat flows. Newton’s law of cooling is
a distinct analogue of the Fourier law.
q = −k∇T
where,
q= heat transfer rate, W/m2
k=The conductivity of the material, W/m. k
∇T=Temperature Gradient, k
Convection is the type of heat transfer that occurs due to the movement of
the fluid from one place to the other. Convection is the combination of
Conduction and advection. Since there is a similarity between the conduction and
convection, the Newton’s law of cooling which is an analogue for Fourier
Transformation can be used for the analysis. It states that the rate of heat loss of
a body is proportional to the temperature difference between the body and its
surroundings when subjected to the effects of a breeze.

1
Q = hA(T − Tf )b
where,
Q=heat transferred per unit time, W/s
h= heat transfer coefficient, W/m2. K
A= area of the object, m2
T= object’s surface temperature, K
Tf = fluid temperature, K

Radiation is the type of heat transfer that occurs through the vacuum by
means of Electromagnetic waves. Thermal radiation is emitted by all the matter
which is above the absolute 0 temperature. Radiation is governed by Stefan-
Boltzmann law. The law states that the total energy radiated per unit surface area
of a black body across all wavelengths per unit time (also known as the black-
body radiant emittance) is directly proportional to the fourth power of the black
body's thermodynamic temperature.
Q = ∈ σF(Ta4 − Tb4 )
where,
Q= heat flux
∈= emissivity
𝜎= Stefan-Boltzmann constant
Ta, Tb = Absolute temperatures
F= view factor
The other modes of heat transfer are through boiling and condensing.
The heat transfer problems even though appear easy to calculate, need to
consider a lot of other factors on which the heat transfer depends. The solution
for the heat transfer problems can be formulated in mainly 3 ways:
1. Numerical Methods
2. Analytical Methods
3. Experimental Methods

2
1.1 Numerical Methods
A numerical method is a mathematical tool for resolving numerical issues. A
numerical algorithm is a computer language implementation of a numerical
technique with an acceptable convergence check.
Let be F(x,y)=0 a well-posed problem, i.e. F:X*Y→R is a real or complex
functional relationship, defined on the cross-product of an input data set X and
an output data set Y ,such that there exists a Lipschitz function g:X→Y called
resolvent, which has the property that for every root of (x, y) of F, y=g(x). We
define numerical method for the approximation of F (x, y) =0.
A numerical model is said to be convergent when a series of model solutions
with increasingly refined solution domains approaches a fixed value.
Furthermore, a numerical model is consistent if the sequence converges to the
solution of the continuous equations governing the physical phenomenon being
modelled. That is, if the numerical method used is convergent, the solution will
be consistent for every problem we attempt to solve with it.
There are about a few methods for performing numerical heat transfer analysis.
1. Finite Difference Method
2. Finite Volume Method
3. Galerkin Finite Element Method
4. Spectral Method etc.

1.2 Analytical Methods:


An analytical solution entails framing the problem in a clear manner and
calculating the exact solution. Analytic methods present formulas that can be used
to present solutions to mathematical problems with or without the use of
numerical methods, using exact theorems. Analytical methods are the most
rigorous, providing exact solutions, but they are difficult to apply to complex
problems. The formulae like Newton’s law of cooling, Fourier law and Stefan
Boltzmann law, Lumped analysis etc. are the examples of Analytical methods of
solving the given heat transfer problem.

1.3 Experimental Methods:


The experimental process involves carrying out an experiment on a similar
setup for the required problem and deducing the required output from it. It is
frequently difficult to recreate or even attempt to reach the problem parameters

3
using the experimental setup. As a result, there will frequently be a deviation from
the exact solution. The experimental process involves manipulating one variable
to see if changes in one variable cause changes in another. The different steps
involved in this method are:
Step 1- Make observations
Step 2- Form a hypothesis
Step 3- Make a prediction
Step 4- Perform an experiment
Step 5- Analyse the result of the experiment
Step 6- Draw conclusion
Step 7- Report the result

1.4 Errors Involved In Numerical Methods


In the solution of differential equations with finite differences, real numbers
are represented in “floating point” form and, as a result, errors are caused due to
the rounding off of the real numbers. And also in finite difference representation
of derivatives with Taylor’s series expansion, the higher order terms are neglected
by truncating the series; the error caused as a result of such truncation is called
the truncation error. Discretization error is commonly used to identify the error
due to the truncation error.
Total Error in finite difference calculations consisting of the discretization
error plus the round-off error. The discretization error increases with increasing
mesh size, while the round-off error decreases with increasing mesh size.
Therefore, the total error is expected to exhibit a minimum as the mesh size is
decreased.

4
2. FINITE DIFFERENCE METHOD

Finite difference is expressed mathematically as f (x + b)f (x + a). A difference


quotient is obtained by dividing a finite difference by b a. The approximation of
derivatives by finite differences is central to finite difference methods for
numerically solving differential equations, particularly boundary value problems.
Brook Taylor introduced finite differences in 1715, and they have since been
studied as abstract self-standing mathematical objects in works by George Boole
(1860), L. M. Milne-Thomson (1933), and Károly Jordan (1939). Finite
differences can be traced back to one of Jost Bürgi's algorithms (c. 1592), as well
as work by others such as Isaac Newton.
There are three basic types of finite differences that are commonly
considered: forward, backward, and central finite differences.
A forward difference is an expression of the form:
∆𝑓(𝑥) = 𝑓(𝑥 + ℎ) − 𝑓(𝑥)
A backward difference is an expression of the form
𝛻𝑓(𝑥) = 𝑓(𝑥) − 𝑓(𝑥 − ℎ)
Finally, the central difference is provided by:
ℎ ℎ
𝛿𝑓(𝑥) = 𝑓 (𝑥 + ) − 𝑓 (𝑥 − )
2 2
Finite difference methods (FDMs) are fast, accurate, and easy to use for
solving partial differential equations (PDEs). The continuous domain is
discretized using FDM, and the differential terms of the equation are converted
into a linear algebraic equation, known as a finite-difference equation.
The FDM is a very versatile modelling technique that is relatively simple
for users to understand and apply. Finite Difference Methods (FDM) can provide
a comprehensive view of the problem, allowing you to track the calculations.
Furthermore, it can handle a variety of boundary and initial conditions with ease.

5
2.1 Higher Order Differences:
In a similar manner, finite difference approximations to higher order
derivatives and differential operators can be obtained. For example, using the
h h
above central difference formulas for f ′(x + ) and f ′(x − ) and a central
2 2
difference formula for the derivative of f’ at x, we obtain the central difference
approximation of f's second derivative:
Second order central:
ℎ ℎ
𝑓 (𝑥 + ) 𝑓 (𝑥 − )
2 − 2
𝑓 ′′ (𝑥) = ℎ ℎ

Which equates to:
𝑓(𝑥 + ℎ) − 2𝑓(𝑥) + 𝑓(𝑥 − ℎ)
𝑓 ′′ (𝑥) =
ℎ2
Second order forward:
𝑓(𝑥 + 2ℎ) − 2𝑓(𝑥 + ℎ) + 𝑓(𝑥)
𝑓 ,, (𝑥) =
ℎ2
Second order backward:
𝑓(𝑥) − 2𝑓(𝑥 − ℎ) + 𝑓(𝑥 − 2ℎ)
𝑓 ,, (𝑥) =
ℎ2
Finite Difference method is derived from the Taylors theorem

𝑓 (𝑛) (𝑎) 𝑛
𝑓 1 (𝑎) 𝑓 (𝑛) (𝑎)
∑ (𝑥 − 𝑎) = 𝑓(𝑎) + (𝑥 − 𝑎) + ⋯ + (𝑥 − 𝑎)𝑛
𝑛! 1! 𝑛!
𝑛=0

Despite the simplicity of the finite difference representation of governing


partial differential equations, selecting the appropriate scheme for a specific
problem requires considerable experience and knowledge. The number of
physical dimensions, the type of partial differential equations, the coordinate
system used, whether or not the governing equations and whether the boundary
conditions are linear or nonlinear, and whether the problem is linear or nonlinear
are one of the factors influencing the type of numerical scheme chosen from a
large number of options is whether it is steady-state or transient.
The choice of a particular finite differencing scheme in the solution of partial
differential equations with finite differences is also dependent on the type of

6
partial differential equation considered. Partial differential equations are divided
into three types: elliptic, parabolic, and hyperbolic. To illustrate, consider
Forsythe and Wasow's (1967) general second-order partial differential equation
with two independent variables x, y:
𝜕2 ϕ 𝜕2 ϕ 𝜕2 ϕ ∂ϕ ∂ϕ
A +B +C +D +E + Fϕ + G(x,y)=0
𝜕𝑥 2 𝜕𝑥𝜕𝑦 𝜕𝑥 2 𝜕𝑥 𝜕𝑦

In this case, we assume a linear equation (this restriction is optional), which


means that the coefficients A, B, C, D, E, and F, as well as the known source term
G, are functions of the two independent variables x and y but not of the dependent
variable. The partial differential equation's mathematical nature is determined by
the coefficients of the higher order terms, A, B, and C. The partial differential
equation at (x0, y0) is known as:

Elliptic, if B2 − 4AC < 0,


Parabolic, if B2 – 4AC = 0,
Hyperbolic, if B2 – 4AC > 0.

2.2 Methods to Solve FDM Equations:


To solve the FDM equations, we must first simplify the problem. This is
accomplished by converting the partial differential equations into algebraic
equations.
The methods for solving such a system of algebraic equations can be
classified into two types:
• Direct methods involving a finite number of operations in the solution
• Iterative techniques in which answers become more accurate as the
number of iterations increases, provided that the convergence criterion
related to the diagonal dominance of the coefficient matrix is satisfied

There are two important methods in the direct method:


• Gauss Elimination
• Thomas Algorithm

Gauss Elimination is a straightforward method for solving simultaneous


algebraic equations. The coefficient matrix is transformed into an upper triangular
matrix using a systematic set of algebraic operations, while the solution to the
system of equations remains invariant. The two main operations used are:

7
• Multiplication or division of any equation by a constant.
• Replacement of any equation by the sum (or difference) of that equation
with any other equation

For example, consider the equations:


ax+by+cz=l
dx+ey+fz=m
gx+hy+iz=n
We use the two operations mentioned above to first change the equations to:
ax+by+cz=l*
0x+e*y+f*z=m*
0x+h*y+i*z=n*
Then we try to make b, h* as 0
a*x+0y+c*z=l**
0x+e*y+f*z=m**
0x+0y+i**z=n**
Then we try to make c*, f* as 0
a**x+0y+0z=l***
0x+e**y+0z=m***
0x+0y+i**z=n***
By solving these 3 simplified equations we find the value of x, y and z.
The Gauss elimination method can be further simplified in the case of a
tridiagonal system of algebraic equations, such as the one encountered in the
solution of one-dimensional heat conduction problems, by taking advantage of
the zeros of the tridiagonal coefficient matrix. This is done by using Thomas
algorithm. Consider an N-element algebraic equation system with a tridiagonal
coefficient matrix given by equation. The elimination process described here is
used to convert the matrix of coefficients into upper diagonal form in order to
solve this system of equations:

8
b1 c1 0 … … 0 0 T1 d1
a2 b2 c2 … … 0 0 T2 d2
0 a3 b3 … … 0 0 T3 d3
: : : : : : : : = :
: : : : : : : : :
0 0 0 … … bN−1 cN−1 TN−1 dN−1
[0 0 0 … … aN bN ] [ TN ] [ dN ]

Step 1: The first equation (row) is chosen as the “pivot,” multiplied by “a2/b1”
and subtracted from the second equation (row) to eliminate a2. The resulting
second equation is equivalent to
a ∗c
replacing “b2” by b2 - 2 1
b1
a2 ∗d1
replacing “d2” by d2 -
b1

Step 2: The modified second equation is chosen as the “pivot,” and a similar
approach is followed to eliminate a3. The resulting third equation is equivalent to
a ∗c
Replacing “b3” by b3 - 3 2
b2
a3 ∗d2
Replacing “d3” by d3 -
b2

This process is continued till the triangular form is achieved. Once the
triangular form is achieved the values of unknown variables are found out using
back substitution, starting from last equation to backwards.

9
3. APPLICATION OF FDM IN HEAT TRANSFER
Finite difference method can be used for solving heat transfer problems by
substituting the derivates in their mathematical model with forward, backward
or central difference formulae.
This process is explained in detailed for plane slab, fins and transient heat
conduction, in the following sections.
3.1 Plane Slab
The governing equation for one-dimensional, constant property, steady-
state diffusion in a plane slab is:
d2 T q
+ =0 ---1
dx2 k
The first step in the finite difference method is to construct a grid with points
on which we are interested in solving the equation (this is called discretization).
The next step is to replace the continuous derivatives with their finite difference
approximations. The derivatives can be approximated by the central difference as
∂2 T (Ti+1 −2Ti +Ti−1 )
= ---2
∂x2 ∆x2

∂T Ti+1 −Ti−1
= ---3
∂x 2∆x

We now substitute the value of 2 in 1. It makes that equation


q∗(∆x)2
Ti−1 − 2Ti + Ti+1 = −
k

Now nodal equations are written for n=1, 2,….


The next step is to specify the boundary conditions at both ends. The different
types of boundary conditions are:
• Dirichlet: We know the initial temperatures on both ends.
• Neumann: We know an initial temperature on an end and a derivative
temperature at the other.
• Robin: We know the differential equations which the system follows to
obtain its temperatures.

Now the boundary conditions are discretized and the nodal equations are
modified accordingly.
This set of linear equations are now represented in the form of AX=B.
where,
A is coefficient matrix
B is constant matrix

10
These are now solved and the required temperature distribution is obtained.

3.2 Fins
The fin is typically used when the convection heat transfer coefficient is low,
particularly when free convection is present. The fin is widely used in industry,
for example, electronic accessories, motorcycles, air cooling cylinders of lawn
mowers, and cooling fins attached to refrigerators. As a result, calculating the
heat through the fin surface is very useful.
The steady-state heat flow problems through fins or extended surfaces are
typical examples of one-dimensional heat conduction where a partial lumping
formulation is used; that is, gradients are approximated by the boundary
conditions in the fin cross section.
Uniform Cross section:
We consider a fin of length L and uniform cross section area A. The fin base
at x = 0 is kept at constant temperature T0 , and heat is dissipated from its lateral
surfaces by convection with a heat transfer coefficient h into an ambient at a
constant temperature T∞ . The heat loss from the fin tip is negligible compared to
that from the lateral surfaces. This fin problem's mathematical formulation is
provided by
d2 θ
– m2θ = 0 in 0 < x < L
dx2

θ(x)= θ0 at x=0


= 0 at x=L
dx

Where,
h∗P
m2=
k∗A

θ(x)= Tx -T∞

θ0 =T0 -T∞

To discretize, we use a second-order accurate central differencing scheme


both the differential equation and the system's boundary conditions and to obtain
the following finite difference equation.

θi−1 − (2 + (∆x ∗ m)2 ) ∗ θi + θi+1 = 0, i = 1, 2, …, (M–1)

11
θi−1 − (2 + (∆x ∗ m)2 ) ∗ θi , i = M
Where the base temperature θ0 = T0 – T∞ and the parameter m2 = (Ph/kA) are
known. The system provides M algebraic equations for M algebraic unknown
nodal temperatures.
The varying boundary condition in the case of fin is at its free end. Therefore, the
different types of boundary conditions in fins are:
• Insulated tip.
• Convection at tip.
• Infinitely long fin.

To evaluate the heat flow rate Q through the fin, we need to discretize equation
dθ(x)
Q= − Ak |x=0
dx
To improve accuracy, we prefer to discretize the derivative about the node at
x = 0 using a second-order accurate central difference formula. There is a fictional
node “-1” in the central difference formula. So, if we eliminate it the formula
becomes
A∗k∗(θ1 −θ2 ) P∗h∗∆x∗θ1
Q= +
∆x 2
where the first term on the right-hand side represents heat flow by conduction
and the second term represents the heat flow from the lateral surface by
convection.

3.3 Transient Heat Conduction


During any period in which temperatures changes in time at any place within
an object, the mode of thermal energy flow is termed transient
conduction. Another term is "non-steady-state" conduction, referring to time-
dependence of temperature fields in an object. Non-steady-state situations arise
as a result of an imposed change in temperature at an object's boundary.
Temperature changes within an object may also occur as a result of a new source
or sink of heat being introduced suddenly within an object, causing temperatures
near the source or sink to change in time.
The governing equation for transient heat conduction is:
∂T ∂2 T
=∝( 2 )
∂t ∂x
The next step is to replace the continuous derivatives with their finite
difference approximations. The derivatives can be approximated by the central
difference as
∂2 T (Tn n n
i+1 −2Ti +Ti−1 )
=
∂x2 ∆x2

12
∂T Tnew
i −Told
i
=
∂t ∆t

After substituting the above equations in the governing equation, we get:


∝∗∆t ∝∗∆t ∝∗∆t
Tin+1 = ( 2 ∗ Ti−1
n
) + (1-2( 2 )) Tin + ( 2 ∗ Ti+1
n
)
∆x ∆x ∆x

Because the temperature at the current time step (n) is known, we can use
the above equation to compute the next temperature without solving any
additional equations. This is an explicit finite difference method.
Explicit and implicit methods are approaches in numerical analysis that are
used to obtain numerical approximations to the solutions of time-dependent
ordinary and partial differential equations, as required in computer simulations of
physical processes. Explicit methods calculate the state of a system at a later time
from the current state, whereas implicit methods find a solution by solving an
equation involving both the current and later states of the system. Implicit
methods necessitate an additional computation (solving the above equation), and
they can be much more difficult to implement. Implicit methods are used because
many problems encountered in practise are difficult, requiring impractically small
time steps to keep the error in the result bounded.
Because it has been demonstrated to be consistent, we know that this
numerical scheme will converge to the exact solution for small ∆x and ∆t- that its
discretization process can be reversed to recover the governing partial differential
equation using a Taylor series expansion – and that it is stable for certain values
of ∆t and ∆x.
We use simple Explicit method for solving the Transient conduction
problems.
For simplicity in the analysis, we consider a diffusion problem in a finite
region 0 ≤ x ≤ L given in the form
∂T ∂2 T
=∝( 2 ) , 0 < x < L, t > 0
∂t ∂x

The region 0 ≤ x ≤ L is divided into M equal parts of mesh size


L
Δx = .
M
The differential equation is discretized using the second-order method.
Precise central difference formula for spatial second derivative and the time
derivative's first-order accurate forward differencing formula to produce

Tn+1
i −Tn
i Tni−1 −2Tni +Tni+1
= ∝∗ ∆x2
∆t

13
Where,
Tin =T (x, t) =T (i∆x, n Δt)

The spatial derivative was discretized with the values of the function T at
time tn = nΔt. The equation is rearranged as
Tn+1i = rTni+ (1 − 2r) Tni+ rTni +1
Where,
∝∗∆t
r=
∆x2
The next step is to specify the initial and the boundary conditions. The
different types of boundary conditions are:
• Dirichlet: We know the initial temperatures on both ends.
• Neumann: We know an initial temperature on an end and a derivative
temperature at the other.
• Robin: We know the differential equations which the system follows to
obtain its temperatures.

Now the boundary conditions are discretized and the nodal equations are
modified accordingly and solved to obtain temperatures and different time steps.

3.4 Discretization of Boundary Conditions


After forming the nodal equations by discretising the governing equation,
the boundary conditions are discretized and are used to modify the nodal
equations in order to obtain a set of linear equations which upon solving produce
a single unique solution. The method in which different boundary conditions are
discretised is explained below.
Dirichlet-Constant Temperature Boundary Condition:
In this type of boundary condition, the temperature at a boundary is known,
it is of the type:
T= constant
This value can be directly substituted in the respective nodal equation.
Neumann-Insulated Wall Boundary Condition:
In this case the value of the derivative of temperature at an end is known, it
is of the type:
dT
=0
dx

14
This equation after discretization becomes,
Ti+1 −Ti−1
=0
2∗∆x

This implies,
Ti−1 = Ti+1
The above equation is now substituted in the required nodal equations (at ith
node).
Robin-Convection at End Boundary Condition:
In this case we know the differential equation which the system follows to
obtain its temperatures, it is of the form:
dT
-k = h (T-T∞ )
dx
This equation after discretization becomes,
Ti+1 −Ti−1
-k ∗ ( ) = h (T-T∞ )
2∗∆x

This implies,
2∗∆x∗h
Ti+1 − Ti−1 = - ∗ (Ti − T∞ )
k

The above equation is now substituted in the required nodal equations (at ith
node).

15
4. INTRODUCTION TO MATLAB
MATLAB is a high-performance technical computing language. It combines
computation, visualisation, and programming in a user-friendly interface with
problems and solutions written in common mathematical notation. Matrix
Laboratory is the abbreviation for Matrix Laboratory. MATLAB was created to
implement the LINPACK (Linear system package) and EISPACK (Eigen system
package) projects' easy approach to matrix software. Typical applications
include:

• Math and computation


• Algorithm development
• Modelling, simulation, and prototyping
• Data analysis, exploration, and visualization
• Scientific and engineering graphics
• Application development, including Graphical User Interface building

MATLAB is an interactive system with an array as its basic data element


that does not require dimensioning. This allows you to solve many technical
computing issues in a fraction of the time it takes to build a programme in a scalar
noninteractive language like C or Fortran, especially ones using matrix and vector
formulations.
Many users have contributed to the development of MATLAB over the
years. It is the standard instructional tool for introductory and advanced
mathematics, engineering, and science courses at universities. For high-
productivity research, development, and analysis in industry, MATLAB is the
tool of choice.
MATLAB is a multi-paradigm programming language. As a result, it may
be used with a variety of programming styles, including Functional, Object-
Oriented, and Visual.
MATLAB is a programming language as well as an environment. Because
the word "matrix" appears in its name, MATLAB bases all of its computations
on mathematical matrices and arrays. MATLAB's all forms of variables, whether
integer, character, or String variables, only hold data in the form of an array.
4.1 Main Features and Capabilities of MATLAB:
The built-in functions in MATLAB are used for linear algebra, data
analysis, signal processing, optimization, numerical solution of ordinary
differential equations (ODEs), quadrate, and a variety of other scientific
calculations.

16
The majority of these routines make use of cutting-edge algorithms. There
are several functions available for 2-D and 3-D graphics, as well as animations.
MATLAB has an external interface that allows you to run those programmes
from within the software. The user is not restricted to the built-in functions; he
can create his own using the MATLAB programming language.
MATLAB's creators additionally offer a number of optional "toolboxes."
These toolboxes are a set of functions for common tasks like symbolic
computations, image processing, statistics, control system design, and neural
networks.
The matrix is one of MATLAB's most important building blocks. The
array is the most basic data type. As special cases of the basic data type, vectors,
scalars, real matrices, and complex matrices are all handled automatically.
Matrixes and matrix functions are MATLAB's favourite. The built-in functions
are vector function optimised. As a result, vectorized instructions or programmes
in MATLAB run substantially faster.
4.2 MATLAB System
The MATLAB system consists of five main parts:

4.2.1 The MATLAB working environment

This is a collection of tools and utilities for working with MATLAB


operations and files. The graphical user interface is present in many of these tools.
The MATLAB desktop and command window, a command history, an editor and
debugger, and browsers for looking at help, the workspace, reports, and the search
path are all included.

4.2.2 The MATLAB mathematical function library

This is a comprehensive collection of computing design that includes


everything from simple functions like sum, sine, and cosine to more advanced
features like matrix inverse, matrix eigenvalues, Bessel functions, and rapid
Fourier transforms.

4.2.3 The MATLAB Language


Control flow statements, functions, data structures, input/output, and
object-oriented programming are all features of this high-level matrix/array
language. It enables both "programming in the tiny" and "programming in the
huge" to develop large and complicated application functionalities.

17
Fig 4.1: MATLAB System
Source: https://www.javatpoint.com/matlab-introduction

4.2.4 Handle Graphics


MATLAB includes a number of tools for presenting vector and matrices
as graphs, as well as annotating and printing them. It includes high-level
frameworks for data visualisation in two and three dimensions, image processing,
animation, and presentation graphics. It also has low-level components that allow
us to fully customise the graphical presentation as well as develop complex
applications.

4.2.5 The MATLAB Application Program Interface (API)

This is a library that allows us to interface with MATLAB using C and


FORTRAN programmes. It has functions for dynamically connecting MATLAB
routines, calling MATLAB as a computational engine, and reading and writing
MAT-files.

4.3 Advantages of MATLAB


• Because of its command line interface and file-oriented structure,
MATLAB is simple to use and can be installed on a variety of operating
systems, including Windows, Vista, Linux, and Macintosh.
• MATLAB comes with a large built-in library of functions that can be used
to do a variety of tasks. This makes the job easier and saves time. These
capabilities are included in a variety of toolkits, including signal processing,
image processing, communications, control systems, and neural networks,
among others.

18
• It offers plotting and imaging related commands which are independent of
devices.
• MATLAB provides a tool for creating GUI-based applications that can be
licenced to consumers based on their MAC addresses with just a few lines
of code. Machine-independent p-code is generated from MATLAB
programmes.
• Errors are easier to fix as it is interpreted language.
• Matrix operations are simple and rapid to complete. Large data sets may be
handled and manipulated with MATLAB. As a result, it's utilised to swiftly
develop and write a variety of algorithms.

4.4 Disadvantages of MATLAB


• MATLAB is interpreted language and hence it takes more time to execute
than other compiled languages such as C, C++.
• It is expensive than regular C or Fortran compiler. Individuals find it
expensive to purchase.
• It requires fast computer with sufficient amount of memory. This adds to
the cost for individuals willing to use it for programming.
• It is difficult to develop real time applications using MATLAB as it sits
"on top" of windows.
• It is not free hence users need to obtain licensed version from MathWorks,
Inc.

4.5 MATLAB App Designer


App Designer lets you create professional apps without having to be a
professional software developer. App Designer integrates the two primary tasks
of app building – laying out the visual components of a graphical user interface
(GUI) and programming app behaviour. It is the recommended environment for
building apps in MATLAB.
These apps can be shared MATLAB Drive, or by creating standalone
desktop or web apps with MATLAB Compiler.

19
4.5.1 Designing a User Interface
In the Design View in App Designer, visual components are dragged
and dropped into the design canvas and alignment hints are used to get a precise
layout. App Designer automatically generates the object-oriented code that
specifies the app’s layout and design.

Fig 4.2: Design View Window in App Designer


Source: https://in.mathworks.com/products/matlab/appdesigner.html

4.5.2 Defining App Behaviour


The integrated version of the MATLAB Editor is used to define app’s behaviour.
Call back functions can be added to the components used in the app layout and
can be coding according to one’s requirement in the code view of App Designer.
App Designer can automatically check for coding problems using the Code
Analyzer. Warning and error messages about the code can be viewed while
writing the code and app can be modified based on these messages.

Fig 4.3: Code View Window in App Designer


Source:https://in.mathworks.com/products/matlab/appdesigner.html

20
4.5.3 App Sharing
MATLAB app can be packaged into a single file that can be easily shared
with other users using MATLAB Desktop and MATLAB Online. When an app
is packaged, MATLAB creates a single app installation file (.mlappinstall). This
installation file enables others to install the app and access it with a single-click
from the app gallery.
Standalone applications can be created using MATLAB Compiler and
Simulink Compiler to share them royalty-free with other users. One can also
package apps as interactive web app and share them using MATLAB Web App
Server. End-users can run the web apps directly from their browser without
installing any additional software.

21
5. APP DEVELOPMENT USING FDM
An app named ‘Temperature Distribution Plotter’, which can solve one
dimensional heat conduction problems using finite difference method, has been
designed using MATLAB App Designer.
The algorithms and the code used behind designing this app is explained in
detail in this chapter.
5.1 Algorithm
The logical sequence of steps which are involved in solving the heat transfer
problems using finite difference method is given in this section.
The app's software includes three main forms of heat transfer problems:
1. Plane Slab
2. Fins
3. Transient
5.1.1 Plane Slab
The algorithm we used for the plane slab problems is:
Step 1: The inputs that are needed for the analysis are the material properties.
Now the material properties are input by the user and are saved in a variable.
Step 2: The boundary conditions are the most important input for the Plane Slab
problems. Boundary conditions at each end can be one of three types: constant
wall temperature, insulated, or convection. So, after the variables are declared,
ask the user for input regarding the boundary condition and save it in a variable
Step 3: Since the values of the variables are now available, the next step would
be substituting them in the formula. In the formula we need 2 matrices namely
coefficient and constant matrices are needed to be formed. Depending on the
boundary conditions, the matrix composition and elements vary. The variation is
shown in further sections.
Step 4: Now solve for the required values. We use a “\” operator provided in
MATLAB between those two matrices we generated, in order to get the required
values
Step 5: Now plot the graph between distance and temperature using plot function
provided by MATLAB.

22
5.1.2 Fins
The algorithm for solving fins is:
Step 1: Here the material inputs are needed. So, the values like length, thermal
conductivity, coefficient of heat transfer, no. of nodes, base temperature, ambient
temperature etc. are stored in variables which are taken as input from the user
Step 2: Since cross section of the fin might change, provide the alternatives for
the cross section. Depending on the cross section, the values should be input and
stored in different variables. In case of infinitely long fin the input is not necessary
Step 3: Since the values of the variables are now available, the next step would
be substituting them in the formula. In the formula we need 2 matrices namely
coefficient and constant matrices are needed to be formed. Depending on the
boundary conditions, the matrix composition and elements vary. The variation is
shown in further sections.
Step 4: Now solve for the required values. We use a “\” operator provided in
MATLAB between those two matrices we generated, in order to get the required
values
Step 5: Now plot the graph between distance and temperature using plot function
provided by MATLAB.

5.1.3 Transient
The algorithm for transient heat analysis is:
Step 1: The material properties must be given for the material undergoing the
transient heat conduction. Apart from usual properties, the input must also be
taken for thickness, thermal diffusivity, initial temperature, time.
Step 2: Similar to Plane slab, the boundary conditions are needed. The boundary
conditions are taken through the input and stored in respective variables created
for them.
Step 3: Since the values of the variables are now available, the next step would
be substituting them in the formula. In the formula we need 2 matrices namely
coefficient and constant matrices are needed to be formed. Depending on the
boundary conditions, the matrix composition and elements vary. The variation is
shown in further sections.

23
Step 4: Now solve for the required values. We use a “\” operator provided in
MATLAB between those two matrices we generated, in order to get the required
values
Step 5: Unlike plane slab or fins, the transient heat conduction is not completely
solved by plotting only temperature vs distance graph. The graph is to be plotted
between time and temperature.

5.2 Code Behind Temperature Distribution Plotter


Temperature Distribution Plotter solves problems of three different
varieties, namely Plane Slab, Fins and Transient heat condition (together they can
be called cases in one dimensional heat conduction).
Each of these cases require a different set of inputs and solving procedures
to obtain their temperature distribution curves, due to this the app is conveniently
divided into three parts using tab view.
The set of input values and code modifications required for solving each
case is explained in detail in the following sections.
5.2.1 Plane Slab
This case requires a set of input values and information about the boundary
conditions at both ends (left side and right side). Each end can have anyone of the
three boundary conditions which are constant wall temperature, insulated and
convection.
5.2.1.1 Material Inputs
Irrespective of the type of boundary conditions, there are a set of input
values which are required to solve any plane slab problem. This set of inputs are
mentioned below with the variable used to store their values in the code.

Property Variable

Thickness t
Thermal Conductivity k
Heat Generation q
No. of Nodes n

24
5.2.1.2 Initial Code for Matrix Generation
As mentioned in the earlier chapter two matrices, namely coefficient and
constant matrices, are generated using the material inputs. These matrices are
later modified using the boundary conditions at both ends and are finally solved
to get the temperature distribution. The code required to generate the initial
matrices is mentioned below.

B=zeros(n,1);
dx=t/(n-1);
c=-q*(dx^2)/k;
B(1:n)=c;
T=zeros(n,1);
A=zeros(n);
A(1:1+n:n*n) =-2;
A(n+1:1+n:n*n) = 1;
A(2:1+n:n*n-n) = 1;

where,
A is the coefficient matrix
B is the constant matrix

5.2.1.3 Left Hand Side Boundary Condition


As mentioned earlier there can be three types of boundary conditions on
each side. The input values required and code modification for each type of
boundary condition are mentioned below.
Constant Temperature:
This condition requires one input value. When we click the Constant
Temperature button, these two values will be saved in the code as a variable.
Property Variable

Wall Temperature Tg1

Apart from the input, the code must be changed because the matrix must
be changed owing to the boundary condition. To alter the matrix, you'll need to
use the following code.

25
A(1,1)=1;
A(1,2)=0;
A(2,1)=0;
B(1)=Tg1;
B(2)=c-Tg1;

Insulated Wall:
There is no requirement for an input value for this condition. However,
because the matrix is changing, a code change is required. The code can be found
below.
A(1,2)=2;
Convection:
This condition requires two input values. When we click the Convection
button, these two values will be saved in the code as a variable.

Property Variable

Coefficient of Heat Transfer h


Ambient Temperature Ta

Apart from the input, the code must be changed because the matrix must
be changed owing to the boundary condition. To alter the matrix, you'll need to
use the following code.
H1=(2*h*dx)/k;
H=H1*Ta;
A(1,1)=-H1-2;
A(1,2)=2;
B(1)=c-H;

26
5.2.1.4 Right Hand Side Boundary Condition
Similar to the left hand side boundary condition, the input values required
and code modification for each type of boundary condition are mentioned below.
Constant Temperature:
This condition requires one input value. When we click the Constant
Temperature button, these two values will be stored in the code as a variable.
Property Variable

Wall Temperature Tg2

Apart from the input, the code must be changed because the matrix must be
changed owing to the boundary condition. To alter the matrix, you'll need to use
the following code. A(n,n)=1;
A(n,n-1)=0;
A(n-1,n)=0;
B(n)=Tg2;
B(n-1)=c-Tg2;

Insulated Wall:
There is no requirement for an input value for this condition. However,
because the matrix is changing, a code change is required. The code can be found
below.
A(n,n-1)=2;

Convection:
This condition requires two input values. When we select the Convection
button, these two values will be stored in the code as a variable.

Property Variable

Coefficient of Heat Transfer h


Ambient Temperature Ta

27
Apart from the input, the code must be changed because the matrix must be
changed owing to the boundary condition. To alter the matrix, you'll need to use
the following code.
H1=(2*h*dx)/k;
H=H1*Ta;
A(n,n)=-H1-2;
A(n,n-1)=2;
B(n)=c-H;

5.2.2 Fins
This case also requires a set of input values and information about the
boundary conditions at both ends (left side and right side). Unlike the Plane Slab
case, in this one end (the one attached to the body) has only one boundary
condition i.e., constant base temperature and the other end can have any of the
three boundary conditions which are insulated tip, convection at tip and infinitely
long fin. In this situation, the user must also specify whether the cross-section of
the fin is circular or rectangular.
5.2.2.1 Material Inputs
Regardless of the sort of boundary conditions, each fin problem needs a set
of input values to be solved. These input values also contain the constant base
temperature input i.e., the first boundary condition. This set of inputs is listed
below, along with the variable that will be used to store their values in the code.
However, in the infinitely long fin condition, the user does not need to specify
any length.

Property Variable

Length of Fin L
Thermal Conductivity k
Coefficient of Heat Transfer h
No. of Nodes N
Base Temperature Tb
Ambient Temperature Ta

28
5.2.2.2 Area and Perimeter of cross-section
There are two types of cross-sections, as previously stated. For each sort of
cross-sectional area, the required input values and code are listed below.
Rectangular cross-section:
This condition requires two inputs. When we click the rectangular cross-
section button, these two values will be stored in the code as a variable.

Property Variable

Width l
Thickness b

And the code to calculate area and perimeter is mentioned below:


ar=l*b;
p=2*(l+b);

Circular cross-section:
This condition requires only one input. When we click the circular cross-
section button, the value will be stored in the code as a variable.
Property Variable

Diameter d

And the code to calculate area and perimeter is:


ar= (pi*d^2)/4;
p=pi*d;

5.2.2.3 Initial Code for Matrix Generation


As mentioned in the earlier chapter two matrices, namely coefficient and
constant matrices, are generated using the material inputs and the first
boundary condition i.e., constant base temperature. These matrices are later
modified using the boundary conditions at the other end and are finally solved

29
to get the temperature distribution. The code required to generate the initial
matrices is mentioned below.
m=sqrt((h*p)/(k*ar));
n=N-1;
B=zeros(n,1);
dx=L/n;
Ob=Tb-Ta;
B(1)=-Ob;
T=zeros(n,1);
A=zeros(n);
A(1:1+n:n*n) =-2-(m*dx)^2;
A(n+1:1+n:n*n) = 1;
A(2:1+n:n*n-n) = 1;

where,
A is the coefficient matrix
B is the constant matrix

5.2.2.4 Boundary Conditions at the end of the Fin


At the other end of the fin, there are three types of boundary conditions that
can exist, as previously indicated. Although no input values or code modifications
are necessary for the infinitely long fin, there are code modifications for the other
types of boundary conditions indicated below.
Insulated Tip:
The code modification required is:
A(n,n-1)=2;

Convection at Tip:
The code modification required is:
A(n,n-1)=2;
A(n,n)=A(n,n)-(2*dx*h/k);

Infinitely long fin:


In this case length of fin is not user defined. The length is calculated using
the below code and the solving process continues.
L=11.51/m;

30
5.2.3 Transient Heat Conduction
Similar to the Plane Slab, this case requires a set of input values and
information about the boundary conditions at both ends (left side and right side).
Each end can have anyone of the three boundary conditions which are constant
wall temperature, insulated and convection.
5.2.3.1 Material Inputs
Irrespective of the type of boundary conditions, there are a set of input
values which are required to solve any transient heat conduction problem. This
set of inputs are mentioned below with the variable used to store their values in
the code.
Property Variable

Thickness t
Thermal Diffusivity a
Initial Temperature To
Time time
No. of Nodes n

5.2.3.2 Initial Code for Matrix Generation


In this, two matrices are generated using the material inputs. These
matrices are later modified using the boundary conditions at both ends and are
finally solved to get the temperature distribution w.r.t time at different nodes. The
code required to generate the initial matrices is mentioned below.

dx=t/(n-1);
dt=0.45*(dx^2)/a;
N=round(time/dt);
r=0.45;
A=zeros(n);
A(1:1+n:n*n)=1-(2*r);
A(n+1:1+n:n*n)=r;
A(2:1+n:n*n-n)=r;
B=zeros(n,1);
B(1:n)=To;

31
5.2.3.3 Left Hand Side Boundary Condition
As mentioned earlier there can be three types of boundary conditions on each
side. The input values required and code modification for each type of boundary
condition are mentioned below.
Constant Temperature:
This condition requires one input value. When the Constant Temperature
option is selected, these two values will be saved in the code as a variable.
Property Variable

Wall Temperature Tg1

Apart from the input, the code must be changed because the matrix must be
changed owing to the boundary condition. To alter the matrix, you'll need to use
the following code.
A(1,1)=1;
A(1,2)=0;
B(1,1)=Tg1;

Insulated Wall:
There is no requirement for any additional input value for this condition.
However, because the matrix is changing a code change is required. This code
can be found below.
A(1,2)=2*r;

Convection:
This condition requires two input values. When the convection option is
selected , these two values will be saved in the code as a variable.

Property Variable

Coefficient of Heat Transfer h1


Ambient Temperature Ta1
Thermal Conductivity k

32
Apart from the input, the code must be changed because the matrix must be
changed owing to the boundary condition. To alter the matrix the following code
is used.
h1=(2*h*dx)/k;
A(1,1)=1-r*(2+h1);
A(1,2)=2*r;

5.2.3.4 Right Hand Side Boundary Condition


Similar to the Left Hand Boundary Condition, the input values required
and code modification for each type of boundary condition are mentioned below.
Constant Temperature:
This condition requires one input value. When the Constant Temperature
button is selected, these two values will be stored in the code as a variable.
Property Variable

Wall Temperature Tg2

Apart from the input, the code must be changed because the matrix must be
changed owing to the boundary condition. To alter the matrix, you'll need to use
the following code.
A(n,n)=1;
A(n,n-1)=0;
B(n,1)=Tg2;

Insulated Wall
There is no requirement for any additional input value for this condition.
However, because the matrix is changing, a code change is required. This code
can be found below.
A(n,n-1)=2*r;

33
Convection:
This condition requires two input values. When we click the Convection
button, these two values will be stored in the code as a variable.

Property Variable

Coefficient of Heat Transfer h2


Ambient Temperature Ta2

Apart from the input, the code must be changed because the matrix must
be changed owing to the boundary condition. To alter the matrix, you'll need to
use the following code.
H2=(2*h*dx)/k;
A(n,n)=-1-r*(2+h2);
A(n,n-1)=2*r;

5.2.4 Solving
The solving procedure is similar for plane slab and fins, once the coefficient
and constant matrices are generated and modified according to the boundary
conditions, they can be solved conveniently on MATLAB using the backslash
operator “\”.
X=A\B;
where X is the solution matrix obtained after solving A and B.
In the case of transient heat conduction, the solution is obtained by multiply
the matrices inside a loop. The code used for this is mentioned below.

for i=1:N
X=B
B=A*X
B(1,1)=B(1,1)+(r*h1*Ta1)
B(n,1)=B(n,1)+(r*h2*Ta2)
tab(i+1,:)=B
end

34
5.2.5 Displaying Results
Temperature Distribution Plotter displays results both in tabular and
graphical manner. Results are displayed in a similar manner in plane slab and
fins, a two columned table is used to display the temperature at respective nodes
and the variation is shown on a graph where distance is plotted on X-axis and
temperature on the Y axis.
In the transient conduction case, the results are displayed differently
because of the additional time component. Here the table is used to show
temperature variation in nodes using columns and in time intervals using rows.
The graph is plotted for time and temperature, each line plot represents a different
node.

5.3 Instructions to Install the App


● Download the installation file.
● Switch off the antivirus software’s real time protection until the app is fully
installed.
● Open the Installation file.
● Browse and select the folder to instal ‘MATLAB Runtime’ and
‘Temperature Distribution Plotter’, make sure 1gb of empty space is
available to install the app.
● Select the checkbox to insert app shortcut on the desktop and start
installation.
● Runtime installer is first downloaded from the web and is installed
followed by the installation of Temperature Distribution Plotter.
● App is now installed and ready to use.

Fig 5.1: Installation Window

35
5.4 Instructions To Use Temperature Distribution Plotter
● Double click on the app icon to launch the app.
● Once the app is opened select the tab required i.e; plane slab, fins or
transient.
● Enter the required input values for the selected case.
● Select the required boundary condition and cross-section (in the case of
fins) and enter the input values for the respective boundary conditions if
any.
● Note that the app is scrollable.
● Click ‘Solve’ once all the inputs are entered.
● The results are now displayed in both tabular and graphical modes.

Fig 5.2: Temperature Distribution Plotter App Interface

36
5.5 Advantages of Temperature Distribution Plotter
● All three cases of one-dimensional heat transfer problems can be solved in
a single application.
● It can be shared as a standalone desktop application which ensures that
non-MATLAB users can also use the app.
● All the cases in the plane slab case are included in the app. Constant wall
temperature, insulated wall and convection at end, with and without heat
generation.
● The app is user friendly; boundary conditions are represented using button
groups.
● Results are displayed in both tabular and graphical manner.
● The number of nodes(discretization) option is user defined.

5.6 Drawbacks of Temperature Distribution Plotter


● Number of nodes should always be greater than 2.
● Number of nodes cannot exceed 1000 in the case of plane slab and fins,
and 100 in the case of transient heat conduction.
● Variable thermal conductivity problems cannot be solved using this app.
● Variable cross section problems in fins cannot be solved using this app.
● Time discretization factor is not a user input value in the case of transient
heat conduction.

37
6. RESULTS AND COMPARISONS
This section deals with the comparison between the results obtained from
analytical methods and numerical methods. The results obtained on Temperature
Distribution Plotter app are also provided.

6.1 Plane Slab


Problem 1: Consider a steady state 1-D heat flow in plate of 20 mm thickness
without uniform heat generation The left and right faces are kept at constant
temperatures of 160°c and 120°c respectively. The plate has a constant thermal
conductivity of 200w/mk. Compare the finite difference results with the exact
analytic solution for the problem.

Sol. Solution Using Finite Difference Method:


Given, k = 200 W/m-K; t = 0.02m;

Fig 6.1

1. Mathematical Modelling:
d2 T
=0
dx2
2. Boundary Conditions:
(i) @ x = 0, T = T1 = 160℃
(ii) @ x = t, T = T6 = 120℃
3. Discretization of Physical Domain:
Distance between each node, ∆x = 0.02m
No of Nodes, n = 6 i.e., i = 1 to 6
4. Discretization of Mathematical Model:
d2 T
=0
dx2

38
Ti−1 −2Ti +Ti+1
→ =0
(∆x)2

→ Ti−1 − 2Ti + Ti+1 = 0 ---- General Nodal Equation


5. Writing the Nodal Equation
@ i = 2, T1 − 2T2 + T3 = 0
From 1st boundary condition,
−2T2 + T3 = -160
@ i = 3, T2 − 2T3 + T4 = 0
@ i = 4, T3 − 2T4 + T5 = 0
@ i = 5, T4 − 2T5 + T6 = 0

From 2nd boundary condition,


T4 − 2T5 = -120
This finite difference equations are expressed in the form of a matrix
−2 1 0 0 T2 −160
1 −2. 1 0 T3
[ ] = [ 0 ]
0 1 −2 1 T4 0
0 0 1 −2 [T5 ] −120

6. Applying Thomas Algorithm:


a2 = a3 = a4 = 1;
d2 = d3 = 0; d1 = -160; d4 = -120
c1 = c2 = c3 =1;
b1 = b2 = b3 = b4 -2
a. Decomposition:
a2 ∗c1 (1∗1)
b2 = b2 - = -2- = -1.5
b1 (−2)
a3 ∗c2 (1∗1)
b3 = b3 - = -2- = -1.33
b2 (−1.5)
a4 ∗c3 (1∗1)
b4 = b4 - = -2- = -1.25
b3 (−1.33)
b. Forward Substitution:
a2 ∗d1 (1)∗(−160)
d2 = d2 - = -0 - = -80
b1 (−2)

39
a3 ∗d2 (1)∗(−80)
d3 = d3 - = -0 - = -53.33
b2 (−1.5)
a4 ∗d3 (1)∗(−53.33)
d4 = d4 - = -120 - = -160
b3 (−1.33)

c. Backward Substitution:
d4 (−160)
T5 = = = 128℃
b4 (−1.25)
d3 −(c3 ∗T4 ) (−53.33)−(1∗128)
T4 = = = 136℃
b3 (−1.33)
d2 −(c2 ∗T3 ) (−80)−(1∗136)
T3 = = = 144℃
b2 (−1.5)
d1 −(c1 ∗T2 ) (−160)−(1∗144)
T2 = = = 152℃
b1 (−2)

Solution Using Analytical Method:


For a Plane Slab with Internal Heat Generation,
d2 T
=0
dx2
Integrating on both sides,
T = c1x + c2
@ x = 0, T = T1 = 160℃
→ c2 = 160
@ x = t, T = T6 = 120℃
→ c1 = -2000
T = −2000 ∗ x + 160
@ i = 2, T = −2000 ∗ 0.004 + 160 = 152℃
@ i = 3, T = −2000 ∗ 0.008 + 160 = 144℃
@ i = 4, T = −2000 ∗ 0.012 + 160 = 136℃
@ i = 5, T = −2000 ∗ 0.016 + 160 = 128℃

40
Result:

Node Distance from Finite Difference Analytical Solution


No. the Left End(m) Method Solution
Temperature (℃) Temperature (℃)
1 0 160 160
2 0.02 152 152
3 0.04 144 144
4 0.06 136 136
5 0.08 128 128
6 0.10 120 120
Table 6.1: Solution obtained from FDM method and Analytical method

Comparison of FDM Solution and Analytical Solution

FDS Analytical solution

200
160
160 152
150 152 144
144 136
Temperature(°c)

136 128
128 120
100
120

50

0
0 Analytical solution
0.004 0.008 0.012 FDS
0.016
0.02

Distance From the left end (m)

Graph 6.1: Comparison of FDM Solution and Analytical Solution

41
Result From App:

Fig 6.2: Input values for problem 1

Fig 6.3: Result for problem 1

42
Problem 2: A plane wall of thickness 0.1m & k=25w/m having a uniform
volumetric heat generation of 0.3 Mw/m3 is insulated on one side while the other
side is exposed to atmosphere with heat transfer coefficient 500w/m2 at an
ambient temperature of 92ºC. Compare the finite difference results with the exact
analytic solution for the problem.
Sol. Solution Using Finite Difference Method:
Given, k = 25 W/m-K; t = 0.1m; T∞ = 92ºC;
q = 0.3MW/m3; h=500W/m2

Fig 6.4

1. Mathematical Modelling:
d2 T q
+ =0
dx2 k
2. Boundary Conditions:
dT
(i) @ x = 0, =0
dx
dT
(ii) @ x = t, -k = h (T-T∞ )
dx
3. Discretization of Physical Domain:
Distance between each node, ∆x = 0.02m
No of Nodes, n = 6 i.e., i = 1 to 6
4. Discretization of Mathematical Model:
d2 T q
+ =0
dx2 k
Ti−1 −2Ti +Ti+1 q
→ + =0
(∆x)2 k
q∗(∆x)2
→ Ti−1 − 2Ti + Ti+1 = −
k

43
2
q∗(∆x)2 (0.3∗106 ∗(2∗10−2 ) )
= = 4.8
k 25
→ Ti−1 − 2Ti + Ti+1 = -4.8 ---- General Nodal Equation
5. Writing the Nodal Equation:
From 1st boundary condition,
dT Ti+1 −Ti−1
=0→ = 0 → Ti−1 = Ti+1 → T0 = T2
dx 2∗∆x

@ i =1, T0 − 2T1 + T2 = -4.8


→ −2T1 + 2T2 = -4.8
@ i = 2, T1 − 2T2 + T3 = -4.8
@ i = 3, T2 − 2T3 + T4 = -4.8
@ i = 4, T3 − 2T4 + T5 = -4.8
@ i = 5, T4 − 2T5 + T6 = -4.8
@ i = 6, T5 − 2T6 + T7 = -4.8
From 2nd boundary condition,
dT Ti+1 −Ti−1
-k = h (T-T∞ ) → -k ∗ ( ) = h (T-T∞ )
dx 2∗∆x
2∗∆x∗h 2∗0.02∗500
→ Ti+1 − Ti−1 = - ∗ (Ti − T∞ ) = - ∗ (Ti − T∞ )
k 25

→ Ti+1 − Ti−1 = - 0.8∗ (Ti − 92) → T7 = T5 − 0. 8∗ (Ti − 92)


@ i = 6, T5 − 2T6 + T7 = -4.8
→ 2T5 − 2.8T6 = -78.4
This finite difference equations are expressed in the form of a matrix

−2 2 0 0 0 0 T1 −4.8
1 −2. 1 0 0 0 T2 −4.8
0 1 −2 1 0 0 T3
= −4.8
0 0 1 −2 1 0 T4 −4.8
0 0 0 1 −2 1 T5 −4.8
[0 0 0 0 2 −2.8] [T6 ] [−78.4]

44
6. Applying Thomas Algorithm:
a2 = a3 = a4 =a5 = 1; a6 = 2;
d1 = d2 = d3 = d4 =d5 = -4.8; d6 = -96.8;
c2 = c3 = c4 =c5 = 1; c1 = 2;
b1 = b2 = b3 = b4 = b5 = -2; b6 = -2.8

a. Decomposition:
a2 ∗c1 (1∗2)
b2 = b2 - = -2- = -1
b1 (−2)

a3 ∗c2 (1∗1)
b3 = b3 - = -2- = -1
b2 (−1)

a4 ∗c3 (1∗1)
b4 = b4 - = -2- = -1
b3 (−1)

a5 ∗c4 (1∗1)
b5 = b5 - = -2- = -1
b4 (−1)

a6 ∗c5 (2∗1)
b6 = b6 - = -2.8- = -0.8
b5 (−1)

b. Forward Substitution:
a2 ∗d1 (1)∗(−4.8)
d2 = d2 - = -4.8 - = -7.2
b1 (−2)

a3 ∗d2 (1)∗(−7.2)
d3 = d3 - = -4.8 - = -12
b2 (−1)
a4 ∗d3 (1)∗(−12)
d4 = d4 - = -4.8 - = -16.8
b3 (−1)
a5 ∗d4 (1)∗(−16.8)
d5 = d5 - = -4.8 - = -21.6
b4 (−1)
a6 ∗d5 (2)∗(−21.6)
d6 = d6 - = -78.4 - = -121.6
b5 (−1)

c. Backward Substitution:
d6 (−121.6)
T6 = = = 152℃
b6 (−0.8)

d5 −(c5 ∗T6 ) (−21.6)−(1∗152)


T5 = = = 173.6℃
b5 (−1)

d4 −(c4 ∗T5 ) (−16.8)−(1∗173.6)


T4 = = = 190.4℃
b4 (−1)

d3 −(c3 ∗T4 ) (−12)−(1∗190.4)


T3 = = = 202.4℃
b3 (−1)

45
d2 −(c2 ∗T3 ) (−7.2)−(1∗202.4)
T2 = = = 209.6℃
b2 (−1)

d1 −(c1 ∗T2 ) (−4.8)−(2∗209.6)


T1 = = = 212℃
b1 (−2)

Solution Using Analytical Method:


For a Plane Slab with Internal Heat Generation,
d2 T q d2 T q
+ =0→ = −
dx2 k dx2 k
Integrating on both sides,
(q∗x2 )
T=− + c1x + c2
2k
dT
@ x = 0, =0
dx
(q∗0)
→ 0=− + c1 → c1 = 0
k
dT
@ x = t, -k = h (T-T∞ )
dx
→ c2 = 212
→ T = 6000 ∗ x 2 + 212
@ i = 1, T = 6000 ∗ 02 + 212 = 212℃
@ i = 2, T = 6000 ∗ 0.022 + 212 = 209.6℃
@ i = 3, T = 6000 ∗ 0.042 + 212 = 202.4℃
@ i = 4, T = 6000 ∗ 0.062 + 212 = 190.4℃
@ i = 5, T = 6000 ∗ 0.082 + 212 = 173.6℃
@ i = 6, T = 6000 ∗ 0.12 + 212 = 152℃

46
Result:

Node Distance from Finite Difference Analytical Solution


No. the Left End(m) Method Solution
Temperature (℃) Temperature (℃)
1 0 212 212
2 0.02 209.6 209.6
3 0.04 202.4 202.4
4 0.06 190.4 190.4
5 0.08 173.6 173.6
6 0.10 152 152
Table 6.2: Solution obtained from FDM method and Analytical method

Comparison of FDM Solution and Analytical Solution

250
212 209.6
212 209.6 202.4
200 202.4 190.4
Temperature(°c)

190.4 173.6
150 173.6 152
152
100
FDS
50
Analytical solution
0
0 0.02 0.04 0.06 FDS
0.08 0.1

Distance From the base (m)


Graph 6.2: Comparison of FDM Solution and Analytical Solution

47
Result From App:

Fig 6.5: Input values for problem 2

Fig 6.6: Result for problem 2

48
Problem 3: A plane wall of thickness 0.1m & k=25w/m having a uniform
volumetric heat generation of 0.3 Mw/m3 is insulated on one side while the other
side is kept at a temperature of 92ºC. Compare the finite difference results with
the exact analytic solution for the problem.

Sol. Solution Using Finite Difference Method:


Given, k = 25 W/m-K; t = 0.1m;
q = 0.3MW/m3;

Fig 6.7

1. Mathematical Modelling:
d2 T q
+ =0
dx2 k
2. Boundary Conditions:
dT
(i) @ x = 0, =0
dx
(ii) @ x = t, T = T6 = 92℃
3. Discretization of Physical Domain:
Distance between each node, ∆x = 0.02m
No of Nodes, n = 6 i.e., i = 1 to 6
4. Discretization of Mathematical Model:
d2 T q
+ =0
dx2 k
Ti−1 −2Ti +Ti+1 q
→ + =0
(∆x)2 k

q∗(∆x)2
→ Ti−1 − 2Ti + Ti+1 = −
k
2
q∗(∆x)2 (0.3∗106 ∗(2∗10−2 ) )
= = 4.8
k 25

49
→ Ti−1 − 2Ti + Ti+1 = -4.8 ---- General Nodal Equation

5. Writing the Nodal Equation:


From 1st boundary condition,
dT Ti+1 −Ti−1
=0→ = 0 → Ti−1 = Ti+1 → T0 = T2
dx 2∗∆x

@ i =1, T0 − 2T1 + T2 = -4.8


→ -−2T1 + 2T2 = -4.8
@ i = 2, T1 − 2T2 + T3 = -4.8
@ i = 3, T2 − 2T3 + T4 = -4.8
@ i = 4, T3 − 2T4 + T5 = -4.8
@ i = 5, T4 − 2T5 + T6 = -4.8
From 2nd boundary condition,
→ T4 − 2T5 = -4.8 – 92 = -96.8
This finite difference equations are expressed in the form of a matrix
−2 2 0 0 0 T1 −4.8
1 −2. 1 0 0 T2 −4.8
0 1 −2 1 0 T3 = −4.8
0 0 1 −2 1 T4 −4.8
[0 0 0 1 −2] [T5 ] [−96.8]

6. Applying Thomas Algorithm:


a2 = a3 = a4 =a5 = 1;
d1 = d2 = d3 = d4 = -4.8; d5 = -96.8;
c2 = c3 = c4 = 1; c1 = 2;
b1 = b2 = b3 = b4 = b5 = -2
a. Decomposition:
a2 ∗c1 (1∗2)
b2 = b2 - = -2- = -1
b1 (−2)
a3 ∗c2 (1∗1)
b3 = b3 - = -2- = -1
b2 (−1)
a4 ∗c3 (1∗1)
b4 = b4 - = -2- = -1
b3 (−1)
a5 ∗c4 (1∗1)
b5 = b5 - = -2- = -1
b4 (−1)

50
b. Forward Substitution:
a2 ∗d1 (1)∗(−4.8)
d2 = d2 - = -4.8 - = -7.2
b1 (−2)
a3 ∗d2 (1)∗(−7.2)
d3 = d3 - = -4.8 - = -12
b2 (−1)
a4 ∗d3 (1)∗(−12)
d4 = d4 - = -4.8 - = -16.8
b3 (−1)
a5 ∗d4 (1)∗(−16.8)
d5 = d5 - = -96.8 - = -113.6
b4 (−1)
c. Backward Substitution:
d5 (−113.6)
T5 = = = 113.6℃
b5 (−1)
d4 −(c4 ∗T5 ) (−16.8)−(1∗113.6)
T4 = = = 130.4℃
b4 (−1)
d3 −(c3 ∗T4 ) (−12)−(1∗130.4)
T3 = = = 142.4℃
b3 (−1)
d2 −(c2 ∗T3 ) (−7.2)−(1∗142.4)
T2 = = = 149.6℃
b2 (−1)
d1 −(c1 ∗T2 ) (−4.8)−(2∗149.6)
T1 = = = 152℃
b1 (−2)

Solution Using Analytical Method:


For a Plane Slab with Internal Heat Generation,
d2 T q d2 T q
+ =0→ = −
dx2 k dx2 k
Integrating on both sides,
(q∗x2 )
T=− + c1x + c2
2k
dT
@ x = 0, =0
dx
(q∗0)
→ 0=− + c1 → c1 = 0
k
@ x = t, T = T6 = 92℃
(q∗x2 )
→ c2 = T6 +
2k
q(t2 −x2 )
T= + T6 → T = 6000(t 2 − x 2 ) + 92
2k
@ i = 1, T = 6000(0.12 − 02 ) + 92 = 152℃

51
@ i = 2, T = 6000(0.12 − 0.022 ) + 92 = 149.6℃
@ i = 3, T = 6000(0.12 − 0.042 ) + 92 = 142.4℃
@ i = 4, T = 6000(0.12 − 0.062 ) + 92 = 130.4℃
@ i = 5, T = 6000(0.12 − 0.082 ) + 92 = 113.6℃
Result:
Node Distance from Finite Difference Analytical Solution
No. the Left End(m) Method Solution
Temperature (℃) Temperature (℃)
1 0 152 152
2 0.02 149.6 149.6
3 0.04 142.4 142.4
4 0.06 130.4 130.4
5 0.08 113.6 113.6
6 0.10 92 92
Table 6.3: Solution obtained from FDM method and Analytical method

Comparison of FDM Solution and Analytical Solution

200
152 149.6
152
Temperature(°c)

150 149.6 142.4


142.4 130.4
130.4 113.6
100 113.6
92
92 FDS
50
Analytical solution
0
0 0.02 0.04 0.06 FDS
0.08 0.1

Distance From the base (m)


Graph 6.3: Comparison of FDM Solution and Analytical Solution

52
Result From App:

Fig 6.8: Input values for problem 3

Fig 6.9: Result for problem 3

53
6.2 Fins

Problem 4: An iron rod of length L = 5 cm, diameter D = 2 cm, and thermal


conductivity k = 50 W/(m°C) protruding from a wall is exposed to an ambient at
T∞ = 20°C. The heat transfer coefficient between the ambient and the rod surface
is h = 100 W/(m2°C), and the base of the rod is kept at a constant temperature T0
= 320°C. Assuming a one-dimensional steady-state heat flow, calculate the rate
of heat loss from the rod into the ambient using finite differences. Compare the
finite difference results with the exact analytic solution for the problem.
Sol. Solution Using Finite Difference Method:
π∗D2 𝜋∗0.022
Area (A) = = = 0.000314 m2
4 4

Perimeter (P) = π ∗ D = π ∗ 0.02 = 0.0628 m

Fig 6.10

1. Mathematical Modelling:
d2 θ
– m2θ = 0;
dx2
θ = T-T∞ ;
θ𝑏 = Tb -T∞ = 320 – 20 = 300
2. Boundary Conditions:
(i) @ x = 0, θ = θb = θ1 = 300℃

(ii) @ x = L, =0
dx
3. Discretization of Physical Domain:
Distance between each node, ∆x = 0.01m
No of Nodes, n = 6 i.e., i = 1 to 6

54
4. Discretization of Mathematical Model:
d2 θ
– m2θ = 0
dx2
θi−1 −θi +θi+1
→ – m2θ = 0
(∆x)2

→ θi−1 − (2 + (∆x ∗ m)2 ) ∗ θi + θi+1 = 0

h∗P (100∗0.0628)
m=√ =√ = 20
k∗A (50∗0.000314)

(∆x ∗ m)2 = (0.01∗ 20)2 = 0.04

→ θi−1 − (2.04) ∗ θi + θi+1 = 0 ---- General Nodal Equation


5. Writing the Nodal Equation:
@ i = 2, θ1 − (2.04) ∗ θ2 + θ3 = 0
From 1st boundary condition,
→ -(2.04) ∗ θ2 + θ3 = -θ1 = -300
@ i = 3, θ2 − (2.04) ∗ θ3 + θ4 = 0
@ i = 4, θ3 − (2.04) ∗ θ4 + θ5 = 0
@ i = 5, θ4 − (2.04) ∗ θ5 + θ6 = 0
From 2nd boundary condition,
dθ θi+1 −θi−1
=0→ = 0 → θi−1 = θi+1 → θ5 = θ7
dx 2∗∆x

@ i = 6, θ5 − (2.04) ∗ θ6 + θ7 = 0
→ 2θ5 − (2.04) ∗ θ6 = 0
This finite difference equations are expressed in the form of a matrix
−2.04 1 0 0 0 θ2 −300
1 −2.04 1 0 0 θ 3 0
0 1 −2.04 1 0 θ4 = 0
0 0 1 −2.04 1 θ5 0
[ 0 0 0 2 −2.04] [θ6 ] [ 0 ]

55
6. Applying Thomas Algorithm:
a2 = a3 = a4 = 1; a5 = 2;
d2 = d3 = d4 = d5 = 0; d1 = -300;
c1 = c2 = c3 = c4 = 1;
b1 = b2 = b3 = b4 = b5 = -2.04

a. Decomposition:
a2 ∗c1 (1∗1)
b2 = b2 - = -2.04 - = -1.549
b1 (−2.04)
a3 ∗c2 (1∗1)
b3 = b3 - = -2.04 - = -1.394
b2 (−1.549)
a4 ∗c3 (1∗1)
b4 = b4 - = -2.04 - = -1.323
b3 (−1.394)
a5 ∗c4 (1∗1)
b5 = b5 - = -2.04 - = -0.528
b4 (−1.323)
b. Forward Substitution:
a2 ∗d1 (1)∗(−300)
d2 = d2 - =0- = -147.059
b1 (−2.04)
a3 ∗d2 (1)∗(−147.059)
d3 = d3 - =0- = -94.815
b2 (−1.549)
a4 ∗d3 (1)∗(−94.815)
d4 = d4 - =0- = -67.982
b3 (−1.394)
a5 ∗d4 (1)∗(−67.982)
d5 = d5 - =0- = -102.768
b4 (−1.323)
c. Backward Substitution:
d5 (−102.768)
θ6 = = = 194.49℃
b5 (−0.528)

d4 −(c4 ∗θ6 ) (−67.982)−(1∗194.49)


θ5 = = = 198.39℃
b4 (−1.3229)

d3 −(c3 ∗θ5 ) (−94.815)−(1∗198.393)


θ4 = = = 210.23℃
b3 (−1.394)

d2 −(c2 ∗θ4 ) (−147.059)−(1∗210.23)


θ3 = = = 231.96℃
b2 (−1.549)

d1 −(c1 ∗θ3 ) (−300)−(1∗231.96)


θ2 = = = 260.76℃
b1 (−2.04)

7. Rate of Heat Transfer:


A∗k∗(θ1 −θ2 ) P∗h∗∆x∗θ1
Q= +
∆x 2

56
0.000314∗50∗(300−260.76) 0.0628∗100∗0.01∗300
→ Q= +
0.01 2
→ Q = 71.03W

Solution Using Analytical Method:


For an Insulated Tip,
θn cosh(m∗(L−x))
=
θb cosh(m∗L)
cosh(20∗(0.05−x))
θn = (300) ∗ = 194.42 * cosh(20 ∗ (0.05 − 𝑥))
cosh(20∗0.05)

θ2 = 194.42 ∗ cosh(20 ∗ (0.05 − 0.01)) = 260.02℃


θ3 = 194.42 ∗ cosh(20 ∗ (0.05 − 0.02)) = 230.48℃
θ4 = 194.42 ∗ cosh(20 ∗ (0.05 − 0.03)) = 210.18℃
θ5 = 194.42 ∗ cosh(20 ∗ (0.05 − 0.04)) = 198.32℃
θ6 = 194.42 ∗ cosh(20 ∗ (0.05 − 0.05)) = 194.42℃
Rate of Heat Transfer = K ∗A ∗m ∗ θ1 ∗ tanh(m ∗ L)
→ Q = 50 ∗0.000314 ∗20 ∗ 300 ∗ tanh(20 ∗ 0.05)
→ Q = 71.74W

57
Result:

Node Distance of Finite Difference Analytical Solution


No. (℃)
Node from Method Solution (℃)
the Base(m) θ = T-T∞ Temperature θ = T-T∞ Temperature
1. 0 300 320 300 320
2. 0.01 260.76 280.76 260.02 280.02
3. 0.02 231.96 251.96 230.48 250.48
4. 0.03 210.23 230.23 210.18 230.18
5. 0.04 198.39 218.39 198.32 218.32
6. 0.05 194.49 214.49 194.42 214.42
Table 6.4: Solution obtained from FDM method and Analytical method

Comparison of FDM Method and Analytical Method

400 320
320 280.02
Temperature

300 280.76 250.48


230.18
251.96 218.32 214.42
200 230.23
218.39
214.49
100

0 Analytical Solution
0 FDM Solution
0.01
0.02
0.03
0.04
0.05
Distance of the Node from the Base

FDM Solution Analytical Solution

Graph 6.4: Comparison of FDM Solution and Analytical Solution

58
Result From App:

Fig 6.11: Input values for problem 4

Fig 6.12: Solution for problem 4

59
Problem 5: A plane wall with surface temperature of 350°C is attached with
straight rectangular fins (k = 235 W/mK). The fins are exposed to an ambient air
condition of 25°C and the convection heat transfer coefficient is 154 W/m2 ·K.
Each fin has a length of 50 mm, a base of 5 mm thick and a width of 100 mm.
Assuming a one-dimensional steady-state heat flow, calculate the rate of heat loss
from the rod into the ambient using finite differences. Compare the finite
difference results with the exact analytic solution for the problem.
Sol. Solution Using Finite Difference Method:
Given, k = 235 W/mK; L = 0.04m; t = 0.005m;
h = 154 W/m2K; w = 0.1m;
T∞ = 25°C; Tb = 350°C
Area (A) = w ∗ t = 0.1 ∗ 0.005 = 0.0005m2
Perimeter (P) = 2 ∗ (w + t) = 2 ∗ (0.1 + 0.005) = 0.210m

Fig 6.13

1. Mathematical Modelling:
d2 θ
– m2θ = 0;
dx2
θ = T-T∞ ;
θ𝑏 = Tb -T∞ = 350 – 25 = 325
2. Boundary Conditions:
(i) @ x = 0, θ = θb = θ1 = 325℃

(ii) @ x = L, -k = h (T-T∞ )
dx
3. Discretization of Physical Domain:
Distance between each node, ∆x = 0.01m
No of Nodes, n = 6 i.e., i = 1 to 6

60
4. Discretization of Mathematical Model:
d2 θ
– m2θ = 0
dx2
θi−1 −θi +θi+1
→ – m2θ = 0
(∆x)2

→ θi−1 − (2 + (∆x ∗ m)2 ) ∗ θi + θi+1 = 0

h∗P (154∗0.210)
m=√ =√ = 16.59
k∗A (235∗0.0005)

(∆x ∗ m)2 = (0.01∗ 16.59)2 = 0.027

→ θi−1 − (2.027) ∗ θi + θi+1 = 0 ---- General Nodal Equation


5. Writing the Nodal Equation:
@ i = 2, θ1 − (2.027) ∗ θ2 + θ3 = 0
From 1st boundary condition,
→ -(2.027) ∗ θ2 + θ3 = -θ1 = -325
@ i = 3, θ2 − (2.027) ∗ θ3 + θ4 = 0
@ i = 4, θ3 − (2.027) ∗ θ4 + θ5 = 0
@ i = 5, θ4 − (2.027) ∗ θ5 + θ6 = 0
From 2nd boundary condition,
dθ θi+1 −θi−1
-k = h (T-T∞ ) → -k ∗ ( ) = h (T-T∞ )
dx 2∗∆x
2∗∆x∗h 2∗0.01∗154
→ θi+1 − θi−1 = - ∗ θi = - ∗ θi
k 235

→ θi+1 − θi−1 = - 0.013∗ θi → θ7 = θ5 − 0.013∗ θ6


@ i = 6, θ5 − (2.027) ∗ θ6 + θ7 = 0
2θ5 − (2.041) ∗ θ6 = 0
This finite difference equations are expressed in the form of a matrix
−2.027 1 0 0 0 θ2 −325
1 −2.027 1 0 0 θ 3 0
0 1 −2.027 1 0 θ4 = 0
0 0 1 −2.027 1 θ5 0
[ 0 0 0 2 −2.041] [θ6 ] [ 0 ]

61
6. Applying Thomas Algorithm:
a2 = a3 = a4 = 1; a5 = 2;
d2 = d3 = d4 = d5 = 0; d1 = -325;
c1 = c2 = c3 = c4 = 1;
b1 = b2 = b3 = b4 = -2.027; b5 = -2.041
a. Decomposition:
a2 ∗c1 (1∗1)
b2 = b2 - = -2.027 - = -1.534
b1 (−2.027)
a3 ∗c2 (1∗1)
b3 = b3 - = -2.027 - = -1.375
b2 (−1.534)
a4 ∗c3 (1∗1)
b4 = b4 - = -2.027 - = -1.300
b3 (−1.375)
a5 ∗c4 (1∗1)
b5 = b5 - = -2.027 - = -0.502
b4 (−1.300)
b. Forward Substitution:
a2 ∗d1 (1)∗(−325)
d2 = d2 - =0- = -160.335
b1 (−2.027)
a3 ∗d2 (1)∗(−160.335)
d3 = d3 - =0- = -104.521
b2 (−1.534)
a4 ∗d3 (1)∗(−104.521)
d4 = d4 - =0- = -76.015
b3 (−1.375)
a5 ∗d4 (1)∗(−76.015)
d5 = d5 - =0- = -116.946
b4 (−1.300)

c. Backward Substitution:
d5 (−116.946)
θ6 = = = 232.96℃
b5 (−0.502)
d4 −(c4 ∗θ6 ) (−76.015)−(1∗232.96)
θ5 = = = 237.67℃
b4 (−1.300)
d3 −(c3 ∗θ5 ) (−104.521)−(1∗237.673)
θ4 = = = 248.87℃
b3 (−1.375)
d2 −(c2 ∗θ4 ) (−160.335)−(1∗2248.868)
θ3 = = = 266.75℃
b2 (−1.534)
d1 −(c1 ∗θ3 ) (−325)−(1∗266.75)
θ2 = = = 291.94℃
b1 (−2.027)

7. Rate of Heat Transfer:


A∗k∗(θ1 −θ2 ) P∗h∗∆x∗θ1
Q= +
∆x 2
0.0005∗235∗(325−291.94) 0.21∗154∗0.01∗325
→ Q= +
0.01 2
→ Q = 444.005W

62
Solution Using Analytic Method:
For a Convective Tip,

θn cosh(m∗(L−x)) + (𝑚∗𝑘)(sinh(𝑚∗(𝐿−𝑥)))
= ℎ
θb cosh(m∗L) + (𝑚∗𝑘)(sinh(𝑚∗𝐿))

154
cosh(16.59∗(0.05−x)) + ( )(sinh(16.59∗(0.05−𝑥)))
16.59∗235
→ θn = 325 ∗ 154
cosh(16.59∗0.05) + (16.59∗235)(sinh(16.59∗0.05))

→ θn = 232.14 ∗ cosh(16.59 ∗ (0.05 − x)) + (0.039)(sinh(16.59 ∗ (0.05 − 𝑥)))

θ2 = 232.14 ∗ cosh(16.59 ∗ (0.05 − 0.01)) + (0.039)(sinh(16.59 ∗ (0.05 − 0.01)))

= 291.69℃
θ3 = 232.14 ∗ cosh(16.59 ∗ (0.05 − 0.02)) + (0.039)(sinh(16.59 ∗ (0.05 − 0.02)))

= 266.48℃
θ4 = 232.14 ∗ cosh(16.59 ∗ (0.05 − 0.03)) + (0.039)(sinh(16.59 ∗ (0.05 − 0.03)))

= 248.11℃
θ5 = 232.14 ∗ cosh(16.59 ∗ (0.05 − 0.04)) + (0.039)(sinh(16.59 ∗ (0.05 − 0.04)))

= 236.86℃
θ6 = 232.14 ∗ cosh(16.59 ∗ (0.05 − 0.05)) + (0.039)(sinh(16.59 ∗ (0.05 − 0.05)))

= 232.14℃

sinh(𝑚∗𝐿) + (𝑚∗𝑘)(cosh(m∗L))
Rate of Heat Transfer = K ∗A ∗m ∗ θ1 ∗ ℎ
cosh(m∗L) + (𝑚∗𝑘)(sinh(𝑚∗𝐿))
154
cosh(16.59∗(0.05)) + ( )(sinh(16.59∗(0.05)))
→ Q = (235*0.0005*16.59*325) * 16.59∗235
154
cosh(16.59∗0.05) + ( )(sinh(16.59∗0.05))
16.59∗235

→ Q = 384.356W

63
Result:

Node Distance of Finite Difference Analytical Solution


No. (℃)
Node from Method Solution (℃)
the Base(m) θ = T-T∞ Temperature θ = T-T∞ Temperature
1. 0 325 350 325 350
2. 0.01 291.94 316.94 291.69 316.69
3. 0.02 266.75 291.75 266.48 291.48
4. 0.03 248.87 273.87 248.11 273.11
5. 0.04 237.67 262.67 236.86 261.86
6. 0.05 232.96 257.96 232.14 257.14
Table 6.5: Solution obtained from FDM method and Analytical method

Comparison of FDM Solution with Analytical Solution

400 350
350 316.69
316.94 291.48
273.11
Temperature

300 291.75 261.86


273.87 257.14
200 262.67
257.96

100

0 Analytical Solution
0
0.01 FDM Solution
0.02
0.03
0.04
0.05
Distance of the node from the base

FDM Solution Analytical Solution

Graph 6.5: Comparison of FDM Solution and Analytical Solution

64
Result From App:

Fig 6.14: Input values for problem 5

Fig 6.15: Solution for problem 5

65
6.3 Transient Heat Conduction
Problem 6: A slab of thickness, 12cm and thermal diffusivity 4*10 -5 m2/s has a
initial temperature of 100℃, for t>0 one of the boundaries are kept at 0℃ while
other is insulated. By using FDM with mesh size 3cm, obtain temperature at the
end of 1min.
Sol. Given,
∝ = 4*10-5 m2/s; L = 0.12m

Fig 6.16

1. Mathematical Modelling
∂T ∂2 T
=∝( 2 )
∂t ∂x
2. Conditions
Boundary Condition
dT
(i) @ x = 0, =0
dx
(ii) @ x = L, T = T5 = 0℃
Initial Condition
@ t = 0, T = 100℃
3. Discretization of Physical Domain
Distance between each node, ∆x = 0.03m
No of Nodes, n = 5 i.e., i = 1 to 5
Stability Criteria,
∝∗∆t
≤ 0.5
∆x2
0.5∗0.032
→ ∆t ≤ → ∆t ≤ 11.25
4∗10−5

66
Taking ∆t as 10sec
4. Discretization of Mathematical Model
∂T ∂2 T
=∝( 2 )
∂t ∂x
Tn+1
i −Tn
i Tni−1 −2Tni +Tni+1
→ = ∝∗
∆t ∆x2

n
)) Tin + ( ∆x2 ∗ Tni+1 )
∝∗∆t ∝∗∆t ∝∗∆t
→ Tin+1 = ( ∗ Ti−1 ) + (1-2(
∆x2 ∆x2

∝∗∆t 4∗10−5 ∗10


= = 0.444
∆x2 0.032

Tin+1 = 0.444Ti−1
n
+ 0.112Tin + 0.444Ti+1
n
---- General Nodal Equation
5. Writing the Nodal Equation
@ i = 1, T1n+1 = 0.444T0n + 0.112T1n + 0.444T2n
From 1st boundary condition,
dT Ti+1 −Ti−1
=0→ = 0 → Ti−1 = Ti+1 → T0 = T2
dx 2∗∆x

T1n+1 = −0.112T1n + 0.888T2n


@ i = 2, T2n+1 = 0.444T1n + 0.112T2n + 0.444T3n
@ i = 3, T3n+1 = 0.444T2n + 0.112T3n + 0.444T4n
@ i = 4, T4n+1 = 0.444T3n + 0.112T4n + 0.444T5n
6. Solving the Equations
At t = 10sec
@ i = 1, T1n+1 = 0.444T0n + 0.112T1n + 0.444T2n
→ T1n+1 = (0.444 ∗ 100) + (0.112 ∗ 100) + (0.444 ∗ 100)
→ T1n+1 = 100℃
@ i = 2, T2n+1 = 0.444T1n + 0.112T2n + 0.444T3n
→ T2n+1 = (0.444 ∗ 100) + (0.112 ∗ 100) + (0.444 ∗ 100)
→ T2n+1 = 100℃
@ i = 3, T3n+1 = 0.444T2n + 0.112T3n + 0.444T4n
→ T3n+1 = (0.444 ∗ 100) + (0.112 ∗ 100) + (0.444 ∗ 100)

67
→ T3n+1 = 100℃
@ i = 4, T4n+1 = 0.444T3n + 0.112T4n + 0.444T5n
→ T4n+1 = (0.444 ∗ 100) + (0.112 ∗ 100) + (0.444 ∗ 0)
→ T4n+1 = 55.6℃
Similarly, by calculating for other time intervals, the solution is

Time Temperature (℃)


(sec)
T1 T2 T3 T4 T5
0 100 100 100 100 100
10 100 100 100 55.6 0
20 100 100 80.286 50.627 0
30 100 91.247 75.871 41.317 0
40 92.227 88.306 67.356 38.314 0
50 88.745 80.745 63.763 34.197 0
60 81.055 76.444 57.717 31.98 0

Table 6.6: Solution obtained from FDM method and Analytical method

Temperature vs Time at each node

100
80
Temperatue

60
40
20 T5

0 T3
0 10 20 T1
30
40
50
60
Time

T1 T2 T3 T4 T5

Graph 6.6: Comparison of FDM Solution and Analytical Solution

68
Result From App:

Fig 6.17: Input values for problem 6

Fig 6.18: Result for problem 6

69
7. CONCLUSIONS
The following conclusions are drawn from the design of the MATLAB app
and its comparison with numerical and analytical methods:
• Application of Finite Difference Method in one dimensional steady state
heat conduction problems has been studied.
• An app named ‘Temperature Distribution Plotter’, which can solve one
dimensional heat conduction problems using finite difference method, has
been designed using MATLAB App Designer.
• Temperature Distribution Plotter can solve problems on plane slab, fins
and transient heat conduction for all combinations of boundary conditions
and display results in both tabular and graphical representations.
• The results obtained from the app perfectly matched with the results
obtained from numerical and analytical methods.
• This app can be useful for teachers while solving one dimensional heat
conduction problems in class.

70
REFERENCES

Books Referred:
• Finite Difference Methods in Heat Transfer By M. Necati Özişik, Helcio
R. B. Orlande, Marcelo J. Colaço, Renato M.Cotta ,2017.
• Numerical Heat Transfer and Fluid Flow By Suhas Patankar,2018.
• Numerical Methods in Heat Transfer, Volume 3,A Wiley-Interscience
publication, Roland Wynne Lewis.
• Advanced Numerical Methods with Matlab By Bouchaib
Radi, Abdelkhalak El Hami.
• MATLAB for Beginners A Gentle Approach, Peter I. Kattan,2008.

Websites Referred:

• https://matlabacademy.mathworks.com/

• https://www.thermopedia.com/content/991/

• http://faculty.washington.edu/finlayso/ebook/pde/FD/FD.Matlab.htm

• https://in.mathworks.com/matlabcentral/fileexchange/55058-2d-heat-

equation-using-finite-difference-method-with-steady-state-solution

• https://numfactory.upc.edu/web/NumMethods/PDE/PDECalor.html

71

You might also like