LaserPy_Quantum Documentation

Welcome to LaserPy_Quantum

LaserPy_Quantum provides an intuitive interface for simulating complex laser interactions, current drivers, and interferometer setups, with plans to offload performance-critical components to Rust for high-speed numerical computations. A high-level, open-source Python library designed for the theoretical simulation of laser systems in quantum communication and cryptographic protocols.

Top-level namespace

Classes Exposed for LaserPy_Quantum

class Clock(dt: float, sampling_rate: int = -1, name: str = 'default_clock')[source]

Bases: Component

Represents the clock class.

This class manages the time counter and all operations on it.

Parameters:
  • dt (float) – Time step variable for the simulation

  • sampling_rate (int = 1) – Integral postive multiple of dt, simulation data are stored on these time steps

  • name (str = “default_clock”) – Name of the component

Variables:
  • dt (float) – Time step variable for the simulation

  • _sampling_rate (float) – Integral postive multiple of dt, simulation data are stored on these time steps

  • t (float = 0.0) – Time counter variable for simulation

  • _t_sample (float = 0.0) – Helper for sampling rate

  • running (bool = True) – Clock status for time updates

  • _t_final (float = 0.0) – Time at which to stop simulation and set running to False

output_port(kwargs: dict = {})[source]

Clock output port method

Parameters:

kwargs (dict = {})

Returns:

kwargs – Returns dict with ‘clock’:self data

Return type:

dict

set(t_final: float, t: float | None = None)[source]

Clock set method

Sets t_final and t. Also sets running to True.

Parameters:
  • t_final (float)

  • t (float = None)

update()[source]

Clock update method

Checks if t exceeded _t_final, then sets running to False and returns. Else it updates both t and _t_sample by one time step, ie dt. If _t_sample exceeds _sampling_rate then sets _t_sample to 0.0

dt

Clock Delta time data

t

Clock time data

running

Clock running state data

class PhysicalComponent(name: str = 'default_physical_component')[source]

Bases: DataComponent, TimeComponent

PhysicalComponent class

input_port()[source]

PhysicalComponent input port method to override

simulate(clock: Clock, _data: float | None = None)[source]

PhysicalComponent simulate method to override

class LangevinNoise(Mu: int, Std_dev: int, name: str = 'default_langevin_noise')[source]

Bases: NoNoise

LangevinNoise class

class ArbitaryWave(name: str, t_unit: float = -1, total_spread: float = 1.0)[source]

Bases: SignalID

ArbitaryWave class

WaveSignal(t: float)[source]

ArbitaryWave WaveSignal method to override

class StaticWave(name: str, static_val: float)[source]

Bases: ArbitaryWave

StaticWave class

WaveSignal(t: float)[source]

StaticWave WaveSignal method

class PulseWave(name: str, pulse_low: float, pulse_high: float, t_unit: float, total_spread: float = 1)[source]

Bases: ArbitaryWave

PulseWave class

WaveSignal(t: float)[source]

PulseWave WaveSignal method

class AlternatingPulseWave(name: str, static_val: float, pulse_val: float, t_unit: float, total_spread: float = 1)[source]

Bases: ArbitaryWave

AlternatingPulseWave class

WaveSignal(t: float)[source]

AlternatingPulseWave WaveSignal method

class ArbitaryWaveGenerator(*arg, **kwargs)[source]

Bases: object

ArbitaryWaveGenerator Singleton class

set(arbitarywaves: ArbitaryWave | tuple[ArbitaryWave, ...])[source]

ArbitaryWaveGenerator set method

simulate(clock: Clock, signal_keys: str | tuple[str, ...]) float[source]

ArbitaryWaveGenerator simulate method

signals: dict[str, ArbitaryWave]

Signals dictionary for ArbitaryWaves

class Connection(input_components: Component | tuple[Component, ...] | None, output_components: Component | tuple[Component, ...], name: str = 'default_connection')[source]

Bases: TimeComponent

Connection class

reset(save_simulation: bool)[source]

Connection reset method

reset_data()[source]

Connection reset_data method

simulate(clock: Clock)[source]

Connection simulate method

class Simulator(simulation_clock: Clock, name: str = 'default_simulator')[source]

Bases: DataComponent

Simulator class

display_data()[source]

Simulator display_data method

get_data()[source]

Simulator get_data method

reset(save_simulation: bool = False)[source]

Simulator reset method

reset_data()[source]

Simulator reset_data method

set(connections: Connection | tuple[Connection, ...])[source]

Simulator set method

simulate()[source]

Simulator simulate method

store_data()[source]

Simulator store_data method

class QuantumEntangler(photons: tuple[Photon, ...], quantum_state: QuantumState | None = None, sync=True)[source]

Bases: object

sync_qubits()[source]
class Gates[source]

Bases: object

static CNOT(target: Photon, control: Photon) None[source]

CNOT gate: |T> -> X|C>

static H(target: Photon) None[source]

Hadamard gate: |0> -> |+> and |1> -> |->

static I(target: Photon) None[source]

Identity gate: |Ψ> -> |Ψ>

static X(target: Photon) None[source]

Pauli-X gate (Bit-flip): |0> -> |1> and |1> -> |0>

static Y(target: Photon) None[source]

Pauli-Y gate: |0> -> i|1> and |1> -> -i|0>

static Z(target: Photon) None[source]

Pauli-Z gate (Phase-flip): |0> -> |0> and |1> -> -|1>

class ModulationFunction(name: str, t_unit: float, dt: float, modulation_bits: tuple[int, ...])[source]

Bases: ArbitaryWave

ModulationFunction class

WaveSignal(t)[source]

ArbitaryWave WaveSignal method to override

class CurrentDriver(AWG: ArbitaryWaveGenerator, name: str = 'default_current_driver')[source]

Bases: TimeComponent

CurrentDriver class

output_port(kwargs: dict = {})[source]

CurrentDriver output port method

set(modulation_OFF: ArbitaryWave | tuple[ArbitaryWave, ...], modulation_ON: ArbitaryWave | tuple[ArbitaryWave, ...] | None = None, modulation_function: ArbitaryWave | None = None)[source]

CurrentDriver set method

simulate(clock: Clock)[source]

CurrentDriver simulate method

class Laser(laser_wavelength: float | None = None, name: str = 'default_laser')[source]

Bases: PhysicalComponent

Laser class

input_port()[source]

Laser input port method

output_port(kwargs: dict = {})[source]

Laser output port method

set_noise(Fn_t: NoNoise, Fs_t: NoNoise, Fphi_t: NoNoise)[source]

Laser set noise method

set_slave_Laser(slave_locked: bool = True)[source]

Laser set master laser method

simulate(clock: Clock, current: float, photon: Photon | tuple[Photon, ...] | None = None)[source]

Laser simulate method

photon_number: float

photon number data for Laser

carrier: float

carrier data for Laser

phase: float

phase data for Laser

current: float

current data for Laser

class VariableOpticalAttenuator(attenuation_dB: float = 0.0, name: str = 'default_variable_optical_attenuator')[source]

Bases: Component

VariableOpticalAttenuator class

input_port()[source]

VariableOpticalAttenuator input port method

output_port(kwargs: dict = {})[source]

VariableOpticalAttenuator output port method

set(attenuation_dB: float)[source]

VariableOpticalAttenuator set method

simulate(photon: Photon)[source]

VariableOpticalAttenuator simulate method

class AsymmetricMachZehnderInterferometer(clock: Clock, time_delay: float, splitting_ratio_ti: float = 0.5, splitting_ratio_tf: float = 0.5, name: str = 'default_asymmetric_machzehnder_interferometer')[source]

Bases: Component

AsymmetricMachZehnderInterferometer class

display_SPD_data(time_data: ndarray, simulation_keys: tuple[str, ...] | None = None)[source]

AsymmetricMachZehnderInterferometer display_SPD_data method

get_SPD_data()[source]

AsymmetricMachZehnderInterferometer get_SPD_data method

input_port()[source]

AsymmetricMachZehnderInterferometer input port method

output_port(kwargs: dict = {})[source]

AsymmetricMachZehnderInterferometer output port method

reset(save_simulation: bool = False)[source]

AsymmetricMachZehnderInterferometer reset method

reset_data()[source]

AsymmetricMachZehnderInterferometer reset_data method

set_beam_splitters(splitting_ratio_ti: float = 0.5, splitting_ratio_tf: float = 0.5)[source]

AsymmetricMachZehnderInterferometer set beam splitters method

set_phases(short_arm_phase: float | None = None, long_arm_phase: float | None = None, short_arm_phase_interval: float | None = None, long_arm_phase_interval: float | None = None)[source]

AsymmetricMachZehnderInterferometer set phases method

simulate(photon: Photon)[source]

AsymmetricMachZehnderInterferometer simulate method

store_data()[source]

AsymmetricMachZehnderInterferometer store_data method

class Photon(field: complex = (1e-12+0j), frequency: float = 1e-12, photon_number: float = 1e-12, source_phase: float = 1e-12, photon_id: int = <factory>, qubit_index: int = -1, quantum_entangler: ~LaserPy_Quantum.QuantumOptics.Entangler.QuantumEntangler | None = None)[source]

Bases: object

Photon class.

field: complex
frequency: float
photon_number: float
source_phase: float
photon_id: int
qubit_index: int
quantum_entangler: QuantumEntangler | None
property amplitude: float

amplitude (V/m) of the field

classmethod from_photon(other: Photon) Photon[source]

Photon classmethod from photon deepcopy method

property phase: float

phase (rad) of the field

qubit()[source]
display_class_instances_data(class_instances: tuple[DataComponent, ...], time_data: ndarray, simulation_keys: tuple[str, ...] | None = None)[source]

display merged graph for comparision of same class members data

get_time_delay_phase_correction(laser: Laser, time_delay: float)[source]

Calculate the phase correction for a given time delay.

Parameters:
  • laser (Laser) – Laser instance for which we want the phase correction

  • time_delay (float)

Returns:

Phase correction in radians in the range [-pi, pi)

Return type:

float