Skip to content

StevenKight/Physics-Engine

Repository files navigation

High-Performance Physics Engine

A research project building a physics simulation engine using C/C++, Fortran, and CUDA. The goal is rigid body mechanics simulation with computation routed to whatever hardware makes the most sense for the job.

The short version: CUDA handles the big parallel workloads, Fortran handles small tight-loop numerical operations where it genuinely outperforms the alternatives, and C++ manages everything in between. Getting all three to compile together through CMake was its own adventure.


Why This Stack

CUDA for GPU-accelerated parallel work is a straightforward choice. The Fortran decision gets more questions — the reasoning is that for small, tight numerical loops, Fortran's array handling and compiler optimizations are hard to beat and don't carry the overhead of GPU dispatch. Rather than forcing everything onto the GPU, the idea is to use the right tool for the scale of the problem.

C/C++ ties it all together and handles the core simulation logic.


Current State

  • CMake build system configured for all three languages compiling together
  • Naive matrix operations implemented in both CUDA and Fortran for baseline testing
  • Rigid body mechanics in active development

The Wiki has derivations and math notes as they get worked out.


Build

Prerequisites

  • NVIDIA GPU and the CUDA Toolkit
  • Fortran compiler (GNU Fortran or Intel Fortran)
  • CMake 3.18+
  • CuBLAS (optional, for optimized matrix operations)

Instructions

git clone https://github.com/StevenKight/Physics-Engine.git
cd Physics-Engine
mkdir build && cd build
cmake ..
make

Roadmap

  • Optimized matrix operations replacing naive implementations
  • Core rigid body mechanics
  • Benchmarking against existing engines
  • Soft-body dynamics and constraint systems
  • Mixed-precision arithmetic for GPU throughput
  • Shared library interface for external use
  • Rendering pipeline integration

License

Licensed under the GNU General Public License v3.0. Derivative works must carry the same license.


Contributing

Not open for contributions yet. If you want to discuss the project or have ideas, open an issue or reach out directly. See CONTRIBUTING.md for more details.

About

This physics engine is a research project aimed at leveraging high-performance computing (HPC) to simulate complex physical systems. It is designed to test and apply mathematical derivations in matrix form while utilizing modern hardware acceleration, including CUDA for GPU offloading and Fortran for optimizing critical tight-loop calculations.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors