Skip to content

patelMaharshii/ROCsim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ROCsim - Real-Time Physics Simulation Engine

ROCsim Logo

Build Status License ROCm Qt

ROCsim is an open-source, GPU-accelerated physics simulation engine optimized for AMD Radeon GPUs using ROCm/HIP, with full support for NVIDIA GPUs. Built with Qt and OpenGL, ROCsim provides real-time visualization of complex physics simulations including gravitational systems, collision dynamics, and spring networks.


πŸ“Έ Video

🌟 Features

Core Physics Engine

  • Multiple Physics Models
    • Gravitational N-Body simulation with orbital mechanics
    • Particle collision system with elastic/inelastic collisions
    • Spring-mass network with Hooke's Law
  • GPU-Accelerated Computing
    • HIP/ROCm optimized kernels for AMD GPUs
    • Full CUDA compatibility for NVIDIA GPUs
    • Direct GPU-to-GPU data sharing (zero-copy pipeline)
  • Advanced Numerical Integration
    • Verlet integration for energy conservation
    • Runge-Kutta 4th order for high precision
    • Adaptive time stepping for stability

Professional Qt GUI

  • Interactive 3D Visualization
    • Real-time OpenGL rendering
    • Smooth particle systems with 100-5000+ particles
    • Color-coded particles based on velocity/energy
  • Real-Time Controls
    • Play/Pause/Reset simulation
    • Dynamic parameter adjustment (gravity, damping, particle count)
    • Runtime physics model switching
  • Performance Monitoring
    • Live FPS counter
    • GPU compute time tracking
    • Memory usage statistics

Technical Highlights

  • OpenGL-HIP Interoperability: Direct buffer sharing between compute and graphics
  • Cross-Platform: Linux (Ubuntu 22.04+) and Windows 10/11 (WSL2)
  • Modern C++17: Clean architecture with design patterns
  • Extensible Design: Plugin-ready for custom physics models

πŸ”§ Development

Core Project Structure

ROCsim/
β”œβ”€β”€ code/                   # Header and C++ source files
β”‚   β”œβ”€β”€ mainwindow.h
β”‚   β”œβ”€β”€ openglwidget.h
β”‚   β”œβ”€β”€ particlekernel.h
β”‚   β”œβ”€β”€ CMakeLists.txt
β”‚   └── ...
β”œβ”€β”€ docs/                   # Project report, UML diagrams and any design files
β”‚   β”œβ”€β”€ Deliverable 1/
β”‚   β”œβ”€β”€ Deliverable 2/
β”‚   └── Deliverable 3/
β”œβ”€β”€ tests/                  # GoogleTest unit tests
└── README.md

Building for Development

# Debug build with verbose output
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON
make -j$(nproc)

# Run tests
ctest --output-on-failure

Design Patterns Used

  • Strategy Pattern: Interchangeable physics models
  • Factory Pattern: Physics model instantiation
  • Singleton Pattern: GPU memory manager
  • Observer Pattern: Performance monitoring

🎯 Project Goals

ROCsim addresses the lack of open-source physics simulators optimized for AMD GPUs. While many tools use NVIDIA's CUDA, ROCsim provides:

  1. AMD-First Development: Optimized for ROCm and Radeon GPUs
  2. Cross-Vendor Compatibility: Works on both AMD and NVIDIA hardware
  3. Educational Focus: Visualize physics concepts for students and researchers
  4. Performance: Real-time simulation of thousands of particles at 60 FPS

πŸ“‹ Requirements

Hardware

  • GPU: AMD Radeon (RDNA2+) or NVIDIA (Compute 6.0+) with HIP support
  • RAM: Minimum 8GB system memory
  • Display: OpenGL 3.3+ compatible graphics

Software

  • OS: Ubuntu 22.04+ or Windows 10/11 (with WSL2)
  • ROCm: Version 6.4.2 or newer
  • Qt: Version 6.5 or newer
  • CMake: Version 3.16 or newer
  • Compiler: GCC 11+ or Clang 14+ with C++17 support

πŸš€ Quick Start

Installation

1. Install ROCm (AMD GPUs)

