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/90bcf0cf944f91c6e4c9e21beec56509e6a046daf99bf41103c77697ffd6cf20.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-05-29 16:43:37.754 | WARNING  | gdsfactory.component:plot_klayout:1646 - UserWarning: Unnamed cells, 1 in 'Unnamed_a176a91e'

../_images/771210d824bc7fa63f1e98731dc60c0e366b6a5d89705cd2560639c358d41a3e.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/ace8741343e9c0236d56773ee8c16e1161d45ee5218e5fff46e79b13ac5b5e4a.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/a564cb2aa6a42d34dfd08acd479c9ffbec1633cace43f72a88c09871f88bff75.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/1acf5b7ac495a87a8f3aa529ddd4c609f8be416247dc3166b4f26ee037298d64.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/8fe8da2bf7b2762d16a870f0eaf501fbc79bdf16112a6bbdafe26ed137d25865.png
c = gf.components.ring_single(gap=0.2, radius=10, length_x=4, length_y=2)
c.plot()

../_images/066babdb065f05f66dca5217497254f55e34a8c17af9441e2ede0791782eb2a2.png
import gdsfactory as gf

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

../_images/7b1b215443121abf615d4177201c32105375b1244222a59d9875572f9fce04c6.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/2d1a28f32aa1d1ddbf9e0ac307c3ffa6df205f0175cd21d2ea2864b816472fe4.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-05-29 16:43:39.137 | WARNING  | gdsfactory.cross_section:validate_radius:223 - UserWarning: min_bend_radius 2.0 < CrossSection.radius_min 5.0. 

../_images/0dfdc8a2de78b91acbfbecd020ae8afee7369a1d2714c8f3821101c01a1d39e4.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/5af54d4bba85532af96334be9379056ee7d2a9b3ceb13e945b18271aa16e718d.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/96fd46dab4ca845c25d951709e437b636117e8f974650b972c5925164a55104e.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/786df7efcfc9239e3f2338771254315dd269d011b1a954af3193d0a379efbc95.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/b9f533fef59704eab02f00d7a80cdbdffc8f6b63a5ed1c983b026c37e9aba7ba.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/8ac61415a496496ac718aa332f639181a7daa58c357d2a7620401e95c7f69388.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/056a6c746fefce423b72ed179ad0f616dc61216118427f1ebcfa335b174ffc35.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/f4cae073ec8fef5e26e1bddaab5572753b5dcb2e9599196f9262460655faed97.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/e81d38e1808fa8912d0e2904b4865aa9e7dee48f5e3f7aa5c4d648232499b235.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/e5aa3a262d5ad2d9b8acf71145c7009facad29148e797a58d043515fab0983ae.png

Straight#

import gdsfactory as gf

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

../_images/c78219d317b8ad707d90646f9920ce1dd84b7c2857797b77a4480b9bd52efc32.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/b50547bbb7e3edd90ab676c0b37da3ee3a3b5553356be489e9a69119d8812b9f.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/b882f9c0c6a888f4cdaa0a5234f780a2048f632efeba6a03d055a090eb3fe9b5.png

Delay spiral#

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

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

../_images/76982f392d2abd82d6ced3ac28a7032ee574369dda6758954b1db100a94e14d7.png
c = gf.components.spiral_external_io()
c.plot()

../_images/24efd910504bf2f7f3040815cb4efdd589c8eaa8e468065c81753424c0682ccb.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/08575d8d95db297bc48bda96f5c3aea0c1b28739541edaf0b6d3c20b410c3a4f.png
c = gf.components.nxn(north=3, south=4, east=0, west=0)
c.plot()

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

../_images/35194c860aead58fc677d4601442dbb8026dac50e7bc495f75f10fae589cb37d.png
c = gf.components.pad_array90(columns=3)
c.plot()

../_images/47144e556f8e9f8178ea63520db83055808538037d661b46d7655d509b6e688e.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/053fcf15948104b9e98a553c783d7ed91b89facc30d0ae8291ece1989539c70b.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/bee94bedd4a2b0376936d23704b8c29955ae942f9b723ddea7dbbd0c82938679.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/4156bc790bc3f28a1630d4e0213b2383923214f67a258569b1bd8103668d44c0.png
c = gf.components.optimal_90deg(width=100.0, num_pts=15, length_adjust=1, layer=(2, 0))
c.plot()

../_images/cf6dae5be5862fbf3fc5dd62f187cf66c6fed089a1a793ebe0b98e9dac9d50cb.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/01a6ba44670ab3ebbfb6b6380aa27f4dfc419d526a7326725f4be4235cd130db.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.