gdshelpers.parts package¶
Submodules¶
gdshelpers.parts.cavity module¶
-
class
gdshelpers.parts.cavity.
PhotonicCrystalCavity
(origin, angle, width, lengthofcavity, numberofholes=14, holediameters=0.5, holedistances=0.5, tapermode=None, finalwidth=None, taperlength=None, samplepoints=1000, holeparams=None, underetching=True, markers=True)¶ Bases:
object
class to implement standard Photonic Crystal Cavity devices with GDS helpers see below for examples how to implement cavities with 1. constant hole diameters/distances 2. varying hole diameters/distances 3. tapered waveguide width (set cavity length to - holediameter)
-
generate_marker
()¶
-
generate_underetch
()¶
-
get_holes_list
()¶
-
get_left_port
()¶
-
get_right_port
()¶
-
classmethod
make_at_port
(port, **kwargs)¶
-
gdshelpers.parts.coupler module¶
-
class
gdshelpers.parts.coupler.
GratingCoupler
(origin, angle, width, full_opening_angle, grating_lines, n_points=300, extra_triangle_layer=False, start_radius_absolute=False)¶ Bases:
object
A standard style radial grating coupler.
This coupler starts with the
width
of the input/output waveguide. The input is widened to the opening angle and ended with a circle which radius is given by the first value in the list of grating lines. The taper radius is either measured absolutely starting at the part origin or relative to the minimum radius. The minimum radius is the radius needed to achieve the opening angle.All grating lines are given in a list which is the distance of the grating line to the last grating line. A list like
(10, 2, 5, 3, 6)
generates a coupler:- with taper radius 10
- followed by a gap of 2 um and 5 um of material
- followed by a gap of 4 um and 5 um of material
In most cases it is too much work to calculate these grating intervals. The class functions
make_traditional_coupler()
,make_traditional_coupler_at_port()
andmake_traditional_coupler_from_database()
will help you to create traditional couplers efficiently.Parameters: - origin (list, tuple) – 2-element list or tuple specifying the
(x, y)
coordinates of the coupler. - width (float) – With of the waveguide
- full_opening_angle (float) – Full opening angle of the coupler in radiant.
- grating_lines – List specifying the taper radius and the position of the grating edges.
- n_points – Number of points used per grating edge.
- extra_triangle_layer (bool) – If True, the taper triangle is painted separately and can be accessed via
get_shapely_object_triangle()
. Disabled by default. - angle – Angle of the coupler in radiant. Defaults to -pi/2, hence the waveguide of the coupler points upwards.
- start_radius_absolute – If set to True, the first element of
grating_lines
is the absolute radius of the taper measured to its origin. An assertion error is thrown, if the radius is to small to achieve the full opening angle.
-
get_description_str
(grating_period=True, fill_factor=True, taper_length=True, opening_angle=True)¶
-
get_description_text
(height=3.0, space=10, side='right', **desc_options)¶
-
get_shapely_object
()¶ Get the Shapely object of this coupler.
If requested during creation of the coupler, the tapered triangle is not included in this Shapely object. It has to be acquired via
get_shapely_object_triangle()
.Returns: A Shapely object.
-
get_shapely_object_triangle
()¶ Get the Shapely object of this coupler, but only the tapered triangle.
Returns: A Shapely object.
-
classmethod
make_traditional_coupler
(origin, width, full_opening_angle, grating_period, grating_ff, n_gratings, ap_max_ff=1.0, n_ap_gratings=0, taper_length=None, extra_triangle_layer=False, angle=-1.5707963267948966, n_points=394, implement_cadence_ff_bug=True, ap_start_period=None)¶ Generate a traditional coupler as the
lib/coupler/
functions did. But this version is versatile enough to generate all kinds of couplers, including:- constant fill factor couplers
- apodized couplers (where the fill factor is varied from ap_max_ff to grating_ff and the grating period
- is varied from ap_start_period to grating_period over n_ap_gratings gratings.)
All couplers can have the taper triangle separated onto its own layer for better e-beam dose.
Parameters: - origin (list, tuple) – 2-element list or tuple specifying the
(x, y)
coordinates of the coupler. - width (float) – With of the waveguide
- full_opening_angle (float) – Full opening angle of the coupler in radiant.
- grating_period (float) – The grating period of the coupler.
- grating_ff (float) – The fill factor of the coupler between 0 and 1.
- n_gratings (int) – Number of gratings.
- ap_max_ff – Maximum fill factor of apodized gratings.
- n_ap_gratings (int) – Number of apodized gratings.
- taper_length – If not None, this sets the radius if the inner taper. Otherwise the length will be equal to the grating length.
- n_points – Number of points used per grating edge.
- extra_triangle_layer (bool) – If True, the taper triangle is painted seperatly and can be accessed via
get_shapely_object_triangle()
. Disabled by default. - angle – Angle of the coupler in radiant. Defaults to -pi/2, hence the waveguide of the coupler points upwards.
- implement_cadence_ff_bug (bool) –
- ap_start_period – The starting period in the apodized region. If a value is passed, the period will be swept from ap_start_period to grating_period over the apodized gratings. If None, the period will be constant.
Returns: The constructed traditional grating coupler.
Return type:
-
classmethod
make_traditional_coupler_at_port
(port, **kwargs)¶ Make a traditional coupler at a port.
This function is identical to
make_traditional_coupler()
. Parameters of the port can also be overwritten via keyword arguments.Parameters: - port (Port) – The port at which the coupler shall be created.
- kwargs – Keyword arguments passed to
make_traditional_coupler()
.
Returns: The constructed traditional grating coupler.
Return type:
-
classmethod
make_traditional_coupler_from_database
(origin, width, db_id, wavelength, **kwargs)¶
-
classmethod
make_traditional_coupler_from_database_at_port
(port, db_id, wavelength, **kwargs)¶
-
maximal_radius
¶
-
origin
¶
-
width
¶
gdshelpers.parts.coupler_references module¶
This module includes a collection of coupler parameters. It is not meant to be used directly but
rather via the GratingCoupler.make_traditional_coupler_from_database()
functions.
Feel free to report your coupler findings for inclusion in this database.
gdshelpers.parts.image module¶
gdshelpers.parts.interferometer module¶
-
class
gdshelpers.parts.interferometer.
MachZehnderInterferometer
(origin, angle, width, splitter_length, splitter_separation, bend_radius, upper_vertical_length, lower_vertical_length, horizontal_length)¶ Bases:
object
A simple Mach-Zehnder interferometer based on Y-splitters.
Parameters: - origin (tuple) – Start of the interferometer.
- angle (float) – Angle of the interferometer in rad.
- width (float) – Waveguide width.
- splitter_length (float) – Length of the splitter
- splitter_separation (float) – Separation of the slitter branches.
- bend_radius (float) – Bend radius.
- upper_vertical_length (float) – Straight length of the upper branch.
- lower_vertical_length (float) – Straight length of the lower branch.
- horizontal_length (float) – Straight horizontal length for both branches.
-
device_width
¶
-
get_shapely_object
()¶
-
classmethod
make_at_port
(port, splitter_length, splitter_separation, bend_radius, upper_vertical_length, lower_vertical_length, horizontal_length)¶
-
port
¶
-
class
gdshelpers.parts.interferometer.
MachZehnderInterferometerMMI
(origin, angle, width, splitter_length, splitter_width, bend_radius, upper_vertical_length, lower_vertical_length, horizontal_length)¶ Bases:
object
A simple Mach-Zehnder interferometer based on Y-splitters.
Parameters: - origin (tuple) – Start of the interferometer.
- angle (float) – Angle of the interferometer in rad.
- width (float) – Waveguide width.
- splitter_length (float) – Length of the splitter
- splitter_separation (float) – Separation of the slitter branches.
- bend_radius (float) – Bend radius.
- upper_vertical_length (float) – Straight length of the upper branch.
- lower_vertical_length (float) – Straight length of the lower branch.
- horizontal_length (float) – Straight horizontal length for both branches.
-
device_width
¶
-
get_shapely_object
()¶
-
classmethod
make_at_port
(port, splitter_length, splitter_width, bend_radius, upper_vertical_length, lower_vertical_length, horizontal_length)¶
-
port
¶
gdshelpers.parts.logo module¶
-
class
gdshelpers.parts.logo.
KITLogo
(origin, height, min_radius_fraction=0.05)¶ Bases:
object
A simplified logo of the Karlsruhe Institute of Technology (KIT).
Parameters: - origin – Tuple specifying the lower left corner of the logo.
- height – Height of the logo.
- min_radius_fraction – To avoid steep angles, the rays are cut at the minimum radius fraction.
-
get_shapely_object
()¶
gdshelpers.parts.marker module¶
-
class
gdshelpers.parts.marker.
AutoStigmationMarker
(origin, maximum_feature_size=3.0, minimum_feature_size=0.1, reduction_factor=1.2, resolution=16)¶ Bases:
object
-
get_shapely_object
()¶
-
-
class
gdshelpers.parts.marker.
CrossMarker
(origin, cross_length, cross_width, paddle_length, paddle_width)¶ Bases:
object
Simple cross type marker with support for paddles.
This code is an adapted version of Nico’s marker.
-
get_shapely_object
()¶
-
classmethod
make_simple_cross
(origin, cross_length, cross_width)¶
-
classmethod
make_traditional_paddle_markers
(origin, scale=1.0, cross_length_factor=2.0, cross_width_factor=0.1, paddle_length_factor=3.0, paddle_width_factor=0.5)¶
-
-
class
gdshelpers.parts.marker.
DLWPrecisionMarker
(origin, size, frame_width)¶ Bases:
object
A specific marker to test the writing accuracy/alignment of the Nanoscribe DLW machine.
Parameters: - origin – Position of the marker.
- size – Size of the marker.
- frame_width – Size of the marker frame.
-
get_shapely_object
()¶
gdshelpers.parts.mode_converter module¶
-
class
gdshelpers.parts.mode_converter.
StripToSlotModeConverter
(origin, angle, width, taper_length, final_width, pre_taper_length, pre_taper_width)¶ Bases:
object
Generates a strip to slot mode converter as presented by Palmer et. al https://doi.org/10.1109/JPHOT.2013.2239283. If the input port width is a scalar und the final width is an array, a strip to slot mode converter is generated. On the other hand, if the input port width is an array and the final width is a scaler, a slot to strip mode converter is generated.
-
get_shapely_object
()¶ Generates the mode converter. If the input port width is a scalar und the final width is an array, a strip to slot mode converter is generated. On the other hand, if the input port width is an array and the final width is a scaler, a slot to strip mode converter is generated.
Returns: shapely object
-
in_port
¶ Returns the input port of the mode converter
Returns: port
-
classmethod
make_at_port
(port, taper_length, final_width, pre_taper_length, pre_taper_width)¶ Parameters: - port – port of the taper (origin, angle, width)
- taper_length – length of the taper
- final_width – final width of the mode converter. Array if strip to slot, scalar if slot to strip
- pre_taper_length – length of the pre taper
- pre_taper_width – width of the pre taper
Returns:
-
out_port
¶ Returns the output port of the mode converter
Returns: port
-
gdshelpers.parts.ntron module¶
-
class
gdshelpers.parts.ntron.
Ntron
(origin, angle, gate_width_1, gate_width_2, choke_width_1, choke_width_2, choke_length_2, choke_length_3, choke_point_2=(0.5, 0), choke_point_3=(1, 0.5), points_per_curve=1000, gate_start=0, gate_point_2=(0.3333333333333333, 0), gate_point_3=(0.6666666666666666, 1), channel_point_2=(0.3333333333333333, 0), channel_point_3=(0.6666666666666666, 0), channel_length=2.5, outer_channel_width=0.4, inner_channel_width=0.2, channel_position=0.5, gate_length=0.5, choke_start=0.5, gate_choke_length=0.2)¶ Bases:
object
-
angle
¶
-
get_shapely_object
()¶
-
classmethod
make_at_port_
(port, gate_width_1, gate_width_2, choke_width_1, choke_width_2, choke_length_2, choke_length_3, choke_point_2=(0.5, 0), choke_point_3=(1, 0.5), points_per_curve=1000, gate_start=0, gate_point_2=(0.3333333333333333, 0), gate_point_3=(0.6666666666666666, 1), channel_point_2=(0.3333333333333333, 0), channel_point_3=(0.6666666666666666, 0), channel_length=2.5, outer_channel_width=0.4, inner_channel_width=0.2, channel_position=0.3, gate_length=0.5, choke_start=0.5, gate_choke_length=0.2, target='_gate')¶ Class method to directly place a ntron to a given port, connected to a chosen port
Parameters: - port – port from the connecting structure
- gate_width_1 – outer width of the _gate port
- gate_width_2 – connection gate-choke, should be same as choke_width_1
- choke_width_1 – outer width of the choke
- choke_width_2 – Inner choke width, which is the bottleneck and the most important parameter
- choke_length_2 – length of the gate sided choke bezier shape
- choke_length_3 – length of the channel sided choke bezier shape
- choke_point_2 – 2nd bezier point in a rectangle (Look Bezier explanation above)
- choke_point_3 – 3rd bezier point in a rectangle (Look Bezier explanation above)
- points_per_curve – number of of points per Bezier curve used to create a shapely geometry
- gate_start – starting x pos of the gate section, should be zero
- gate_point_2 – 2nd bezier point in a rectangle (Look Bezier explanation above)
- gate_point_3 – 3rd bezier point in a rectangle (Look Bezier explanation above)
- channel_point_2 – 2nd bezier point in a rectangle (Look Bezier explanation above)
- channel_point_3 – 3rd bezier point in a rectangle (Look Bezier explanation above)
- channel_length – length of the channel
- outer_channel_width – starting width of the channel at the gates
- inner_channel_width – end width in the middle of the channel
- channel_position – channel position corresponding to the gate, for 0 choke is on the bottom, for 1 on the top
- gate_length – the length of the bezier calculated shape of the gate
- choke_start – starting x pos of the choke section, should be equal to gate_length
- gate_choke_length –
- target – the ntron port to connect to
Returns:
-
origin
¶
-
port_drain
¶
-
port_gate
¶
-
port_source
¶
-
width
¶
-
gdshelpers.parts.ofwa module¶
Parts for Optical Field Writable Arrays (OFWA)
-
class
gdshelpers.parts.ofwa.
MultiPortSwitch
(origin, angle, in_ports, out_ports, port_spacing, taper_length, taper_function, radius, wg_bend_radius, displacement=0.0, minimal_final_spacing=None)¶ Bases:
object
-
angle
¶
-
dlw_in_ports
¶
-
dlw_out_ports
¶
-
get_dlw_in_port
(idx)¶
-
get_dlw_out_port
(idx)¶
-
get_in_port
(idx)¶
-
get_out_port
(idx)¶
-
get_shapely_object
()¶
-
in_ports
¶
-
classmethod
make_at_in_port
(port, in_port_idx, **kwargs)¶
-
classmethod
make_at_out_port
(port, out_port_idx, **kwargs)¶
-
marker_positions
¶
-
origin
¶
-
out_ports
¶
-
gdshelpers.parts.optical_codes module¶
-
class
gdshelpers.parts.optical_codes.
QRCode
(origin, data, box_size, version=None, error_correction=0, border=0, alignment='left-bottom')¶ Bases:
object
Quick Response (QR) code part.
This part is a simple wrapper around the qrcode library using the ShapelyImageFactory. If you need more flexibility this class might be extended or you can use the shapely output factory ShapelyImageFactory and qrcode directly.
Parameters: - origin – Lower left corner of the QR code.
- data – Data which is to be encoded into the QR code.
- box_size – Size of each box.
- version – QR code version.
- error_correction – Level of error correction.
- border – Size of the surrounding free border.
-
ERROR_CORRECT_H
= 2¶
-
ERROR_CORRECT_L
= 1¶
-
ERROR_CORRECT_M
= 0¶
-
ERROR_CORRECT_Q
= 3¶
-
get_shapely_object
()¶
-
class
gdshelpers.parts.optical_codes.
ShapelyImageFactory
(border, width, box_size, *args, **kwargs)¶ Bases:
qrcode.image.base.BaseImage
Output factory for qrcode, generating Shapely polygons.
Probably you will not need to use it directly. The
QRCode
class provides a simple to use part based on this image factory.-
drawrect
(row, col)¶ Draw a single rectangle of the QR code.
-
get_shapely_object
()¶
-
kind
= 'shapely'¶
-
new_image
(origin=(0, 0), scale_factor=0.001, **kwargs)¶ Build the image class. Subclasses should return the class created.
-
origin
¶
-
size
¶
-
gdshelpers.parts.pattern_import module¶
gdshelpers.parts.port module¶
-
class
gdshelpers.parts.port.
Port
(origin, angle, width)¶ Bases:
object
Abstraction of a waveguide port.
Other objects might dock to a port. It is simply a helper object to allow easy chaining of parts.
Parameters: - origin – Origin of the port.
- angle – Angle of the port.
- width (float) – Width of the port.
-
angle
¶ The angle of the port.
-
debug_shape
¶
-
get_parameters
()¶ Get a dictionary representation of the port properties.
Returns: A dictionary containing the origin
,angle
andwidth
of the port.Return type: dict
-
inverted_direction
¶ Get a port which points in the opposite direction.
Returns: A copy of this port, pointing in the opposite direction. Return type: Port
-
longitudinal_offset
(offset)¶ Returns a new port, which offset in in direction of this port.
Parameters: offset (float) – Offset from the end of the port. Positive is the direction, the port is pointing. Returns: The new offset port Return type: Port
-
origin
¶ The origin coordinates of this port.
When reading it is guarantied to be a 2-dim numpy array.
-
parallel_offset
(offset)¶ Returns a new port, which offset in parallel from this port.
Parameters: offset (float) – Offset from the center of the port. Positive is left of the port. Returns: The new offset port Return type: Port
-
rotated
(angle)¶ Returns a new port, which is rotated by the given angle.
Parameters: angle (float) – Angle to rotate. Returns: The new rotated port Return type: Port
-
set_port_properties
(**kwargs)¶ Set port parameters via named keyword arguments.
Parameters: kwargs – The keywords to set. Returns: The modified port Return type: Port
-
total_width
¶ The total width of the port.
Guarantied to be a positive float.
-
width
¶ The width of the port. E.g. for slot waveguides it can also be an array in the format [width, gap, width, …], where each width describe the width of each rail and the gap defines the gap in between. This array can also end with a gap, which facilitates e.g. the design of adiabatic mode converters.
-
with_width
(width)¶ Returns a new port, of which the width is set to the new value
Parameters: width – Width of the resulting port Returns: The new port Return type: Port
-
x
¶
-
y
¶
gdshelpers.parts.resonator module¶
Ring and race track resonators
-
class
gdshelpers.parts.resonator.
RingResonator
(origin, angle, width, gap, radius, race_length=0, draw_opposite_side_wg=False, res_wg_width=None, n_points=None, straight_feeding=False, vertical_race_length=0)¶ Bases:
object
A simple Ring / Race track resonator.
This part implements a super simple ring resonator with optional race tracks. Several helper functions are available to calculate points and ports of interest. The width of the feeding waveguide and the ring waveguide may differ.
Parameters: - origin – Origin of the resonator, which is the start of the input waveguide.
- angle – Angle of the input waveguide.
- width – Width of the angle waveguide.
- gap – Gap between ring and waveguide. If positive, the ring will be on the left, and on the right side for negative gap values. Can also be a 2-tuple, if input and output gap should be different.
- radius – Radius of the bends.
- race_length – Length of the race track. Defaults to zero.
- draw_opposite_side_wg – If True, draw the opposing waveguides, (a.k.a. drop ports.)
- res_wg_width – Width of the resonator waveguide. If None, the width of the input waveguide is assumend.
- n_points – Number of points used per quarter circle. If None, it uses the bend default.
- straight_feeding – Add straight connections on both sides of the resonator.
- vertical_race_length – Length of a vertical race track section. Defaults to zero.
-
add_port
¶
-
angle
¶
-
center_coordinates
¶
-
circumference
¶
-
drop_port
¶
-
get_shapely_object
()¶
-
in_port
¶
-
classmethod
make_at_port
(port, gap, radius, **kwargs)¶
-
opposite_side_port_in
¶
-
opposite_side_port_out
¶
-
origin
¶
-
out_port
¶
-
port
¶
-
through_port
¶
-
width
¶
gdshelpers.parts.snspd module¶
-
class
gdshelpers.parts.snspd.
SNSPD
(origin, angle, width, nano_wire_width, nano_wire_gap, nano_wire_length, waveguide_tapering, passivation_buffer)¶ Bases:
object
-
current_port
¶
-
get_passivation_layer
()¶
-
get_shapely_object
()¶
-
get_waveguide
()¶
-
left_electrode_port
¶
-
classmethod
make_at_port
(port, nw_width, nw_gap, nw_length, waveguide_tapering, passivation_buffer)¶
-
right_electrode_port
¶
-
gdshelpers.parts.source module¶
-
class
gdshelpers.parts.source.
CNT
(origin, angle, width, gap=0.15, l_taper=10, w_taper=0.9, el_l_straight=8, el_l_taper=2.5, el_final_width=2, el_l_fine=1.4, el_radius=0.1, n_points=128)¶ Bases:
object
Creates a CNT source (Electrodes + tapered waveguide) at waveguide port.
This class implements the electrodes and tapered waveguide for an integrated CNT source. It provides the electrodes ports and the connecting waveguide port. The Electrode is made up of three part: the round head (defined by the radius) followed by a straight fine line of length el_l_fine, followed by a taper to final_width with length el_l_taper and a box with length el_l_straight.
Parameters: - origin – Origin of the resonator, which is the start of the input waveguide.
- angle – Angle of the input waveguide.
- width – Width of the angle waveguide.
- gap – Gap between electrode tip and waveguide.
- l_taper – length of the waveguide taper used before and after the cnt. i.a. 2*l_taper will be added to the waveguide
- w_taper – width of waveguide at the cnts position
- el_l_straight – length of electrode part with largest thickness
- el_l_taper – length over which 2*el_radius is tapered to el_final_width
- el_final_width – largest width of the electrode
- el_l_fine – length of small strip to the tip of the electrode
- el_radius – radius of electrodes tip
- n_points – number of points used to make electrode tip polygon
-
get_shapely_object
()¶
-
in_port
¶
-
left_electrode_port
¶
-
classmethod
make_at_port
(port, **kwargs)¶
-
out_port
¶
-
right_electrode_port
¶
gdshelpers.parts.spiral module¶
-
class
gdshelpers.parts.spiral.
Spiral
(origin, angle, width, num, gap, inner_gap)¶ Bases:
object
-
angle
¶
-
get_shapely_object
()¶
-
in_port
¶
-
length
¶
-
classmethod
make_at_port
(port, num, gap, inner_gap)¶ Creates a Spiral around the given port
Parameters: - port – port at which the spiral starts
- num – number of turns
- gap – gap between two waveguides
- inner_gap – inner radius of the spiral
-
origin
¶
-
out_port
¶
-
width
¶
-
gdshelpers.parts.splitter module¶
-
class
gdshelpers.parts.splitter.
DirectionalCoupler
(origin, angle, wg_width, length, gap, bend_radius, bend_angle=0.6283185307179586)¶ Bases:
object
-
get_shapely_object
()¶
-
classmethod
make_at_port
(port, length, gap, bend_radius, bend_angle=0.6283185307179586, which=0)¶ Creates a dc coupler starting at the port :param port: starting port :param length: coupling length :param gap: gap between the waveguides in the coupling area :param bend_radius: radius of the curves :param bend_angle: angle of the curves :param which: decides on which side to start, either 0 or 1 :return:
-
-
class
gdshelpers.parts.splitter.
MMI
(origin, angle, wg_width, length, width, num_inputs, num_outputs, taper_width=2, taper_length=10)¶ Bases:
object
-
get_shapely_object
()¶
-
left_branch_port
¶ Returns the leftmost output port (like a Y-Splitter)
Returns: leftmost Port
-
classmethod
make_at_port
(port, length, width, num_inputs, num_outputs, pos='i0', taper_width=2, taper_length=10)¶ Creates a Multimode Interference Coupler at the given port :param port: port to make the coupler at :param length: length of the multimode area :param width: width of the multimode area :param num_inputs: number of input ports :param num_outputs: number of output ports :param pos: port, that has to be connected to the given port, first letter-> i=input/o=output, second letter->number of the input/output :param taper_width: width of the tapers at the multimode area :param taper_length: length of the tapers :return:
-
right_branch_port
¶ Returns the rightmost output port (like a Y-Splitter)
Returns: rightmost Port
-
separation
¶
-
-
class
gdshelpers.parts.splitter.
Splitter
(origin, angle, total_length, wg_width_root, sep, wg_width_branches=None, n_points=50, implement_cadence_bug=False)¶ Bases:
object
-
get_shapely_object
()¶
-
left_branch_port
¶
-
classmethod
make_at_left_branch_port
(port, total_length, sep, wavelength_root=None, **kwargs)¶
-
classmethod
make_at_right_branch_port
(port, total_length, sep, wavelength_root=None, **kwargs)¶
-
classmethod
make_at_root_port
(port, total_length, sep, **kwargs)¶
-
right_branch_port
¶
-
root_port
¶
-
gdshelpers.parts.text module¶
gdshelpers.parts.waveguide module¶
-
class
gdshelpers.parts.waveguide.
Waveguide
(origin, angle, width)¶ Bases:
object
-
add_arc
(final_angle, radius, final_width=None, n_points=128, shortest=True, **kwargs)¶
-
add_bend
(angle, radius, final_width=None, n_points=128, **kwargs)¶
-
add_bezier_to
(final_coordinates, final_angle, bend_strength, width=None, **kwargs)¶
-
add_bezier_to_port
(port, bend_strength, width=None, **kwargs)¶
-
add_cubic_bezier_path
(p0, p1, p2, p3, width=None, **kwargs)¶ Add a cubic bezier path to the waveguide.
Coordinates are in the “waveguide tip coordinate system”, so the first point will probably be p0 == (0, 0). Note that your bezier curve undergoes the same restrictions as a parameterized path. Don’t self-intersect it and don’t use small bend radii.
Parameters: - p0 – 2 element tuple like coordinates
- p1 – 2 element tuple like coordinates
- p2 – 2 element tuple like coordinates
- p3 – 2 element tuple like coordinates
- width – Width of the waveguide, as passed to :func:add_parameterized_path
- kwargs – Optional keyword arguments, passed to :func:add_parameterized_path
Returns: Changed waveguide
Return type:
-
add_left_bend
(radius, angle=1.5707963267948966)¶ Add a left turn (90° or as defined by angle) with the given bend radius
-
add_parameterized_path
(path, width=None, sample_distance=0.5, sample_points=100, path_derivative=None, path_function_supports_numpy=False, width_function_supports_numpy=False)¶ Generate a parameterized path.
The path coordinate system is the origin and rotation of the current path. So if you want to continue your path start at (0, 0) in y-direction.
Note, that path is either a list of (x,y) coordinate tuples or a callable function which takes one float parameter between 0 and 1. If you use a parameterized function, its first derivative must be continuous. When using a list of coordinates, these points will be connected by straight lines. They must be sufficiently close together to simulate a first derivative continuous path.
This function will try to space the final points of the curve equidistantly. To achieve this, it will first sample the function and find its first derivative. Afterwards it can calculate the cumulative sum of the length of the first derivative. This allows to sample the function nearly equidistantly in a second step. This approach might be wasteful for paths like (x**2, y). You can suppress resampling for length by passing zero or none as sample_distance parameter.
The width of the generated waveguide may be constant when passing a number, or variable along the path when passing an array or a callable function, using the same parameter as the path. For generating slot/coplanar/… waveguides, start with a Port which has an array of the form [rail_width_1, gap_width_1, rail_width_2, …] set as width and which defines the width of each rail and the gaps between the rails. This array is also allowed to end with a gap_width for positioning the rails asymmetrically to the path which can be useful e.g. for strip-to-slot mode converters.
Note, that your final direction of the path might not be what you expected. This is caused by the numerical procedure which generates numerical errors when calculating the first derivative. You can either append another arc to the waveguide to get to you a correct angle or you can also supply a function which is the algebraic first derivative. The returned vector is not required to be normed.
By default, for each parameter point t, the parameterized functions are call. You will notice that this is rather slow. To achieve the best performance, write your functions in such a way, that they can handle a numpy array as parameter t. Once the path_function_supports_numpy option is set to True, the function will be called only once, speeding up the calculation considerable.
Parameters: - path –
- width –
- sample_distance –
- sample_points –
- path_derivative –
- path_function_supports_numpy –
- width_function_supports_numpy –
-
add_right_bend
(radius, angle=1.5707963267948966)¶ Add a right turn (90° or as defined by angle) with the given bend radius
-
add_route_single_circle_to
(final_coordinates, final_angle, final_width=None, max_bend_strength=None, on_line_only=False)¶ Connect two points by straight lines and one circle.
Works for geometries like round edges and others. The final straight line can also be omitted so that the waveguide only end on the line described by the support vector and angle.
By default, this method tries to route to the target with the greatest possible circle. But the valid bending range may be limited via the max_bend_strength parameter.
This method does not work for geometries which cannot be connected only by straight lines and one circle, such as parallel lines etc.
Still, this method can prove extremely useful for routing to i.e. grating couplers etc.
Parameters: - final_coordinates – Final destination point.
- final_angle – Final angle of the waveguide.
- final_width – Final width of the waveguide.
- max_bend_strength – The maximum allowed bending radius.
- on_line_only – Omit the last straight line and only route to described line.
-
add_route_single_circle_to_port
(port, max_bend_strength=None, on_line_only=False)¶ Connect to port by straight lines and one circle.
Helper function to conveniently call add_route_single_circle_to. :param port: Target port. :param max_bend_strength: The maximum allowed bending radius. :param on_line_only: Omit the last straight line and only route to line described by port.
-
add_route_straight_to_port
(port)¶ Add a straight segment to a given port. The added segment will keep the angle of the current port at the start and use the angle of the target port at the end. If the ports are laterally shifted, this will result in a trapezoidal shape.
The width will be linearly tapered to that of the target port.
Parameters: port – Target port.
-
add_straight_segment
(length, final_width=None, **kwargs)¶
-
add_straight_segment_to_intersection
(line_origin, line_angle, **line_kw)¶ Add a straight line until it intersects with an other line.
The other line is described by the support vector and the line angle.
Parameters: - line_origin – Intersection line support vector.
- line_angle – Intersection line angle.
- line_kw – Parameters passed on to add_straight_segment.
Raises: ArithmeticError – When there is no intersection due to being parallel or if the intersection is behind the waveguide.
-
add_straight_segment_until_level_of_port
(port, **line_kw)¶ Add a straight line until it is on the same level as the given port. If several ports are given in a list, the most distant port is chosen.
In this context “on the same level” means the intersection of the waveguide with the line orthogonal to the given port.
Parameters: - port – The port or a list of ports.
- line_kw –
-
add_straight_segment_until_x
(x, **line_kw)¶ Add straight segment until the given x value is reached.
Parameters: - x – value
- line_kw – Parameters passed on to add_straight_segment.
-
add_straight_segment_until_y
(y, **line_kw)¶ Add straight segment until the given y value is reached.
Parameters: - y – value
- line_kw – Parameters passed on to add_straight_segment.
-
angle
¶
-
center_coordinates
¶
-
current_port
¶
-
get_segments
()¶ Returns the list of tuples, containing their ports and shapely objects.
-
get_shapely_object
()¶ Get a shapely object which forms this path.
-
get_shapely_outline
()¶ Get a shapely object which forms the outline of the path.
-
in_port
¶
-
length
¶
-
length_last_segment
¶
-
classmethod
make_at_port
(port, **kargs)¶
-
origin
¶
-
port
¶
-
width
¶
-
x
¶
-
y
¶
-
Module contents¶
-
class
gdshelpers.parts.
Port
(origin, angle, width)¶ Bases:
object
Abstraction of a waveguide port.
Other objects might dock to a port. It is simply a helper object to allow easy chaining of parts.
Parameters: - origin – Origin of the port.
- angle – Angle of the port.
- width (float) – Width of the port.
-
angle
¶ The angle of the port.
-
debug_shape
¶
-
get_parameters
()¶ Get a dictionary representation of the port properties.
Returns: A dictionary containing the origin
,angle
andwidth
of the port.Return type: dict
-
inverted_direction
¶ Get a port which points in the opposite direction.
Returns: A copy of this port, pointing in the opposite direction. Return type: Port
-
longitudinal_offset
(offset)¶ Returns a new port, which offset in in direction of this port.
Parameters: offset (float) – Offset from the end of the port. Positive is the direction, the port is pointing. Returns: The new offset port Return type: Port
-
origin
¶ The origin coordinates of this port.
When reading it is guarantied to be a 2-dim numpy array.
-
parallel_offset
(offset)¶ Returns a new port, which offset in parallel from this port.
Parameters: offset (float) – Offset from the center of the port. Positive is left of the port. Returns: The new offset port Return type: Port
-
rotated
(angle)¶ Returns a new port, which is rotated by the given angle.
Parameters: angle (float) – Angle to rotate. Returns: The new rotated port Return type: Port
-
set_port_properties
(**kwargs)¶ Set port parameters via named keyword arguments.
Parameters: kwargs – The keywords to set. Returns: The modified port Return type: Port
-
total_width
¶ The total width of the port.
Guarantied to be a positive float.
-
width
¶ The width of the port. E.g. for slot waveguides it can also be an array in the format [width, gap, width, …], where each width describe the width of each rail and the gap defines the gap in between. This array can also end with a gap, which facilitates e.g. the design of adiabatic mode converters.
-
with_width
(width)¶ Returns a new port, of which the width is set to the new value
Parameters: width – Width of the resulting port Returns: The new port Return type: Port
-
x
¶
-
y
¶