Skip to content

atahabilder1/Heat-Flow-Visualization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heat Flow Visualization in 2D Surface

A MATLAB simulation for observing heat flow and temperature distribution across a 2D conductive surface using the finite difference method with Gauss-Seidel iteration.


Project Information

Field Details
Author Anik Tahabilder
Institution Western Carolina University, NC
Program Master of Science
Date Submitted November 27, 2018

Overview

This program simulates steady-state heat conduction on a 2D rectangular surface. The simulation models how heat distributes across a conductive material when temperature sources (probes) are applied at various positions.

Key Capabilities

  • Define custom grid dimensions (3x3 to 100x100)
  • Place temperature probes on all four edges (top, right, bottom, left)
  • Add an optional center probe for internal heat sources
  • Real-time animated visualization of heat propagation
  • Automatic convergence detection using RMS error analysis
  • Export simulation as MP4 video

Mathematical Background

Heat Equation

The simulation solves the 2D steady-state heat conduction equation (Laplace equation):

∂²T/∂x² + ∂²T/∂y² = 0 

Finite Difference Approximation

Using the finite difference method, the temperature at each interior node is calculated as the average of its four neighboring nodes:

T(i,j) = [T(i-1,j) + T(i+1,j) + T(i,j-1) + T(i,j+1)] / 4 

Iterative Solution (Gauss-Seidel Method)

The program uses the Gauss-Seidel iterative method to solve the system:

  1. Initialize the grid with boundary conditions
  2. Update each interior point using the 4-point average formula
  3. Calculate RMS error between consecutive iterations
  4. Repeat until RMS error < accuracy threshold OR maximum iterations reached

Convergence Criteria

RMS = sqrt( Σ(T_new - T_old)² / (rows × columns) ) 

The solution converges when RMS falls below the user-specified accuracy (0 to 1).


Boundary Conditions

Region Condition
Probe locations Fixed temperature (Dirichlet boundary)
Non-probe edges Heat insulated (Neumann boundary - zero flux)
Center probe Fixed temperature island (optional)

The heat-insulated boundary condition is implemented by copying the temperature from the adjacent interior cell:

% Example: Top edge insulation (before probe) Matrix(1, 1:probeStart-1) = Matrix(2, 1:probeStart-1)

Installation & Requirements

Prerequisites

  • MATLAB R2015a or later
  • Image Processing Toolbox (for visualization)
  • No additional dependencies required

Setup

  1. Clone or download this repository
  2. Open MATLAB
  3. Navigate to the project directory
  4. Run the main script:
>> Project

Usage Guide

Step 1: Define Grid Size

Enter the number of rows (3 to 100): 60 Enter the number of columns (3 to 100): 50 

Step 2: Configure Edge Probes

For each edge (upper, right, bottom, left), you will specify:

  • Start position: Where the probe begins
  • End position: Where the probe ends
  • Temperature: Temperature value in degrees Celsius
Enter start position for upper probe: 15 Enter end position for upper probe: 32 Enter temperature for upper probe: 500 

Step 3: Optional Center Probe

Do you want to have a center probe? Enter Y for yes and N for No: Y Enter center probe row start: 15 Enter center probe row end: 38 Enter center probe column start: 35 Enter center probe column end: 42 Enter temperature for center probe: 600 

Step 4: Set Accuracy

Insert the value of minimum accuracy: 0.01 

Step 5: View Results

The program will display:

  • Real-time heat map animation
  • Iteration count
  • Final RMS error
  • Execution time

Output

Console Output

********************************************* Number of iterations = 287 RMS Error = 9.85e-03 Run Time = 12.45 seconds ********************************************* 

Visual Output

  • Live Figure: Color-coded temperature distribution (jet colormap)
  • Color Scale: 0°C (blue) to 1000°C (red)
  • Axes: Row and column indices

Video Export

The simulation automatically generates TEMP.MP4 in the project directory:

  • Format: MPEG-4
  • Frame Rate: 20 fps
  • Contains: Complete iteration history

Project Structure

