components

The components submodule contains functionality for simulating individual optical components, such as a single phase shifter, a beamsplitter, or an MZI. Components are combined in a ComponentLayer, which describes the arrangement of the components on-chip.

class neuroptica.components.Beamsplitter(m: int, n: int)[source]

Bases: neuroptica.components.OpticalComponent

Simulation of a perfect 50:50 beamsplitter

__init__(m: int, n: int)[source]
Parameters:
  • m – first waveguide index
  • n – second waveguide index
__repr__()[source]

String representation, can be overridden in child classes

get_transfer_matrix() → <MagicMock id='140414712935480'>[source]

Logic for computing the transfer operator of the component

class neuroptica.components.MZI(m: int, n: int, theta: float = None, phi: float = None, phase_uncert=0.0)[source]

Bases: neuroptica.components.OpticalComponent

Simulation of a programmable phase-shifting Mach-Zehnder interferometer

__init__(m: int, n: int, theta: float = None, phi: float = None, phase_uncert=0.0)[source]
Parameters:
  • m – first waveguide index
  • n – second waveguide index
  • theta – phase shift value for inner phase shifter; assigned randomly between [0, 2pi) if unspecified
  • phi – phase shift value for outer phase shifter; assigned randomly between [0, 2pi) if unspecified
  • phase_uncertainty – optional uncertainty to add to the phase shifters; effective phase is computed as

self.(theta, phi) + np.random.normal(0, self.phase_uncert) if add_uncertainties is set to True during simulation

__repr__()[source]

String representation, can be overridden in child classes

get_partial_transfer_matrices(backward=False, cumulative=True, add_uncertainties=False) → <MagicMock id='140414712532832'>[source]

Compute the partial transfer matrices of each “column” of the MZI – after first beamsplitter, after first phase shifter, after second beamsplitter, and after second phase shifter :param backward: if true, compute the reverse transfer matrices in backward order :param cumulative: if true, each partial transfer matrix represents the total transfer matrix up to that point in the device :param add_uncertainties: whether to include uncertainties in the partial transfer matrix computation :return: numpy array of partial transfer matrices

get_transfer_matrix(add_uncertainties=False) → <MagicMock id='140414712520320'>[source]

Compute the transfer matrix for the tunable MZI given the current values of theta, phi :param add_uncertainties: whether to include uncertainties in the transfer matrix computation :return: the transfer matrix

class neuroptica.components.OpticalComponent(ports: List[int], tunable: bool = True, dof: int = None, id: int = None)[source]

Bases: object

Base class for an on-chip optical component

__init__(ports: List[int], tunable: bool = True, dof: int = None, id: int = None)[source]

Initialize the component

Parameters:
  • ports (list) – list of ports the component is connected to
  • tunable (bool) – whether the component is tunable or static
  • dof (int) – number of degrees of freedom the component has
  • id (int) – optional identifier for the component
__repr__()[source]

String representation, can be overridden in child classes

__weakref__

list of weak references to the object (if defined)

get_transfer_matrix() → <MagicMock id='140414712971336'>[source]

Logic for computing the transfer operator of the component

class neuroptica.components.PhaseShifter(m: int, phi: float = None)[source]

Bases: neuroptica.components.OpticalComponent

Single-mode phase shifter

__init__(m: int, phi: float = None)[source]
Parameters:
  • m – waveguide index
  • phi – optional phase shift value; assigned randomly between [0, 2pi) if unspecified
__repr__()[source]

String representation, can be overridden in child classes

get_transfer_matrix() → <MagicMock id='140414712855856'>[source]

Logic for computing the transfer operator of the component