Assignment 1: Computational Fluid Dynamics (ME543), Aug-Nov 2024
Dr. Atul K. Soti, Department of Mechanical Engineering, Indian Institute of Technology Guwahati
• Provide: (i) the grid detail, (ii) the discretized equations detail, (iii) the boundary condition
implementation detail, (iv) the required output (plots/any other such means), (v) a well-documented code.
• Items (i), (ii), and (iii) above should be written out/typed on a separate sheet and attached before items
(iv). Soft copy of document containing items (i) to (iv) and code need to be submitted.
• Solve the following problems using finite difference method. You can decide your own grid spacing and
determine roughly the coarsest grid for sufficient accuracy, say 10−6 . If the analytical solution can be
found for a problem then compare the numerical results with the analytical solution by plotting them
together. Determine if the heat balance is obeyed in the numerical solution by comparing the heat entering
and leaving the domain.
1. The left- and right-hand faces of a 0.5 m long insulated rod of uniform cross-section are maintained a 100 ∘ C
and 500 ∘ C, respectively. Calculate the steady state temperature distribution in the rod. Thermal conductivity
equals 1000 W/m-K.
2. Consider a one-dimensional plane wall of thickness 100 mm. The conductivity of the wall material is 0.1
W/m-K. The left face of the wall is exposed to a heat flux of 200 W/m2 and also to a hot fluid with temperature
300 ∘ C. Assume a heat transfer coefficient of 25 W/m2-K between the left face and the hot fluid. The right
face of the wall is maintained at 50 ∘ C. Assuming steady-state condition, find temperature distribution inside
the wall.
3. A large and thin plate of thickness 𝐿 = 2 cm has thermal conductivity k = 0.5 W/m-K and uniform heat
generation Q = 1000 kW/m3. The left- and right-hand faces of the plate are heated to 100 ∘ C and 200 ∘ C,
respectively. Calculate the steady state temperature distribution in the plate.
4. Consider a one-dimensional composite slab of total width 130 mm, made up of three materials as follows:
(a) Plasterboard (𝑘 = 0.15 W/m-K): 0 ≤ 𝑥 ≤ 10 mm.
(b) Fiberglass (𝑘 = 0.038 W/m-K): 10 < 𝑥 ≤ 110 mm.
(c) Plywood (𝑘 = 0.1 W/m-K): 110 < 𝑥 ≤ 130 mm.
The left face of the slab (𝑥 = 0) is raised to 600 K, the right face (𝑥 = 130 mm) is raised to 400 K. Find the
steady state temperature distribution in the slab.
5. Solve Problem 1 with the following specification for the thermal conductivity: 𝑘 = 0.1(1 + 𝛽𝑇) W/m-K,
where T is in Kelvin. Solve for 𝛽 = 0.001 and -0.001. Plot the temperature distribution within the rod for both
cases.
6. A one-dimensional wall of 1 m width and a constant thermal diffusivity of 1 m2/hr is initially at a uniform
temperature of 100 ∘ C. At t = 0, the surface temperatures of the left (x = 0) and right (x = L) faces are suddenly
increased to 300 ∘ C, and maintained at this temperature thereafter. There are no sources within the wall.
Determine the temperature distribution within the wall as a function of time. Specifically, plot the temperature
distribution at each 0.1 hr. interval from 0.0 to 0.5 hr. Use a grid size of 0.05 m (you can experiment with the
grid size as well).
(a) Solve the problem with the fully explicit method. Demonstrate the stability criterion as discussed in
class (this should involve the time step size and the consequent behavior of the solution).
(b) Solve the problem with the Crank-Nicolson method. Investigate the behavior of the solution with a
few choices of the time step. Do not exceed the time step beyond 0.1 hr.
(c) Solve the problem with the fully implicit method. Investigate the behavior of the solution with a few
choices of the time step. Do not exceed the time step beyond 0.1 hr.
The analytical solution for this case is given by
1
∞
𝑚𝜋 2 1 − (−1)𝑚 𝑚𝜋𝑥
𝑇 = 𝑇𝑠 + 2(𝑇𝑖 − 𝑇𝑠 ) ∑ exp [− ( ) 𝛼𝑡] sin ( )
𝐿 𝑚𝜋 𝐿
𝑚=1
where 𝑇𝑠 denotes the equal surface temperatures at the two faces, 𝑇𝑖 is the initial temperature in the wall, and
L is the width of the wall.
Theoretical background
The one-dimensional steady-state heat conduction equation in a domain 𝐷 ≡ 𝑥 ∈ [𝑥𝑙 , 𝑥𝑟 ] is
𝑑 𝑑
(𝑘(𝑥) 𝑇(𝑥)) + 𝑞(𝑥) = 0
𝑑𝑥 𝑑𝑥
where 𝑇, 𝑘 and 𝑞 represents temperature, thermal conductivity and heat generation, respectively. The
𝑑𝑇
governing equations are subjected to boundary conditions of form + 𝑎𝑇 = 𝑏 at domain boundaries where
𝑑𝑥
𝑎 and 𝑏 are either constant or some known functions of 𝑥 and/or T. Let 𝑇 = (𝑇1 , 𝑇2 , … . , 𝑇𝑛 )𝑇 represent the
column vector of temperatures at discreate locations 𝑥 = (𝑥1 = 𝑥𝑙 , 𝑥2 , 𝑥3 , … , 𝑥𝑛 = 𝑥𝑟 )𝑇 in the domain D. If
𝑇 𝑎 and 𝑇 𝑘 represent the analytical and numerical solution of the above equation, respectively, where 𝑘
represents the iteration count, then a measure of the error 𝑒 𝑘 = 𝑇 𝑎 − 𝑇 𝑘 in the numerical solution can be
defined as 𝐸 = ‖𝑒 𝑘 ‖2 . The 2-norm of the vector 𝑣 which is defined as
‖𝑣‖2 = √𝑣12 + 𝑣22 + ⋯ + 𝑣𝑛2
The system of algebraic equations arising from discretization of the governing equation is 𝐴𝑇 = 𝑏, where 𝐴
is the coefficient matrix. The residual after 𝑘 iterations is defined as 𝑟 𝑘 = 𝑏 − 𝐴𝑇 𝑘 . We stop the iterations
when ‖𝑟 𝑘 ‖2 < 𝜖 where 𝜖 is a small number, say 10−6 . Generally, 𝜖 should be in the order of the truncation
error of the discretization scheme.
Coding guidelines/tips
• You can use C/C++ or Fortran (except Fortran 77) programming languages for writing your codes.
Both GNU and intel compilers can be used free of cost.
• Pay attention to the row/column major storage schemes of C and Fortran. Discontinuous memory
excess significantly slows down a CFD code.
• (Not for beginners) It is advisable to declare appropriate variables as three-dimensional arrays so that
later one can add three-dimensionality to the code with ease.
• All major operations such as calculation of coefficients, application of boundary conditions, point
GS/ADI, file writing, etc. should be done through the use of functions/subroutines.
• Fortran users should learn the use of Modules and kind specifiers.
• User inputs such as grid size, Reynolds number, convergence criteria, boundary conditions, etc. should
be read from an ASCI formatted text file called “input.dat”.
• For plotting you can use Tecplot, Matplotlib (Python), or Gnuplot. Matplotlib is my personal
preference for line plots.
• Use compiler optimization flags like -O2.
• Variable names should be self-explanatory and there should be enough comments to describe the
working and flow of your code. There is an open-source tool called doxygen for code documentation
(learn yourself if interested).
• There are IDEs such as VScode, eclipse, vim, etc. that offer advanced editing features to help you write
codes with ease. It is okay to use normal text editors if this seems too much to you.
• Use of Linux-based operating systems, such as Ubuntu, is encouraged. You can learn shell scripting
for automating repetitive tasks.