components

Each Component is generally defined by several key attributes defining the behavior of the component in a network.

  • num_ports: The number of ports of the components.

  • S: The scattering matrix of the component.

  • C: The connection matrix for the component (usually all zero for base components)

  • sources_at: The location of the sources in the component (usually all zero for base components)

  • detectors_at: The location of the detectors in the component (usually all zero for base components)

  • actions_at: The location of the active nodes in the component (usually all zero for passive components)

  • delays: delays introduced by the nodes of the component.

Defining your own Component comes down to subclassing Component and redefining the relevant setters set_* for these attributes. For example:

class Waveguide(pt.Component):
    num_ports = 2
    def __init__(self, length=1e-5, neff=2.34, ng=3.40, name=None):
        super(Waveguide, self).__init__(self, name=name)
        self.neff = float(neff)
        self.wl0 = float(wl0)
        self.ng = float(ng)
        self.length = float(length)
    def set_delays(self, delays):
        delays[:] = self.ng * self.length / self.env.c
    def set_S(self, S):
        wls = torch.tensor(self.env.wl, dtype=torch.float64, device=self.device)
        phase = (2 * np.pi * neff * self.length / wls) % (2 * np.pi)
        S[0, :, 0, 1] = S[0, :, 1, 0] = torch.cos(phase).to(torch.float32) # real part
        S[1, :, 0, 1] = S[1, :, 1, 0] = torch.sin(phase).to(torch.float32) # imag part

component

The base component is a parent class meant for subclassing.

It should not be used directly.

class photontorch.components.component.Component(name=None)

Bases: photontorch.nn.nn.Module

Generic base component.

The base component is a parent class meant for subclassing; it should not be used directly.

To define your own component, subclass Component and overwrite the __init__ and the set_* methods.

__init__(name=None)

Component

Parameters

name (optional, str) – the name of the component

action(t, x_in, x_out)

Nonlinear action of the component on its active nodes

Parameters
  • t (float) – the current time in the simulation

  • x_in (torch.Tensor[#active nodes, 2, #wavelengths, #batches]) – the input tensor used to define the action

  • x_out (torch.Tensor[#active nodes, 2, #wavelengths, #batches]) – the output tensor. The result of the action should be stored in the elements of this tensor.

property env

Get the environment object for which the component is initialized

initialize()

initialize the component with the current simulation environment.

Before a component can be used for simulation, it should be initialized with a simulation environment.

num_ports = 0

Number of ports of the component.

set_C(C)

Set the connection matrix of the component.

Parameters

C (Tensor[2, #ports, #ports]) – the empty connection matrix for the component to set the elements for. The first dimension of size two denotes the stacked real and imaginary part.

Note

For most base components the connection matrix should stay empty. Only for composite components, like Network, the connection matrix will be non-empty.

set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

set_actions_at(actions_at)

Set the locations of the active ports in the component.

Parameters

actions_at (Tensor[#ports]) – the empty boolean tensor for the component to set the elements for. The actions_at tensor signifies which ports of the component act actively.

set_delays(delays)

Set the delays introduced by the component.

Parameters

delays (Tensor[#ports]) – the empty delay tensor for the component to set the elements for. The delay tensor signifies the delay each port of the component introduces.

set_detectors_at(detectors_at)

Set the locations of the detector ports in the component.

Parameters

detectors_at (Tensor[#ports]) – the empty boolean tensor for the component to set the elements for. The detectors_at tensor signifies which ports of the component act as a detector.

set_port_order(port_order)

Set the port ordering

Parameters

port_order (Tensor[#ports]) – the indices denoting the port order.

Note

The port order will NOT be reflected in the S-matrix of the component. It will however be used when components are connected together into a network.

set_sources_at(sources_at)

Set the locations of the source ports in the component.

Parameters

sources_at (Tensor[#ports]) – the empty boolean tensor for the component to set the elements for. The sources_at tensor signifies which ports of the component act as a source.

training

connection

A Connection connects two ports without reflection.

It is generally recommended to make direct connections in a network. But if for some reason, you’re unable to do so, a Connection object can be used.

class photontorch.components.connection.Connection(name=None)

Bases: photontorch.components.component.Component

A connection connects two ports without delays and without reflection.

Terms:

0---1

Note

It is generally recommended to make direct connections in a network. But if for some reason, you’re unable to do so, a Connection object can be used.

num_ports = 2
set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

training

directionalcouplers

Directional Couplers are 4-port components coupling two waveguides together.

class photontorch.components.directionalcouplers.DirectionalCoupler(coupling=0.5, trainable=True, name=None)

Bases: photontorch.components.component.Component

A directional coupler is a memory-less component with 4 ports.

A directional coupler has one trainable parameter: the squared coupling coupling.

Terms:

3        2
 \______/
 /------\
0        1
__init__(coupling=0.5, trainable=True, name=None)
Parameters
  • coupling (float) – power coupling of the directional coupler (between 0 and 1)

  • trainable (bool) – makes the coupling trainable

  • name (optional, str) – the name of the component (default: lowercase classname)

num_ports = 4
set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

training
class photontorch.components.directionalcouplers.DirectionalCouplerWithLength(length=1e-05, coupling=0.5, loss=0, neff=2.34, wl0=1.55e-06, ng=3.4, phase=0, trainable_phase=True, trainable_coupling=True, name=None)

Bases: photontorch.components.component.Component

A directional coupler with length is a memory-containing component with 4 ports.

Terms:

3        2
 \______/
 /------\
0        1

Note

This version of a directional coupler is prefered over a wg-wg-wg-wg-dc network becuase it only has 4 ports in stead of 12.

__init__(length=1e-05, coupling=0.5, loss=0, neff=2.34, wl0=1.55e-06, ng=3.4, phase=0, trainable_phase=True, trainable_coupling=True, name=None)
Parameters
  • length (float) – length of the waveguide in meter.

  • coupling (float) – power coupling of the directional coupler (between 0 and 1)

  • loss (float) – loss in the waveguide [dB/m]

  • neff (float) – effective index of the waveguide

  • ng (float) – group index of the waveguide

  • wl0 (float) – the center wavelength for which neff is defined.

  • phase (float) – additional phase correction added to the phase introduced by the length of the waveguide. Adding this can be useful for training purposes.

  • trainable_phase (bool) – makes the phase parameter trainable

  • trainable_coupling (bool) – makes the coupling parameter trainable

  • name (optional, str) – the name of the component (default: lowercase classname)

num_ports = 4
set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

set_delays(delays)

Set the delays introduced by the component.

Parameters

delays (Tensor[#ports]) – the empty delay tensor for the component to set the elements for. The delay tensor signifies the delay each port of the component introduces.

training
class photontorch.components.directionalcouplers.RealisticDirectionalCoupler(length=1.28e-05, k0=0.2332, n0=0.0208, de1_k0=1.2435, de1_n0=0.1169, de2_k0=5.3022, de2_n0=0.4821, wl0=1.55e-06, name=None)

Bases: photontorch.components.component.Component

A directional coupler is a memory-less component with 4 ports.

Terms:

3        2
 \______/
 /------\
0        1

Notes

  • This directional coupler introduces no delays (for now)

  • This directional coupler is not trainable (for now)

__init__(length=1.28e-05, k0=0.2332, n0=0.0208, de1_k0=1.2435, de1_n0=0.1169, de2_k0=5.3022, de2_n0=0.4821, wl0=1.55e-06, name=None)
Parameters
  • length (float) – the length

  • k0 (float) – the bend coupling

  • n0 (float) – effective index difference between even and odd mode

  • de1_k0 (float) – first derivative of k0 w.r.t. wavelength

  • de1_n0 (float) – first derivative of n0 w.r.t. wavelength

  • de2_k0 (float) – second derivative of k0 w.r.t. wavelength

  • de2_n0 (float) – second derivative of n0 w.r.t. wavelength

  • wl0 (float) – the center wavelength for which the parameters are defined

  • name (optional, str) – the name of the component (default: lowercase classname)

Note

The default parameters are based on a directional coupler with
  • bend radius : 5um

  • adiabatic angle : 10 degrees

  • gap distance : 250 nm

num_ports = 4
set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

training

gratingcouplers

Grating Couplers

Grating couplers are a special kind of 2-port component that simulate the behavior of coupling light from a fiber onto the chip.

class photontorch.components.gratingcouplers.GratingCoupler(R=0.0, R_in=0.0, Tmax=1.0, bandwidth=6e-08, wl0=1.55e-06, name=None)

Bases: photontorch.components.component.Component

Grating couplers are partly reflecting and partly transmitting connections.

Terms:

  0
   \
    \
_|-|_|-|_|-|___ 1

Note

A Grating Coupler is not trainable (for now).

__init__(R=0.0, R_in=0.0, Tmax=1.0, bandwidth=6e-08, wl0=1.55e-06, name=None)
Parameters
  • R (float) – reflection of the grating coupler (between 0 and 1)

  • R_in (float) – incoupling reflection for the grating coupler

  • Tmax (float) – maximum transmission at center wavelength

  • bandwidth (float) – 3dB Bandwidth of the grating coupler

  • wl0 (float) – Center wavelength of the grating coupler

  • name (optional, str) – the name of the component (default: lowercase classname)

num_ports = 2
set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

training

mirrors

Mirrors are partly reflecting and partly transmitting connections.

class photontorch.components.mirrors.Mirror(R=0.5, trainable=True, name=None)

Bases: photontorch.components.component.Component

Mirrors are partly reflecting and partly transmitting connections.

A mirror has one trainable parameter: the reflectivity R.

Terms:

    |
0 --|-- 1
    |
__init__(R=0.5, trainable=True, name=None)
Parameters
  • R (float) – reflectivity of the mirror (between 0 and 1)

  • trainable (bool) – makes the reflection trainable

  • name (optional, str) – the name of the component (default: lowercase classname)

num_ports = 2
set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

training

mmis

An MMI performs a weighted transition from m waveguides to n waveguides

The MMI implemented in this module performs an arbitrary splitting operation specified by a weight matrix

class photontorch.components.mmis.Mmi(weights=None, trainable=True, name=None)

Bases: photontorch.components.component.Component

An MMI performs a weighted transition from m waveguides to n waveguides

Terms:

     m+1
0___/ m+2
1____/
 :  :
m____
     \
      m+n
__init__(weights=None, trainable=True, name=None)

Mmi initialization

Parameters
  • weights (np.ndarray) – interconnection weights between input wageguides and output waveguides. If no weights are specified, the component defaults to a 1x2 splitter.

  • trainable (bool) – makes the interconnection weights trainable

  • name (optional, str) – the name of the component (default: lowercase classname)

num_ports = None
set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

training

mzis

MZIs are 4-port components coupling two waveguides together.

class photontorch.components.mzis.Mzi(phi=0, theta=0.7853981633974483, neff=2.34, ng=3.4, wl0=1.55e-06, length=1e-05, loss=0, trainable=True, name=None)

Bases: photontorch.components.component.Component

An MZI is a component with 4 ports.

An MZI has two trainable parameters: the input phase phi and the phase difference between the arms theta. .

Terms:

            _[2*theta]_
3  ______  /           \  ___2
         \/             \/
0__[phi]_/\_____________/\___1

Note

This MZI implementation assumes the armlength difference is too small to have a noticable delay difference between the arms, i.e. only the phase difference matters

__init__(phi=0, theta=0.7853981633974483, neff=2.34, ng=3.4, wl0=1.55e-06, length=1e-05, loss=0, trainable=True, name=None)
Parameters
  • phi (float) – input phase

  • theta (float) – phase difference between the arms

  • neff (float) – effective index of the waveguide

  • ng (float) – group index of the waveguide

  • wl0 (float) – the center wavelength for which neff is defined.

  • length (float) – length of the waveguide in meter.

  • loss (float) – loss in the waveguide [dB/m]

  • trainable (bool) – whether phi and theta are trainable

  • name (optional, str) – name of this specific MZI

num_ports = 4
set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

set_delays(delays)

Set the delays introduced by the component.

Parameters

delays (Tensor[#ports]) – the empty delay tensor for the component to set the elements for. The delay tensor signifies the delay each port of the component introduces.

training

soas

Semiconductor Optical Amplifiers

SOAs amplify your signal.

class photontorch.components.soas.AgrawalSoa(L=0.0005, W=2e-06, H=2e-07, N0=1e+24, a=2.7e-20, I=0.18666666666666668, tc=3e-10, gamma=0.3, alpha=5.0, neff=2.34, ng=3.75, wl=1.55e-06, name=None)

Bases: photontorch.components.soas.BaseSoa

The AgrawalSoa is a memory-containing component with one input and one output.

It amplifies a signal according to its internal state, which in turn is modified by its rate equation defined by Agrawal et. al.

Terms:

0 ---- 1
Reference:

Agrawal, G.P. and Olsson, N.A., 1989. Self-phase modulation and spectral broadening of optical pulses in semiconductor laser amplifiers. IEEE Journal of Quantum Electronics, 25(11), pp.2297-2306.

__init__(L=0.0005, W=2e-06, H=2e-07, N0=1e+24, a=2.7e-20, I=0.18666666666666668, tc=3e-10, gamma=0.3, alpha=5.0, neff=2.34, ng=3.75, wl=1.55e-06, name=None)
Parameters
  • L (float) – length of soa

  • W (float) – width of soa

  • H (float) – height of soa

  • N0 (float) – transparency carrier density

  • a (float) – differenctial gain coefficient

  • I (float) – current through soa

  • tc (float) – lifetime of the carriers

  • gamma (float) – confinement factor

  • alpha (float) – linewidth enhancement

  • neff (float) – effective index used to calculate phase offset

  • ng (float) – group index used to calculate delay of soa

  • wl (float) – wavelength of the simulation

  • name (optional, str) – the name of the component (default: lowercase classname)

dhdt(t, h, a)

Derivative of the internal state h with respect to time

Parameters
  • t (float) – the current time in the simulation

  • h (Tensor[2, #wavelengths, #batches]) – the current internal state of the SOA

  • a (Tensor[2, #wavelengths, #batches]) – the current input amplitude of the SOA

Returns

the rate of change of the internal state

Return type

Tensor[2, #wavelengths, #batches]

initialize()

initialize the component with the current simulation environment.

Before a component can be used for simulation, it should be initialized with a simulation environment.

set_delays(delays)

Set the delays introduced by the component.

Parameters

delays (Tensor[#ports]) – the empty delay tensor for the component to set the elements for. The delay tensor signifies the delay each port of the component introduces.

training
class photontorch.components.soas.BaseSoa(name=None)

Bases: photontorch.components.component.Component

The BaseSoa is a memory-containing component with one input and one output.

It amplifies a signal according to its internal state, which in turn is modified by its rate equation.

Terms:

0 ---- 1
action(t, x_in, x_out)

Nonlinear action of the component on its active nodes

Parameters
  • t (float) – the current time in the simulation

  • x_in (torch.Tensor[#active nodes, 2, #wavelengths, #batches]) – the input tensor used to define the action

  • x_out (torch.Tensor[#active nodes, 2, #wavelengths, #batches]) – the output tensor. The result of the action should be stored in the elements of this tensor.

dhdt(t, h, a)

Derivative of the internal state h with respect to time

Parameters
  • t (float) – the current time in the simulation

  • h (Tensor[2, #wavelengths, #batches]) – the current internal state of the SOA

  • a (Tensor[2, #wavelengths, #batches]) – the current input amplitude of the SOA

Returns

the rate of change of the internal state

Return type

Tensor[2, #wavelengths, #batches]

num_ports = 3
set_C(C)

Set the connection matrix of the component.

Parameters

C (Tensor[2, #ports, #ports]) – the empty connection matrix for the component to set the elements for. The first dimension of size two denotes the stacked real and imaginary part.

Note

For most base components the connection matrix should stay empty. Only for composite components, like Network, the connection matrix will be non-empty.

set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

set_actions_at(actions_at)

Set the locations of the active ports in the component.

Parameters

actions_at (Tensor[#ports]) – the empty boolean tensor for the component to set the elements for. The actions_at tensor signifies which ports of the component act actively.

training
class photontorch.components.soas.LinearSoa(amplification=2, trainable=True, name=None)

Bases: photontorch.components.component.Component

A Linear SOA is a memory-less component with one input and one output.

It amplifies a signal instantaneously and linearly with the specified amplification factor

A simple SOA has one trainable parameter: the amplification.

Terms:

0 ---- 1
__init__(amplification=2, trainable=True, name=None)
Parameters
  • amplification (float) – Amplification of the soa

  • trainable (bool) – makes the amplification trainable

  • name (optional, str) – the name of the component (default: lowercase classname)

num_ports = 2
set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

training
class photontorch.components.soas.Soa(amplification=1.0, startup_time=1e-10, trainable=True, name=None)

Bases: photontorch.components.soas.BaseSoa

The Soa is a memory-containing component with one input and one output.

It amplifies a signal according to its internal state, which in turn is modified by its rate equation.

Terms:

0 ---- 1
__init__(amplification=1.0, startup_time=1e-10, trainable=True, name=None)
Parameters
  • amplification (float) – the maximum amplification of the soa

  • startup_time (float) – how long it takes before the soa reaches max amplification

  • trainable (bool) – makes the amplification trainable

  • name (optional, str) – the name of the component (default: lowercase classname)

dhdt(t, h, a)

Derivative of the internal state h with respect to time

Parameters
  • t (float) – the current time in the simulation

  • h (Tensor[2, #wavelengths, #batches]) – the current internal state of the SOA

  • a (Tensor[2, #wavelengths, #batches]) – the current input amplitude of the SOA

Returns

the rate of change of the internal state

Return type

Tensor[2, #wavelengths, #batches]

training

terms

Terminations

In order to be able to simulate a Network, the connection matrix should be fully connected.

Ports that are not connected to other components, should be connected to a Term.

Network terminations can be absorbing (Term), injecting (Source) or absorbing and detecting (Detector)

class photontorch.components.terms.Detector(name=None)

Bases: photontorch.components.terms.Term

A detector is a Term where the power is saved

Terms::

–0

set_detectors_at(detectors_at)

Set the locations of the detector ports in the component.

Parameters

detectors_at (Tensor[#ports]) – the empty boolean tensor for the component to set the elements for. The detectors_at tensor signifies which ports of the component act as a detector.

training
class photontorch.components.terms.Source(name=None)

Bases: photontorch.components.terms.Term

A source is a special kind of Term where power is injected in the system

Terms:

--0
set_sources_at(sources_at)

Set the locations of the source ports in the component.

Parameters

sources_at (Tensor[#ports]) – the empty boolean tensor for the component to set the elements for. The sources_at tensor signifies which ports of the component act as a source.

training
class photontorch.components.terms.Term(name=None)

Bases: photontorch.components.component.Component

A term is a memory-less component with a single input.

It terminates an unconnected node.

Terms:

--0
num_ports = 1
training

waveguides

Waveguides connect two ports with a delay and a phase.

class photontorch.components.waveguides.Waveguide(length=1e-05, loss=0, neff=2.34, wl0=1.55e-06, ng=3.4, phase=0, trainable=True, name=None)

Bases: photontorch.components.connection.Connection

Waveguides connect two ports with a delay and a phase.

A waveguide is a Component where each of the two nodes introduces a delay corresponding to the length of the waveguide.

Terms:

0 ---- 1
__init__(length=1e-05, loss=0, neff=2.34, wl0=1.55e-06, ng=3.4, phase=0, trainable=True, name=None)
Parameters
  • length (float) – length of the waveguide in meter.

  • loss (float) – loss in the waveguide [dB/m]

  • neff (float) – effective index of the waveguide

  • ng (float) – group index of the waveguide

  • wl0 (float) – the center wavelength for which neff is defined.

  • phase (float) – additional phase correction added to the phase introduced by the length of the waveguide. Adding this can be useful for training purposes.

  • trainable (bool) – makes the phase parameter trainable

  • name (optional, str) – the name of the component (default: lowercase classname)

set_S(S)

Set the elements of the scattering matrix.

Parameters

S (Tensor[2, #wavelengths, #ports, #ports]) – the empty scattering matrix of the component to set the elements for (defined for each wavelength of the simulation). The first dimension of size two denotes the stacked real and imaginary part.

set_delays(delays)

Set the delays introduced by the component.

Parameters

delays (Tensor[#ports]) – the empty delay tensor for the component to set the elements for. The delay tensor signifies the delay each port of the component introduces.

training