Skip to content

Commit

Permalink
code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
flaport committed May 22, 2020
1 parent 7f29f7c commit 4ee2637
Show file tree
Hide file tree
Showing 16 changed files with 180 additions and 127 deletions.
5 changes: 2 additions & 3 deletions photontorch/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, name=None):
""" Component
Args:
name (str): the name of the component
name (optional, str): the name of the component
"""
super(Component, self).__init__()
self.name = name
Expand Down Expand Up @@ -185,8 +185,7 @@ def get_S(self):
denotes the stacked real and imaginary part.
"""
S = torch.zeros(
(2, self.env.num_wl, self.num_ports, self.num_ports),
device=self.device,
(2, self.env.num_wl, self.num_ports, self.num_ports), device=self.device,
)
self.set_S(S)
return S
Expand Down
6 changes: 3 additions & 3 deletions photontorch/components/directionalcouplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, coupling=0.5, trainable=True, name=None):
Args:
coupling (float): power coupling of the directional coupler (between 0 and 1)
trainable (bool): makes the coupling trainable
name (str): the name of the component (default: lowercase classname)
name (optional, str): the name of the component (default: lowercase classname)
"""
super(DirectionalCoupler, self).__init__(name=name)

Expand Down Expand Up @@ -120,7 +120,7 @@ def __init__(
purposes.
trainable_phase (bool): makes the phase parameter trainable
trainable_coupling (bool): makes the coupling parameter trainable
name (str): the name of the component (default: lowercase classname)
name (optional, str): the name of the component (default: lowercase classname)
"""
super(DirectionalCouplerWithLength, self).__init__(name=name)
# Handle inputs
Expand Down Expand Up @@ -213,7 +213,7 @@ def __init__(
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 (str): the name of the component (default: lowercase classname)
name (optional, str): the name of the component (default: lowercase classname)
Note:
The default parameters are based on a directional coupler with
Expand Down
2 changes: 1 addition & 1 deletion photontorch/components/gratingcouplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(
Tmax (float): maximum transmission at center wavelength
bandwidth (float): 3dB Bandwidth of the grating coupler
wl0 (float): Center wavelength of the grating coupler
name (str): the name of the component (default: lowercase classname)
name (optional, str): the name of the component (default: lowercase classname)
"""
super(GratingCoupler, self).__init__(name=name)
self.R = R
Expand Down
2 changes: 1 addition & 1 deletion photontorch/components/mirrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, R=0.5, trainable=True, name=None):
Args:
R (float): reflectivity of the mirror (between 0 and 1)
trainable (bool): makes the reflection trainable
name (str): the name of the component (default: lowercase classname)
name (optional, str): the name of the component (default: lowercase classname)
"""
super(Mirror, self).__init__(name=name)

Expand Down
2 changes: 1 addition & 1 deletion photontorch/components/mmis.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def __init__(self, weights=None, trainable=True, name=None):
wageguides and output waveguides. If no weights are specified, the
component defaults to a 1x2 splitter.
trainable (bool): makes the interconnection weights trainable
name (str): the name of the component (default: lowercase classname)
name (optional, str): the name of the component (default: lowercase classname)
"""

# validate weights
Expand Down
2 changes: 1 addition & 1 deletion photontorch/components/mzis.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(
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 (str): name of this specific MZI
name (optional, str): name of this specific MZI
"""
super(Mzi, self).__init__(name=name)

Expand Down
26 changes: 11 additions & 15 deletions photontorch/components/soas.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, amplification=2, trainable=True, name=None):
Args:
amplification (float): Amplification of the soa
trainable (bool): makes the amplification trainable
name (str): the name of the component (default: lowercase classname)
name (optional, str): the name of the component (default: lowercase classname)
"""
super(LinearSoa, self).__init__(name=name)

Expand Down Expand Up @@ -147,7 +147,7 @@ def __init__(
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 (str): the name of the component (default: lowercase classname)
name (optional, str): the name of the component (default: lowercase classname)
"""
super(Soa, self).__init__(name=name)

Expand Down Expand Up @@ -202,19 +202,19 @@ def __init__(
):
"""
Args:
L (loat): length of soa
W (loat): width of soa
H (loat): height of soa
N0 (loat): transparency carrier density
a (loat): differenctial gain coefficient
I (loat): current through soa
tc (loat): lifetime of the carriers
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 (str): the name of the component (default: lowercase classname)
name (optional, str): the name of the component (default: lowercase classname)
"""

super(AgrawalSoa, self).__init__(name=name)
Expand Down Expand Up @@ -251,11 +251,7 @@ def initialize(self):
) # saturation power of the SOA
self.delay = self.L * self.ng / env.c # delay introduced by the soa
self.phase = (
self.L
* self.neff
* 2
* np.pi
* np.mean(env.wl) # TODO: make this an array
self.L * self.neff * 2 * np.pi * np.mean(env.wl) # TODO: make this an array
) # phase introduced by the soa

super(AgrawalSoa, self).initialize()
Expand Down
2 changes: 1 addition & 1 deletion photontorch/components/waveguides.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(
by the length of the waveguide. Adding this can be useful for training
purposes.
trainable (bool): makes the phase parameter trainable
name (str): the name of the component (default: lowercase classname)
name (optional, str): the name of the component (default: lowercase classname)
"""
Connection.__init__(self, name=name)
# Handle inputs
Expand Down
Loading

0 comments on commit 4ee2637

Please sign in to comment.