Heat-Flow-Visualization/ │ ├── Project.m # Main program file ├── figure1.m # Results display function ├── README.md # This file │ ├── Grid Input Functions/ │ ├── getRowMatrix.m # Row count input (3-100) │ └── getColMatrix.m # Column count input (3-100) │ ├── Probe Position Functions/ │ ├── getupperProbStart.m # Upper probe start position │ ├── getupperProbEnd.m # Upper probe end position │ ├── getrightProbStart.m # Right probe start position │ ├── getrightProbEnd.m # Right probe end position │ ├── getbottomProbStart.m # Bottom probe start position │ ├── getbottomProbEnd.m # Bottom probe end position │ ├── getleftProbStart.m # Left probe start position │ ├── getleftProbEnd.m # Left probe end position │ ├── getcenterProbRowStart.m # Center probe row start │ ├── getcenterProbRowEnd.m # Center probe row end │ ├── getcenterProbColStart.m # Center probe column start │ └── getcenterProbColEnd.m # Center probe column end │ ├── Temperature Input Functions/ │ ├── getTempUpper.m # Upper edge temperature │ ├── getTempRight.m # Right edge temperature │ ├── getTempBottom.m # Bottom edge temperature │ ├── getTempLeft.m # Left edge temperature │ └── getTempCenter.m # Center probe temperature │ ├── Simulation Parameters/ │ ├── getAccuracy.m # Convergence threshold (0-1) │ └── getMaxIter.m # Maximum iterations │ └── Output/ └── TEMP.MP4 # Generated video (after run) 

Example Configuration

Here is a sample configuration for testing:

Parameter Value
Grid Size 60 rows × 50 columns
Upper Probe Position 15-32, Temperature 500°C
Right Probe Position 36-43, Temperature 1000°C
Bottom Probe Position 17-25, Temperature 800°C
Left Probe Position 22-38, Temperature 387°C
Center Probe Rows 15-38, Cols 35-42, Temperature 600°C
Accuracy 0.01
Max Iterations 300

Algorithm Flowchart

┌─────────────────────────────────┐ │ Start Program │ └─────────────┬───────────────────┘ ▼ ┌─────────────────────────────────┐ │ Input Grid Dimensions │ │ (Rows: 3-100, Cols: 3-100) │ └─────────────┬───────────────────┘ ▼ ┌─────────────────────────────────┐ │ Configure Edge Probes │ │ (Position + Temperature) │ └─────────────┬───────────────────┘ ▼ ┌─────────────────────────────────┐ │ Optional: Add Center Probe │ └─────────────┬───────────────────┘ ▼ ┌─────────────────────────────────┐ │ Set Accuracy Threshold │ └─────────────┬───────────────────┘ ▼ ┌─────────────────────────────────┐ │ Initialize Zero Matrix │ │ Apply Boundary Conditions │ └─────────────┬───────────────────┘ ▼ ┌─────────────────────────────────┐ │ ┌───────────────────────────┐ │ │ │ Iteration Loop │ │ │ │ ──────────────────── │ │ │ │ 1. Update interior nodes │ │ │ │ 2. Apply insulation BC │ │ │ │ 3. Calculate RMS error │ │ │ │ 4. Update visualization │ │ │ │ 5. Capture video frame │ │ │ └───────────────────────────┘ │ │ │ │ │ ▼ │ │ RMS < Accuracy OR │ │ Iterations >= MaxIter? │ │ │ Yes │ └─────────┼───────────────────────┘ ▼ ┌─────────────────────────────────┐ │ Display Results │ │ Export Video (TEMP.MP4) │ └─────────────┬───────────────────┘ ▼ ┌─────────────────────────────────┐ │ Run Again? (Y/N) │ └─────────────────────────────────┘ 

Applications

This simulation can be used to study:

  • Heat distribution in electronic components
  • Thermal analysis of building materials
  • Heat sink design optimization
  • Understanding thermal equilibrium concepts
  • Educational demonstrations of heat transfer principles

Limitations

  • 2D simulation only (no 3D heat flow)
  • Assumes homogeneous material properties
  • Fixed colormap range (0-1000°C)
  • Maximum grid size limited to 100×100

Future Improvements

  • Add support for non-rectangular geometries
  • Implement variable thermal conductivity
  • Add 3D visualization option
  • Include transient (time-dependent) heat analysis
  • Export temperature data to CSV

License

Academic Project - Western Carolina University, 2018


Acknowledgments

This project was completed as part of the Master of Science program at Western Carolina University, Cullowhee, North Carolina.

About

MATLAB simulation of 2D heat conduction using finite difference method with Gauss-Seidel iteration. Features configurable temperature probes, real-time visualization, RMS convergence analysis, and MP4 video export. MS project at Western Carolina University (2018).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages