Coding Assignment Report
Numerical Techniques for Fluid Flow and Heat Transfer
Samarth Subramanya Rao
f20230991@[Link]
November 16, 2025
Abstract
This report contains details regarding the ’Coding Assignment’ completed as a part of
the ME F485 (Numerical Techniques for Fluid Flow and Heat Transfer) course. The assign-
ment consisted of five standard problems - 2D steady state heat conduction, transient heat
conduction in a composite slab, flow past a backward-facing step, lid-driven cavity flow, and
mixed convection in a square cavity. The discretization details, along with the implementa-
tion of the vorticity stream function method, and the SIMPLE method, have been detailed
in the PDF uploaded along with the assignment codes.
1
Contents
1 Problem 1: Steady-State Heat Conduction in a Duct 3
1.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Numerical Method and Discretization . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Results and Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Problem 2: Transient Heat Conduction in Composite 6
2.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Numerical Method and Discretization . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.1 Forward Euler (FTCS) Scheme . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.2 Crank-Nicolson Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.3 Interface Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Results and Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.1 Stability Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3 Problem 3: Flow Over a Backward-Facing Step 8
3.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 Numerical Method and Discretization . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3 Results and Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4 Problem 4: Lid-Driven Cavity Flow 10
4.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.2 Numerical Method and Discretization . . . . . . . . . . . . . . . . . . . . . . . . 10
4.3 Results and Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5 Problem 5: Mixed Convection in a Square Cavity 13
5.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.2 Numerical Method and Discretization . . . . . . . . . . . . . . . . . . . . . . . . 13
5.3 Results and Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.3.1 Case 1: Gr = 100, Re = 400, P r = 0.71 . . . . . . . . . . . . . . . . . . . 13
5.3.2 Case 2: Gr = 106 , Re = 1000, P r = 10 . . . . . . . . . . . . . . . . . . . . 13
2
1 Problem 1: Steady-State Heat Conduction in a Duct
1.1 Problem Statement
The first problem involves finding the steady-state temperature distribution in a hollow square
duct of side length L = 500 cm. The exterior surfaces are maintained at T = 800◦ C and the
interior square surface (of side L/5) is maintained at T = 50◦ C. The problem is solved for two
different spatial discretizations: (a) ∆x = ∆y = 5 cm, and (b) ∆x = ∆y = 2.5 cm.
1.2 Numerical Method and Discretization
Under the given problem conditions, the governing equation for steady-state heat conduction is
the 2D Laplace equation:
∂2T ∂2T
+ =0
∂x2 ∂y 2
This partial differential equation is discretized using a central difference scheme (CDS) on a
uniform grid. For any interior node (i, j), the 5-point finite difference stencil is:
Ti+1,j − 2Ti,j + Ti−1,j Ti,j+1 − 2Ti,j + Ti,j−1
2
+ =0
(∆x) (∆y)2
Given ∆x = ∆y, the equation for Ti,j simplifies to:
1
Ti,j = (Ti+1,j + Ti−1,j + Ti,j+1 + Ti,j−1 )
4
Using the symmetry of the geometry, the problem was tackled by solving for only the upper
right quadrant with the appropriate Neumann-type BCs along the edges normal to the x and y
cutting planes.
In addition, Dirichlet BCs along the outer and inner boundaries were applied. The conver-
gence check was an L-infinity-based one with a tolerance of 10−6 . This linear system of algebraic
equations is solved iteratively using a simple Gauss-Jacobi algorithm for both the 2.5 cm and 5
cm cases.
1.3 Results and Discussion
The raw results from the solver were written into a text file. This text file was then uploaded
onto MATLAB online, where post-processing was performed. For both the 2.5 cm and 5 cm
grid spacing cases, heatmaps and contour plots were generated. Expected results were obtained,
which fairly match the analytical solution.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut,
placerat ac, adipiscing vitae, felis.
3
Image Placeholder
Contour plot for ∆x = ∆y = 5 cm.
Figure 1: Steady-state temperature distribution for ∆x = ∆y = 5 cm.
4
Image
Placeholder
Contour plot for ∆x = ∆y = 2.5 cm.
Figure 2: Steady-state temperature distribution for ∆x = ∆y = 2.5 cm.
5
2 Problem 2: Transient Heat Conduction in Composite
2.1 Problem Statement
This problem involves modeling the 1D transient heat conduction across a multi-layered compos-
ite insulation. The slab consists of three layers (A, B, C) with different thermal properties. The
left boundary is held at 1000◦ C and the right at 50◦ C. The initial temperature of the insulation
is 35◦ C. The goal is to find the temporal evolution of the temperature distribution using two
schemes: (a) Forward Euler (FTCS) and (b) Crank-Nicolson.
2.2 Numerical Method and Discretization
The governing equation is the 1D transient heat equation:
∂T ∂2T
=α 2
∂t ∂x
2.2.1 Forward Euler (FTCS) Scheme
The explicit FTCS scheme is discretized as:
Tin+1 − Tin T n − 2Tin + Ti−1
n
= α i+1
∆t (∆x)2
This scheme is stable only for a specific time step size, F o ≤ 0.5, where F o = α∆t/(∆x)2 .
2.2.2 Crank-Nicolson Scheme
The implicit Crank-Nicolson scheme is unconditionally stable and discretized as:
" #
n+1 n+1 n+1
Tin+1 − Tin α Ti+1 − 2Ti + Ti−1 n − 2T n + T n
Ti+1 i i−1
= +
∆t 2 (∆x)2 (∆x)2
This results in a tri-diagonal system of equations which is solved at each time step.
2.2.3 Interface Handling
At the interfaces between materials, a harmonic mean of thermal conductivity (k) and a weighted
average of thermal diffusivity (α) must be used... Nam dui ligula, fringilla a, euismod sodales,
sollicitudin vel, wisi. Morbi auctor lorem non justo.
2.3 Results and Discussion
2.3.1 Stability Analysis
Given ∆x = 1 mm and the material properties, the most restrictive stability criterion comes
from material B (αB = 4αA ). The critical time step for the FTCS scheme was found to be...
Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at, tincidunt tristique,
libero.
6
Image Placeholder
Temporal evolution using Forward Euler scheme.
Figure 3: Temperature evolution (T(x, t)) using the Forward Euler scheme.
Image Placeholder
Temporal evolution using Crank-Nicolson scheme.
Figure 4: Temperature evolution (T(x, t)) using the Crank-Nicolson scheme.
7
3 Problem 3: Flow Over a Backward-Facing Step
3.1 Problem Statement
This problem models 2D steady, incompressible flow over a backward-facing step at a Reynolds
number of Re = 800. The inlet velocity profile is parabolic. The simulation is performed using
the stream function-vorticity (ψ − ω) approach.
3.2 Numerical Method and Discretization
The governing equations in the ψ − ω formulation are:
∂2ω ∂2ω
∂ω ∂ψ ∂ω ∂ψ ∂ω 1
+ − = +
∂t ∂y ∂x ∂x ∂y Re ∂x2 ∂y 2
∂2ψ ∂2ψ
+ = −ω
∂x2 ∂y 2
Quisque ullamcorper placerat ipsum. Cras nibh. Morbi vel justo vitae lacus tincidunt ultrices.
3.3 Results and Discussion
The steady-state solution was obtained, and velocity profiles were extracted at three downstream
locations: x/h = 6, 14, and 30.
Image Placeholder
u-velocity profiles at x/h = 6, 14, 30. Compare with Erturk [1].
Figure 5: Horizontal (u) velocity profiles at downstream locations.
Fusce mauris. Vestibulum luctus nibh at lectus.
8
Image Placeholder
v-velocity profiles at x/h = 6, 14, 30. Compare with Erturk [1].
Figure 6: Vertical (v) velocity profiles at downstream locations.
Image Placeholder
Contour of X-velocity (u) for the steady-state solution.
Figure 7: Contour plot of horizontal (u) velocity.
9
4 Problem 4: Lid-Driven Cavity Flow
4.1 Problem Statement
This problem involves simulating steady-state incompressible flow in a square lid-driven cavity
at Re = 100. The top lid moves with a velocity U . The problem is solved using the SIMPLE
algorithm on a staggered grid for three mesh sizes: 20 × 20, 40 × 40, and 80 × 80.
4.2 Numerical Method and Discretization
The steady-state, incompressible Navier-Stokes equations are solved:
∇ · (u) = 0
1 2
(u · ∇)u = −∇p + ∇ u
Re
Suspendisse vel felis. Ut lorem lorem, interdum eu, tincidunt sit amet, laoreet vitae, arcu.
Aenean faucibus pede eu ante.
4.3 Results and Discussion
A grid independence study was performed. The velocity components u (along the vertical cen-
terline x = L/2) and v (along the horizontal centerline y = L/2) are plotted for all three meshes
and compared with the benchmark data from Ghia et al. [2].
Image Placeholder
u-velocity along x = L/2 for 20 × 20, 40 × 40, 80 × 80 grids.
Figure 8: Grid independence study: u-velocity along the vertical centerline.
Sed commodo posuere pede. Mauris ut est.
The contours for u-velocity, v-velocity, and pressure for the 80 × 80 grid are shown below.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Donec odio elit, dictum in, hendrerit sit amet, egestas sed, leo.
10
Image Placeholder
v-velocity along y = L/2 for 20 × 20, 40 × 40, 80 × 80 grids.
Figure 9: Grid independence study: v-velocity along the horizontal centerline.
11
u-velocity v-velocity
pressure
Figure 10: Contours of u-velocity, v-velocity, and pressure (p) for the 80 × 80 grid.
12
5 Problem 5: Mixed Convection in a Square Cavity
5.1 Problem Statement
This problem extends Problem 4 to include mixed convection. Buoyancy effects are introduced
via the Boussinesq approximation. The SIMPLE algorithm is used to solve the coupled Navier-
Stokes and thermal energy equations. Two cases are studied:
1. Case 1: Gr = 100, Re = 400, P r = 0.71
2. Case 2: Gr = 106 , Re = 1000, P r = 10
5.2 Numerical Method and Discretization
The governing equations are modified to include the thermal energy equation and the Boussinesq
buoyancy term in the y-momentum equation:
∂p 1 2 Gr
(u · ∇)v = − + ∇ v+ (T − Tref )
∂y Re Re2
1
(u · ∇)T = ∇2 T
Re · P r
Morbi luctus, wisi viverra faucibus pretium, nibh est placerat odio, nec commodo wisi enim eget
quam. Quisque libero justo, consectetuer a, feugiat vitae, porttitor eu, libero. Suspendisse sed
mauris vitae elit sollicitudin malesuada.
5.3 Results and Discussion
5.3.1 Case 1: Gr = 100, Re = 400, P r = 0.71
Suspendisse vitae elit. Aliquam arcu neque, ornare in, ullamcorper quis, commodo eu, libero.
5.3.2 Case 2: Gr = 106 , Re = 1000, P r = 10
Sed feugiat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus
mus.
13
Image Placeholder
u, v, and T profiles along centerlines for Case 1. Compare with [3, 4].
Figure 11: Velocity and Temperature profiles for Case 1 (Re = 400, Gr = 100).
Velocity Contours Temp. Contours
Figure 12: Velocity and Temperature contours for Case 1 (Re = 400, Gr = 100).
14
Image Placeholder
Temperature profile along x = L/2 for Case 2. Compare with [3, 4].
Figure 13: Temperature profile along vertical centerline for Case 2 (Re = 1000, Gr = 106 ).
15
References
[1] Ercan Erturk. Numerical solutions of 2-d steady incompressible flow over a backward-facing
step, Part I: High Reynolds number solutions. Computers & Fluids, 37(6):633–655, 2008.
[2] U. Ghia, K.N. Ghia, and C.T. Shin. High-re solutions for incompressible flow using the navier-
stokes equations and a multigrid method. Journal of Computational Physics, 48(3):387–411,
1982.
[3] Reima Iwatsu, Jae Min Hyun, and Kunio Kuwahara. Mixed convection in a driven cavity
with a stable vertical temperature gradient. International Journal of Heat and Mass Transfer,
36(6):1601–1608, 1993.
[4] Hemanshul Garg, Atul K. Soti, and Rajneesh Bhardwaj. A sharp interface immersed bound-
ary method for vortex-induced vibration in the presence of thermal buoyancy. Physics of
Fluids, 30(2):023603, 02 2018.
16