A physically accurate 3D black hole visualization and sonification system using C++ and OpenGL, implementing real general relativity physics with scientifically accurate audio generation.
- Dual Physics Engines: Factory pattern supporting both Schwarzschild (non-rotating) and Kerr (rotating) black holes
- Schwarzschild Metric: Accurate spacetime curvature around non-rotating black holes
- Kerr Metric: Full rotating black hole physics with frame dragging and ergosphere effects
- Ergosphere Physics: Regions where spacetime itself is dragged, enabling energy extraction
- Dual Event Horizons: Outer and inner horizons for rotating black holes with spin-dependent geometry
- Geodesic Ray Tracing: Light paths calculated using Einstein's field equations
- 4th-Order Runge-Kutta Integration: Numerical solution of geodesic differential equations
- Adaptive Step Sizes: Smaller integration steps near the event horizon for accuracy
- Gravitational Lensing: Realistic light bending around the black hole
- Event Horizon: True black region where light cannot escape (dual horizons for Kerr black holes)
- Photon Sphere: Critical orbital radius at 1.5 × Schwarzschild radius
- Ergosphere Visualization: Frame-dragging region where spacetime is dragged around rotating black holes
- Relativistic Jets: Highly collimated plasma streams with synchrotron emission and relativistic beaming
- Accretion Disk: Hot plasma with temperature gradient and Doppler shift effects
- Background Stars: Procedural star field showing gravitational lensing distortion
- Scientific Sonification: Real-time audio generation from physics calculations
- Gravitational Wave Audio: Convert orbital frequencies using Kepler's laws (
f = (1/2π)√(GM/r³)) - Electromagnetic Sonification: Temperature-based frequencies from accretion disk (
f = k_B T/h) - Relativistic Effects: Gravitational redshift, Doppler shifts, and frame-dragging audio
- Musical Scales: Physics frequencies mapped to pleasant musical scales (pentatonic, chromatic, harmonic series)
- Multi-Physics Audio: Simultaneous sonification of jets, tidal forces, and Hawking radiation
- Spatial Audio: Stereo positioning based on frame-dragging and observer position
- Real-time Processing: 44.1kHz audio with professional-grade EQ, compression, and de-essing
- Factory Pattern Architecture: Modular physics engines with runtime switching between Schwarzschild and Kerr
- Real-time Ray Marching: GPU-accelerated fragment shader ray tracing
- Camera System: Precision orbital camera with emergency escape controls
- Performance System: Adaptive quality scaling, turbo mode, and automatic FPS optimization
- Performance Logging: Real-time monitoring and analysis of rendering performance
- Cross-platform: macOS native with OpenGL 3.3 Core Profile
- Modular Audio Engine: Separate sonification system with EQ, compression, and spatial audio
Event Horizon: rs = 2GM/c² = 2M (in geometric units) Photon Sphere: rph = 1.5rs = 3M ISCO: risco = 3rs = 6M
Metric Components (exact implementation):
g_tt = -(1 - rs/r)
g_rr = 1/(1 - rs/r)
g_θθ = r²
g_φφ = r²sin²θGeodesic Equations (actual implementation):
d²t/dλ² = -2rs/(r(r-rs)) × dr/dλ × dt/dλ
d²r/dλ² = -rs(r-rs)/(2r³)(dt/dλ)² + rs/(2r(r-rs))(dr/dλ)² + (r-rs)[(dθ/dλ)² + sin²θ(dφ/dλ)²]
d²θ/dλ² = -2/r × dr/dλ × dθ/dλ + sinθcosθ(dφ/dλ)²
d²φ/dλ² = -2/r × dr/dλ × dφ/dλ - 2cosθ/sinθ × dθ/dλ × dφ/dλBoyer-Lindquist Coordinates with spin parameter a:
Horizons: r± = M ± √(M² - a²)
Ergosphere: r_ergo = M + √(M² - a²cos²θ)
Critical Functions:
- Δ = r² - 2Mr + a²
- Σ = r² + a²cos²θ
- A = (r² + a²)² - a²Δsin²θ
Metric Components:
g_tt = -(1 - 2Mr/Σ)
g_rr = Σ/Δ
g_θθ = Σ
g_φφ = (A sin²θ)/Σ
g_tφ = -2Mar sin²θ/Σ // Frame-dragging termFrame-Dragging Angular Velocity:
ω = -g_tφ/g_φφ = 2Mar/(r² + a²)² - a²Δsin²θ)Implementation (both Schwarzschild and Kerr):
k1 = h × f(x_n, y_n)
k2 = h × f(x_n + h/2, y_n + k1/2)
k3 = h × f(x_n + h/2, y_n + k2/2)
k4 = h × f(x_n + h, y_n + k3)
y_{n+1} = y_n + (k1 + 2k2 + 2k3 + k4)/6Orbital Frequency to Audio:
f_orbital = (1/(2π)) × √(GM/r³) [Kepler's Law]
audio_freq = scale × log(f_orbital/1e-6) / log(1e6)Electromagnetic to Audio:
f_em = c/λ
log_audio = log_min + (log_em - 6)/(18-6) × (log_max - log_min)
audio_freq = 10^log_audioTemperature to Audio (Planck's relation):
f_thermal = k_B × T / h
audio_freq = scale × √(f_thermal/1e12)Synchrotron Emission (relativistic jets):
f_sync = (eB/2πm_e) × γ² [Cyclotron × Lorentz²]
audio_freq = scale × log(f_sync/1e9) / log(1e6)Beaming Factor (exact implementation):
δ = 1/(γ(1 - β·n̂)) [Relativistic Doppler]
γ = 1/√(1 - β²) [Lorentz factor]
β = v/c [Normalized velocity]Synchrotron Power:
P_sync ∝ B²γ²β²sin²α [Larmor formula]
Temperature: T = 1e9 × (B/B_0)^(2/3) [Equipartition]Beaming Cone Angle:
θ_cone ≈ 1/γ [Natural beaming cone]Physics-to-Audio Conversion:
log_normalized = (log₁₀(f_physics) - log₁₀(f_min)) / (log₁₀(f_max) - log₁₀(f_min))
f_musical = A₄ × 2^((scale_note - 69)/12) [Equal temperament]Einstein Deflection Angle (weak-field approximation):
α ≈ 4GM/(c²b) = 2rs/b [Impact parameter b]
deflectionAngle = 2.0 * schwarzschildRadius / max(impactParameter, 0.1 * rs)Strong-Field Deflection (Darwin's exact formula):
δφ ≈ 4Rs/b + 15πRs²/(4b²) + 128Rs³/(3b³) + ... [Higher-order terms]Impact Parameter Calculation:
impactParameter = distanceToBlackHole × sin(acos(dot(rayDir, toBlackHole)))Coordinate Transformations (Boyer-Lindquist ↔ Cartesian):
r = √(0.5 × (ρ² + √(ρ²⁺ + 4a²z²))) where ρ² = x² + y² + z² - a²
x = √(r² + a²) × sinθ × cosφ
y = √(r² + a²) × sinθ × sinφ
z = r × cosθSchwarzschild Step Size:
if (r < 2rs): h = 0.001 [Event horizon region]
if (2rs < r < 5rs): h = linear interpolation [Transition zone]
if (r > 5rs): h = 0.1 [Far field]Kerr Step Size (includes ergosphere):
if (r < 1.1r₊ || inErgosphere): h = 0.001 [Critical regions]
if (r < 2r_ergo): h = interpolated [Near ergosphere]
if (r > 2r_ergo): h = 0.1 [Safe region]Performance-Adaptive Quality:
if (frameTime > 100ms): performance_scale = 0.2 [Emergency mode]
if (frameTime > 50ms): performance_scale = 0.4 [Severe degradation]
zoom_speed = base_speed × (1 - 0.95 × journey_progress²) [Dramatic slowdown]Strong-Field Deflection (exact Darwin series):
u = M/b [Dimensionless parameter]
α₀ = 4u [Weak field (Newton)]
α₁ = (15π/4)u² [Post-Newtonian correction]
α₂ = (128/3)u³ [Strong field correction]
α₃ = (3465π/64)u⁴ [Higher-order relativistic]
α_total = α₀ + α₁ + α₂ + α₃ [Complete deflection]- macOS 10.15+ (optimized for Apple Silicon M4 Max)
- OpenGL 3.3 Core Profile support
- CoreAudio framework (built-in on macOS)
- Audio output device (headphones recommended for spatial audio)
- CMake 3.20+
- C++17 compatible compiler (Clang recommended)
./build.shmkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j$(sysctl -n hw.ncpu)cd build
./BlackHoleSimulator- SPACEBAR: Toggle auto-movement through the black hole (enable/disable autopilot)
- Mouse Wheel: Zoom in/out (allows extremely close approach to event horizon)
- W/S: Zoom in/out (hold Ctrl for fine control)
- Q/E: Precision zoom control (ultra-fine steps)
- BACKSPACE: Emergency reverse to safe distance (instant escape)
- 1-3: Change render modes
- L: Toggle light ray visualization
- J: Toggle relativistic jets on/off
- U/I: Increase/decrease jet Lorentz factor
- O/P: Increase/decrease jet opening angle
- V: Show dramatic visual effects status
- F: Test jump to close distance (1.5 Rs)
- ESC: Exit
- Q: Toggle optimization mode (OPTIMIZED ↔ STANDARD)
- R: Reset performance settings to defaults
- T: TURBO mode (ultra performance for smooth movement)
- Y: QUALITY mode (all features enabled)
- E: Toggle control panel
- S: Toggle black hole sonification on/off
- +/-: Adjust audio volume
- M: Toggle spatial audio effects
- N: Toggle relativistic audio effects
Default configuration with mass equal to our Sun:
- Mass: 1 Solar Mass (1.989 × 10³⁰ kg)
- Spin Parameter: a = 0.0 (no rotation)
- Event Horizon: ~2,954 meters (single horizon)
- Photon Sphere: ~4,431 meters (exact calculation using Newton's method)
- ISCO (Innermost Stable Circular Orbit): ~8,862 meters
Configurable spin parameter up to near-extremal rotation:
- Spin Parameter Range: -0.998 ≤ a ≤ 0.998 (dimensionless)
- Outer Event Horizon: r₊ = M + √(M² - a²) (depends on spin)
- Inner Event Horizon: r₋ = M - √(M² - a²) (Cauchy horizon)
- Ergosphere: r_ergo = M + √(M² - a²cos²θ) (frame-dragging region)
- ISCO: Spin-dependent, ranges from ~6M (a=0) to ~1.2M (a→1)
- Frame Dragging: Spacetime rotation effects with angular velocity Ω
- Frequency Range: 20 Hz - 20 kHz (typical hearing range)
- Sample Rate: 44.1 kHz professional audio standard
- Default Musical Scale: Major Pentatonic (most consonant)
- Dynamic Range: 60 dB with professional audio compression
- Spatial Audio: Stereo positioning based on frame-dragging effects
Optimized for real-time rendering on M4 Max MacBook:
- Adaptive Ray Marching: Variable step sizes based on gravitational field strength
- GPU Fragment Shaders: Parallel ray computation
- Efficient Integration: 4th-order Runge-Kutta with optimized step selection
- Auto-FPS Optimization: Dynamic quality scaling to maintain target framerate
- Turbo Mode: Ultra-performance mode for smooth extreme proximity navigation
- Emergency Controls: Instant escape mechanisms for safe exploration
- Modular Design: Separate implementations for Schwarzschild and Kerr physics
- Runtime Switching: Dynamic selection between physics engines based on spin parameter
- Interface Abstraction: Clean separation between physics calculations and rendering
- Extensible Framework: Easy addition of new black hole types (e.g., charged Reissner-Nordström)
- BlackHolePhysics: Core physics calculations and metric computations
- RayTracer: GPU-accelerated ray marching with geodesic integration
- BlackHoleSonification: Real-time audio generation from physics parameters
- RelativisticJets: Synchrotron emission and relativistic beaming calculations
- LightSystem: Photon sphere and gravitational lensing effects
- PerformanceLogger: Real-time monitoring and adaptive optimization
- MelodiousCalculator: Musical scale mapping for pleasant sonification
- Multi-Physics Sources: Orbital dynamics, thermal emission, jets, and gravitational waves
- Professional Processing: EQ, compression, de-essing, and spatial audio
- Musical Mapping: Physics frequencies converted to consonant musical scales
- Real-time Generation: 44.1 kHz sample rate with low-latency CoreAudio integration
This simulation implements exact solutions with validated numerical methods:
- Schwarzschild Metric: Complete implementation with exact metric components
g_μν - Kerr Metric: Full Boyer-Lindquist coordinates including frame-dragging term
g_tφ - Geodesic Integration: 4th-order Runge-Kutta with adaptive step sizes near horizons
- Event Horizon Detection: Exact calculation using
r < r_±for Kerr,r < 2Mfor Schwarzschild
- Orbital Mechanics: Kepler's third law
f = (1/2π)√(GM/r³)with exact GM computation - Photon Spheres: Newton's method for
r = 1.5rs(Schwarzschild) and spin-dependent Kerr orbits - ISCO Computation:
3rsfor Schwarzschild, complex spin-dependent formula for Kerr - Frame Dragging: Angular velocity
ω = 2Mar/((r²+a²)²-a²Δsin²θ)from metric
- Synchrotron Emission: Exact
f = (eB/2πm_e)γ²with realistic magnetic field profiles - Relativistic Beaming: Doppler factor
δ = 1/(γ(1-β·n̂))with proper Lorentz transformations - Magnetic Field Evolution:
B(r) ∝ (r_h/r)^1.5with ergosphere amplification for rotating BHs - Temperature Profiles: Equipartition
T = 10⁹(B/B₀)^(2/3)K with realistic cooling
- Physics Frequencies: All derived from fundamental constants (ℏ, k_B, c, G, e, m_e)
- Logarithmic Mapping: Proper frequency scaling from physics ranges to audible spectrum
- Musical Quantization: Equal temperament
f = A₄ × 2^((n-69)/12)with consonant scale selection - Relativistic Effects: Gravitational redshift
√(-g_tt_obs/-g_tt_emit)and Doppler corrections
- Adaptive Integration: Step size
h ∝ 1/√(|acceleration|)near strong-field regions - Coordinate Transformations: Exact spherical ↔ Cartesian with singularity handling
- Metric Evaluation: Cache-optimized computation of
Σ,Δ,Afunctions for Kerr - Professional Audio: 44.1 kHz sampling with anti-aliasing and musical EQ processing
- Schwarzschild, K. (1916). "Über das Gravitationsfeld eines Massenpunktes nach der Einsteinschen Theorie"
- Kerr, R. P. (1963). "Gravitational field of a spinning mass as an example of algebraically special metrics"
- Chandrasekhar, S. (1983). "The Mathematical Theory of Black Holes"
- Luminet, J.-P. (1979). "Image of a spherical black hole with thin accretion disk"
- Hermann, T. (2008). "Taxonomy and definitions for sonification and auditory display"
- Kramer, G. (1994). "Auditory Display: Sonification, Audification, and Auditory Interfaces"
- Dubus, G. & Bresin, R. (2013). "A systematic review of mapping strategies for the sonification of physical quantities"
- Milne, A. (2013). "A computational model of the cognition of tonality"
- Gravitational wave visualization ripples in spacetime
- Multiple black hole systems and binary mergers
- Charged black holes (Reissner-Nordström metric)
- Wormhole traversability visualization
- VR/AR support for immersive exploration
- Tidal force visualization on extended objects
- Hawking radiation particle animation
- Frame-dragging field line visualization
- Plasma magnetohydrodynamics in jets
- MIDI output for external synthesizers
- Real-time gravitational wave data sonification (LIGO/Virgo data)
- Interactive physics parameter control via audio feedback
- Binaural beats from orbital resonances and beat frequencies
- Machine learning-optimized pleasant frequency mapping
- Sonification of gravitational memory effects
MIT License - See LICENSE file for details.
"The most beautiful thing we can experience is the mysterious." - Albert Einstein