Skip to article frontmatterSkip to article content

Import PDK

Import PDK from GDS files

To import a PDK from GDS files into gdsfactory you need:

  • GDS file with all the cells that you want to import in the PDK (or separate GDS files, where each file contains a GDS design).

Ideally you also get:

  • Klayout layer properties files, to define the Layers that you can use when creating new custom Components. This allows you to define the LayerMap that maps Layer_name to (GDS_LAYER, GDS_PuRPOSE).
  • layer_stack information (material index, thickness, z positions of each layer).
  • DRC rules. If you don’t get this you can easily build one using klayout.

GDS files are great for describing geometry thanks to the concept of References, where you store any geometry only once in memory.

For storing device metadata (settings, port locations, port widths, port angles ...) there is no clear standard.

gdsfactory stores the that metadata in YAML files, and also has functions to add pins

  • Component.write_gds() saves GDS
  • Component.write_gds_metadata() save GDS + YAML metadata
# Lets generate the script that we need to have to each GDS cell into gdsfactory
import gdsfactory as gf
from gdsfactory.config import PATH
from gdsfactory.generic_tech import get_generic_pdk
from gdsfactory.technology import lyp_to_dataclass

gf.config.rich_output()
PDK = get_generic_pdk()
PDK.activate()

c = gf.components.mzi()
c.plot()
Loading...

You can write GDS files only

gdspath = c.write_gds("extra/mzi.gds")
2023-12-09 17:32:08.981 | INFO     | gdsfactory.component:_write_library:1937 - Wrote to 'extra/mzi.gds'

Or GDS with YAML metadata information (ports, settings, cells ...)

gdspath = c.write_gds("extra/mzi.gds", with_metadata=True)
2023-12-09 17:32:08.988 | INFO     | gdsfactory.component:_write_library:1937 - Wrote to 'extra/mzi.gds'
2023-12-09 17:32:09.087 | INFO     | gdsfactory.component:_write_library:1941 - Write YAML metadata to 'extra/mzi.yml'

This created a mzi.yml file that contains:

  • ports
  • cells (flat list of cells)
  • info (function name, module, changed settings, full settings, default settings)
c.metadata.keys()
Loading...

You can read GDS files into gdsfactory thanks to the import_gds function

import_gds reads the same GDS file from disk without losing any information

gf.clear_cache()

c = gf.import_gds(gdspath, read_metadata=True)
c.plot()
Loading...
c2 = gf.import_gds(gdspath, name="mzi_sample", read_metadata=True)
c2.plot()
Loading...
c2.name
Loading...
c3 = gf.routing.add_fiber_single(c2)
c3.plot()
Loading...
gdspath = c3.write_gds("extra/pdk.gds", with_metadata=True)
2023-12-09 17:32:10.076 | INFO     | gdsfactory.component:_write_library:1937 - Wrote to 'extra/pdk.gds'
2023-12-09 17:32:10.174 | INFO     | gdsfactory.component:_write_library:1941 - Write YAML metadata to 'extra/pdk.yml'
gf.labels.write_labels.write_labels_klayout(gdspath, layer_label=(201, 0))
Loading...

add ports from pins

Sometimes the GDS does not have YAML metadata, therefore you need to figure out the port locations, widths and orientations.

gdsfactory provides you with functions that will add ports to the component by looking for pins shapes on a specific layers (port_markers or pins)

There are different pin standards supported to automatically add ports to components:

  • PINs towards the inside of the port (port at the outer part of the PIN)
  • PINs with half of the pin inside and half outside (port at the center of the PIN)
  • PIN with only labels (no shapes). You have to manually specify the width of the port.

Lets add pins, save a GDS and then import it back.

c = gf.components.straight(
    decorator=gf.add_pins.add_pins
)  # add pins inside the component
c.plot()
Loading...
gdspath = c.write_gds("extra/wg.gds")
2023-12-09 17:32:10.341 | INFO     | gdsfactory.component:_write_library:1937 - Wrote to 'extra/wg.gds'
gf.clear_cache()
c2 = gf.import_gds(gdspath)
c2.plot()
Loading...
c2.ports  # import_gds does not automatically add the pins
Loading...
c3 = gf.import_gds(gdspath, decorator=gf.add_ports.add_ports_from_markers_inside)
c3.plot()
Loading...
c3.ports
Loading...

Foundries provide PDKs in different formats and commercial tools.

The easiest way to import a PDK into gdsfactory is to:

  1. have each GDS cell into a separate GDS file
  2. have one GDS file with all the cells inside
  3. Have a KLayout layermap. Makes easier to create the layermap.

With that you can easily create the PDK as as python package.

Thanks to having a gdsfactory PDK as a python package you can:

  • version control your PDK using GIT to keep track of changes and work on a team
    • write tests of your pdk components to avoid unwanted changes from one component to another.
    • ensure you maintain the quality of the PDK with continuous integration checks
    • pin the version of gdsfactory, so new updates of gdsfactory won’t affect your code
  • name your PDK version using semantic versioning. For example patches increase the last number (0.0.1 -> 0.0.2)
  • install your PDK easily pip install pdk_fab_a and easily interface with other tools

To create a Python package you can start from a customizable template (thanks to cookiecutter)

You can create a python package by running this 2 commands inside a terminal:

pip install cookiecutter
cookiecutter https://github.com/joamatab/cookiecutter-pypackage-minimal

It will ask you some questions to fill in the template (name of the package being the most important)

Then you can add the information about the GDS files and the Layers inside that package

print(lyp_to_dataclass(PATH.klayout_lyp))

from gdsfactory.typings import Layer
from gdsfactory.technology.layer_map import LayerMap


class LayerMapFab(LayerMap):
    CAPACITOR: Layer = (42, 0)
    DEEPTRENCH: Layer = (4, 0)
    DEEP_ETCH: Layer = (3, 6)
    DICING: Layer = (65, 0)
    DRC_EXCLUDE: Layer = (67, 0)
    DRC_MARKER: Layer = (205, 0)
    DevRec: Layer = (68, 0)
    ERROR_PATH: Layer = (1000, 0)
    Errors: Layer = (69, 0)
    FLOORPLAN: Layer = (64, 0)
    FbrTgt: Layer = (81, 0)
    GE: Layer = (5, 0)
    GENPP: Layer = (26, 0)
    GEPPP: Layer = (29, 0)
    LABEL_INSTANCES: Layer = (206, 0)
    LABEL_OPTICAL_IO: Layer = (201, 0)
    LABEL_SETTINGS: Layer = (202, 0)
    Lumerical: Layer = (733, 0)
    M1: Layer = (41, 0)
    M1TILES: Layer = (191, 0)
    M2: Layer = (45, 0)
    M3: Layer = (49, 0)
    METALOPEN: Layer = (46, 0)
    MH: Layer = (47, 0)
    MONITOR: Layer = (101, 0)
    N: Layer = (20, 0)
    NOTILE_M1: Layer = (71, 0)
    NOTILE_M2: Layer = (72, 0)
    NOTILE_M3: Layer = (73, 0)
    NP: Layer = (22, 0)
    NPP: Layer = (24, 0)
    OXIDE_ETCH: Layer = (6, 0)
    PDPP: Layer = (27, 0)
    PP: Layer = (23, 0)
    PPP: Layer = (25, 0)
    P_210: Layer = (21, 0)
    PinRec: Layer = (1, 10)
    PinRecM: Layer = (1, 11)
    SHALLOW_ETCH: Layer = (2, 6)
    SHOW_PORTS: Layer = (1, 12)
    SILICIDE: Layer = (39, 0)
    SIM_REGION: Layer = (100, 0)
    SITILES: Layer = (190, 0)
    SLAB150: Layer = (2, 0)
    SLAB150CLAD: Layer = (2, 9)
    SLAB90: Layer = (3, 0)
    SLAB90CLAD: Layer = (3, 1)
    SOURCE: Layer = (110, 0)
    TE: Layer = (203, 0)
    TM: Layer = (204, 0)
    Text: Layer = (66, 0)
    VIA1: Layer = (44, 0)
    VIA2: Layer = (43, 0)
    VIAC: Layer = (40, 0)
    WAFER: Layer = (99999, 0)
    WGCLAD: Layer = (111, 0)
    WGN_Nitride: Layer = (34, 0)
    WGclad_material: Layer = (36, 0)
    Waveguide: Layer = (1, 0)
    XS_BOX: Layer = (300, 0)
    XS_GE: Layer = (315, 0)
    XS_M2: Layer = (399, 0)
    XS_MH: Layer = (306, 0)
    XS_N: Layer = (320, 0)
    XS_NPP: Layer = (321, 0)
    XS_OVERLAY: Layer = (311, 0)
    XS_OXIDE_M1: Layer = (305, 0)
    XS_OXIDE_M2: Layer = (307, 0)
    XS_OXIDE_M3: Layer = (311, 0)
    XS_OXIDE_MH: Layer = (317, 0)
    XS_OXIDE_ML: Layer = (309, 0)
    XS_OX_NIT_CLAD: Layer = (304, 0)
    XS_OX_SI: Layer = (302, 0)
    XS_P: Layer = (330, 0)
    XS_PDPP: Layer = (327, 0)
    XS_PPP: Layer = (331, 0)
    XS_SI: Layer = (301, 0)
    XS_SIN: Layer = (319, 0)
    XS_SIN2: Layer = (305, 0)
    XS_SI_SLAB: Layer = (313, 0)
    XS_VIA1: Layer = (308, 0)
    XS_VIA2: Layer = (310, 0)
    XS_VIAC: Layer = (303, 0)


LAYER = LayerMapFab()

# lets create a sample PDK (for demo purposes only) using GDSfactory
# if the PDK is in a commercial tool you can also do this. Make sure you save a single pdk.gds

sample_pdk_cells = gf.grid(
    [
        gf.components.straight,
        gf.components.bend_euler,
        gf.components.grating_coupler_elliptical,
    ]
)
sample_pdk_cells.write_gds("extra/pdk.gds")
sample_pdk_cells
Loading...
sample_pdk_cells.get_dependencies()
Loading...
# we write the sample PDK into a single GDS file
gf.clear_cache()
gf.write_cells.write_cells(
    gdspath="extra/pdk.gds", dirpath="extra/gds", recursively=True
)
Loading...
print(gf.write_cells.get_import_gds_script("extra/gds"))
2023-12-09 17:32:10.972 | INFO     | gdsfactory.write_cells:get_import_gds_script:92 - Writing 4 cells from PosixPath('/home/runner/work/gdsfactory/gdsfactory/docs/notebooks/extra/gds')

from pathlib import PosixPath
from functools import partial
import gdsfactory as gf

add_ports_optical = partial(
    gf.add_ports.add_ports_from_markers_inside, pin_layer=(1, 0), port_layer=(2, 0)
)
add_ports_electrical = partial(
    gf.add_ports.add_ports_from_markers_inside, pin_layer=(41, 0), port_layer=(1, 0)
)
add_ports = gf.compose(add_ports_optical, add_ports_electrical)


gdsdir = '/home/runner/work/gdsfactory/gdsfactory/docs/notebooks/extra/gds'

import_gds = partial(gf.import_gds, gdsdir=gdsdir, decorator=add_ports)



@gf.cell
def bend_euler3()->gf.Component:
    '''Returns bend_euler3 fixed cell.'''
    return import_gds('bend_euler$3.gds')




@gf.cell
def grating_coupler_elliptical()->gf.Component:
    '''Returns grating_coupler_elliptical fixed cell.'''
    return import_gds('grating_coupler_elliptical.gds')




@gf.cell
def grid_d9610e5f()->gf.Component:
    '''Returns grid_d9610e5f fixed cell.'''
    return import_gds('grid_d9610e5f.gds')




@gf.cell
def straight()->gf.Component:
    '''Returns straight fixed cell.'''
    return import_gds('straight.gds')


You can also include the code to plot each fix cell in the docstring.

print(gf.write_cells.get_import_gds_script("extra/gds", module="samplepdk.components"))
2023-12-09 17:32:10.978 | INFO     | gdsfactory.write_cells:get_import_gds_script:92 - Writing 4 cells from PosixPath('/home/runner/work/gdsfactory/gdsfactory/docs/notebooks/extra/gds')

from pathlib import PosixPath
from functools import partial
import gdsfactory as gf

add_ports_optical = partial(
    gf.add_ports.add_ports_from_markers_inside, pin_layer=(1, 0), port_layer=(2, 0)
)
add_ports_electrical = partial(
    gf.add_ports.add_ports_from_markers_inside, pin_layer=(41, 0), port_layer=(1, 0)
)
add_ports = gf.compose(add_ports_optical, add_ports_electrical)


gdsdir = '/home/runner/work/gdsfactory/gdsfactory/docs/notebooks/extra/gds'

import_gds = partial(gf.import_gds, gdsdir=gdsdir, decorator=add_ports)



@gf.cell
def bend_euler3()->gf.Component:
    '''Returns bend_euler3 fixed cell.

    .. plot::
      :include-source:

      import samplepdk

      c = samplepdk.components.bend_euler3()
      c.plot()
    '''
    return import_gds('bend_euler$3.gds')




@gf.cell
def grating_coupler_elliptical()->gf.Component:
    '''Returns grating_coupler_elliptical fixed cell.

    .. plot::
      :include-source:

      import samplepdk

      c = samplepdk.components.grating_coupler_elliptical()
      c.plot()
    '''
    return import_gds('grating_coupler_elliptical.gds')




@gf.cell
def grid_d9610e5f()->gf.Component:
    '''Returns grid_d9610e5f fixed cell.

    .. plot::
      :include-source:

      import samplepdk

      c = samplepdk.components.grid_d9610e5f()
      c.plot()
    '''
    return import_gds('grid_d9610e5f.gds')




@gf.cell
def straight()->gf.Component:
    '''Returns straight fixed cell.

    .. plot::
      :include-source:

      import samplepdk

      c = samplepdk.components.straight()
      c.plot()
    '''
    return import_gds('straight.gds')


Import PDK from other python packages

You can Write the cells to GDS and use the

Ideally you also start transitioning your legacy code Pcells into gdsfactory syntax. It’s a great way to learn the gdsfactory way!

Here is some advice:

  • Ask your foundry for the gdsfactory PDK.
  • Leverage the generic pdk cells available in gdsfactory.
  • Write tests for your cells.
  • Break the cells into small reusable functions.
  • use GIT to track changes.
  • review your code with your colleagues and other gdsfactory developers to get feedback. This is key to get better at coding gdsfactory.
  • get rid of any warnings you see.

Import PDK from YAML uPDK

gdsfactory supports read and write to uPDK YAML definition

Lets write a PDK into uPDK YAML definition and then convert it back to a gdsfactory script.

the uPDK extracts the code from the docstrings.


def evanescent_coupler_sample() -> None:
    """Evanescent coupler example.

    Args:
      coupler_length: length of coupling (min: 0.0, max: 200.0, um).
    """
    pass
from gdsfactory.samples.pdk.fab_c import pdk

yaml_pdk_decription = pdk.to_updk()
print(yaml_pdk_decription)
Fetching long content....
from gdsfactory.read.from_updk import from_updk

gdsfactory_script = from_updk(yaml_pdk_decription)
print(gdsfactory_script)


import sys
import gdsfactory as gf
from gdsfactory.get_factories import get_cells
from gdsfactory.add_pins import add_pins_inside2um

layer_bbox = (68, 0)
layer_bbmetal = None
layer_pin_label = None
layer_pin = None
xs_nc = gf.CrossSection(width=1.0)
xs_no = gf.CrossSection(width=0.9)

cross_sections = dict(xs_nc=xs_nc,xs_no=xs_no)

@gf.cell
def mmi1x2_nc(width:float=1.0, width_taper:float=1.0, length_taper:float=10.0, length_mmi:float=5.5, width_mmi:int=3, gap_mmi:float=0.25, with_bbox:bool=True)->gf.Component:
    """1x2 MultiMode Interferometer (MMI).

    Args:
      width: input and output straight width. Defaults to cross_section width. (min: 0, max: 0, None).
      width_taper: interface between input straights and mmi region. (min: 0, max: 0, None).
      length_taper: into the mmi region. (min: 0, max: 0, None).
      length_mmi: in x direction. (min: 0, max: 0, None).
      width_mmi: in y direction. (min: 0, max: 0, None).
      gap_mmi: gap between tapered wg. (min: 0, max: 0, None).
      with_bbox: add rectangular box in cross_section (min: 0, max: 0, None).
    """
    c = gf.Component()
    p = c.add_polygon([[-10.0, -7.5], [15.5, -7.5], [15.5, 7.5], [-10.0, 7.5]], layer=layer_bbox)
    xc, yc = p.center
    ysize = p.ysize
    name = f'mmi1x2_nc:width={width},width_taper={width_taper},length_taper={length_taper},length_mmi={length_mmi},width_mmi={width_mmi},gap_mmi={gap_mmi},with_bbox={with_bbox}'
    c.add_port(name='o1', width=1.0, cross_section='strip', center=(-10.0, 0.0), orientation=180.0, port_type='optical')
    c.add_port(name='o2', width=1.0, cross_section='strip', center=(15.5, 0.625), orientation=0.0, port_type='optical')
    c.add_port(name='o3', width=1.0, cross_section='strip', center=(15.5, -0.625), orientation=0.0, port_type='optical')

    c.name = name
    if layer_pin:
        add_pins_inside2um(c, layer=layer_pin)
    return c

@gf.cell
def mmi1x2_no(width:float=0.9, width_taper:float=1.0, length_taper:float=10.0, length_mmi:float=5.5, width_mmi:float=2.5, gap_mmi:float=0.25, with_bbox:bool=True)->gf.Component:
    """1x2 MultiMode Interferometer (MMI).

    Args:
      width: input and output straight width. Defaults to cross_section width. (min: 0, max: 0, None).
      width_taper: interface between input straights and mmi region. (min: 0, max: 0, None).
      length_taper: into the mmi region. (min: 0, max: 0, None).
      length_mmi: in x direction. (min: 0, max: 0, None).
      width_mmi: in y direction. (min: 0, max: 0, None).
      gap_mmi: gap between tapered wg. (min: 0, max: 0, None).
      with_bbox: add rectangular box in cross_section (min: 0, max: 0, None).
    """
    c = gf.Component()
    p = c.add_polygon([[-10.0, -7.25], [15.5, -7.25], [15.5, 7.25], [-10.0, 7.25]], layer=layer_bbox)
    xc, yc = p.center
    ysize = p.ysize
    name = f'mmi1x2_no:width={width},width_taper={width_taper},length_taper={length_taper},length_mmi={length_mmi},width_mmi={width_mmi},gap_mmi={gap_mmi},with_bbox={with_bbox}'
    c.add_port(name='o1', width=0.9, cross_section='strip', center=(-10.0, 0.0), orientation=180.0, port_type='optical')
    c.add_port(name='o2', width=0.9, cross_section='strip', center=(15.5, 0.625), orientation=0.0, port_type='optical')
    c.add_port(name='o3', width=0.9, cross_section='strip', center=(15.5, -0.625), orientation=0.0, port_type='optical')

    c.name = name
    if layer_pin:
        add_pins_inside2um(c, layer=layer_pin)
    return c

@gf.cell
def bend_euler_nc(angle:float=90.0, p:float=0.5, with_arc_floorplan:bool=True, direction:str=ccw, with_bbox:bool=True)->gf.Component:
    """Euler bend with changing bend radius.

    Args:
      angle: total angle of the curve. (min: 0, max: 0, None).
      p: Proportion of the curve that is an Euler curve. (min: 0, max: 0, None).
      with_arc_floorplan: None (min: 0, max: 0, None).
      direction: cw (min: 0, max: 0, None).
      with_bbox: add bbox_layers and bbox_offsets to avoid DRC sharp edges. (min: 0, max: 0, None).
    """
    c = gf.Component()
    p = c.add_polygon([[-6.123233995736766e-17, -3.5], [13.5, -3.5], [13.5, 10.0], [-6.123233995736766e-17, 10.0]], layer=layer_bbox)
    xc, yc = p.center
    ysize = p.ysize
    name = f'bend_euler_nc:angle={angle},p={p},with_arc_floorplan={with_arc_floorplan},direction={direction},with_bbox={with_bbox}'
    c.add_port(name='o1', width=1.0, cross_section='strip', center=(0.0, 0.0), orientation=180.0, port_type='optical')
    c.add_port(name='o2', width=1.0, cross_section='strip', center=(10.0, 10.0), orientation=90.0, port_type='optical')

    c.name = name
    if layer_pin:
        add_pins_inside2um(c, layer=layer_pin)
    return c

@gf.cell
def straight_nc(length:float=10.0, npoints:int=2, with_bbox:bool=True)->gf.Component:
    """Returns a Straight waveguide.

    Args:
      length: straight length (min: 0, max: 0, None).
      npoints: number of points. (min: 0, max: 0, None).
      with_bbox: box in bbox_layers and bbox_offsets to avoid DRC sharp edges. (min: 0, max: 0, None).
    """
    c = gf.Component()
    p = c.add_polygon([[-6.123233995736766e-17, -3.5], [10.0, -3.5], [10.0, 3.5], [-6.123233995736766e-17, 3.5]], layer=layer_bbox)
    xc, yc = p.center
    ysize = p.ysize
    name = f'straight_nc:length={length},npoints={npoints},with_bbox={with_bbox}'
    c.add_port(name='o1', width=1.0, cross_section='strip', center=(0.0, 0.0), orientation=180.0, port_type='optical')
    c.add_port(name='o2', width=1.0, cross_section='strip', center=(10.0, 0.0), orientation=0.0, port_type='optical')

    c.name = name
    if layer_pin:
        add_pins_inside2um(c, layer=layer_pin)
    return c

