Hydrogen Quantum Orbital Visualizer
Real-time 3D visualization of atomic orbitals in Rust
Features โข Quick Start โข Documentation โข Physics โข Contributing
Atoms_Rust is a high-performance Rust port of the Atoms_C++ project, providing interactive 3D visualization of hydrogen atomic orbitals. Built with macroquad for cross-platform rendering, it supports real-time visualization of 100,000+ particles with probability current flow animation.
graph TB
subgraph "๐ฎ User Interface"
UI[Interactive Controls<br/>W/S E/D R/F T/G]
CAM[Orbit Camera<br/>Mouse Drag + Scroll]
FPS[FPS & Status Display]
end
subgraph "๐ฌ Visualization Modes"
R3D[3D Realtime<br/>100k-2M particles]
RAY[Raytracer<br/>GPU Lighting & Shadows]
A2D[2D Atom Sim<br/>Wave-Particle Physics]
W2D[Wave 2D<br/>Energy Level Viz]
end
subgraph "โ๏ธ Core Engine"
PHYS[Physics Module<br/>Laguerre & Legendre]
REND[Render Module<br/>Shaders & Batches]
SAMPL[Sampler<br/>CDF-based Sampling]
end
UI --> R3D
UI --> RAY
UI --> A2D
UI --> W2D
CAM --> R3D
CAM --> RAY
R3D --> PHYS
RAY --> PHYS
A2D --> PHYS
W2D --> PHYS
PHYS --> SAMPL
R3D --> REND
RAY --> REND
| Feature | Description |
|---|---|
| ๐ Real-time 3D | Interactive rendering of hydrogen orbital probability clouds |
| ๐ Probability Flow | Animated probability current for orbitals with m โ 0 |
| ๐จ Inferno Colormap | Professional scientific visualization colors |
| โก High Performance | Parallel processing with rayon, 60 FPS with 100k particles |
| ๐ฅ๏ธ Cross-platform | Windows, Linux, macOS, and WebAssembly support |
| ๐ Multiple Modes | 4 visualization binaries for different use cases |
# Clone and enter the repository
git clone https://github.com/your-repo/Atoms.git
cd Atoms/Atoms_Rust
# Run the 3D realtime visualizer (recommended first)
cargo run --bin realtime --release
# Other visualization modes
cargo run --bin raytracer --release # GPU raytracing
cargo run --bin atom_2d --release # 2D atom simulation
cargo run --bin wave_2d --release # 2D wave visualization๐ Platform-specific prerequisites
sudo apt install build-essential pkg-config libasound2-dev libssl-dev \
libfreetype6-dev libexpat1-dev libxcb1-dev libgl1-mesa-devxcode-select --installInstall Visual Studio Build Tools with C++ development.
| Binary | Description | Particles | Use Case |
|---|---|---|---|
realtime |
3D probability cloud with flow animation | 100k-2M | Interactive exploration |
raytracer |
GPU point sprites with realistic lighting | 1k-50k | High-quality rendering |
atom_2d |
Multi-atom Bohr model with wave physics | 20 atoms | Understanding transitions |
wave_2d |
Electron wave function visualization | 1 electron | Energy level education |
| Key | Action |
|---|---|
W / S |
Increase / Decrease principal quantum number n |
E / D |
Increase / Decrease angular momentum l |
R / F |
Increase / Decrease magnetic quantum number m |
T / G |
Add / Remove 100k particles |
Space |
Pause / Resume animation |
Escape |
Reset camera position |
| ๐ฑ๏ธ Drag | Orbit camera around origin |
| ๐ฑ๏ธ Scroll | Zoom in / out |
| Key / Action | Effect |
|---|---|
W / S |
Fine energy adjustment (ยฑ0.01 eV) |
E / D |
Medium energy adjustment (ยฑ0.1 eV) |
R / F |
Coarse energy adjustment (ยฑ1.0 eV) |
Space |
Pause / Resume |
R / Escape |
Reset simulation |
| ๐ฑ๏ธ Click | Spawn energy waves (atom_2d only) |
The visualization is based on the hydrogen wave function:
Where
Particles are sampled from the probability density
flowchart LR
A[Quantum Numbers<br/>n, l, m] --> B[Build CDF Tables]
B --> C[Sample r]
C --> D[Sample ฮธ]
D --> E[Sample ฯ]
E --> F[Convert to<br/>Cartesian]
F --> G[Calculate Color]
G --> H[Render Particle]
H --> C
๐ Full physics derivation: docs/PHYSICS.md
src/
โโโ lib.rs # Library entry point
โโโ constants.rs # Physical constants (aโ, ฤง, mโ)
โ
โโโ physics/ # Quantum mechanics calculations
โ โโโ polynomials.rs # Laguerre & Legendre polynomials
โ โโโ sampling.rs # CDF-based probability sampling
โ โโโ color.rs # Inferno colormap implementation
โ
โโโ render/ # Rendering utilities
โ โโโ instanced.rs # Instanced particle rendering
โ โโโ shaders.rs # GLSL shader code
โ
โโโ camera/ # Camera controllers
โ โโโ orbit.rs # Orbit camera implementation
โ
โโโ bin/ # Executables
โโโ realtime.rs # 3D realtime visualizer
โโโ raytracer.rs # GPU raytracing mode
โโโ atom_2d.rs # 2D atom simulation
โโโ wave_2d.rs # 2D wave visualization
๐ Detailed architecture: docs/ARCHITECTURE.md
| Binary | Target FPS | Particles | Memory |
|---|---|---|---|
realtime |
60 | 100,000 | ~200 MB |
raytracer |
30 | 10,000 | ~50 MB |
atom_2d |
60 | 20 atoms | ~20 MB |
wave_2d |
60 | 1 electron | ~10 MB |
Key optimizations:
- Parallel processing:
rayonfor multi-core particle updates - CDF caching: Reuse probability tables between frames
- Pre-allocation: Zero runtime allocations in render loop
๐ Optimization guide: docs/PERFORMANCE.md
| Document | Description |
|---|---|
| Getting Started | Installation and first run |
| User Guide | Complete usage documentation |
| Physics | Quantum mechanics derivation |
| Architecture | Code structure and design |
| Performance | Optimization techniques |
| API Reference | Library documentation |
# Add WebAssembly target
rustup target add wasm32-unknown-unknown
# Build
cargo build --target wasm32-unknown-unknown --releaseSee macroquad WASM documentation for HTML setup.
Atoms/
โโโ Atoms_C++/ # Original C++ implementation
โ โโโ src/
โ โโโ atom_realtime.cpp
โ โโโ atom_raytracer.cpp
โ โโโ atom.cpp
โ โโโ wave_atom_2d.cpp
โ
โโโ Atoms_Rust/ # Rust port (this project)
โโโ src/
โโโ docs/
โโโ examples/
Contributions are welcome! Please read our Contributing Guide for details on:
- Code style and conventions
- Pull request process
- Adding new features
This project is licensed under the MIT License - see the LICENSE file for details.
- Original Atoms_C++ implementation
- macroquad - Cross-platform game framework
- rayon - Data parallelism library
Made with โค๏ธ for quantum physics education
