Introduction and architecture

AnuQarana simulates a photonic quantum network the way you would build one on an optical setup: you instantiate components, you wire them together with channels, and you run the clock. Nothing about the optical behaviour is hard-coded per experiment - each component applies its own mode transformation to a shared quantum state, and detection statistics fall out of that state.

The four layers

AnuQarana is organised into four layers, each built on top of the one below it. At the bottom, QNS.StateEvolution holds the actual quantum-mechanical state and the operators that act on it. Above that, QNS.channels carries photons between components, modelling propagation delay and loss along the way. QNS.components sits on top of the channels layer and represents the physical devices on the optical table - lasers, wave plates, polarizers, beam splitters, and detectors, plus the Timeline that drives the Timeline clock. Finally, QNS.protocols sits above all of it, composing components and channels into complete, named experiments.

The two objects (Timeline and StateManager) that tie everything together

Every simulation begins with exactly two objects: a Timeline, which owns the underlying SimPy event loop and drives the simulation clock, and a StateManager, which owns every live quantum state in the simulation. Every component and every channel is tied to the same Timeline, and every component that touches the quantum state is tied to the same StateManager.

Photons, pulses and modes

The distinction that makes the rest of the library legible:

photon object

A lightweight token that travels the optical setup. It carries a unique ID, a wavelength, a temporal width, and - crucially - a photon_id. The photon object is a handle to an optical mode, not a quantum of light.

photon_id (the pulse)

Assigned by the state manager when the laser emits. Every optical mode descended from the same laser pulse shares one photon_id, and therefore shares one quantum state. This is what lets two arms of an interferometer recombine coherently.

When a photon reaches a single-input component like a wave plate, the component looks up the shared quantum state for that photon’s pulse, applies its own transformation to the mode the photon occupies, and writes the updated state back for the next component to use. Every single-input component follows this same pattern. Two-input components (beam splitters) do the same thing but must first decide whether the two arriving photons belong to the same pulse - see BeamSplitter.

How a photon actually moves

A component never calls the next component directly; instead, it hands the photon to the channel connecting them. The channel accounts for propagation delay, and rolls for coupling and transmission loss along the way, before delivering the photon to whatever is wired to its far end. That destination then applies its own transformation and repeats the process onward to the next channel.

Each component knows not just which photon arrived, but which channel - and therefore which input port - it arrived on, which is how two-input components (like beam splitters) tell their two inputs apart.

Wiring, ports and direction

Components are never wired to each other directly. Instead, you create a channel and use it to connect a specific output port on one component to a specific input port on another. That connection is registered on both ends at once, so each side knows exactly which port it’s talking to. Requesting a port number a component doesn’t have raises an error immediately, which is the cheapest way to catch a mis-wired circuit before running anything.

Port budget per component

Component

Inputs

Outputs

Port numbers

Laser

0

1

out 0

HalfWavePlate

1

1

in 0, out 0

QuarterWavePlate

1

1

in 0, out 0

LinearPolarizer

1

1

in 0, out 0

PhaseShifter

1

1

in 0, out 0

BeamSplitter

2

2

in 0/1, out 0/1

PolarisingBeamSplitter

2

2

in 0/1, out 0/1

Detector

1

0

in 0

A two-port component with only one arm connected works fine: the unconnected receiver stays None and that output mode simply goes nowhere.

Protocols

Protocol Library is where you can run pre-built protocols repository. A protocol is orchestration code, not new physics: it assembles the components and channels documented above into a specific topology, drives the clock, and interprets the resulting detector clicks (bases, keys, or classical bits, depending on the protocol).

AnuQarana ships eight pre-built protocols:

Protocol

What it demonstrates

QKD-BB84 Protocol

Quantum key distribution using the BB84 protocol: random basis encoding, sifting, and a raw shared key between two parties.

QKD-BB84 Post Processing Protocol

BB84 extended with the Cascade error-correction protocol, reconciling a noisy raw key into a usable secret key.

Quantum Entanglement Barrett-Kok

Heralded entanglement generation between two distant nodes using the Barrett-Kok scheme.

Quantum Entanglement Swapping

Extending entanglement across an intermediate node by swapping two independently generated entangled pairs.

Quantum Teleportation

Transferring an unknown qubit state from one party to another using a shared entangled pair and classical communication.

Superdense Protocol

Sending two classical bits over a single qubit using a pre-shared entangled pair.

Quantum Random Number Generator

Generating random bits from genuinely quantum measurement outcomes rather than a classical pseudo-random source.

QKD-COW Protocol

Quantum key distribution using the Coherent One-Way (COW) protocol, which encodes bits in the presence or absence of a coherent pulse.