Components

QNS.components holds every optical device plus the simulation clock. All of them are re-exported from the subpackage:

from QNS.components import (Timeline, Laser, HalfWavePlate, QuarterWavePlate,
                            LinearPolarizer, PhaseShifter, BeamSplitter,
                            PolarisingBeamSplitter, Detector)

Overview

Class

In

Out

Role

Laser

0

1

Pulsed source with Poissonian photon number per pulse.

Entangled Source

0

2

SPDC pair source; polarisation-entangled signal and idler arms.

HalfWavePlate

1

1

Rotates linear polarisation about a fast axis at angle.

QuarterWavePlate

1

1

Converts between linear and circular polarisation.

LinearPolarizer

1

1

Projects onto angle; lossy by construction.

PhaseShifter

1

1

Applies \(e^{i\phi}\) to one mode, both polarisations.

BeamSplitter

2

2

Non-polarising splitter with adjustable transmittance.

PolarisingBeamSplitter

2

2

Routes H one way and V the other.

Detector

1

0

Single-photon detector with dead time, jitter, dark counts.

Common constructor signature

Every optical component starts with the same three arguments:

Component(uID, env, stateManager, **device_parameters)
uID

A unique string. It shows up in the result dictionary for detectors, in error messages, and in the generated IDs of photon objects downstream of splitters. Keep them distinct.

env

The simpy.Environment, always timeline.env.

stateManager

The single StateManager for the experiment.

Both env and stateManager are checked for None and raise ValueError if missing. Device parameters are range-checked in the constructor, so an out-of-range angle or efficiency fails immediately rather than producing quiet nonsense later.

Common instance methods

receive(qc, p)

Called by a channel when a photon arrives. qc is the channel it arrived on (used by two-input components to identify the port); p is the photon object. Transforms the pulse’s quantum state and forwards the photon onto the outgoing channel. Not called by user code.

set_receiver(receiver=None, port=None)

Registers an outgoing channel on port. Raises TypeError for an invalid port. Called for you by channel.connect_channel.

set_sender(sender=None, port=None)

Registers an incoming channel on port. Same contract as above.

You should not call set_receiver or set_sender yourself - use connect_channel so both ends of the link stay consistent.

Reference pages