Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ghonimo/heat-diffusion-grid-simulation-using-pthreads--ece588
This repository contains the code and documentation for a parallelized heat diffusion simulator implemented using Pthreads in C. It simulates the diffusion of heat across a 2D grid, using a finite difference method to calculate temperature changes over time. This program was designed for Portland State University ECE 588 Class
https://github.com/ghonimo/heat-diffusion-grid-simulation-using-pthreads--ece588
c heat-transfer heatmap parallel-computing parallel-programming perl portland-state-university pthreadjoin pthreads
Last synced: about 2 months ago
JSON representation
This repository contains the code and documentation for a parallelized heat diffusion simulator implemented using Pthreads in C. It simulates the diffusion of heat across a 2D grid, using a finite difference method to calculate temperature changes over time. This program was designed for Portland State University ECE 588 Class
- Host: GitHub
- URL: https://github.com/ghonimo/heat-diffusion-grid-simulation-using-pthreads--ece588
- Owner: Ghonimo
- License: gpl-3.0
- Created: 2024-02-03T18:04:28.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-03T01:51:11.000Z (10 months ago)
- Last Synced: 2024-10-13T11:23:30.684Z (3 months ago)
- Topics: c, heat-transfer, heatmap, parallel-computing, parallel-programming, perl, portland-state-university, pthreadjoin, pthreads
- Language: C
- Homepage:
- Size: 9.63 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Heat Distribution Simulation using Pthreads
This repository contains a C program designed to simulate heat distribution across a 2D grid. The simulation is parallelized using POSIX threads (pthreads) to enhance performance and demonstrate the application of multithreading in computational physics problems.
## Problem Description
The program models the temporal evolution of heat distribution on a 2D grid, representing a simplified scenario of heat conduction in a square plate. The simulation uses a finite difference method to approximate the heat equation, with specific initial and boundary conditions.
### Initial and Boundary Conditions
- **Grid Size**: The computational domain is a 2D grid of size 1000 x 1000 points.
- **Initial Temperature Distribution**:
- All points within the central region defined by coordinates (200, 200) to (800, 800) are initialized to 500 degrees.
- The temperature of all other points is set to zero.
- **Boundary Conditions**: Points on the boundary of the grid maintain a constant temperature of zero throughout the simulation.### Simulation Parameters
- **Temperature Update Rule**: The temperature of a point at timestep `t` is computed based on its temperature and the temperatures of its immediate neighbors at timestep `t-1`, according to the formula:
T(x,y)(t) = T(x,y)(t-1) + Cx * (T(x+1,y)(t-1) + T(x-1,y)(t-1) – 2 * T(x,y)(t-1))
+ Cy * (T(x,y+1)(t-1) + T(x,y-1)(t-1) – 2 * T(x,y)(t-1))Where `Cx` and `Cy` are constants that govern the rate of heat transfer along the x and y axes, respectively.
- **Time Steps**: The simulation progresses through 4000 time steps.
- **Reporting**: After every 200 time steps, the program prints the temperatures at specific grid points: (1, 1), (150,150), (400, 400), (500, 500), (750, 750), and (900,900).## Implementation Details
The program is implemented in C and utilizes pthreads to divide the computation across multiple processors, aiming for a high degree of parallel speedup. A barrier synchronization mechanism ensures that all threads have completed their calculations at each timestep before proceeding to the next, maintaining data consistency.
## Building and Running
To compile the program, use:
```bash
cc -lpthread -lrt TempGrid_HW3.c -o TempGrid_HW3
```To run the compiled binary, specifying the number of threads:
```bash
./bin/HW3_updated
```
To run in batch more, comparing the performance of with different cores, you can execute the perl script below:
```bash
./automate/batch_run.pl
```## Output
The program outputs the temperatures of specified grid points after every 200 timesteps and displays the total runtime in nanoseconds and seconds.## License
This project is open-sourced under the MIT License.