A quantum universe simulator with a C-engine
Project description
qbitUni — Quantum Universe Simulator
s/o Gemini....
Installation
git clone https://github.com/imesh97/qbit-universe.git
Setup
Note: This project uses Python 3.13.
Create and run a virtual environment.
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Tests
python3 tests/gates.py
python3 tests/melinda.py
python3 tests/xy.py
python3 tests/parallel.py
python3 tests/universality.py
python3 tests/teleport.py
python3 tests/grover.py
Running your first simulation
Code
Create script.py file for this test.
from qbitUni import QuantumUniverse
# ⚡ Initialize a 2-qubit Universe
# This allocates the state vector in C memory
univ = QuantumUniverse(2)
univ.print_state() # Print initial state
# (Notice the |00> state only -- as the other |01>, |10>, |11> are all 0 -- we only print probabilities > 0.01%)
# ⊹ Apply a Hadamard gate to Qubit 0
# This puts Qubit 0 into a 50/50 superposition of |0> and |1>
univ.h(0)
univ.print_state() # Print state after Hadamard
# 🎛️ Apply a CNOT (Controlled-NOT) gate
# Control: Qubit 0, Target: Qubit 1
# This 'links' the two qubits together (Entanglement)
univ.cnot(0, 1)
univ.print_state() # Print state after CNOT
# 🧮 Peek at the Math
# Check the probability of the universe being in state |00> or |11>
print(f"Prob of |00>: {univ.get_prob(0):.2f}")
print(f"Prob of |11>: {univ.get_prob(3):.2f}")
# 🌊 Collapse the Wavefunction
# Measuring will force the universe into a single classical state
result = univ.measure_all()
print(f"Final Measurement: {result:02b}")
univ.print_state() # Print state after collapse
Execution
python3 script.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
qbituni-0.0.7.tar.gz
(11.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qbituni-0.0.7.tar.gz.
File metadata
- Download URL: qbituni-0.0.7.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3089f2b0edd4d8023741d0f7a3faf49ce770c185b8c764dce42184cae38953b4
|
|
| MD5 |
7d88600e8afb1c97b3ca2f554387028d
|
|
| BLAKE2b-256 |
e425fe2a04ec976777623e14e1ed6d61c474a83fac66b7885aa6af4510eedc2b
|
File details
Details for the file qbituni-0.0.7-cp313-cp313-macosx_10_13_universal2.whl.
File metadata
- Download URL: qbituni-0.0.7-cp313-cp313-macosx_10_13_universal2.whl
- Upload date:
- Size: 27.0 kB
- Tags: CPython 3.13, macOS 10.13+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fddb95804418e947b6cc33e4635c78ecdba0243e8ae967a8d1346fef83684c7b
|
|
| MD5 |
e6ad419e45d8f6f336a2a5948a245685
|
|
| BLAKE2b-256 |
2e1536b93dc7d7096a79ea01c18abdb8b318f952d08b14ea0308a1229023cfc4
|