Skip to main content

A quantum universe simulator with a C-engine

Project description

qbitUni — Quantum Universe Simulator

s/o Gemini....

About

qbitUni (qu) is a quantum simulator that allows you to simulate a quantum environment locally -- with operations. We use a C engine to perform the quantum operations and a Python wrapper to interface.

We have a test suite in tests/. Try the OpenQASM parser too!

🚀 Features

  • Core Engine: Written in C with multithreading.
  • Universality: Supports all standard gates (H, X, Y, Z, S, T, CNOT, CZ, Toffoli, RX, Phase).
  • Scientific Tools: Expectation Value <Z> calculation and Noise Simulation for VQE. Benchmarks, too.
  • Compatibility: Includes an OpenQASM 2.0 parser.
  • Visualization: Built-in ASCII Bloch Spheres and Histograms.

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

Test Suite

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
python3 tests/science.py
python3 tests/visuals.py
python3 tests/energy.py
python3 tests/qasm/run.py

python3 tests/benchmark.py

Running your first simulation

1. Code

Create script.py file for this test.

# 📚 Import the Quantum Universe from Qbit
import qbitUni as qu

# ⚡ Initialize a 2-qubit Universe
# This allocates the state vector in C memory
univ = qu.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

2. Execute

Terminal:

python3 script.py

UI Studio:

streamlit run app.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qbituni-1.0.0.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qbituni-1.0.0-cp313-cp313-macosx_10_13_universal2.whl (33.5 kB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

File details

Details for the file qbituni-1.0.0.tar.gz.

File metadata

  • Download URL: qbituni-1.0.0.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for qbituni-1.0.0.tar.gz
Algorithm Hash digest
SHA256 41568a189547e27d9d6407ecc8850f3505a4c64d5e3ae97da4d0f12e07364999
MD5 77d1bcd8fe13a6cee421fb2718837583
BLAKE2b-256 6bf147ea9037fab3957d540494d1b0f3ca46497f181a89070e49e3039ffe9a1b

See more details on using hashes here.

File details

Details for the file qbituni-1.0.0-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for qbituni-1.0.0-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 17d9a2fde71b6034ee28ce424ac70ae5e57a36af38280e4ef38f0e58b54f66c9
MD5 d2e6ab0a25e86643e802ff5c4d248895
BLAKE2b-256 be5d43d278048fbe8e1f65904bff812e1a7a5bd6c7418c9db328e95c99ba5023

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page