Netlist driven flow (circuits)#

You have two options for working with gdsfactory:

  1. layout driven flow: you code your layout using python functions, and then extract the YAML netlist to simulate the circuit. This is the flow that you have been doing so far.

  2. netlist driven flow: you define your circuit (instances, placements and routes) in YAML. From the netlist you can simulate the circuit or generate the layout.

Using the netlist driven flow you can define components, circuits and masks.

YAML is a more human readable version of JSON

to define a Component from YAML you need to define:

  • instances: with each instance setting

  • placements: with X and Y

And optional:

  • routes: between instances

  • connections: to connect components ports

  • ports: define input and output circuit ports

When running this tutorial make sure you UNCOMMENT this line %matplotlib widget so you can live update your changes in the YAML file

# %matplotlib widget -> %matplotlib widget

[1]:
# %matplotlib widget
[2]:
import ipywidgets
from IPython.display import clear_output
import matplotlib.pyplot as plt
import gdsfactory as gf

x = ipywidgets.Textarea(rows=20, columns=480)

x.value = """
name: sample_different_factory

instances:
    bl:
      component: pad
    tl:
      component: pad
    br:
      component: pad
    tr:
      component: pad

placements:
    tl:
        x: 200
        y: 500

    br:
        x: 400
        y: 400

    tr:
        x: 400
        y: 600


routes:
    electrical:
        settings:
            separation: 20
            layer: [31, 0]
            width: 10
        links:
            tl,e3: tr,e1
            bl,e3: br,e1
    optical:
        settings:
            radius: 100
        links:
            bl,e4: br,e3
"""

out = ipywidgets.Output()
display(x, out)


def f(change, out=out):
    try:
        c = gf.read.from_yaml(change["new"])
        # clear_output()
        fig = c.plot()
        c.show(show_ports=True)
        out.clear_output()
    except Exception as e:
        out.clear_output()
        with out:
            display(e)


x.observe(f, "value")
f({"new": x.value})
2022-06-28 17:01:29.496 | INFO     | gdsfactory.config:<module>:52 - Load '/home/runner/work/gdsfactory/gdsfactory/gdsfactory' 5.11.4
../_images/notebooks_06_yaml_component_2_3.png

Lets start by defining the instances and placements section in YAML

Lets place an mmi_long where you can place the W0 port at x=20, y=10

[3]:
x.value = """
name: mmis
instances:
    mmi_long:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 10
    mmi_short:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 5

placements:
    mmi_long:
        port: o1
        x: 20
        y: 10
        mirror: False
"""
display(x, out)
../_images/notebooks_06_yaml_component_4_0.png
[4]:
x.value = """
name: mmi_mirror
instances:
    mmi_long:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 10
    mmi_short:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 5

placements:
    mmi_long:
        port: o1
        x: 20
        y: 10
        mirror: False
"""
display(x, out)
../_images/notebooks_06_yaml_component_5_0.png

ports#

You can expose any ports of any instance to the new Component with a ports section in YAML

Lets expose all the ports from mmi_long into the new component.

Ports are exposed as new_port_name: instance_name, port_name

you can see the ports in red and subports in blue

[5]:
x.value = """
instances:
    mmi_long:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 5
placements:
    mmi_long:
        port: o1
        x: 20
        y: 10
        mirror: True

ports:
    o3: mmi_long,o3
    o2: mmi_long,o2
    o1: mmi_long,o1
"""

