Shapes and generic cells#

gdsfactory provides some generic parametric cells in gf.components that you can customize for your application.

Basic shapes#

Rectangle#

To create a simple rectangle, there are two functions:

gf.components.rectangle() can create a basic rectangle:

import gdsfactory as gf
from gdsfactory.generic_tech import get_generic_pdk

gf.config.rich_output()

PDK = get_generic_pdk()
PDK.activate()

r1 = gf.components.rectangle(size=(4.5, 2), layer=(1, 0))
r1.plot()

../_images/e371118fb60b277c8991ec8ad275e180ed5eb5fa3b01deb0a264a1327fc49c2f.png

gf.components.bbox() can also create a rectangle based on a bounding box. This is useful if you want to create a rectangle which exactly surrounds a piece of existing geometry. For example, if we have an arc geometry and we want to define a box around it, we can use gf.components.bbox():

c = gf.Component()
arc = c << gf.components.bend_circular(radius=10, width=0.5, angle=90, layer=(1, 0))
arc.rotate(90)
# Draw a rectangle around the arc we created by using the arc's bounding box
rect = c << gf.components.bbox(bbox=arc.bbox, layer=(0, 0))
c.plot()
2024-10-31 18:39:03.693 | WARNING  | gdsfactory.component:plot_klayout:1646 - UserWarning: Unnamed cells, 1 in 'Unnamed_9ff8c14f'

../_images/71e553dc8c0bbda587c71ee0b9514aa1b236358411692b17b3e3f629af74840c.png

Cross#

The gf.components.cross() function creates a cross structure:

c = gf.components.cross(length=10, width=0.5, layer=(1, 0))
c.plot()

../_images/a71592d39db7145f25da400edc67ca7086e52fc0c9a72edfe49ded0f31d82a3f.png

Ellipse#

The gf.components.ellipse() function creates an ellipse by defining the major and minor radii:

c = gf.components.ellipse(radii=(10, 5), angle_resolution=2.5, layer=(1, 0))
c.plot()

../_images/c2ce5c524a465bda61849be64f37e1cb2408536c577368932e44fa323581d654.png

Circle#

The gf.components.circle() function creates a circle:

c = gf.components.circle(radius=10, angle_resolution=2.5, layer=(1, 0))
c.plot()

../_images/d03678c9c7fb81e0666124e23ed3017141c59ec68da55402991b73983f876e69.png

Ring#

The gf.components.ring() function creates a ring. The radius refers to the center radius of the ring structure (halfway between the inner and outer radius).

c = gf.components.ring(radius=5, width=0.5, angle_resolution=2.5, layer=(1, 0))
c.plot()

../_images/1c672e65af3ff50f2c2f687feb806878de3b11a60d013f07e83474e76d8bfbae.png
c = gf.components.ring_single(gap=0.2, radius=10, length_x=4, length_y=2)
c.plot()

../_images/2e471c009e3d6b1ed0fc256d09ec4e0af6a3d64eb9ee18829bb2331e6178b56a.png
import gdsfactory as gf

c = gf.components.ring_double(gap=0.2, radius=10, length_x=4, length_y=2)
c.plot()

../_images/259e5d84a7094d9ef85e7b09b14805646b911b7dd96b18c300d56ea10cb835f5.png
c = gf.components.ring_double(
    gap=0.2,
    radius=10,
    length_x=4,
    length_y=2,
    bend=gf.components.bend_circular,
)
c.plot()

../_images/c5b0af2117888e91de4980fce15439b8adcc2f1d56d8c0d951e6321430b91fca.png

Bend circular#

The gf.components.bend_circular() function creates an arc. The radius refers to the center radius of the arc (halfway between the inner and outer radius).

c = gf.components.bend_circular(
    radius=2.0, width=0.5, angle=90, npoints=720, layer=(1, 0)
)
c.plot()
2024-10-31 18:39:04.760 | WARNING  | gdsfactory.cross_section:validate_radius:223 - UserWarning: min_bend_radius 2.0 < CrossSection.radius_min 5.0. 

../_images/3488b81aacac13dde80c786fc86b91a208bc0c5e165a73e99e6b0929bbc34e0a.png

Bend euler#

The gf.components.bend_euler() function creates an adiabatic bend in which the bend radius changes gradually. Euler bends have lower loss than circular bends.

c = gf.components.bend_euler(radius=2.0, width=0.5, angle=90, npoints=720, layer=(1, 0))
c.plot()

../_images/e1b1cc5aa81c72ea0fb6d1418b208fb72a248a97d15ef7f67d011c02ded655a3.png

Tapers#

gf.components.taper()is defined by setting its length and its start and end length. It has two ports, 1 and 2, on either end, allowing you to easily connect it to other structures.

c = gf.components.taper(length=10, width1=6, width2=4, port=None, layer=(1, 0))
c.plot()

../_images/329e14a359571e7844b74059b093d18757452c781585247e2f8a4e73273af730.png

gf.components.ramp() is a structure is similar to taper() except it is asymmetric. It also has two ports, 1 and 2, on either end.

c = gf.components.ramp(length=10, width1=4, width2=8, layer=(1, 0))
c.plot()

../_images/8d674461cbc33775756d9fdd6a9c8709a21c078552876945155dfdec1fd4fcc9.png

Common compound shapes#

The gf.components.L() function creates a “L” shape with ports on either end named 1 and 2.

c = gf.components.L(width=7, size=(10, 20), layer=(1, 0))
c.plot()

../_images/fe2c18730d9bb5b8d6c07efa54714b8a52cacd2a67e40a67db3722474d20b23c.png

The gf.components.C() function creates a “C” shape with ports on either end named 1 and 2.

c = gf.components.C(width=7, size=(10, 20), layer=(1, 0))
c.plot()

../_images/c98355a1972cd698f05e923bd2db675a9783ef928153ed478335be618aad84b6.png

Text#

Gdsfactory has an implementation of the DEPLOF font with the majority of english ASCII characters represented (thanks to phidl)

c = gf.components.text(
    text="Hello world!\nMultiline text\nLeft-justified",
    size=10,
    justify="left",
    layer=(1, 0),
)
c.plot()
# `justify` should be either 'left', 'center', or 'right'

../_images/ad88dbac96ff8cd66477f009ab66b5ff3b298d83141e5930d24e6f2cd8607e0d.png

Lithography structures#

Step-resolution#

The gf.components.litho_steps() function creates lithographic test structure that is useful for measuring resolution of photoresist or electron-beam resists. It provides both positive-tone and negative-tone resolution tests.

c = gf.components.litho_steps(
    line_widths=[1, 2, 4, 8, 16], line_spacing=10, height=100, layer=(1, 0)
)
c.plot()

../_images/1e439e0134d394a5ada55733bd5851ee2c3330a6e75a8c8091e05baf597e98e9.png

Calipers (inter-layer alignment)#

The gf.components.litho_calipers() function is used to detect offsets in multilayer fabrication. It creates a two sets of notches on different layers. When an fabrication error/offset occurs, it is easy to detect how much the offset is because both center-notches are no longer aligned.

D = gf.components.litho_calipers(
    notch_size=[1, 5],
    notch_spacing=2,
    num_notches=7,
    offset_per_notch=0.1,
    row_spacing=0,
    layer1=(1, 0),
    layer2=(2, 0),
)
D.plot()

../_images/61358811281e02a7347e1ddbfd9d503f16f430a12da1535fd887c5fc8487a09c.png

Paths#

See Path tutorial for more details – this is just an enumeration of the available built-in Path functions

Circular arc#

P = gf.path.arc(radius=10, angle=135, npoints=720)
f = P.plot()

../_images/6c2673d630ac2ba75e984ca75a58bb15d47f77324eb820ff30a31d75ecc6e828.png

Straight#

import gdsfactory as gf

P = gf.path.straight(length=5, npoints=100)
f = P.plot()

../_images/f6ac2c898bd4fcc309d4b00c157e07d92707cf4a223a6cc7691f1742f1c707e3.png

Euler curve#

Also known as a straight-to-bend, clothoid, racetrack, or track transition, this Path tapers adiabatically from straight to curved. Often used to minimize losses in photonic straights. If p < 1.0, will create a “partial euler” curve as described in Vogelbacher et. al. https://dx.doi.org/10.1364/oe.27.031394. If the use_eff argument is false, radius corresponds to minimum radius of curvature of the bend. If use_eff is true, radius corresponds to the “effective” radius of the bend– The curve will be scaled such that the endpoints match an arc with parameters radius and angle.

P = gf.path.euler(radius=3, angle=90, p=1.0, use_eff=False, npoints=720)
f = P.plot()

../_images/2866b9b776283b9ebd14929f7ff75d08540b3630a76c1b8b1b920a07dc7b5e04.png

Smooth path from waypoints#

import numpy as np

import gdsfactory as gf

points = np.array([(20, 10), (40, 10), (20, 40), (50, 40), (50, 20), (70, 20)])

P = gf.path.smooth(
    points=points,
    radius=2,
    bend=gf.path.euler,
    use_eff=False,
)
f = P.plot()

../_images/df35336cf14663025838ab3de923a90a3e4f1ecc62a80231de33a808fa676342.png

Delay spiral#

c = gf.components.spiral_double()
c.plot()

../_images/c8ef793f1a466153ddd12caf865187eaa43399ca3d084ae5d5d6ddf45f122f0c.png
c = gf.components.spiral_inner_io()
c.plot()

../_images/680858e9521cd3dffe96afcd94be0f9ff1f3ecbc57c56444b869d4df3be84ec8.png
c = gf.components.spiral_external_io()
c.plot()

../_images/628b3ddbbcfc42e2d0ca9a9e908b01d187619a9f68649e3bb8b1408526137145.png

Useful contact pads / connectors#

These functions are common shapes with ports, often used to make contact pads

c = gf.components.compass(size=(4, 2), layer=(1, 0))
c.plot()

../_images/841281ef2f38feefed309fa3dafc4ed3e0024b0ee520478d648d31a0eb3343be.png
c = gf.components.nxn(north=3, south=4, east=0, west=0)
c.plot()

../_images/fea4b5b2cd00f25b0b839bb14ba6e1fefc6b98f0defbf33f1a4a8ce7ac9df651.png
c = gf.components.pad()
c.plot()

../_images/10bfe21932aee8904ca88a7cb314721f6d68a9f095e57f0ad3225c668e7bfb0c.png
c = gf.components.pad_array90(columns=3)
c.plot()

../_images/2890ba9a4d6986c4276719224b3e88de5c61635685736d02674c97a4ad135936.png

Chip / die template#

import gdsfactory as gf

c = gf.components.die(
    size=(10000, 5000),  # Size of die
    street_width=100,  # Width of corner marks for die-sawing
    street_length=1000,  # Length of corner marks for die-sawing
    die_name="chip99",  # Label text
    text_size=500,  # Label text size
    text_location="SW",  # Label text compass location e.g. 'S', 'SE', 'SW'
    layer=(2, 0),
    bbox_layer=(3, 0),
)
c.plot()

../_images/5be392db6dd90bdb70e187741f84949d2e118fe26fa1de12ec4751481fafc37d.png

Optimal superconducting curves#

The following structures are meant to reduce “current crowding” in superconducting thin-film structures (such as superconducting nanowires). They are the result of conformal mapping equations derived in Clem, J. & Berggren, K. “Geometry-dependent critical currents in superconducting nanocircuits.” Phys. Rev. B 84, 1–27 (2011).

import gdsfactory as gf

c = gf.components.optimal_hairpin(
    width=0.2, pitch=0.6, length=10, turn_ratio=4, num_pts=50, layer=(2, 0)
)
c.plot()

../_images/6b8e6b61d7d92d92eb34f94ef9761d53962f7414295d70fc46b9ec895ada4974.png
c = gf.components.optimal_step(
    start_width=10,
    end_width=22,
    num_pts=50,
    width_tol=1e-3,
    anticrowding_factor=1.2,
    symmetric=False,
    layer=(2, 0),
)
c.plot()

../_images/c4324753e02be012da2155a3a874dd1eef6afcfaf737f2eaba4bee8496ee89c1.png
c = gf.components.optimal_90deg(width=100.0, num_pts=15, length_adjust=1, layer=(2, 0))
c.plot()

../_images/ecab0c3861c2d00694eefa1d7fefb5f9bed5651dc11a2f72fddd6eeff98a10d9.png
c = gf.components.snspd(
    wire_width=0.2,
    wire_pitch=0.6,
    size=(10, 8),
    num_squares=None,
    turn_ratio=4,
    terminals_same_side=False,
    layer=(2, 0),
)
c.plot()

../_images/64138996bbafc5eaa612b50758db9bc002c6b09eb6205756cce8e37d674ee1cb.png

Generic library#

gdsfactory comes with a generic library that you can customize it to your needs or even modify the internal code to create the Components that you need.