@gf.cell
def mzi_nc(delta_length:float=10.0, length_y:float=2.0, length_x:float=0.1, with_splitter:bool=True, port_e1_splitter:str=o2, port_e0_splitter:str=o3, port_e1_combiner:str=o2, port_e0_combiner:str=o3, nbends:int=2, mirror_bot:bool=False, add_optical_ports_arms:bool=False)->gf.Component:
    """Mzi.

    Args:
      delta_length: bottom arm vertical extra length. (min: 0, max: 0, None).
      length_y: vertical length for both and top arms. (min: 0, max: 0, None).
      length_x: horizontal length. None uses to the straight_x_bot/top defaults. (min: 0, max: 0, None).
      with_splitter: if False removes splitter. (min: 0, max: 0, None).
      port_e1_splitter: east top splitter port. (min: 0, max: 0, None).
      port_e0_splitter: east bot splitter port. (min: 0, max: 0, None).
      port_e1_combiner: east top combiner port. (min: 0, max: 0, None).
      port_e0_combiner: east bot combiner port. (min: 0, max: 0, None).
      nbends: from straight top/bot to combiner (min: 0, max: 0, None).
      mirror_bot: if true, mirrors the bottom arm. (min: 0, max: 0, None).
      add_optical_ports_arms: add all other optical ports in the arms (min: 0, max: 0, None).
    """
    c = gf.Component()
    p = c.add_polygon([[-10.0, -31.125], [81.12, -31.125], [81.12, 26.125], [-10.0, 26.125]], layer=layer_bbox)
    xc, yc = p.center
    ysize = p.ysize
    name = f'mzi_nc:delta_length={delta_length},length_y={length_y},length_x={length_x},with_splitter={with_splitter},port_e1_splitter={port_e1_splitter},port_e0_splitter={port_e0_splitter},port_e1_combiner={port_e1_combiner},port_e0_combiner={port_e0_combiner},nbends={nbends},mirror_bot={mirror_bot},add_optical_ports_arms={add_optical_ports_arms}'
    c.add_port(name='o1', width=1.0, cross_section='strip', center=(-10.0, 0.0), orientation=180.0, port_type='optical')
    c.add_port(name='o2', width=1.0, cross_section='strip', center=(81.12, 0.0), orientation=0.0, port_type='optical')

    c.name = name
    if layer_pin:
        add_pins_inside2um(c, layer=layer_pin)
    return c

@gf.cell
def mzi_no(delta_length:float=10.0, length_y:float=2.0, length_x:float=0.1, with_splitter:bool=True, port_e1_splitter:str=o2, port_e0_splitter:str=o3, port_e1_combiner:str=o2, port_e0_combiner:str=o3, nbends:int=2, mirror_bot:bool=False, add_optical_ports_arms:bool=False)->gf.Component:
    """Mzi.

    Args:
      delta_length: bottom arm vertical extra length. (min: 0, max: 0, None).
      length_y: vertical length for both and top arms. (min: 0, max: 0, None).
      length_x: horizontal length. None uses to the straight_x_bot/top defaults. (min: 0, max: 0, None).
      with_splitter: if False removes splitter. (min: 0, max: 0, None).
      port_e1_splitter: east top splitter port. (min: 0, max: 0, None).
      port_e0_splitter: east bot splitter port. (min: 0, max: 0, None).
      port_e1_combiner: east top combiner port. (min: 0, max: 0, None).
      port_e0_combiner: east bot combiner port. (min: 0, max: 0, None).
      nbends: from straight top/bot to combiner (min: 0, max: 0, None).
      mirror_bot: if true, mirrors the bottom arm. (min: 0, max: 0, None).
      add_optical_ports_arms: add all other optical ports in the arms (min: 0, max: 0, None).
    """
    c = gf.Component()
    p = c.add_polygon([[-10.0, -31.075000000000003], [81.12, -31.075000000000003], [81.12, 26.075000000000003], [-10.0, 26.075000000000003]], layer=layer_bbox)
    xc, yc = p.center
    ysize = p.ysize
    name = f'mzi_no:delta_length={delta_length},length_y={length_y},length_x={length_x},with_splitter={with_splitter},port_e1_splitter={port_e1_splitter},port_e0_splitter={port_e0_splitter},port_e1_combiner={port_e1_combiner},port_e0_combiner={port_e0_combiner},nbends={nbends},mirror_bot={mirror_bot},add_optical_ports_arms={add_optical_ports_arms}'
    c.add_port(name='o1', width=0.9, cross_section='strip', center=(-10.0, 0.0), orientation=180.0, port_type='optical')
    c.add_port(name='o2', width=0.9, cross_section='strip', center=(81.12, 0.0), orientation=0.0, port_type='optical')

    c.name = name
    if layer_pin:
        add_pins_inside2um(c, layer=layer_pin)
    return c

