This repository contains my submission for HPSC 2026 Assignment 1.
The project implements a compact three-dimensional discrete element method (DEM) solver for spherical particles in a rectangular box. The submitted work includes:
- a serial C++17 baseline solver
- verification cases
- runtime profiling
- OpenMP parallelisation of the particle-contact loop
- Section 18 bonus: neighbour search
- Section 19 bonus: damping and particle-cloud settling studies
This submission covers the assignment through the second bonus section. The larger research problem was not attempted.
src/main.cpp: solver, experiment drivers, output writing, profiling, OpenMP, and bonus-study logicscripts/plot_results.py: reads generated CSV/text outputs and produces report figuresrequirements.txt: Python packages needed for plottingreport/white_paper.tex: LaTeX source for the reportreport/figures/: generated figures used in the reportresults/: generated simulation outputs, summaries, diagnostics, and selected snapshotsrun_all.ps1: end-to-end Windows workflowMakefile: optional shortcuts for common tasks
Running the workflow generates three main outputs:
results/: per-case diagnostics, summaries, and selected particle snapshotsreport/figures/: plots created from the generated resultsreport/white_paper.pdf: final compiled report
The report figures are not hand-made. They are generated from the data in results/ by scripts/plot_results.py.
The executable supports these modes:
free_fall: one-particle analytical verification under gravityconstant_velocity: zero-force constant-velocity verificationbounce: one-particle wall-bounce caseverification: grouped verification cases, including timestep sensitivityexperiment: increasing-particle-count serial experimentscaling: profiling, OpenMP strong scaling, weak scaling, and serial-versus-parallel checksneighbor_bonus: brute-force versus neighbour-search comparisonscience_bonus: damping and particle-cloud settling studies
To reproduce the runs and rebuild the report, the following tools are needed:
- a C++17 compiler with OpenMP support
- Python 3
pippdflatex
Python packages used for plotting:
matplotlibnumpypandas
They can be installed with:
python -m pip install -r requirements.txtThe repository includes a Windows PowerShell script for a one-command run:
powershell -ExecutionPolicy Bypass -File .\run_all.ps1For a fresh rerun that removes old generated outputs first:
powershell -ExecutionPolicy Bypass -File .\run_all.ps1 -CleanThis workflow:
- checks required tools
- builds the solver
- runs all verification, experiment, scaling, neighbour-search, and science-bonus cases
- installs Python plotting dependencies
- regenerates the report figures
- compiles the final PDF
The packaged automation script is Windows-specific, but the project can be reproduced manually on Linux or macOS with equivalent tools.
git clone https://github.com/Praveenjhas/HPSC_assignment.git
cd HPSC_assignmentpython3 -m pip install -r requirements.txtWith clang++:
clang++ -std=c++17 -O3 -Wall -Wextra -pedantic -fopenmp src/main.cpp -o dem_solver -fopenmpIf your system uses g++ with OpenMP:
g++ -std=c++17 -O3 -Wall -Wextra -pedantic -fopenmp src/main.cpp -o dem_solver./dem_solver verification results
./dem_solver free_fall results
./dem_solver constant_velocity results
./dem_solver bounce results
./dem_solver experiment results
./dem_solver scaling results
./dem_solver neighbor_bonus results
./dem_solver science_bonus resultspython3 scripts/plot_results.pycd report
pdflatex -interaction=nonstopmode -halt-on-error white_paper.tex
pdflatex -interaction=nonstopmode -halt-on-error white_paper.texThe final PDF will be:
report/white_paper.pdf
If a full rerun is not needed, the stages can be run separately.
Build only:
clang++ -std=c++17 -O3 -Wall -Wextra -pedantic -fopenmp src/main.cpp -o dem_solver -fopenmpRun only one mode:
./dem_solver free_fall resultsRegenerate only plots:
python3 scripts/plot_results.pyRecompile only the report:
cd report
pdflatex -interaction=nonstopmode -halt-on-error white_paper.tex
pdflatex -interaction=nonstopmode -halt-on-error white_paper.tex- Progress information is printed during longer runs, including timestep, simulated time, kinetic energy, center-of-mass height, active contacts, and maximum speed.
- Reported runtimes in the generated summaries are wall-clock runtimes of the simulation runs.
- Different experiments use different physical simulation times depending on purpose, so the reported runtime should not be confused with simulated physical time.
If make is available, these shortcuts can also be used:
make full
make run-free-fall
make run-constant-velocity
make run-bounce
make run-verify
make run-experiment
make run-scaling
make run-neighbor
make run-scienceOn Windows, make full is just a shortcut for run_all.ps1.
All figures in the report are generated from repository data and scripts. The intended order is:
- compile the solver
- run the required simulation modes
- generate the figures from
results/ - compile the LaTeX report
If these steps are followed, the report can be regenerated from the repository contents.