display(x, out)
../_images/notebooks_06_yaml_component_7_0.png
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/component.py:1054: UserWarning: Component 'Unnamed_ff80cc58' contains 1 Unnamed cells
  warnings.warn(

You can also define a mirror placement using a port

Try mirroring with other ports o2, o3 or with a number as well as with a rotation 90, 180, 270

[6]:
x.value = """
instances:
    mmi_long:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 5
placements:
    mmi_long:
        x: 0
        y: 0
        mirror: o1
        rotation: 0
"""

display(x, out)
../_images/notebooks_06_yaml_component_9_0.png
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/component.py:1054: UserWarning: Component 'Unnamed_49396694' contains 1 Unnamed cells
  warnings.warn(

connections#

You can connect any two instances by defining a connections section in the YAML file.

it follows the syntax.

instance_source,port : instance_destination,port

[7]:
x.value = """
instances:
    b:
      component: bend_circular
    mmi_long:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 10
    mmi_short:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 5
placements:
    mmi_short:
        port: o1
        x: 10
        y: 20
connections:
    b,o1 : mmi_short,o2
    mmi_long,o1: b, o2

ports:
    o1: mmi_short,o1
    o2: mmi_long,o2
    o3: mmi_long,o3
"""

display(x, out)
../_images/notebooks_06_yaml_component_11_0.png
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/component.py:1054: UserWarning: Component 'Unnamed_044ca791' contains 1 Unnamed cells
  warnings.warn(

Relative port placing

You can also place a component with respect to another instance port

You can also define an x and y offset with dx and dy

[8]:
x.value = """
instances:
    mmi_long:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 10
    mmi_short:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 5

placements:
    mmi_short:
        port: o1
        x: 0
        y: 0
    mmi_long:
        port: o1
        x: mmi_short,o2
        y: mmi_short,o2
        dx : 10
        dy: -10
"""


display(x, out)
../_images/notebooks_06_yaml_component_13_0.png
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/component.py:1054: UserWarning: Component 'Unnamed_2c2e495d' contains 1 Unnamed cells
  warnings.warn(

routes#

You can define routes between two instances by defining a routes section in YAML

it follows the syntax

routes:
    route_name:
        links:
            instance_source,port: instance_destination,port
        settings:  # for the route (optional)
            waveguide: strip
            width: 1.2
[9]:
x.value = """
instances:
    mmi_long:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 10
    mmi_short:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 5
placements:
    mmi_long:
        x: 100
        y: 100
routes:
    optical:
        links:
            mmi_short,o2: mmi_long,o1
        settings:
            cross_section:
                cross_section: strip
                settings:
                    layer: [2, 0]
"""

display(x, out)
../_images/notebooks_06_yaml_component_15_0.png
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/component.py:1054: UserWarning: Component 'Unnamed_728519ea' contains 1 Unnamed cells
  warnings.warn(

You can rotate and instance specifying the angle in degrees

You can also access the routes in the newly created component

instances, placements, connections, ports, routes#

Lets combine all you learned so far.

You can define the netlist connections of a component by a netlist in YAML format

Note that you define the connections as instance_source.port -> instance_destination.port so the order is important and therefore you can only change the position of the instance_destination

You can define several routes that will be connected using gf.routing.get_bundle

[10]:
x.value = """
name:
    connections_2x2_problem

instances:
    mmi_bottom:
      component: mmi2x2
    mmi_top:
      component: mmi2x2

placements:
    mmi_top:
        x: 100
        y: 100

routes:
    optical:
        links:
            mmi_bottom,o4: mmi_top,o1
            mmi_bottom,o3: mmi_top,o2

"""

display(x, out)
../_images/notebooks_06_yaml_component_20_0.png

You can also add custom component_factories to gf.read.from_yaml

[11]:
@gf.cell
def pad_new(size=(100, 100), layer=gf.LAYER.WG):
    c = gf.Component()
    compass = c << gf.components.compass(size=size, layer=layer)
    c.ports = compass.ports
    return c


gf.get_active_pdk().register_cells(pad_new=pad_new)
c = pad_new(cache=False)
f = c.plot()
../_images/notebooks_06_yaml_component_22_0.png
[12]:
x.value = """
name:
    connections_2x2_problem

instances:
    bot:
      component: pad_new
    top:
      component: pad_new

placements:
    top:
        x: 0
        y: 200
"""

display(x, out)
../_images/notebooks_06_yaml_component_23_0.png
[13]:
x.value = """
name: custom_routes

instances:
    t:
      component: pad_array
      settings:
          orientation: 270
          columns: 3
    b:
      component: pad_array
      settings:
          orientation: 90
          columns: 3

placements:
    t:
        x: 200
        y: 400
routes:
    electrical:
        settings:
            layer: [31, 0]
            width: 10.
            end_straight_length: 150
        links:
            t,e11: b,e11
            t,e13: b,e13
"""

display(x, out)
../_images/notebooks_06_yaml_component_24_0.png

Also, you can define route aliases, that have different settings and specify the route factory as a parameter as well as the settings for that particular route alias.

[14]:
x.value = """
name: sample_settings

instances:
    bl:
      component: pad
    tl:
      component: pad
    br:
      component: pad
    tr:
      component: pad

placements:
    tl:
        x: 0
        y: 200

    br:
        x: 400
        y: 400

    tr:
        x: 400
        y: 600

routes:
    optical_r100:
        settings:
            radius: 100
            layer: [31, 0]
            width: 50
        links:
            tl,e2: tr,e2
    optical_r200:
        settings:
            radius: 200
            width: 10
            layer: [31, 0]
        links:
            bl,e3: br,e3
"""

display(x, out)
../_images/notebooks_06_yaml_component_26_0.png
[15]:
x.value = """
instances:
    t:
      component: pad_array
      settings:
          orientation: 270
          columns: 3
    b:
      component: pad_array
      settings:
          orientation: 90
          columns: 3

placements:
    t:
        x: 200
        y: 500
routes:
    optical:
        settings:
            radius: 50
            width: 40
            layer: [31,0]
            end_straight_length: 150
            separation: 50
        links:
            t,e11: b,e11
            t,e12: b,e12
            t,e13: b,e13
"""

display(x, out)
../_images/notebooks_06_yaml_component_27_0.png
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/component.py:1054: UserWarning: Component 'Unnamed_b65bdc03' contains 1 Unnamed cells
  warnings.warn(
[16]:
x.value = """

instances:
    t:
      component: pad_array
      settings:
          orientation: 270
          columns: 3
    b:
      component: pad_array
      settings:
          orientation: 90
          columns: 3

placements:
    t:
        x: 100
        y: 1000
routes:
    route1:
        routing_strategy: get_bundle_path_length_match
        settings:
            extra_length: 500
            width: 2
            layer: [31,0]
            end_straight_length: 500
        links:
            t,e11: b,e11
            t,e12: b,e12
"""

display(x, out)
../_images/notebooks_06_yaml_component_28_0.png
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/component.py:1054: UserWarning: Component 'Unnamed_e5a6bfdc' contains 1 Unnamed cells
  warnings.warn(
[17]:
x.value = """
instances:
    t:
      component: pad_array
      settings:
          orientation: 270
          columns: 3
    b:
      component: pad_array
      settings:
          orientation: 90
          columns: 3

placements:
    t:
        x: -250
        y: 1000
routes:
    route1:
        routing_strategy: get_bundle_from_waypoints
        settings:
            waypoints:
                - [0, 300]
                - [400, 300]
                - [400, 400]
                - [-250, 400]
            auto_widen: False
        links:
            b,e11: t,e11
            b,e12: t,e12

"""

display(x, out)
../_images/notebooks_06_yaml_component_29_0.png
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/component.py:1054: UserWarning: Component 'Unnamed_75b44ce9' contains 1 Unnamed cells
  warnings.warn(

Note that you define the connections as instance_source.port -> instance_destination.port so the order is important and therefore you can only change the position of the instance_destination

Custom factories#

You can leverage netlist defined components to define more complex circuits

[18]:
mmi1x2_faba = gf.partial(gf.components.mmi1x2, length_mmi=30)
mmi2x2_faba = gf.partial(gf.components.mmi2x2, length_mmi=30)
gf.get_active_pdk().register_cells(mmi1x2_faba=mmi1x2_faba, mmi2x2_faba=mmi2x2_faba)

x.value = """
name: sample_custom_cells
instances:
    mmit:
      component: mmi2x2_faba
    mmib:
      component: mmi1x2_faba
      settings:
        width_mmi: 4.5
placements:
    mmit:
        x: 100
        y: 100
routes:
    route1:
        links:
            mmib,o2: mmit,o2

ports:
    o1: mmib,o1
    o2: mmit,o2
    o3: mmit,o3
    o4: mmit,o4
"""

display(x, out)
../_images/notebooks_06_yaml_component_32_0.png
[19]:
c = gf.components.mzi()
c
../_images/notebooks_06_yaml_component_33_0.png
[19]:
mzi: uid 166, ports ['o1', 'o2'], aliases [], 0 polygons, 20 references
[20]:
c.plot_netlist()
[20]:
<networkx.classes.graph.Graph at 0x7ff4b3496100>
../_images/notebooks_06_yaml_component_34_1.png
[21]:
n = c.get_netlist()
[22]:
print(c.get_netlist_dict().keys())
dict_keys(['connections', 'instances', 'placements', 'ports', 'name'])

variables#

You can define a global variables settings in your YAML file, and use the variable in the other YAML settings by using ${settings.length_mmi}

[23]:
x.value = """
settings:
    length_mmi: 10

instances:
    mmi_long:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: ${settings.length_mmi}
    mmi_short:
      component: mmi1x2
      settings:
        width_mmi: 4.5
        length_mmi: 5
"""

display(x, out)
../_images/notebooks_06_yaml_component_38_0.png
/home/runner/work/gdsfactory/gdsfactory/gdsfactory/component.py:1054: UserWarning: Component 'Unnamed_d74be02d' contains 1 Unnamed cells
  warnings.warn(

get_netlist (Component -> YAML)#

Any component exports its netlist get_netlist and returns an OmegaConf dict that can be easily converted into JSON and YAML.

While component_from_yaml converts YAML -> Component

get_netlist converts Component -> YAML

[24]:
import io
from omegaconf import OmegaConf
import gdsfactory as gf
[25]:
c = gf.components.ring_single()
c
../_images/notebooks_06_yaml_component_41_0.png
[25]:
ring_single: uid 182, ports ['o2', 'o1'], aliases [], 0 polygons, 6 references
[26]:
c.plot_netlist()
[26]:
<networkx.classes.graph.Graph at 0x7ff49cf99760>
../_images/notebooks_06_yaml_component_42_1.png
[27]:
netlist = c.get_netlist()
[28]:
n = netlist
[29]:
c.write_netlist("ring.yml")
[30]:
n = OmegaConf.load("ring.yml")
[31]:
i = list(n["instances"].keys())
i
[31]:
['bend_euler_radius10p0_5p124_16p425',
 'bend_euler_radius10p0_m9p124_16p425',
 'coupler_ring_a551ad66_m2p0_5p226',
 'straight_length0p6_10p0_11p0',
 'straight_length0p6_m14p0_11p0',
 'straight_length4p0_m2p0_21p3']
[32]:
instance_name0 = i[0]
[33]:
n["instances"][instance_name0]["settings"]
[33]:
{'radius': 10.0}
import gdsfactory as gf
from omegaconf import OmegaConf
import pathlib

c1 = gf.read.from_yaml('ring.yml')
c1
n = c1.get_netlist(full_settings=True)
connections = n['connections']
len(connections)

Plot netlist#

You can plot the netlist of components.

Every gdsfactory component can either be defined by its netlist or using layout friendly functions such as component sequence to define it and then get_netlist() method.

Connections are determined by extracting all the ports of a component, and assuming that ports with the same (x, y) are connected.

When you do get_netlist() for a component it will only show connections for the instances that belong to that component (it trims the netlist). So despite havingĀ  a lot of connections, it will show only the meaningful connections for that component. For example, a ring has a ring_coupler. but if you want to digg deeper, the connections that made that ring coupler are still available.

[34]:
import gdsfactory as gf
[35]:
c = gf.components.mzi()
c
../_images/notebooks_06_yaml_component_54_0.png
[35]:
mzi: uid 166, ports ['o1', 'o2'], aliases [], 0 polygons, 20 references
[36]:
c = gf.components.mzi()
n = c.get_netlist()
print(c.get_netlist_dict().keys())
dict_keys(['connections', 'instances', 'placements', 'ports', 'name'])
[37]:
c.plot_netlist()
[37]:
<networkx.classes.graph.Graph at 0x7ff4e5ad10a0>
../_images/notebooks_06_yaml_component_56_1.png
[38]:
n.keys()
[38]:
dict_keys(['connections', 'instances', 'placements', 'ports', 'name'])
[39]:
import gdsfactory as gf

yaml = """
name: mmi_with_bend
instances:

    mmi1x2_12_0:
        component: mmi1x2

    bend_circular_R10p00_32_4:
      component: bend_circular

    straight_L1p00_35_11:
        component: straight
        settings:
            length: 10
            layer: [2, 0]

connections:
    bend_circular_R10p00_32_4,o1: mmi1x2_12_0,o2
    straight_L1p00_35_11,o1: bend_circular_R10p00_32_4,o2
"""

c = gf.read.from_yaml(yaml)
c.name = "mmi_with_bend_circular"
print(c.name)
c
mmi_with_bend_circular
../_images/notebooks_06_yaml_component_58_1.png
[39]:
mmi_with_bend_circular: uid 193, ports [], aliases [], 0 polygons, 3 references
[40]:
n = c.get_netlist()
[41]:
print(c.get_netlist_yaml())
connections:
  bend_circular_R10p00_32_4,o1: mmi1x2_12_0,o2
  bend_circular_R10p00_32_4,o2: straight_L1p00_35_11,o1
instances:
  bend_circular_R10p00_32_4:
    component: bend_circular
    info:
      length: 15.708
      dy: 10.0
      radius: 10.0
    settings: {}
  mmi1x2_12_0:
    component: mmi1x2
    settings: {}
  straight_L1p00_35_11:
    component: straight
    info:
      length: 10.0
      width: 0.5
    settings:
      layer:
      - 2
      - 0
      length: 10
placements:
  bend_circular_R10p00_32_4:
    x: 15.5
    'y': 0.625
    rotation: 0
    mirror: 0
  mmi1x2_12_0:
    x: 0.0
    'y': 0.0
    rotation: 0
    mirror: 0
  straight_L1p00_35_11:
    x: 25.5
    'y': 10.625
    rotation: 90
    mirror: 0
ports: {}
name: mmi_with_bend_circular

[42]:
n["connections"]
[42]:
{'bend_circular_R10p00_32_4,o1': 'mmi1x2_12_0,o2', 'bend_circular_R10p00_32_4,o2': 'straight_L1p00_35_11,o1'}
[43]:
c.plot_netlist()
[43]:
<networkx.classes.graph.Graph at 0x7ff4a086fcd0>
../_images/notebooks_06_yaml_component_62_1.png
[44]:
c = gf.components.mzi()
c
../_images/notebooks_06_yaml_component_63_0.png
[44]:
mzi: uid 166, ports ['o1', 'o2'], aliases [], 0 polygons, 20 references
[45]:
c.plot_netlist()
[45]:
<networkx.classes.graph.Graph at 0x7ff4a0623f40>
../_images/notebooks_06_yaml_component_64_1.png
[46]:
c = gf.components.ring_single()
c
../_images/notebooks_06_yaml_component_65_0.png
[46]:
ring_single: uid 182, ports ['o2', 'o1'], aliases [], 0 polygons, 6 references
[47]:
c.plot_netlist()
[47]:
<networkx.classes.graph.Graph at 0x7ff4a07997c0>
../_images/notebooks_06_yaml_component_66_1.png
[48]:
c = gf.components.ring_double()
c
../_images/notebooks_06_yaml_component_67_0.png
[48]:
ring_double: uid 202, ports ['o1', 'o2', 'o3', 'o4'], aliases [], 0 polygons, 4 references
[49]:
c.plot_netlist()
[49]:
<networkx.classes.graph.Graph at 0x7ff4b345f250>
../_images/notebooks_06_yaml_component_68_1.png
[50]:
import gdsfactory as gf

c = gf.components.ring_single()
c
../_images/notebooks_06_yaml_component_69_0.png
[50]:
ring_single: uid 182, ports ['o2', 'o1'], aliases [], 0 polygons, 6 references
[51]:
c.plot_netlist()
[51]:
<networkx.classes.graph.Graph at 0x7ff4b345f220>
../_images/notebooks_06_yaml_component_70_1.png
[52]:
c = gf.components.ring_double()
c
../_images/notebooks_06_yaml_component_71_0.png
[52]:
ring_double: uid 202, ports ['o1', 'o2', 'o3', 'o4'], aliases [], 0 polygons, 4 references
[53]:
c.plot_netlist()
[53]:
<networkx.classes.graph.Graph at 0x7ff4a0c4cb80>
../_images/notebooks_06_yaml_component_72_1.png
[54]:
print(c.get_netlist_yaml())
connections:
  coupler_ring_d2e9af6d_m0p005_16p184,o2: straight_08352659_10p0_10p705,o2
  coupler_ring_d2e9af6d_m0p005_16p184,o3: straight_08352659_m10p01_10p705,o2
  coupler_ring_d2e9af6d_m0p005_5p226,o2: straight_08352659_m10p01_10p705,o1
  coupler_ring_d2e9af6d_m0p005_5p226,o3: straight_08352659_10p0_10p705,o1
instances:
  coupler_ring_d2e9af6d_m0p005_16p184:
    component: coupler_ring
    settings:
      cross_section:
        function: cross_section
        settings:
          add_pins:
            function: add_pins_siepic
            settings:
              pin_length: 0.002
          add_bbox:
            function: add_bbox_siepic
          cladding_layers:
          - DEVREC
          cladding_offsets:
          - 0
      length_x: 0.01
      radius: 10.0
  coupler_ring_d2e9af6d_m0p005_5p226:
    component: coupler_ring
    settings:
      cross_section:
        function: cross_section
        settings:
          add_pins:
            function: add_pins_siepic
            settings:
              pin_length: 0.002
          add_bbox:
            function: add_bbox_siepic
          cladding_layers:
          - DEVREC
          cladding_offsets:
          - 0
      length_x: 0.01
      radius: 10.0
  straight_08352659_10p0_10p705:
    component: straight
    info:
      length: 0.01
      width: 0.5
    settings:
      cross_section:
        function: cross_section
        settings:
          add_pins:
            function: add_pins_siepic
            settings:
              pin_length: 0.002
          add_bbox:
            function: add_bbox_siepic
          cladding_layers:
          - DEVREC
          cladding_offsets:
          - 0
      length: 0.01
  straight_08352659_m10p01_10p705:
    component: straight
    info:
      length: 0.01
      width: 0.5
    settings:
      cross_section:
        function: cross_section
        settings:
          add_pins:
            function: add_pins_siepic
            settings:
              pin_length: 0.002
          add_bbox:
            function: add_bbox_siepic
          cladding_layers:
          - DEVREC
          cladding_offsets:
          - 0
      length: 0.01
placements:
  coupler_ring_d2e9af6d_m0p005_16p184:
    x: -0.01
    'y': 21.41
    rotation: 180
    mirror: 0
  coupler_ring_d2e9af6d_m0p005_5p226:
    x: 0.0
    'y': 0.0
    rotation: 0
    mirror: 0
  straight_08352659_10p0_10p705:
    x: 10.0
    'y': 10.7
    rotation: 90
    mirror: 0
  straight_08352659_m10p01_10p705:
    x: -10.01
    'y': 10.7
    rotation: 90
    mirror: 0
ports:
  o1: coupler_ring_d2e9af6d_m0p005_5p226,o1
  o2: coupler_ring_d2e9af6d_m0p005_5p226,o4
  o3: coupler_ring_d2e9af6d_m0p005_16p184,o4
  o4: coupler_ring_d2e9af6d_m0p005_16p184,o1
name: ring_double

[55]:
c = gf.components.mzi()
c
../_images/notebooks_06_yaml_component_74_0.png
[55]:
mzi: uid 166, ports ['o1', 'o2'], aliases [], 0 polygons, 20 references
[56]:
c.plot_netlist()
[56]:
<networkx.classes.graph.Graph at 0x7ff4a0acba00>
../_images/notebooks_06_yaml_component_75_1.png
[57]:
c = gf.components.mzit()
c
../_images/notebooks_06_yaml_component_76_0.png
[57]:
mzit: uid 203, ports ['o4', 'o3', 'o2', 'o1'], aliases [], 0 polygons, 17 references
[58]:
c.plot_netlist()
[58]:
<networkx.classes.graph.Graph at 0x7ff4a0c8a1f0>
../_images/notebooks_06_yaml_component_77_1.png
[59]:
c = gf.components.mzi_lattice()
c
../_images/notebooks_06_yaml_component_78_0.png
[59]:
mzi_lattice: uid 236, ports ['o1', 'o2', 'o3', 'o4'], aliases [], 0 polygons, 1 references
[60]:
import gdsfactory as gf

coupler_lengths = [10, 20, 30]
coupler_gaps = [0.1, 0.2, 0.3]
delta_lengths = [10, 100]

c = gf.components.mzi_lattice(
    coupler_lengths=coupler_lengths,
    coupler_gaps=coupler_gaps,
    delta_lengths=delta_lengths,
)
c
../_images/notebooks_06_yaml_component_79_0.png
[60]:
mzi_lattice_3b4b99d8: uid 254, ports ['o1', 'o2', 'o3', 'o4'], aliases [], 0 polygons, 2 references
[61]:
print(c.get_netlist_yaml())
connections:
  mzi_9a4fb01d_45p1_m2p2,o3: mzi_a19adceb_145p302_m24p65,o2
  mzi_9a4fb01d_45p1_m2p2,o4: mzi_a19adceb_145p302_m24p65,o1
instances:
  mzi_9a4fb01d_45p1_m2p2:
    component: mzi
    settings:
      combiner:
        name: coupler_gap0p2
        version: 0.0.1
        settings:
          name: coupler_gap0p2
          module: gdsfactory.components.coupler
          function_name: coupler
          info:
            length: 10.319
            min_bend_radius: 9.387
          info_version: 2
          full:
            gap: 0.2
            length: 20.0
            coupler_symmetric:
              function: coupler_symmetric
            coupler_straight:
              function: coupler_straight
            dy: 5.0
            dx: 10.0
            cross_section: strip
          changed:
            gap: 0.2
          default:
            gap: 0.236
            length: 20.0
            coupler_symmetric:
              function: coupler_symmetric
            coupler_straight:
              function: coupler_straight
            dy: 5.0
            dx: 10.0
            cross_section: strip
          child: null
      port_e0_combiner: o4
      port_e0_splitter: o4
      port_e1_combiner: o3
      port_e1_splitter: o3
      splitter:
        name: coupler_gap0p1_length10p0
        version: 0.0.1
        settings:
          name: coupler_gap0p1_length10p0
          module: gdsfactory.components.coupler
          function_name: coupler
          info:
            length: 10.334
            min_bend_radius: 9.213
          info_version: 2
          full:
            gap: 0.1
            length: 10.0
            coupler_symmetric:
              function: coupler_symmetric
            coupler_straight:
              function: coupler_straight
            dy: 5.0
            dx: 10.0
            cross_section: strip
          changed:
            gap: 0.1
            length: 10.0
          default:
            gap: 0.236
            length: 20.0
            coupler_symmetric:
              function: coupler_symmetric
            coupler_straight:
              function: coupler_straight
            dy: 5.0
            dx: 10.0
            cross_section: strip
          child: null
  mzi_a19adceb_145p302_m24p65:
    component: mzi
    settings:
      combiner:
        name: coupler_gap0p3_length30p0
        version: 0.0.1
        settings:
          name: coupler_gap0p3_length30p0
          module: gdsfactory.components.coupler
          function_name: coupler
          info:
            length: 10.305
            min_bend_radius: 9.568
          info_version: 2
          full:
            gap: 0.3
            length: 30.0
            coupler_symmetric:
              function: coupler_symmetric
            coupler_straight:
              function: coupler_straight
            dy: 5.0
            dx: 10.0
            cross_section: strip
          changed:
            gap: 0.3
            length: 30.0
          default:
            gap: 0.236
            length: 20.0
            coupler_symmetric:
              function: coupler_symmetric
            coupler_straight:
              function: coupler_straight
            dy: 5.0
            dx: 10.0
            cross_section: strip
          child: null
      delta_length: 100.0
      port_e0_combiner: o4
      port_e0_splitter: o4
      port_e1_combiner: o3
      port_e1_splitter: o3
      splitter:
        name: coupler_gap0p2
        version: 0.0.1
        settings:
          name: coupler_gap0p2
          module: gdsfactory.components.coupler
          function_name: coupler
          info:
            length: 10.319
            min_bend_radius: 9.387
          info_version: 2
          full:
            gap: 0.2
            length: 20.0
            coupler_symmetric:
              function: coupler_symmetric
            coupler_straight:
              function: coupler_straight
            dy: 5.0
            dx: 10.0
            cross_section: strip
          changed:
            gap: 0.2
          default:
            gap: 0.236
            length: 20.0
            coupler_symmetric:
              function: coupler_symmetric
            coupler_straight:
              function: coupler_straight
            dy: 5.0
            dx: 10.0
            cross_section: strip
          child: null
      with_splitter: false
placements:
  mzi_9a4fb01d_45p1_m2p2:
    x: 0.0
    'y': 0.0
    rotation: 0
    mirror: 0
  mzi_a19adceb_145p302_m24p65:
    x: 70.201
    'y': 0.0
    rotation: 0
    mirror: 0
ports:
  o1: mzi_9a4fb01d_45p1_m2p2,o1
  o2: mzi_9a4fb01d_45p1_m2p2,o2
  o3: mzi_a19adceb_145p302_m24p65,o3
  o4: mzi_a19adceb_145p302_m24p65,o4
name: mzi_lattice_3b4b99d8

[62]:
c.plot_netlist()
[62]:
<networkx.classes.graph.Graph at 0x7ff4b32acfd0>
../_images/notebooks_06_yaml_component_81_1.png
[63]:
coupler_lengths = [10, 20, 30, 40]
coupler_gaps = [0.1, 0.2, 0.4, 0.5]
delta_lengths = [10, 100, 200]

c = gf.components.mzi_lattice(
    coupler_lengths=coupler_lengths,
    coupler_gaps=coupler_gaps,
    delta_lengths=delta_lengths,
)
c
../_images/notebooks_06_yaml_component_82_0.png
[63]:
mzi_lattice_d52c1fad: uid 273, ports ['o1', 'o2', 'o3', 'o4'], aliases [], 0 polygons, 3 references
[64]:
n = c.get_netlist()
[65]:
c.plot_netlist()
[65]:
<networkx.classes.graph.Graph at 0x7ff4b3496ca0>
../_images/notebooks_06_yaml_component_84_1.png