@gf.cell
def gc_nc(polarization:str=te, taper_length:float=16.6, taper_angle:float=40.0, wavelength:float=1.554, fiber_angle:float=15.0, grating_line_width:float=0.6, neff:float=2.638, nclad:float=1.443, n_periods:int=30, big_last_tooth:bool=False, slab_xmin:float=-1.0, slab_offset:float=2.0, spiked:bool=True)->gf.Component:
    """Grating coupler with parametrization based on Lumerical FDTD simulation.

    Args:
      polarization: te or tm. (min: 0, max: 0, None).
      taper_length: taper length from input. (min: 0, max: 0, None).
      taper_angle: grating flare angle. (min: 0, max: 0, None).
      wavelength: grating transmission central wavelength (min: 0, max: 0, None).
      fiber_angle: fibre angle in degrees determines ellipticity. (min: 0, max: 0, None).
      grating_line_width: in um. (min: 0, max: 0, None).
      neff: tooth effective index. (min: 0, max: 0, None).
      nclad: cladding effective index. (min: 0, max: 0, None).
      n_periods: number of periods. (min: 0, max: 0, None).
      big_last_tooth: adds a big_last_tooth. (min: 0, max: 0, None).
      slab_xmin: where 0 is at the start of the taper. (min: 0, max: 0, None).
      slab_offset: in um. (min: 0, max: 0, None).
      spiked: grating teeth have sharp spikes to avoid non-manhattan drc errors. (min: 0, max: 0, None).
    """
    c = gf.Component()
    p = c.add_polygon([[-6.123233995736766e-17, -11.128], [37.18, -11.128], [37.18, 11.128], [-6.123233995736766e-17, 11.128]], layer=layer_bbox)
    xc, yc = p.center
    ysize = p.ysize
    name = f'gc_nc:polarization={polarization},taper_length={taper_length},taper_angle={taper_angle},wavelength={wavelength},fiber_angle={fiber_angle},grating_line_width={grating_line_width},neff={neff},nclad={nclad},n_periods={n_periods},big_last_tooth={big_last_tooth},slab_xmin={slab_xmin},slab_offset={slab_offset},spiked={spiked}'
    c.add_port(name='o1', width=1.0, cross_section=None, center=(0.0, 0.0), orientation=180.0, port_type='optical')
    c.add_port(name='opt_te_1554_15', width=10, cross_section=None, center=(16.6, 0.0), orientation=0.0, port_type='optical')

    c.name = name
    if layer_pin:
        add_pins_inside2um(c, layer=layer_pin)
    return c



if __name__ == "__main__":
    c = gc_nc()
    c.show(show_ports=True)

Build your own PDK

You can create a PDK as a python library using a cookiecutter template. For example, you can use this one.

pip install cookiecutter
cookiecutter https://github.com/joamatab/cookiecutter-pypackage-minimal

Or you can fork the ubcpdk and create new PCell functions that use the correct layers for your foundry. For example.


from pydantic import BaseModel


class LayerMap(BaseModel):
    WGCORE = (3, 0)
    LABEL = (100, 0)
    DEVREC: Layer = (68, 0)
    LABEL: Layer = (10, 0)
    PORT: Layer = (1, 10)  # PinRec
    PORTE: Layer = (1, 11)  # PinRecM
    FLOORPLAN: Layer = (99, 0)

    TE: Layer = (203, 0)
    TM: Layer = (204, 0)
    TEXT: Layer = (66, 0)
    LABEL_INSTANCE: Layer = (66, 0)


LAYER = LayerMap()