- Overview
- Features
- Installation
- Usage
- Architecture
- Configuration
- Advanced Features
- Screenshots
- Contributing
- License & Contact
Quantum Whirl is an interactive educational tool designed to visualize and simulate single-qubit quantum mechanics. Unlike standard educational tools that rely on static diagrams, Quantum Whirl provides a real-time, interactive Bloch Sphere and a Quantum Coin Flip experiment that demonstrates superposition, probability amplitudes, and measurement collapse.
| Feature | ๐ช Standard Coin Flip Sim | โ๏ธ Quantum Whirl |
|---|---|---|
| State Representation | Binary (H or T) | Continuous Bloch Sphere |
| Probability | Fixed 50/50 | Adjustable Amplitudes (ฮฑ, ฮฒ) |
| 3D Visualization | None | Interactive Three.js Sphere |
| Math Transparency | Hidden | Real-time Calculation Steps |
| Quantum Concepts | N/A | Superposition, Phase, Fidelity |
- Superposition: Visualize states where the qubit exists in both |0โฉ and |1โฉ simultaneously.
- Measurement Collapse: Watch the state collapse to a basis state upon measurement (coin flip).
- Quantum Noise: Simulate environmental effects like decoherence and entanglement.
- Interactive Bloch Sphere: Rotate and zoom to explore the qubit state vector in 3D space.
- Dynamic State Vector: Real-time updates to the vector position based on ฮธ (theta) and ฯ (phi) parameters.
- Visual Guides: Equatorial and meridian rings for precise state tracking.
- Real-time Parameters: Adjust probabilities and angles using intuitive sliders.
- Step-by-Step Math: computation panel showing the exact math behind every quantum operation.
- Immersive Design: Particle background, custom cursor trails, and neon aesthetics.
| Software | Version | Description |
|---|---|---|
| Node.js | 14.x+ | Required for the dev server (optional if just opening HTML) |
| Web Browser | Modern | Chrome, Firefox, Edge, or Safari with WebGL support |
-
Clone the Repository
git clone https://github.com/muhib-mehdi/quantum-coin-flip.git cd quantum-coin-flip -
Install Dependencies (Optional) If you want to use the included lightweight server:
npm install
-
Run the Application
npm start
Or simply open
index.htmlin your browser.
graph LR
A[Start] --> B[Explore Page]
B --> C{Action}
C -->|Adjust Sliders| D[Update Quantum State]
C -->|Click Coin| E[Measure Qubit]
D --> F[Bloch Sphere Updates]
E --> G[Collapse Wavefunction]
G --> H["Show Result |0โฉ or |1โฉ"]
- Enter the Lab: Click "Explore" on the landing page.
- Define State: Use the Quantum Parameters panel on the right to set your qubit's state (e.g., set
Alphato0.5for a 25% chance of Heads). - Visual Check: Verify the state on the Bloch Sphere at the bottom right.
- Experiment: Click the Quantum Coin to perform a measurement.
- Analyze: Watch the Computation Display to see how probability + noise determined the outcome.
The application is built with a separation of concerns between the Physics engine, the Visualization layer, and the User Interface.
graph TD
subgraph UI [User Interface]
HTML[index.html]
CSS[styles.css]
Script[script.js]
end
subgraph Logic [Quantum Core]
QState[QuantumState Class]
Math[Probabilities & Phase]
end
subgraph Vis [Visualization]
Three[Three.js Renderer]
Sphere[Bloch Sphere Mesh]
end
HTML -->|User Input| Script
Script -->|Update Params| QState
QState -->|State Vector| Sphere
Sphere -->|Render| HTML
QState -->|Measurement Result| Script
quantum.js: Contains theQuantumStateclass which handles all physics calculations (amplitudes, probabilities, noise simulation).script.js: Manages UI interactions, custom cursor effects, and the particle background system.Three.js: Used withinquantum.js(and inline scripts) to render the 3D Bloch Sphere.
Expand the sections below to understand the adjustable parameters.
๐ Geometric Parameters (Bloch Sphere)
- ฮธ (Theta): The polar angle (0 to 180ยฐ). Determines the probability of |0โฉ vs |1โฉ.
- 0ยฐ = |0โฉ (Heads)
- 180ยฐ = |1โฉ (Tails)
- 90ยฐ = Superposition
- ฯ (Phi): The azimuthal angle (0 to 360ยฐ). Represents the phase of the qubit.
- Phase (ฮด): Additional global phase factor.
๐ Environmental Factors
- Entanglement Factor: Simulates noise from entanglement with an environment, adding randomness to the probability distribution.
- Decoherence Rate (ฮณ): Simulates the loss of quantum coherence over time, pushing the state towards a classical mix.
- Fidelity: Represents the quality of the quantum gate/operation.
The simulation calculates the probability of measuring state
Where:
$\alpha = \cos(\theta/2)$ $\beta = e^{i\phi}\sin(\theta/2)$ -
$F$ is the Fidelity factor.
| Key | Action |
|---|---|
Space |
Flip Coin (Measure) |
R |
Reset Parameters |
Esc |
Return to Menu |
The Quantum Whirl Interface showing the Coin (left), Parameters (center), and Bloch Sphere (bottom right).
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request