Metadata-Version: 2.4
Name: fuqit
Version: 0.1.0
Summary: An educational quantum circuit simulator, with a GUI, for people who know quantum mechanics.
Author: Tabby Lickman, Ben Hancock, Diyaco Shwany
License-Expression: MIT
Project-URL: Repository, https://github.com/QC2-python-SE/FUQIT
Project-URL: Issues, https://github.com/QC2-python-SE/FUQIT/issues
Keywords: quantum computing,quantum circuits,qubits,education,simulator
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Education
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: matplotlib
Requires-Dist: pillow
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Provides-Extra: docs
Requires-Dist: mkdocs<2; extra == "docs"
Requires-Dist: mkdocs-material; extra == "docs"
Requires-Dist: mkdocstrings[python]; extra == "docs"
Requires-Dist: mkdocs-jupyter; extra == "docs"
Dynamic: license-file

# FUQIT

**FUQIT** is an educational Python package for simulating small quantum circuits.

It is written for students who have a working knowledge of non-relativistic quantum mechanics
up to a Masters' level (bra-ket notation, states, unitary evolution, measurement, tensor products, transformations etc.) but are new to quantum *computing*. FUQIT aims to prepare students for the transition into industry.
One can build circuits in code or by clicking gates onto a board in a graphical interface, and see the resulting state, measurement probabilities and simulated measurement counts.

FUQIT is a teaching tool, not a high-performance simulator: it stores every gate
as a full matrix, which keeps the linear algebra transparent and is fast enough
for the small circuits (a handful of qubits) that are useful for learning.

## Features

- **States** of any number of qubits: from amplitudes, labels such as `"01"` or `"+-"`,
  Bell states and GHZ states, with reduced density matrices, entanglement checks
  and fidelity.
- **Gates**: X, Y, Z, H, S, T, rotations Rx/Ry/Rz, CNOT, CZ, SWAP and Toffoli, on any
  qubit(s), plus your own gates from any unitary matrix.
- **Circuits**: chain gates together, run them, get the overall unitary, invert them,
  and simulate measurements with a chosen number of shots.
- **Graphical interface**: choose initial states, build circuits by clicking, step
  through them in time, compare exact probabilities with simulated measurements, and
  save, reopen and export circuits.

## Installation

FUQIT needs Python 3.10 or newer.

### From PyPI

```bash
pip install fuqit
```

### From the source code (for development)

1. Clone the repository and move into it:

   ```bash
   git clone https://github.com/QC2-python-SE/FUQIT.git
   cd FUQIT
   ```

2. Install the package (this also installs its dependencies: numpy, matplotlib and pillow):

   ```bash
   pip install -e .
   ```

   The `-e` ("editable") flag means Python uses the code in this folder directly,
   so any changes you make take effect without reinstalling.

   To also install the tools for running the tests, use:

   ```bash
   pip install -e ".[test]"
   ```

3. Check it worked:

   ```bash
   python -c "import fuqit; print(fuqit.__version__)"
   ```

   This should print the version number, e.g. `0.1.0`.

The graphical interface uses Tkinter, which comes with Python on Windows and macOS.
On some Linux distributions it is a separate package (e.g. `sudo apt install python3-tk`).

## Quick start

### In code

Build a Bell state with a Hadamard and a CNOT:

```python
from fuqit import Circuit

bell = Circuit(2).h(0).cnot(0, 1)

state = bell.run()                # starts from |00> by default
print(state)                      # 0.707|00⟩ + 0.707|11⟩
print(state.probabilities())      # 0.5 for '00' and '11', 0 for '01' and '10'
print(state.is_entangled())       # True

counts = bell.measure(shots=1000) # simulate 1000 measurements
print(counts)                     # e.g. {'00': 503, '01': 0, '10': 0, '11': 497}
```

States can also be created directly:

```python
from fuqit import QubitState

QubitState.from_label("+0")       # |+>|0>
QubitState.bell("psi-")           # (|01> - |10>)/sqrt(2)
QubitState([1, 0, 0, 1])          # amplitudes, normalised automatically
```

### Graphical interface

Launch it with:

```bash
python -m fuqit.gui
```

Click a qubit's label (e.g. `|0⟩`) to choose its initial state, pick a gate from the
sidebar and click a slot on the board to place it; click a placed gate to remove it.
For a CNOT, click the control qubit first and then the target qubit in the same
column. For rotation gates, type the angle as a multiple of π in the θ box (e.g. `1/2`
for π/2). The time axis and slider under the board step through the circuit, the
Measurement box simulates a chosen number of shots, and circuits can be saved,
reopened and exported as images. See the documentation's GUI guide for details.

## Conventions

- **Qubit ordering:** qubit 0 is the *leftmost* symbol in a ket. So `|10⟩` means
  qubit 0 is in `|1⟩` and qubit 1 is in `|0⟩`, and a gate U acting on qubit 0 of a
  two-qubit register is U ⊗ I. This matches most textbooks (e.g. Nielsen & Chuang),
  but differs from some software such as Qiskit.
- **Rotation gates:** R_σ(θ) = exp(−iθσ/2) for σ = X, Y, Z, with θ in radians.
- **States are immutable:** applying a gate returns a new state and never changes
  the original.

## Documentation

The full documentation (installation, a quantum-computing primer for physicists,
a GUI guide, tutorials as Jupyter notebooks, and the API reference) is built with
MkDocs. To view it locally:

```bash
pip install -e ".[docs]"
mkdocs serve
```

then open the address it prints (usually <http://127.0.0.1:8000>).

## Running the tests

After installing with the test extras (see above), run from the repository folder:

```bash
pytest
```

The tests also run automatically on GitHub for every pull request.

## Project structure

```
src/fuqit/
    states.py     QubitState: quantum states of n qubits
    gates.py      Gate class and the standard gates
    circuit.py    Circuit: sequences of gates, running and measuring
    gui/          the graphical circuit builder
tests/            the test suite
```

## Authors

Tabby Lickman, Ben Hancock and Diyaco Shwany.
