A real-time 3D black hole simulation built with Python and Pygame, featuring gravitational physics, particle systems, and visual effects.
- Realistic Physics: Implements gravitational acceleration and Schwarzschild radius calculations
- Particle System: Simulates accretion disk with hundreds of particles
- Visual Effects: Glow effects, particle trails, and gravitational lensing visualization
- Interactive Camera: Full 3D camera controls with zoom and movement
- Real-time Simulation: 60 FPS simulation with dynamic particle generation
- Clone the repository:
git clone https://github.com/yourusername/black-hole-simulation.git
cd black-hole-simulation- Create a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtRun the simulation:
python src/main.py- WASD: Move camera
- Q/E: Move camera up/down
- +/-: Zoom in/out
- R: Reset camera position
- G: Toggle gravity on/off
- ESC: Exit simulation
src/
├── main.py # Main simulation loop
├── physics/ # Physics calculations
│ ├── black_hole.py # Black hole physics
│ ├── particle.py # Particle system
│ └── constants.py # Physical constants
├── rendering/ # Rendering system
│ ├── renderer.py # Main renderer
│ ├── camera.py # Camera controls
│ └── camera_config.py # Camera settings
└── utils/ # Utility functions
└── vectors.py # Vector operations
The simulation implements:
- Gravitational Force: F = GMm/r²
- Schwarzschild Radius: Rs = 2GM/c²
- Event Horizon: Particles crossing the event horizon turn black
- Orbital Mechanics: Particles follow realistic orbital paths
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Run tests:
python -m pytest tests/ - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Physics calculations based on Einstein's General Relativity
- Inspired by real black hole observations from Event Horizon Telescope
- Built with Python, Pygame, and NumPy