# Ubuntu 22.04/24.04
wget https://repo.radeon.com/amdgpu-install/latest/ubuntu/jammy/amdgpu-install_latest_all.deb
sudo apt install ./amdgpu-install_latest_all.deb
sudo amdgpu-install -y --usecase=rocm

# Verify installation
rocminfo

2. Install Qt and Dependencies

sudo apt update
sudo apt install -y qt6-base-dev qt6-opengl-dev
sudo apt install -y libglfw3-dev libglew-dev cmake build-essential

3. Clone and Build

git clone https://github.com/yourusername/ROCsim.git
cd ROCsim
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)

4. Run

./rocm_qt_opengl_physics_demo

πŸ“– Usage

Basic Controls

  • Mouse Left Click + Drag: Rotate 3D camera
  • Mouse Scroll: Zoom in/out
  • Spacebar: Pause/Resume simulation
  • R: Reset simulation
  • 1/2/3: Switch physics models (Gravity/Collision/Springs)
  • +/-: Increase/decrease particle count
  • ESC: Exit application

GUI Controls

  • Simulation Type Dropdown: Select physics model
  • Parameter Sliders:
    • Gravity strength (0.0 - 2.0)
    • Damping factor (0.5 - 1.0)
    • Particle count (100 - 5000)
  • Performance Monitor: Real-time FPS and GPU metrics

Exporting Data

// Export simulation state
File β†’ Export β†’ Simulation Data (CSV)

// Save configuration
File β†’ Save Configuration β†’ config.json

πŸ—οΈ Architecture

ROCsim follows a layered architecture with clear separation of concerns:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Qt GUI                        β”‚
β”‚  MainWindow | ControlPanel | PerformanceMonitor β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          Business Logic Layer                     β”‚
β”‚  SimulationManager | PhysicsEngine | RenderEngine β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               Compute Layer                   β”‚
β”‚  HIPKernelManager | GPUMemoryManager          β”‚
β”‚  IntegratorConstraintSolver | PhysicsModels   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                Data Layer                         β”‚
β”‚  Particle | PhysicsParameters                     β”‚
β”‚  ConfigurationManager | PerformanceMetrics        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

Physics Engine (Team 1)

  • PhysicsEngine: Core physics computation coordinator
  • HIPKernelManager: GPU kernel execution
  • IntegratorConstraintSolver: ODE solving with constraints
  • PhysicsModel (Strategy Pattern): Gravitational, Collision, Spring models

Rendering Engine (Team 2)

  • RenderEngine: OpenGL visualization pipeline
  • MainWindow: Qt application framework
  • ControlPanel: User interaction controls
  • PerformanceMonitor: Real-time metrics display

πŸ“Š Performance Benchmarks

Configuration Particle Count FPS (AMD RX 6800) FPS (NVIDIA RTX 3070)
Gravity 500 60 60
Gravity 1000 58 60
Collision 500 55 58
Springs 1000 52 55

Benchmarks on Ubuntu 22.04, ROCm 6.4, Qt 6.5


🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Team Structure

  • Team 1 (Physics & GPU Compute): Jiwon Lee, Jacob Lee
  • Team 2 (Visualization & UI): Eric Jean, Maharshii Patel

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“… Roadmap

Deliverable 2 (October 30, 2025)

  • βœ… Basic physics engine with gravitational model
  • βœ… Qt GUI with OpenGL rendering
  • βœ… HIP-OpenGL interoperability
  • ⏳ Single physics model working

Deliverable 3 (December 15, 2025)

  • ⏳ All three physics models (Gravity, Collision, Springs)
  • ⏳ Advanced numerical integration (Verlet, RK4)
  • ⏳ Performance optimization
  • ⏳ Complete testing suite
  • ⏳ Final documentation and video demo

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • AMD ROCm Team: For excellent GPU computing platform
  • Qt Project: For robust cross-platform GUI framework
  • Western University CS3307: Course project for Object-Oriented Design
  • NVIDIA CUDA Samples: Reference implementations for GPU interoperability
  • OpenGL Community: Tutorials and documentation

πŸ“§ Contact

Project Link: https://github.com/yourusername/ROCsim

Team 1 (Physics/GPU):

Team 2 (Graphics/UI):


🌐 Resources


Made with ❀️ by the ROCkers | Fall 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors