Cell#
A @cell
is a decorator for functions that return a Component. Make sure you add the @cell
decorator to each function that returns a Component so you avoid having multiple components with the same name.
Why do you need to add the @cell
decorator?
In GDS each component must have a unique name. Ideally the name is also consistent from run to run, in case you want to merge GDS files that were created at different times or computers.
Two components stored in the GDS file cannot have the same name. They need to be references (instances) of the same component. See
References tutorial
. That way we only have to store the component in memory once and all the references are just pointers to that component.
What does the @cell
decorator does?
Gives the component a unique name depending on the parameters that you pass to it.
Creates a cache of components where we use the name as the key. The first time the function runs, the cache stores the component, so the second time, you get the component directly from the cache, so you don’t create the same component twice.
What is a decorator?
A decorator is a function that runs over a function, so when you do.
@gf.cell
def mzi_with_bend():
c = gf.Component()
mzi = c << gf.components.mzi()
bend = c << gf.components.bend_euler()
return c
it’s equivalent to
def mzi_with_bend():
c = gf.Component()
mzi = c << gf.components.mzi()
bend = c << gf.components.bend_euler(radius=radius)
return c
mzi_with_bend_decorated = gf.cell(mzi_with_bend)
Lets see how it works.
import gdsfactory as gf
def mzi_with_bend(radius: float = 10.0) -> gf.Component:
c = gf.Component()
mzi = c << gf.components.mzi()
bend = c << gf.components.bend_euler(radius=radius)
bend.connect("o1", mzi.ports["o2"])
return c
c = mzi_with_bend()
print(f"this cell {c.name!r} does NOT get automatic name")
c.plot()
this cell 'Unnamed_0' does NOT get automatic name
mzi_with_bend_decorated = gf.cell(mzi_with_bend)
c = mzi_with_bend_decorated(radius=10)
print(f"this cell {c.name!r} gets automatic name thanks to the `cell` decorator")
c.plot()
this cell 'mzi_with_bend_R10' gets automatic name thanks to the `cell` decorator
@gf.cell
def mzi_with_bend(radius: float = 10.0) -> gf.Component:
c = gf.Component()
mzi = c << gf.components.mzi()
bend = c << gf.components.bend_euler(radius=radius)
bend.connect("o1", mzi.ports["o2"])
return c
print(f"this cell {c.name!r} gets automatic name thanks to the `cell` decorator")
c.plot()
this cell 'mzi_with_bend_R10' gets automatic name thanks to the `cell` decorator
# See how the cells get the name from the parameters that you pass them
c = mzi_with_bend()
print(c)
print("second time you get this cell from the cache")
c = mzi_with_bend()
print(c)
print("If you call the cell with different parameters, the cell gets a different name")
c = mzi_with_bend(radius=20)
print(c)
vinsts=[] info=Info() kcl=KCLayout(name='DEFAULT', layout=<klayout.dbcore.Layout object at 0x7fe9d832c9b0>, layer_enclosures=LayerEnclosureModel(root={'78687732': LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure')}), cross_sections={'78687732_500': SymmetricalCrossSection(width=500, enclosure=LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure'), name='78687732_500'), '78687732_1000': SymmetricalCrossSection(width=1000, enclosure=LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure'), name='78687732_1000'), '78687732_2500': SymmetricalCrossSection(width=2500, enclosure=LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure'), name='78687732_2500')}, enclosure=KCellEnclosure(enclosures=LayerEnclosureCollection(enclosures=[])), library=<klayout.dbcore.Library object at 0x7fe9d832c050>, factories={'taper': <function taper at 0x7fe9c2d0c0e0>, 'bend_s_bezier': <function bend_s_bezier_factory.<locals>.bend_s_bezier at 0x7fe9cd2b67a0>, 'bend_circular': <function bend_circular at 0x7fe9c31de520>, 'bend_euler': <function bend_euler at 0x7fe9c31def20>, 'bend_s_euler': <function bend_s_euler_factory.<locals>.bend_s_euler at 0x7fe9cd2ccd60>, 'straight': <function straight at 0x7fe9c2d67880>, 'rotate': <function rotate at 0x7fe9c3828f40>, 'from_image': <function from_image at 0x7fe9c36aee80>, 'floorplan_with_block_letters': <function floorplan_with_block_letters at 0x7fe9c3151b20>, 'bend_circular_heater': <function bend_circular_heater at 0x7fe9c31de7a0>, 'bend_euler_s': <function bend_euler_s at 0x7fe9c31dede0>, 'bezier': <function bezier at 0x7fe9c31df4c0>, 'bend_s': <function bend_s at 0x7fe9c31df6a0>, 'add_fiber_array_optical_south_electrical_north': <function add_fiber_array_optical_south_electrical_north at 0x7fe9c31df920>, 'ramp': <function ramp at 0x7fe9c31dfe20>, 'taper_strip_to_ridge': <function taper_strip_to_ridge at 0x7fe9c2d0c180>, 'taper_strip_to_ridge_trenches': <function taper_strip_to_ridge_trenches at 0x7fe9c2d0c400>, 'taper_sc_nc': <function taper_sc_nc at 0x7fe9c2d0c540>, 'taper_adiabatic': <function taper_adiabatic at 0x7fe9c2d0c860>, 'taper_cross_section': <function taper_cross_section at 0x7fe9c2d0ca40>, 'taper_from_csv': <function taper_from_csv at 0x7fe9c2d0cc20>, 'taper_parabolic': <function taper_parabolic at 0x7fe9c2d0cd60>, 'add_termination': <function add_termination at 0x7fe9c31dfa60>, 'add_trenches': <function add_trenches at 0x7fe9c2d0cb80>, 'array': <function array at 0x7fe9c2d0cf40>, 'copy_layers': <function copy_layers at 0x7fe9c2d0d440>, 'extend_ports_list': <function extend_ports_list at 0x7fe9c2d0d580>, 'extend_ports': <function extend_ports at 0x7fe9c2d0d8a0>, 'pack_doe': <function pack_doe at 0x7fe9c2d0e0c0>, 'pack_doe_grid': <function pack_doe_grid at 0x7fe9c2d0e200>, 'splitter_chain': <function splitter_chain at 0x7fe9c2d0e340>, 'mzi': <function mzi at 0x7fe9c2d0e8e0>, 'mzi_lattice': <function mzi_lattice at 0x7fe9c2d0ec00>, 'mzi_lattice_mmi': <function mzi_lattice_mmi at 0x7fe9c2d0ed40>, 'mzi_pads_center': <function mzi_pads_center at 0x7fe9c2d0efc0>, 'mzit': <function mzit at 0x7fe9c2d0f1a0>, 'mzit_lattice': <function mzit_lattice at 0x7fe9c2d0f2e0>, 'splitter_tree': <function splitter_tree at 0x7fe9c2d0ee80>, 'coupler_symmetric': <function coupler_symmetric at 0x7fe9c2d0f4c0>, 'coupler_straight': <function coupler_straight at 0x7fe9c2d0f600>, 'coupler': <function coupler at 0x7fe9c2d0f740>, 'coupler90': <function coupler90 at 0x7fe9c2d0f920>, 'coupler90bend': <function coupler90bend at 0x7fe9c2d0f9c0>, 'coupler_adiabatic': <function coupler_adiabatic at 0x7fe9c2d0fce0>, 'coupler_asymmetric': <function coupler_asymmetric at 0x7fe9c2d38040>, 'coupler_bent_half': <function coupler_bent_half at 0x7fe9c2d382c0>, 'coupler_bent': <function coupler_bent at 0x7fe9c2d38400>, 'coupler_broadband': <function coupler_broadband at 0x7fe9c2d38680>, 'coupler_full': <function coupler_full at 0x7fe9c2d38860>, 'coupler_ring': <function coupler_ring at 0x7fe9c2d38ae0>, 'coupler_straight_asymmetric': <function coupler_straight_asymmetric at 0x7fe9c2d38d60>, 'align_wafer': <function align_wafer at 0x7fe9c2d39120>, 'add_frame': <function add_frame at 0x7fe9c2d391c0>, 'die': <function die at 0x7fe9c2d394e0>, 'die_with_pads': <function die_with_pads at 0x7fe9c2d396c0>, 'seal_ring': <function seal_ring at 0x7fe9c2d398a0>, 'seal_ring_segmented': <function seal_ring_segmented at 0x7fe9c2d399e0>, 'wafer': <function wafer at 0x7fe9c2d39bc0>, 'free_propagation_region': <function free_propagation_region at 0x7fe9c2d3a020>, 'awg': <function awg at 0x7fe9c2d3a0c0>, 'dbr_cell': <function dbr_cell at 0x7fe9c2d3a3e0>, 'dbr': <function dbr at 0x7fe9c2d3a520>, 'dbr_tapered': <function dbr_tapered at 0x7fe9c2d3a7a0>, 'bbox': <function bbox at 0x7fe9c2d3af20>, 'C': <function C at 0x7fe9c2d3b100>, 'circle': <function circle at 0x7fe9c2d3b2e0>, 'compass': <function compass at 0x7fe9c2d3b560>, 'cross': <function cross at 0x7fe9c2d3b740>, 'ellipse': <function ellipse at 0x7fe9c2d3b920>, 'fiducial_squares': <function fiducial_squares at 0x7fe9c2d3ba60>, 'L': <function L at 0x7fe9c2d3bc40>, 'nxn': <function nxn at 0x7fe9c2d3be20>, 'rectangle': <function rectangle at 0x7fe9c2d3bf60>, 'rectangles': <function rectangles at 0x7fe9c2d64180>, 'regular_polygon': <function regular_polygon at 0x7fe9c2d642c0>, 'triangle': <function triangle at 0x7fe9c2d644a0>, 'triangle2': <function triangle2 at 0x7fe9c2d645e0>, 'triangle4': <function triangle4 at 0x7fe9c2d64720>, 'fiber': <function fiber at 0x7fe9c2d3aac0>, 'fiber_array': <function fiber_array at 0x7fe9c2d647c0>, 'crossing_arm': <function crossing_arm at 0x7fe9c2d671a0>, 'crossing': <function crossing at 0x7fe9c2d672e0>, 'crossing_linear_taper': <function crossing_linear_taper at 0x7fe9c2d67420>, 'crossing_etched': <function crossing_etched at 0x7fe9c2d67560>, 'crossing45': <function crossing45 at 0x7fe9c2d676a0>, 'straight_array': <function straight_array at 0x7fe9c2d67b00>, 'wire_straight': <function wire_straight at 0x7fe9c2d67c40>, 'straight_heater_doped_rib': <function straight_heater_doped_rib at 0x7fe9c2d98040>, 'straight_heater_doped_strip': <function straight_heater_doped_strip at 0x7fe9c2d98220>, 'straight_heater_meander': <function straight_heater_meander at 0x7fe9c2d98540>, 'via': <function via at 0x7fe9c2d98d60>, 'via_circular': <function via_circular at 0x7fe9c2d98ea0>, 'via_chain': <function via_chain at 0x7fe9c2d991c0>, 'via_corner': <function via_corner at 0x7fe9c2d993a0>, 'via_stack': <function via_stack at 0x7fe9c2d99580>, 'via_stack_corner45': <function via_stack_corner45 at 0x7fe9c2d996c0>, 'via_stack_corner45_extended': <function via_stack_corner45_extended at 0x7fe9c2d99800>, 'via_stack_with_offset': <function via_stack_with_offset at 0x7fe9c2d99940>, 'straight_heater_meander_doped': <function straight_heater_meander_doped at 0x7fe9c2d98a40>, 'straight_heater_metal_undercut': <function straight_heater_metal_undercut at 0x7fe9c2d998a0>, 'straight_heater_metal_simple': <function straight_heater_metal_simple at 0x7fe9c2d99bc0>, 'straight_piecewise': <function straight_piecewise at 0x7fe9c2d99d00>, 'straight_pin': <function straight_pin at 0x7fe9c2d99da0>, 'straight_pin_slot': <function straight_pin_slot at 0x7fe9c2d9a020>, 'wire_corner': <function wire_corner at 0x7fe9c2d9a2a0>, 'wire_corner45': <function wire_corner45 at 0x7fe9c2d9a3e0>, 'wire_corner_sections': <function wire_corner_sections at 0x7fe9c2d9a480>, 'loop_mirror': <function loop_mirror at 0x7fe9c2d649a0>, 'mode_converter': <function mode_converter at 0x7fe9c2d9bec0>, 'polarization_splitter_rotator': <function polarization_splitter_rotator at 0x7fe9c2dc8220>, 'terminator': <function terminator at 0x7fe9c2dc87c0>, 'grating_coupler_array': <function grating_coupler_array at 0x7fe9c2dc8a40>, 'grating_coupler_dual_pol': <function grating_coupler_dual_pol at 0x7fe9c2dc8d60>, 'grating_coupler_elliptical': <function grating_coupler_elliptical at 0x7fe9c2dc93a0>, 'grating_coupler_elliptical_arbitrary': <function grating_coupler_elliptical_arbitrary at 0x7fe9c2dc9620>, 'grating_coupler_elliptical_uniform': <function grating_coupler_elliptical_uniform at 0x7fe9c2dc98a0>, 'grating_coupler_elliptical_lumerical': <function grating_coupler_elliptical_lumerical at 0x7fe9c2dc99e0>, 'grating_coupler_elliptical_trenches': <function grating_coupler_elliptical_trenches at 0x7fe9c2dc8040>, 'grating_coupler_loss': <function grating_coupler_loss at 0x7fe9c2dc9bc0>, 'grating_coupler_rectangular': <function grating_coupler_rectangular at 0x7fe9c2dc9da0>, 'grating_coupler_rectangular_arbitrary': <function grating_coupler_rectangular_arbitrary at 0x7fe9c2dca020>, 'grating_coupler_tree': <function grating_coupler_tree at 0x7fe9c2dca2a0>, 'mmi': <function mmi at 0x7fe9c2dca5c0>, 'mmi1x2': <function mmi1x2 at 0x7fe9c2dca8e0>, 'mmi1x2_with_sbend': <function mmi1x2_with_sbend at 0x7fe9c2dcaac0>, 'mmi2x2': <function mmi2x2 at 0x7fe9c2dcade0>, 'mmi2x2_with_sbend': <function mmi2x2_with_sbend at 0x7fe9c2dcaf20>, 'mmi_90degree_hybrid': <function mmi_90degree_hybrid at 0x7fe9c2dcb100>, 'mmi_tapered': <function mmi_tapered at 0x7fe9c2dcb420>, 'pad': <function pad at 0x7fe9c2dcb6a0>, 'pad_array': <function pad_array at 0x7fe9c2dcb920>, 'pad_gsg_short': <function pad_gsg_short at 0x7fe9c2dcbba0>, 'pads_shorted': <function pads_shorted at 0x7fe9c2dcbe20>, 'rectangle_with_slits': <function rectangle_with_slits at 0x7fe9c2dcbf60>, 'cavity': <function cavity at 0x7fe9c2dec220>, 'cdsem_all': <function cdsem_all at 0x7fe9c2dec4a0>, 'cdsem_bend180': <function cdsem_bend180 at 0x7fe9c2dec680>, 'cdsem_coupler': <function cdsem_coupler at 0x7fe9c2dec7c0>, 'cdsem_straight': <function cdsem_straight at 0x7fe9c2decae0>, 'cdsem_straight_density': <function cdsem_straight_density at 0x7fe9c2decc20>, '_bendu_double': <function _bendu_double at 0x7fe9c2decea0>, '_straight_double': <function _straight_double at 0x7fe9c2decfe0>, 'cutback_2x2': <function cutback_2x2 at 0x7fe9c2ded120>, 'cutback_bend': <function cutback_bend at 0x7fe9c2ded4e0>, 'cutback_bend90': <function cutback_bend90 at 0x7fe9c2ded620>, 'staircase': <function staircase at 0x7fe9c2ded760>, 'cutback_bend180': <function cutback_bend180 at 0x7fe9c2ded8a0>, 'cutback_component': <function cutback_component at 0x7fe9c2ded9e0>, 'cutback_splitter': <function cutback_splitter at 0x7fe9c2dedda0>, 'greek_cross': <function greek_cross at 0x7fe9c2dedee0>, 'greek_cross_with_pads': <function greek_cross_with_pads at 0x7fe9c2dee160>, 'litho_calipers': <function litho_calipers at 0x7fe9c2dee340>, 'litho_ruler': <function litho_ruler at 0x7fe9c2dee660>, 'litho_steps': <function litho_steps at 0x7fe9c2dee840>, 'resistance_meander': <function resistance_meander at 0x7fe9c2dee980>, 'resistance_sheet': <function resistance_sheet at 0x7fe9c2deeb60>, 'verniers': <function verniers at 0x7fe9c2deed40>, 'text': <function text at 0x7fe9c2defa60>, 'text_lines': <function text_lines at 0x7fe9c2defc40>, 'text_klayout': <function text_klayout at 0x7fe9c2defd80>, 'text_freetype': <function text_freetype at 0x7fe9c2c340e0>, 'pixel_array': <function pixel_array at 0x7fe9c2c34360>, 'text_rectangular': <function text_rectangular at 0x7fe9c2c344a0>, 'text_rectangular_multi_layer': <function text_rectangular_multi_layer at 0x7fe9c2c345e0>, 'pixel': <function pixel at 0x7fe9c2def060>, 'qrcode': <function qrcode at 0x7fe9c2defce0>, 'version_stamp': <function version_stamp at 0x7fe9c2c34680>, 'disk': <function disk at 0x7fe9c2c34c20>, 'disk_heater': <function disk_heater at 0x7fe9c2c34d60>, 'ring': <function ring at 0x7fe9c2c34fe0>, 'ring_crow': <function ring_crow at 0x7fe9c2c351c0>, 'ring_crow_couplers': <function ring_crow_couplers at 0x7fe9c2c35300>, 'ring_double': <function ring_double at 0x7fe9c2c354e0>, 'ring_double_bend_coupler': <function ring_double_bend_coupler at 0x7fe9c2c35800>, 'ring_double_heater': <function ring_double_heater at 0x7fe9c2c35940>, 'ring_double_pn': <function ring_double_pn at 0x7fe9c2c35c60>, 'ring_single_pn': <function ring_single_pn at 0x7fe9c2c35da0>, 'ring_single': <function ring_single at 0x7fe9c2c35f80>, 'ring_single_array': <function ring_single_array at 0x7fe9c2c360c0>, 'coupler_bend': <function coupler_bend at 0x7fe9c2c36200>, 'coupler_ring_bend': <function coupler_ring_bend at 0x7fe9c2c36340>, 'ring_single_bend_coupler': <function ring_single_bend_coupler at 0x7fe9c2c36480>, 'ring_single_dut': <function ring_single_dut at 0x7fe9c2c36660>, 'delay_snake': <function delay_snake at 0x7fe9c2c368e0>, 'delay_snake2': <function delay_snake2 at 0x7fe9c2c36ac0>, 'delay_snake_sbend': <function delay_snake_sbend at 0x7fe9c2c36d40>, 'spiral': <function spiral at 0x7fe9c2c36fc0>, 'spiral_double': <function spiral_double at 0x7fe9c2c371a0>, 'spiral_racetrack': <function spiral_racetrack at 0x7fe9c2c37420>, 'spiral_racetrack_fixed_length': <function spiral_racetrack_fixed_length at 0x7fe9c2c37560>, 'spiral_racetrack_heater_metal': <function spiral_racetrack_heater_metal at 0x7fe9c2c37740>, 'spiral_racetrack_heater_doped': <function spiral_racetrack_heater_doped at 0x7fe9c2c37880>, 'spiral_inductor': <function spiral_inductor at 0x7fe9c2c379c0>, 'hline': <function hline at 0x7fe9c2c37c40>, 'optimal_90deg': <function optimal_90deg at 0x7fe9c2c37d80>, 'optimal_hairpin': <function optimal_hairpin at 0x7fe9c2c640e0>, 'optimal_step': <function optimal_step at 0x7fe9c2c64220>, 'snspd': <function snspd at 0x7fe9c2c64400>, 'interdigital_capacitor': <function interdigital_capacitor at 0x7fe9c2c645e0>, 'ge_detector_straight_si_contacts': <function ge_detector_straight_si_contacts at 0x7fe9c2c64860>, 'edge_coupler_silicon': <function edge_coupler_silicon at 0x7fe9c2c64ae0>, 'edge_coupler_array': <function edge_coupler_array at 0x7fe9c2c64c20>, 'edge_coupler_array_with_loopback': <function edge_coupler_array_with_loopback at 0x7fe9c2c64d60>, 'mzi_with_bend': <function mzi_with_bend at 0x7fe9a95f9440>}, virtual_factories={'virtual_bend_circular': <function virtual_bend_circular_factory.<locals>.virtual_bend_circular at 0x7fe9cd2cdc60>, 'bend_euler': <function virtual_bend_euler_factory.<locals>.bend_euler at 0x7fe9cd2cdee0>, 'virtual_straight': <function virtual_straight_factory.<locals>.virtual_straight at 0x7fe9cd2ce160>, 'bend_circular_all_angle': <function bend_circular_all_angle at 0x7fe9c31de660>, 'bend_euler_all_angle': <function bend_euler_all_angle at 0x7fe9c31df1a0>, 'straight_all_angle': <function straight_all_angle at 0x7fe9c2d679c0>}, kcells={0: Unnamed_0: ports [], 2 instances, 1: bend_euler_RNone_A90_P0_d7c3a5a9: ports ['o1', 'o2'], 0 instances, 2: mzi_DL10_LY2_LX0p1_Bben_4daac747: ports ['o1', 'o2'], 16 instances, 3: mmi1x2_WNone_WT1_LT10_L_4e0f7121: ports ['o1', 'o2', 'o3'], 0 instances, 4: taper_L10_W0p5_W1_LNone_456c7208: ports ['o1', 'o2'], 0 instances, 5: straight_L5p5_N2_CSxs_5_d3ec67bc: ports ['o1', 'o2'], 0 instances, 6: straight_L7_N2_CSstrip_WNone: ports ['o1', 'o2'], 0 instances, 7: straight_L0p1_N2_CSstrip_WNone: ports ['o1', 'o2'], 0 instances, 8: straight_L2_N2_CSstrip_WNone: ports ['o1', 'o2'], 0 instances, 9: bend_euler_R10_A90_P0p5_2f1f5c6d: ports ['o1', 'o2'], 0 instances, 10: mzi_with_bend_R10: ports [], 2 instances}, layers=<aenum 'LAYER'>, infos=LayerInfos(), layer_stack=LayerStack(layers={}), netlist_layer_mapping={}, sparameters_path=None, interconnect_cml_path=None, constants=Constants(), rename_function=<function rename_clockwise_multi at 0x7fe9d888afc0>, info=Info(), settings=KCellSettings(version='0.23.2', klayout_version='0.29.11', meta_format='v3'), future_cell_name='mzi_with_bend_R10', decorators=<kfactory.decorators.Decorators object at 0x7fe9d8324a50>) function_name='mzi_with_bend' basename=None boundary=None insts=<gdsfactory.component.ComponentReferences object at 0x7fe9a95f1590> size_info=<kfactory.kcell.SizeInfo object at 0x7fe9b5073f50> dsize_info=<kfactory.kcell.DSizeInfo object at 0x7fe9aa7c2390> routes={}
second time you get this cell from the cache
vinsts=[] info=Info() kcl=KCLayout(name='DEFAULT', layout=<klayout.dbcore.Layout object at 0x7fe9d832c9b0>, layer_enclosures=LayerEnclosureModel(root={'78687732': LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure')}), cross_sections={'78687732_500': SymmetricalCrossSection(width=500, enclosure=LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure'), name='78687732_500'), '78687732_1000': SymmetricalCrossSection(width=1000, enclosure=LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure'), name='78687732_1000'), '78687732_2500': SymmetricalCrossSection(width=2500, enclosure=LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure'), name='78687732_2500')}, enclosure=KCellEnclosure(enclosures=LayerEnclosureCollection(enclosures=[])), library=<klayout.dbcore.Library object at 0x7fe9d832c050>, factories={'taper': <function taper at 0x7fe9c2d0c0e0>, 'bend_s_bezier': <function bend_s_bezier_factory.<locals>.bend_s_bezier at 0x7fe9cd2b67a0>, 'bend_circular': <function bend_circular at 0x7fe9c31de520>, 'bend_euler': <function bend_euler at 0x7fe9c31def20>, 'bend_s_euler': <function bend_s_euler_factory.<locals>.bend_s_euler at 0x7fe9cd2ccd60>, 'straight': <function straight at 0x7fe9c2d67880>, 'rotate': <function rotate at 0x7fe9c3828f40>, 'from_image': <function from_image at 0x7fe9c36aee80>, 'floorplan_with_block_letters': <function floorplan_with_block_letters at 0x7fe9c3151b20>, 'bend_circular_heater': <function bend_circular_heater at 0x7fe9c31de7a0>, 'bend_euler_s': <function bend_euler_s at 0x7fe9c31dede0>, 'bezier': <function bezier at 0x7fe9c31df4c0>, 'bend_s': <function bend_s at 0x7fe9c31df6a0>, 'add_fiber_array_optical_south_electrical_north': <function add_fiber_array_optical_south_electrical_north at 0x7fe9c31df920>, 'ramp': <function ramp at 0x7fe9c31dfe20>, 'taper_strip_to_ridge': <function taper_strip_to_ridge at 0x7fe9c2d0c180>, 'taper_strip_to_ridge_trenches': <function taper_strip_to_ridge_trenches at 0x7fe9c2d0c400>, 'taper_sc_nc': <function taper_sc_nc at 0x7fe9c2d0c540>, 'taper_adiabatic': <function taper_adiabatic at 0x7fe9c2d0c860>, 'taper_cross_section': <function taper_cross_section at 0x7fe9c2d0ca40>, 'taper_from_csv': <function taper_from_csv at 0x7fe9c2d0cc20>, 'taper_parabolic': <function taper_parabolic at 0x7fe9c2d0cd60>, 'add_termination': <function add_termination at 0x7fe9c31dfa60>, 'add_trenches': <function add_trenches at 0x7fe9c2d0cb80>, 'array': <function array at 0x7fe9c2d0cf40>, 'copy_layers': <function copy_layers at 0x7fe9c2d0d440>, 'extend_ports_list': <function extend_ports_list at 0x7fe9c2d0d580>, 'extend_ports': <function extend_ports at 0x7fe9c2d0d8a0>, 'pack_doe': <function pack_doe at 0x7fe9c2d0e0c0>, 'pack_doe_grid': <function pack_doe_grid at 0x7fe9c2d0e200>, 'splitter_chain': <function splitter_chain at 0x7fe9c2d0e340>, 'mzi': <function mzi at 0x7fe9c2d0e8e0>, 'mzi_lattice': <function mzi_lattice at 0x7fe9c2d0ec00>, 'mzi_lattice_mmi': <function mzi_lattice_mmi at 0x7fe9c2d0ed40>, 'mzi_pads_center': <function mzi_pads_center at 0x7fe9c2d0efc0>, 'mzit': <function mzit at 0x7fe9c2d0f1a0>, 'mzit_lattice': <function mzit_lattice at 0x7fe9c2d0f2e0>, 'splitter_tree': <function splitter_tree at 0x7fe9c2d0ee80>, 'coupler_symmetric': <function coupler_symmetric at 0x7fe9c2d0f4c0>, 'coupler_straight': <function coupler_straight at 0x7fe9c2d0f600>, 'coupler': <function coupler at 0x7fe9c2d0f740>, 'coupler90': <function coupler90 at 0x7fe9c2d0f920>, 'coupler90bend': <function coupler90bend at 0x7fe9c2d0f9c0>, 'coupler_adiabatic': <function coupler_adiabatic at 0x7fe9c2d0fce0>, 'coupler_asymmetric': <function coupler_asymmetric at 0x7fe9c2d38040>, 'coupler_bent_half': <function coupler_bent_half at 0x7fe9c2d382c0>, 'coupler_bent': <function coupler_bent at 0x7fe9c2d38400>, 'coupler_broadband': <function coupler_broadband at 0x7fe9c2d38680>, 'coupler_full': <function coupler_full at 0x7fe9c2d38860>, 'coupler_ring': <function coupler_ring at 0x7fe9c2d38ae0>, 'coupler_straight_asymmetric': <function coupler_straight_asymmetric at 0x7fe9c2d38d60>, 'align_wafer': <function align_wafer at 0x7fe9c2d39120>, 'add_frame': <function add_frame at 0x7fe9c2d391c0>, 'die': <function die at 0x7fe9c2d394e0>, 'die_with_pads': <function die_with_pads at 0x7fe9c2d396c0>, 'seal_ring': <function seal_ring at 0x7fe9c2d398a0>, 'seal_ring_segmented': <function seal_ring_segmented at 0x7fe9c2d399e0>, 'wafer': <function wafer at 0x7fe9c2d39bc0>, 'free_propagation_region': <function free_propagation_region at 0x7fe9c2d3a020>, 'awg': <function awg at 0x7fe9c2d3a0c0>, 'dbr_cell': <function dbr_cell at 0x7fe9c2d3a3e0>, 'dbr': <function dbr at 0x7fe9c2d3a520>, 'dbr_tapered': <function dbr_tapered at 0x7fe9c2d3a7a0>, 'bbox': <function bbox at 0x7fe9c2d3af20>, 'C': <function C at 0x7fe9c2d3b100>, 'circle': <function circle at 0x7fe9c2d3b2e0>, 'compass': <function compass at 0x7fe9c2d3b560>, 'cross': <function cross at 0x7fe9c2d3b740>, 'ellipse': <function ellipse at 0x7fe9c2d3b920>, 'fiducial_squares': <function fiducial_squares at 0x7fe9c2d3ba60>, 'L': <function L at 0x7fe9c2d3bc40>, 'nxn': <function nxn at 0x7fe9c2d3be20>, 'rectangle': <function rectangle at 0x7fe9c2d3bf60>, 'rectangles': <function rectangles at 0x7fe9c2d64180>, 'regular_polygon': <function regular_polygon at 0x7fe9c2d642c0>, 'triangle': <function triangle at 0x7fe9c2d644a0>, 'triangle2': <function triangle2 at 0x7fe9c2d645e0>, 'triangle4': <function triangle4 at 0x7fe9c2d64720>, 'fiber': <function fiber at 0x7fe9c2d3aac0>, 'fiber_array': <function fiber_array at 0x7fe9c2d647c0>, 'crossing_arm': <function crossing_arm at 0x7fe9c2d671a0>, 'crossing': <function crossing at 0x7fe9c2d672e0>, 'crossing_linear_taper': <function crossing_linear_taper at 0x7fe9c2d67420>, 'crossing_etched': <function crossing_etched at 0x7fe9c2d67560>, 'crossing45': <function crossing45 at 0x7fe9c2d676a0>, 'straight_array': <function straight_array at 0x7fe9c2d67b00>, 'wire_straight': <function wire_straight at 0x7fe9c2d67c40>, 'straight_heater_doped_rib': <function straight_heater_doped_rib at 0x7fe9c2d98040>, 'straight_heater_doped_strip': <function straight_heater_doped_strip at 0x7fe9c2d98220>, 'straight_heater_meander': <function straight_heater_meander at 0x7fe9c2d98540>, 'via': <function via at 0x7fe9c2d98d60>, 'via_circular': <function via_circular at 0x7fe9c2d98ea0>, 'via_chain': <function via_chain at 0x7fe9c2d991c0>, 'via_corner': <function via_corner at 0x7fe9c2d993a0>, 'via_stack': <function via_stack at 0x7fe9c2d99580>, 'via_stack_corner45': <function via_stack_corner45 at 0x7fe9c2d996c0>, 'via_stack_corner45_extended': <function via_stack_corner45_extended at 0x7fe9c2d99800>, 'via_stack_with_offset': <function via_stack_with_offset at 0x7fe9c2d99940>, 'straight_heater_meander_doped': <function straight_heater_meander_doped at 0x7fe9c2d98a40>, 'straight_heater_metal_undercut': <function straight_heater_metal_undercut at 0x7fe9c2d998a0>, 'straight_heater_metal_simple': <function straight_heater_metal_simple at 0x7fe9c2d99bc0>, 'straight_piecewise': <function straight_piecewise at 0x7fe9c2d99d00>, 'straight_pin': <function straight_pin at 0x7fe9c2d99da0>, 'straight_pin_slot': <function straight_pin_slot at 0x7fe9c2d9a020>, 'wire_corner': <function wire_corner at 0x7fe9c2d9a2a0>, 'wire_corner45': <function wire_corner45 at 0x7fe9c2d9a3e0>, 'wire_corner_sections': <function wire_corner_sections at 0x7fe9c2d9a480>, 'loop_mirror': <function loop_mirror at 0x7fe9c2d649a0>, 'mode_converter': <function mode_converter at 0x7fe9c2d9bec0>, 'polarization_splitter_rotator': <function polarization_splitter_rotator at 0x7fe9c2dc8220>, 'terminator': <function terminator at 0x7fe9c2dc87c0>, 'grating_coupler_array': <function grating_coupler_array at 0x7fe9c2dc8a40>, 'grating_coupler_dual_pol': <function grating_coupler_dual_pol at 0x7fe9c2dc8d60>, 'grating_coupler_elliptical': <function grating_coupler_elliptical at 0x7fe9c2dc93a0>, 'grating_coupler_elliptical_arbitrary': <function grating_coupler_elliptical_arbitrary at 0x7fe9c2dc9620>, 'grating_coupler_elliptical_uniform': <function grating_coupler_elliptical_uniform at 0x7fe9c2dc98a0>, 'grating_coupler_elliptical_lumerical': <function grating_coupler_elliptical_lumerical at 0x7fe9c2dc99e0>, 'grating_coupler_elliptical_trenches': <function grating_coupler_elliptical_trenches at 0x7fe9c2dc8040>, 'grating_coupler_loss': <function grating_coupler_loss at 0x7fe9c2dc9bc0>, 'grating_coupler_rectangular': <function grating_coupler_rectangular at 0x7fe9c2dc9da0>, 'grating_coupler_rectangular_arbitrary': <function grating_coupler_rectangular_arbitrary at 0x7fe9c2dca020>, 'grating_coupler_tree': <function grating_coupler_tree at 0x7fe9c2dca2a0>, 'mmi': <function mmi at 0x7fe9c2dca5c0>, 'mmi1x2': <function mmi1x2 at 0x7fe9c2dca8e0>, 'mmi1x2_with_sbend': <function mmi1x2_with_sbend at 0x7fe9c2dcaac0>, 'mmi2x2': <function mmi2x2 at 0x7fe9c2dcade0>, 'mmi2x2_with_sbend': <function mmi2x2_with_sbend at 0x7fe9c2dcaf20>, 'mmi_90degree_hybrid': <function mmi_90degree_hybrid at 0x7fe9c2dcb100>, 'mmi_tapered': <function mmi_tapered at 0x7fe9c2dcb420>, 'pad': <function pad at 0x7fe9c2dcb6a0>, 'pad_array': <function pad_array at 0x7fe9c2dcb920>, 'pad_gsg_short': <function pad_gsg_short at 0x7fe9c2dcbba0>, 'pads_shorted': <function pads_shorted at 0x7fe9c2dcbe20>, 'rectangle_with_slits': <function rectangle_with_slits at 0x7fe9c2dcbf60>, 'cavity': <function cavity at 0x7fe9c2dec220>, 'cdsem_all': <function cdsem_all at 0x7fe9c2dec4a0>, 'cdsem_bend180': <function cdsem_bend180 at 0x7fe9c2dec680>, 'cdsem_coupler': <function cdsem_coupler at 0x7fe9c2dec7c0>, 'cdsem_straight': <function cdsem_straight at 0x7fe9c2decae0>, 'cdsem_straight_density': <function cdsem_straight_density at 0x7fe9c2decc20>, '_bendu_double': <function _bendu_double at 0x7fe9c2decea0>, '_straight_double': <function _straight_double at 0x7fe9c2decfe0>, 'cutback_2x2': <function cutback_2x2 at 0x7fe9c2ded120>, 'cutback_bend': <function cutback_bend at 0x7fe9c2ded4e0>, 'cutback_bend90': <function cutback_bend90 at 0x7fe9c2ded620>, 'staircase': <function staircase at 0x7fe9c2ded760>, 'cutback_bend180': <function cutback_bend180 at 0x7fe9c2ded8a0>, 'cutback_component': <function cutback_component at 0x7fe9c2ded9e0>, 'cutback_splitter': <function cutback_splitter at 0x7fe9c2dedda0>, 'greek_cross': <function greek_cross at 0x7fe9c2dedee0>, 'greek_cross_with_pads': <function greek_cross_with_pads at 0x7fe9c2dee160>, 'litho_calipers': <function litho_calipers at 0x7fe9c2dee340>, 'litho_ruler': <function litho_ruler at 0x7fe9c2dee660>, 'litho_steps': <function litho_steps at 0x7fe9c2dee840>, 'resistance_meander': <function resistance_meander at 0x7fe9c2dee980>, 'resistance_sheet': <function resistance_sheet at 0x7fe9c2deeb60>, 'verniers': <function verniers at 0x7fe9c2deed40>, 'text': <function text at 0x7fe9c2defa60>, 'text_lines': <function text_lines at 0x7fe9c2defc40>, 'text_klayout': <function text_klayout at 0x7fe9c2defd80>, 'text_freetype': <function text_freetype at 0x7fe9c2c340e0>, 'pixel_array': <function pixel_array at 0x7fe9c2c34360>, 'text_rectangular': <function text_rectangular at 0x7fe9c2c344a0>, 'text_rectangular_multi_layer': <function text_rectangular_multi_layer at 0x7fe9c2c345e0>, 'pixel': <function pixel at 0x7fe9c2def060>, 'qrcode': <function qrcode at 0x7fe9c2defce0>, 'version_stamp': <function version_stamp at 0x7fe9c2c34680>, 'disk': <function disk at 0x7fe9c2c34c20>, 'disk_heater': <function disk_heater at 0x7fe9c2c34d60>, 'ring': <function ring at 0x7fe9c2c34fe0>, 'ring_crow': <function ring_crow at 0x7fe9c2c351c0>, 'ring_crow_couplers': <function ring_crow_couplers at 0x7fe9c2c35300>, 'ring_double': <function ring_double at 0x7fe9c2c354e0>, 'ring_double_bend_coupler': <function ring_double_bend_coupler at 0x7fe9c2c35800>, 'ring_double_heater': <function ring_double_heater at 0x7fe9c2c35940>, 'ring_double_pn': <function ring_double_pn at 0x7fe9c2c35c60>, 'ring_single_pn': <function ring_single_pn at 0x7fe9c2c35da0>, 'ring_single': <function ring_single at 0x7fe9c2c35f80>, 'ring_single_array': <function ring_single_array at 0x7fe9c2c360c0>, 'coupler_bend': <function coupler_bend at 0x7fe9c2c36200>, 'coupler_ring_bend': <function coupler_ring_bend at 0x7fe9c2c36340>, 'ring_single_bend_coupler': <function ring_single_bend_coupler at 0x7fe9c2c36480>, 'ring_single_dut': <function ring_single_dut at 0x7fe9c2c36660>, 'delay_snake': <function delay_snake at 0x7fe9c2c368e0>, 'delay_snake2': <function delay_snake2 at 0x7fe9c2c36ac0>, 'delay_snake_sbend': <function delay_snake_sbend at 0x7fe9c2c36d40>, 'spiral': <function spiral at 0x7fe9c2c36fc0>, 'spiral_double': <function spiral_double at 0x7fe9c2c371a0>, 'spiral_racetrack': <function spiral_racetrack at 0x7fe9c2c37420>, 'spiral_racetrack_fixed_length': <function spiral_racetrack_fixed_length at 0x7fe9c2c37560>, 'spiral_racetrack_heater_metal': <function spiral_racetrack_heater_metal at 0x7fe9c2c37740>, 'spiral_racetrack_heater_doped': <function spiral_racetrack_heater_doped at 0x7fe9c2c37880>, 'spiral_inductor': <function spiral_inductor at 0x7fe9c2c379c0>, 'hline': <function hline at 0x7fe9c2c37c40>, 'optimal_90deg': <function optimal_90deg at 0x7fe9c2c37d80>, 'optimal_hairpin': <function optimal_hairpin at 0x7fe9c2c640e0>, 'optimal_step': <function optimal_step at 0x7fe9c2c64220>, 'snspd': <function snspd at 0x7fe9c2c64400>, 'interdigital_capacitor': <function interdigital_capacitor at 0x7fe9c2c645e0>, 'ge_detector_straight_si_contacts': <function ge_detector_straight_si_contacts at 0x7fe9c2c64860>, 'edge_coupler_silicon': <function edge_coupler_silicon at 0x7fe9c2c64ae0>, 'edge_coupler_array': <function edge_coupler_array at 0x7fe9c2c64c20>, 'edge_coupler_array_with_loopback': <function edge_coupler_array_with_loopback at 0x7fe9c2c64d60>, 'mzi_with_bend': <function mzi_with_bend at 0x7fe9a95f9440>}, virtual_factories={'virtual_bend_circular': <function virtual_bend_circular_factory.<locals>.virtual_bend_circular at 0x7fe9cd2cdc60>, 'bend_euler': <function virtual_bend_euler_factory.<locals>.bend_euler at 0x7fe9cd2cdee0>, 'virtual_straight': <function virtual_straight_factory.<locals>.virtual_straight at 0x7fe9cd2ce160>, 'bend_circular_all_angle': <function bend_circular_all_angle at 0x7fe9c31de660>, 'bend_euler_all_angle': <function bend_euler_all_angle at 0x7fe9c31df1a0>, 'straight_all_angle': <function straight_all_angle at 0x7fe9c2d679c0>}, kcells={0: Unnamed_0: ports [], 2 instances, 1: bend_euler_RNone_A90_P0_d7c3a5a9: ports ['o1', 'o2'], 0 instances, 2: mzi_DL10_LY2_LX0p1_Bben_4daac747: ports ['o1', 'o2'], 16 instances, 3: mmi1x2_WNone_WT1_LT10_L_4e0f7121: ports ['o1', 'o2', 'o3'], 0 instances, 4: taper_L10_W0p5_W1_LNone_456c7208: ports ['o1', 'o2'], 0 instances, 5: straight_L5p5_N2_CSxs_5_d3ec67bc: ports ['o1', 'o2'], 0 instances, 6: straight_L7_N2_CSstrip_WNone: ports ['o1', 'o2'], 0 instances, 7: straight_L0p1_N2_CSstrip_WNone: ports ['o1', 'o2'], 0 instances, 8: straight_L2_N2_CSstrip_WNone: ports ['o1', 'o2'], 0 instances, 9: bend_euler_R10_A90_P0p5_2f1f5c6d: ports ['o1', 'o2'], 0 instances, 10: mzi_with_bend_R10: ports [], 2 instances}, layers=<aenum 'LAYER'>, infos=LayerInfos(), layer_stack=LayerStack(layers={}), netlist_layer_mapping={}, sparameters_path=None, interconnect_cml_path=None, constants=Constants(), rename_function=<function rename_clockwise_multi at 0x7fe9d888afc0>, info=Info(), settings=KCellSettings(version='0.23.2', klayout_version='0.29.11', meta_format='v3'), future_cell_name='mzi_with_bend_R10', decorators=<kfactory.decorators.Decorators object at 0x7fe9d8324a50>) function_name='mzi_with_bend' basename=None boundary=None insts=<gdsfactory.component.ComponentReferences object at 0x7fe9a95f1590> size_info=<kfactory.kcell.SizeInfo object at 0x7fe9b5073f50> dsize_info=<kfactory.kcell.DSizeInfo object at 0x7fe9aa7c2390> routes={}
If you call the cell with different parameters, the cell gets a different name
vinsts=[] info=Info() kcl=KCLayout(name='DEFAULT', layout=<klayout.dbcore.Layout object at 0x7fe9d832c9b0>, layer_enclosures=LayerEnclosureModel(root={'78687732': LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure')}), cross_sections={'78687732_500': SymmetricalCrossSection(width=500, enclosure=LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure'), name='78687732_500'), '78687732_1000': SymmetricalCrossSection(width=1000, enclosure=LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure'), name='78687732_1000'), '78687732_2500': SymmetricalCrossSection(width=2500, enclosure=LayerEnclosure(layer_sections={}, main_layer=WG (1/0), yaml_tag='!Enclosure'), name='78687732_2500')}, enclosure=KCellEnclosure(enclosures=LayerEnclosureCollection(enclosures=[])), library=<klayout.dbcore.Library object at 0x7fe9d832c050>, factories={'taper': <function taper at 0x7fe9c2d0c0e0>, 'bend_s_bezier': <function bend_s_bezier_factory.<locals>.bend_s_bezier at 0x7fe9cd2b67a0>, 'bend_circular': <function bend_circular at 0x7fe9c31de520>, 'bend_euler': <function bend_euler at 0x7fe9c31def20>, 'bend_s_euler': <function bend_s_euler_factory.<locals>.bend_s_euler at 0x7fe9cd2ccd60>, 'straight': <function straight at 0x7fe9c2d67880>, 'rotate': <function rotate at 0x7fe9c3828f40>, 'from_image': <function from_image at 0x7fe9c36aee80>, 'floorplan_with_block_letters': <function floorplan_with_block_letters at 0x7fe9c3151b20>, 'bend_circular_heater': <function bend_circular_heater at 0x7fe9c31de7a0>, 'bend_euler_s': <function bend_euler_s at 0x7fe9c31dede0>, 'bezier': <function bezier at 0x7fe9c31df4c0>, 'bend_s': <function bend_s at 0x7fe9c31df6a0>, 'add_fiber_array_optical_south_electrical_north': <function add_fiber_array_optical_south_electrical_north at 0x7fe9c31df920>, 'ramp': <function ramp at 0x7fe9c31dfe20>, 'taper_strip_to_ridge': <function taper_strip_to_ridge at 0x7fe9c2d0c180>, 'taper_strip_to_ridge_trenches': <function taper_strip_to_ridge_trenches at 0x7fe9c2d0c400>, 'taper_sc_nc': <function taper_sc_nc at 0x7fe9c2d0c540>, 'taper_adiabatic': <function taper_adiabatic at 0x7fe9c2d0c860>, 'taper_cross_section': <function taper_cross_section at 0x7fe9c2d0ca40>, 'taper_from_csv': <function taper_from_csv at 0x7fe9c2d0cc20>, 'taper_parabolic': <function taper_parabolic at 0x7fe9c2d0cd60>, 'add_termination': <function add_termination at 0x7fe9c31dfa60>, 'add_trenches': <function add_trenches at 0x7fe9c2d0cb80>, 'array': <function array at 0x7fe9c2d0cf40>, 'copy_layers': <function copy_layers at 0x7fe9c2d0d440>, 'extend_ports_list': <function extend_ports_list at 0x7fe9c2d0d580>, 'extend_ports': <function extend_ports at 0x7fe9c2d0d8a0>, 'pack_doe': <function pack_doe at 0x7fe9c2d0e0c0>, 'pack_doe_grid': <function pack_doe_grid at 0x7fe9c2d0e200>, 'splitter_chain': <function splitter_chain at 0x7fe9c2d0e340>, 'mzi': <function mzi at 0x7fe9c2d0e8e0>, 'mzi_lattice': <function mzi_lattice at 0x7fe9c2d0ec00>, 'mzi_lattice_mmi': <function mzi_lattice_mmi at 0x7fe9c2d0ed40>, 'mzi_pads_center': <function mzi_pads_center at 0x7fe9c2d0efc0>, 'mzit': <function mzit at 0x7fe9c2d0f1a0>, 'mzit_lattice': <function mzit_lattice at 0x7fe9c2d0f2e0>, 'splitter_tree': <function splitter_tree at 0x7fe9c2d0ee80>, 'coupler_symmetric': <function coupler_symmetric at 0x7fe9c2d0f4c0>, 'coupler_straight': <function coupler_straight at 0x7fe9c2d0f600>, 'coupler': <function coupler at 0x7fe9c2d0f740>, 'coupler90': <function coupler90 at 0x7fe9c2d0f920>, 'coupler90bend': <function coupler90bend at 0x7fe9c2d0f9c0>, 'coupler_adiabatic': <function coupler_adiabatic at 0x7fe9c2d0fce0>, 'coupler_asymmetric': <function coupler_asymmetric at 0x7fe9c2d38040>, 'coupler_bent_half': <function coupler_bent_half at 0x7fe9c2d382c0>, 'coupler_bent': <function coupler_bent at 0x7fe9c2d38400>, 'coupler_broadband': <function coupler_broadband at 0x7fe9c2d38680>, 'coupler_full': <function coupler_full at 0x7fe9c2d38860>, 'coupler_ring': <function coupler_ring at 0x7fe9c2d38ae0>, 'coupler_straight_asymmetric': <function coupler_straight_asymmetric at 0x7fe9c2d38d60>, 'align_wafer': <function align_wafer at 0x7fe9c2d39120>, 'add_frame': <function add_frame at 0x7fe9c2d391c0>, 'die': <function die at 0x7fe9c2d394e0>, 'die_with_pads': <function die_with_pads at 0x7fe9c2d396c0>, 'seal_ring': <function seal_ring at 0x7fe9c2d398a0>, 'seal_ring_segmented': <function seal_ring_segmented at 0x7fe9c2d399e0>, 'wafer': <function wafer at 0x7fe9c2d39bc0>, 'free_propagation_region': <function free_propagation_region at 0x7fe9c2d3a020>, 'awg': <function awg at 0x7fe9c2d3a0c0>, 'dbr_cell': <function dbr_cell at 0x7fe9c2d3a3e0>, 'dbr': <function dbr at 0x7fe9c2d3a520>, 'dbr_tapered': <function dbr_tapered at 0x7fe9c2d3a7a0>, 'bbox': <function bbox at 0x7fe9c2d3af20>, 'C': <function C at 0x7fe9c2d3b100>, 'circle': <function circle at 0x7fe9c2d3b2e0>, 'compass': <function compass at 0x7fe9c2d3b560>, 'cross': <function cross at 0x7fe9c2d3b740>, 'ellipse': <function ellipse at 0x7fe9c2d3b920>, 'fiducial_squares': <function fiducial_squares at 0x7fe9c2d3ba60>, 'L': <function L at 0x7fe9c2d3bc40>, 'nxn': <function nxn at 0x7fe9c2d3be20>, 'rectangle': <function rectangle at 0x7fe9c2d3bf60>, 'rectangles': <function rectangles at 0x7fe9c2d64180>, 'regular_polygon': <function regular_polygon at 0x7fe9c2d642c0>, 'triangle': <function triangle at 0x7fe9c2d644a0>, 'triangle2': <function triangle2 at 0x7fe9c2d645e0>, 'triangle4': <function triangle4 at 0x7fe9c2d64720>, 'fiber': <function fiber at 0x7fe9c2d3aac0>, 'fiber_array': <function fiber_array at 0x7fe9c2d647c0>, 'crossing_arm': <function crossing_arm at 0x7fe9c2d671a0>, 'crossing': <function crossing at 0x7fe9c2d672e0>, 'crossing_linear_taper': <function crossing_linear_taper at 0x7fe9c2d67420>, 'crossing_etched': <function crossing_etched at 0x7fe9c2d67560>, 'crossing45': <function crossing45 at 0x7fe9c2d676a0>, 'straight_array': <function straight_array at 0x7fe9c2d67b00>, 'wire_straight': <function wire_straight at 0x7fe9c2d67c40>, 'straight_heater_doped_rib': <function straight_heater_doped_rib at 0x7fe9c2d98040>, 'straight_heater_doped_strip': <function straight_heater_doped_strip at 0x7fe9c2d98220>, 'straight_heater_meander': <function straight_heater_meander at 0x7fe9c2d98540>, 'via': <function via at 0x7fe9c2d98d60>, 'via_circular': <function via_circular at 0x7fe9c2d98ea0>, 'via_chain': <function via_chain at 0x7fe9c2d991c0>, 'via_corner': <function via_corner at 0x7fe9c2d993a0>, 'via_stack': <function via_stack at 0x7fe9c2d99580>, 'via_stack_corner45': <function via_stack_corner45 at 0x7fe9c2d996c0>, 'via_stack_corner45_extended': <function via_stack_corner45_extended at 0x7fe9c2d99800>, 'via_stack_with_offset': <function via_stack_with_offset at 0x7fe9c2d99940>, 'straight_heater_meander_doped': <function straight_heater_meander_doped at 0x7fe9c2d98a40>, 'straight_heater_metal_undercut': <function straight_heater_metal_undercut at 0x7fe9c2d998a0>, 'straight_heater_metal_simple': <function straight_heater_metal_simple at 0x7fe9c2d99bc0>, 'straight_piecewise': <function straight_piecewise at 0x7fe9c2d99d00>, 'straight_pin': <function straight_pin at 0x7fe9c2d99da0>, 'straight_pin_slot': <function straight_pin_slot at 0x7fe9c2d9a020>, 'wire_corner': <function wire_corner at 0x7fe9c2d9a2a0>, 'wire_corner45': <function wire_corner45 at 0x7fe9c2d9a3e0>, 'wire_corner_sections': <function wire_corner_sections at 0x7fe9c2d9a480>, 'loop_mirror': <function loop_mirror at 0x7fe9c2d649a0>, 'mode_converter': <function mode_converter at 0x7fe9c2d9bec0>, 'polarization_splitter_rotator': <function polarization_splitter_rotator at 0x7fe9c2dc8220>, 'terminator': <function terminator at 0x7fe9c2dc87c0>, 'grating_coupler_array': <function grating_coupler_array at 0x7fe9c2dc8a40>, 'grating_coupler_dual_pol': <function grating_coupler_dual_pol at 0x7fe9c2dc8d60>, 'grating_coupler_elliptical': <function grating_coupler_elliptical at 0x7fe9c2dc93a0>, 'grating_coupler_elliptical_arbitrary': <function grating_coupler_elliptical_arbitrary at 0x7fe9c2dc9620>, 'grating_coupler_elliptical_uniform': <function grating_coupler_elliptical_uniform at 0x7fe9c2dc98a0>, 'grating_coupler_elliptical_lumerical': <function grating_coupler_elliptical_lumerical at 0x7fe9c2dc99e0>, 'grating_coupler_elliptical_trenches': <function grating_coupler_elliptical_trenches at 0x7fe9c2dc8040>, 'grating_coupler_loss': <function grating_coupler_loss at 0x7fe9c2dc9bc0>, 'grating_coupler_rectangular': <function grating_coupler_rectangular at 0x7fe9c2dc9da0>, 'grating_coupler_rectangular_arbitrary': <function grating_coupler_rectangular_arbitrary at 0x7fe9c2dca020>, 'grating_coupler_tree': <function grating_coupler_tree at 0x7fe9c2dca2a0>, 'mmi': <function mmi at 0x7fe9c2dca5c0>, 'mmi1x2': <function mmi1x2 at 0x7fe9c2dca8e0>, 'mmi1x2_with_sbend': <function mmi1x2_with_sbend at 0x7fe9c2dcaac0>, 'mmi2x2': <function mmi2x2 at 0x7fe9c2dcade0>, 'mmi2x2_with_sbend': <function mmi2x2_with_sbend at 0x7fe9c2dcaf20>, 'mmi_90degree_hybrid': <function mmi_90degree_hybrid at 0x7fe9c2dcb100>, 'mmi_tapered': <function mmi_tapered at 0x7fe9c2dcb420>, 'pad': <function pad at 0x7fe9c2dcb6a0>, 'pad_array': <function pad_array at 0x7fe9c2dcb920>, 'pad_gsg_short': <function pad_gsg_short at 0x7fe9c2dcbba0>, 'pads_shorted': <function pads_shorted at 0x7fe9c2dcbe20>, 'rectangle_with_slits': <function rectangle_with_slits at 0x7fe9c2dcbf60>, 'cavity': <function cavity at 0x7fe9c2dec220>, 'cdsem_all': <function cdsem_all at 0x7fe9c2dec4a0>, 'cdsem_bend180': <function cdsem_bend180 at 0x7fe9c2dec680>, 'cdsem_coupler': <function cdsem_coupler at 0x7fe9c2dec7c0>, 'cdsem_straight': <function cdsem_straight at 0x7fe9c2decae0>, 'cdsem_straight_density': <function cdsem_straight_density at 0x7fe9c2decc20>, '_bendu_double': <function _bendu_double at 0x7fe9c2decea0>, '_straight_double': <function _straight_double at 0x7fe9c2decfe0>, 'cutback_2x2': <function cutback_2x2 at 0x7fe9c2ded120>, 'cutback_bend': <function cutback_bend at 0x7fe9c2ded4e0>, 'cutback_bend90': <function cutback_bend90 at 0x7fe9c2ded620>, 'staircase': <function staircase at 0x7fe9c2ded760>, 'cutback_bend180': <function cutback_bend180 at 0x7fe9c2ded8a0>, 'cutback_component': <function cutback_component at 0x7fe9c2ded9e0>, 'cutback_splitter': <function cutback_splitter at 0x7fe9c2dedda0>, 'greek_cross': <function greek_cross at 0x7fe9c2dedee0>, 'greek_cross_with_pads': <function greek_cross_with_pads at 0x7fe9c2dee160>, 'litho_calipers': <function litho_calipers at 0x7fe9c2dee340>, 'litho_ruler': <function litho_ruler at 0x7fe9c2dee660>, 'litho_steps': <function litho_steps at 0x7fe9c2dee840>, 'resistance_meander': <function resistance_meander at 0x7fe9c2dee980>, 'resistance_sheet': <function resistance_sheet at 0x7fe9c2deeb60>, 'verniers': <function verniers at 0x7fe9c2deed40>, 'text': <function text at 0x7fe9c2defa60>, 'text_lines': <function text_lines at 0x7fe9c2defc40>, 'text_klayout': <function text_klayout at 0x7fe9c2defd80>, 'text_freetype': <function text_freetype at 0x7fe9c2c340e0>, 'pixel_array': <function pixel_array at 0x7fe9c2c34360>, 'text_rectangular': <function text_rectangular at 0x7fe9c2c344a0>, 'text_rectangular_multi_layer': <function text_rectangular_multi_layer at 0x7fe9c2c345e0>, 'pixel': <function pixel at 0x7fe9c2def060>, 'qrcode': <function qrcode at 0x7fe9c2defce0>, 'version_stamp': <function version_stamp at 0x7fe9c2c34680>, 'disk': <function disk at 0x7fe9c2c34c20>, 'disk_heater': <function disk_heater at 0x7fe9c2c34d60>, 'ring': <function ring at 0x7fe9c2c34fe0>, 'ring_crow': <function ring_crow at 0x7fe9c2c351c0>, 'ring_crow_couplers': <function ring_crow_couplers at 0x7fe9c2c35300>, 'ring_double': <function ring_double at 0x7fe9c2c354e0>, 'ring_double_bend_coupler': <function ring_double_bend_coupler at 0x7fe9c2c35800>, 'ring_double_heater': <function ring_double_heater at 0x7fe9c2c35940>, 'ring_double_pn': <function ring_double_pn at 0x7fe9c2c35c60>, 'ring_single_pn': <function ring_single_pn at 0x7fe9c2c35da0>, 'ring_single': <function ring_single at 0x7fe9c2c35f80>, 'ring_single_array': <function ring_single_array at 0x7fe9c2c360c0>, 'coupler_bend': <function coupler_bend at 0x7fe9c2c36200>, 'coupler_ring_bend': <function coupler_ring_bend at 0x7fe9c2c36340>, 'ring_single_bend_coupler': <function ring_single_bend_coupler at 0x7fe9c2c36480>, 'ring_single_dut': <function ring_single_dut at 0x7fe9c2c36660>, 'delay_snake': <function delay_snake at 0x7fe9c2c368e0>, 'delay_snake2': <function delay_snake2 at 0x7fe9c2c36ac0>, 'delay_snake_sbend': <function delay_snake_sbend at 0x7fe9c2c36d40>, 'spiral': <function spiral at 0x7fe9c2c36fc0>, 'spiral_double': <function spiral_double at 0x7fe9c2c371a0>, 'spiral_racetrack': <function spiral_racetrack at 0x7fe9c2c37420>, 'spiral_racetrack_fixed_length': <function spiral_racetrack_fixed_length at 0x7fe9c2c37560>, 'spiral_racetrack_heater_metal': <function spiral_racetrack_heater_metal at 0x7fe9c2c37740>, 'spiral_racetrack_heater_doped': <function spiral_racetrack_heater_doped at 0x7fe9c2c37880>, 'spiral_inductor': <function spiral_inductor at 0x7fe9c2c379c0>, 'hline': <function hline at 0x7fe9c2c37c40>, 'optimal_90deg': <function optimal_90deg at 0x7fe9c2c37d80>, 'optimal_hairpin': <function optimal_hairpin at 0x7fe9c2c640e0>, 'optimal_step': <function optimal_step at 0x7fe9c2c64220>, 'snspd': <function snspd at 0x7fe9c2c64400>, 'interdigital_capacitor': <function interdigital_capacitor at 0x7fe9c2c645e0>, 'ge_detector_straight_si_contacts': <function ge_detector_straight_si_contacts at 0x7fe9c2c64860>, 'edge_coupler_silicon': <function edge_coupler_silicon at 0x7fe9c2c64ae0>, 'edge_coupler_array': <function edge_coupler_array at 0x7fe9c2c64c20>, 'edge_coupler_array_with_loopback': <function edge_coupler_array_with_loopback at 0x7fe9c2c64d60>, 'mzi_with_bend': <function mzi_with_bend at 0x7fe9a95f9440>}, virtual_factories={'virtual_bend_circular': <function virtual_bend_circular_factory.<locals>.virtual_bend_circular at 0x7fe9cd2cdc60>, 'bend_euler': <function virtual_bend_euler_factory.<locals>.bend_euler at 0x7fe9cd2cdee0>, 'virtual_straight': <function virtual_straight_factory.<locals>.virtual_straight at 0x7fe9cd2ce160>, 'bend_circular_all_angle': <function bend_circular_all_angle at 0x7fe9c31de660>, 'bend_euler_all_angle': <function bend_euler_all_angle at 0x7fe9c31df1a0>, 'straight_all_angle': <function straight_all_angle at 0x7fe9c2d679c0>}, kcells={0: Unnamed_0: ports [], 2 instances, 1: bend_euler_RNone_A90_P0_d7c3a5a9: ports ['o1', 'o2'], 0 instances, 2: mzi_DL10_LY2_LX0p1_Bben_4daac747: ports ['o1', 'o2'], 16 instances, 3: mmi1x2_WNone_WT1_LT10_L_4e0f7121: ports ['o1', 'o2', 'o3'], 0 instances, 4: taper_L10_W0p5_W1_LNone_456c7208: ports ['o1', 'o2'], 0 instances, 5: straight_L5p5_N2_CSxs_5_d3ec67bc: ports ['o1', 'o2'], 0 instances, 6: straight_L7_N2_CSstrip_WNone: ports ['o1', 'o2'], 0 instances, 7: straight_L0p1_N2_CSstrip_WNone: ports ['o1', 'o2'], 0 instances, 8: straight_L2_N2_CSstrip_WNone: ports ['o1', 'o2'], 0 instances, 9: bend_euler_R10_A90_P0p5_2f1f5c6d: ports ['o1', 'o2'], 0 instances, 10: mzi_with_bend_R10: ports [], 2 instances, 11: mzi_with_bend_R20: ports [], 2 instances, 12: bend_euler_R20_A90_P0p5_b207852f: ports ['o1', 'o2'], 0 instances}, layers=<aenum 'LAYER'>, infos=LayerInfos(), layer_stack=LayerStack(layers={}), netlist_layer_mapping={}, sparameters_path=None, interconnect_cml_path=None, constants=Constants(), rename_function=<function rename_clockwise_multi at 0x7fe9d888afc0>, info=Info(), settings=KCellSettings(version='0.23.2', klayout_version='0.29.11', meta_format='v3'), future_cell_name='mzi_with_bend_R10', decorators=<kfactory.decorators.Decorators object at 0x7fe9d8324a50>) function_name='mzi_with_bend' basename=None boundary=None insts=<gdsfactory.component.ComponentReferences object at 0x7fe9a95ebbd0> size_info=<kfactory.kcell.SizeInfo object at 0x7fe9a95ee190> dsize_info=<kfactory.kcell.DSizeInfo object at 0x7fe9a7d0b050> routes={}
Sometimes when you are changing the inside code of the function, you need to remove the component from the cache to make sure the code runs again.
This is useful when using jupyter notebooks or the file watcher.
@gf.cell
def wg(length=10, width=1, layer=(1, 0)):
print("BUILDING waveguide")
c = gf.Component()
c.info["area"] = width * length
c.add_polygon([(0, 0), (length, 0), (length, width), (0, width)], layer=layer)
c.add_port(
name="o1", center=(0, width / 2), width=width, orientation=180, layer=layer
)
c.add_port(
name="o2", center=(length, width / 2), width=width, orientation=0, layer=layer
)
return c
c = wg()
gf.clear_cache()
c = wg()
gf.clear_cache()
c = wg()
gf.clear_cache()
BUILDING waveguide
BUILDING waveguide
BUILDING waveguide
Another option is to just delete the cell after creating it.
c = wg(length=11)
c.delete()
c = wg(length=11)
BUILDING waveguide
BUILDING waveguide
Settings and Info#
Together with the GDS file that you send to the foundry you can also store the settings for each Component.
Component.settings
are the input settings for each Cell to Generate a Component. For example,wg.settings.length
will return you the inputlength
setting that you used to create that waveguide.Component.info
are the derived properties that will be computed inside the Cell function. For examplewg.info.area
will return the computed area of that waveguide.
c.info
Info(area=11)
c.info['area']
11
c.settings
KCellSettings(length=11, width=1, layer=(1, 0))
c.settings['length']
11
Components also have pretty print for ports c.pprint_ports()
c.pprint_ports()
┏━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━┓ ┃ name ┃ width ┃ orientation ┃ layer ┃ center ┃ port_type ┃ ┡━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━┩ │ o1 │ 1.0 │ 180.0 │ WG (1/0) │ (0.0, 0.5) │ optical │ │ o2 │ 1.0 │ 0.0 │ WG (1/0) │ (11.0, 0.5) │ optical │ └──────┴───────┴─────────────┴──────────┴─────────────┴───────────┘
# you always add any relevant information `info` to the cell
c.info["polarization"] = "te"
c.info["wavelength"] = 1.55
c.info
Info(area=11, polarization='te', wavelength=1.55)
Cache#
To avoid that 2 exact cells are not references of the same cell the cell
decorator has a cache where if a component has already been built it will return the component from the cache
@gf.cell
def straight(length=10, width=1):
c = gf.Component()
c.add_polygon([(0, 0), (length, 0), (length, width), (0, width)], layer=(1, 0))
print(f"BUILDING {length}um long straight waveguide")
return c
If you run the cell below multiple times it will print a message because we are deleting the CACHE every single time and every time the cell will have a different Unique Identifier (UID).
wg1 = straight()
id(wg1)
BUILDING 10um long straight waveguide
140641539276496
If you run the cell below multiple times it will NOT print a message because we are hitting CACHE every single time and every time the cell will have the SAME Unique Identifier (UID) because it’s the same cell.
wg2 = straight(length=10)
# cell returns the same straight as before without having to run the function
print(id(wg2)) # notice that they have the same uuid (unique identifier)
140641539276496
wg3 = straight(length=12)
wg4 = straight(length=13)
BUILDING 12um long straight waveguide
BUILDING 13um long straight waveguide
Create cells without cell
decorator#
The cell decorator names cells deterministically and uniquely based on the name of the functions and its parameters.
It also uses a caching mechanisms that improves performance and guards against duplicated names.
The most common mistake new gdsfactory users make is to create cells without the cell
decorator.
Avoid naming cells manually: Use cell decorator#
Naming cells manually is susceptible to name collisions
in GDS you can’t have two cells with the same name.
For example: this code will raise a duplicated cell name ValueError
import gdsfactory as gf
c1 = gf.Component("wg")
c1 << gf.components.straight(length=5)
c2 = gf.Component("wg")
c2 << gf.components.straight(length=50)
c3 = gf.Component("waveguides")
wg1 = c3 << c1
wg2 = c3 << c2
wg2.movey(10)
c3
Solution: Use the gf.cell
decorator for automatic naming your components.
import gdsfactory as gf
@gf.cell
def wg(length: float = 3):
return gf.components.straight(length=length)
gf.clear_cache()
print(wg(length=5).name)
print(wg(length=10).name)
wg_L5
wg_L10
Avoid Unnamed cells. Use cell
decorator#
In the case of not wrapping the function with cell
you will get unique names thanks to the unique identifier uuid
.
This name will be different and non-deterministic for different invocations of the script.
However it will be hard for you to know where that cell came from.
c1 = gf.Component()
c2 = gf.Component()
print(c1.name)
print(c2.name)
Unnamed_25
Unnamed_26
Notice how gdsfactory raises a Warning when you save this Unnamed
Components
c1.write_gds()
PosixPath('/tmp/gdsfactory/Unnamed_25.gds')
Avoid Intermediate Unnamed cells. Use cell
decorator#
While creating a cell, you should not create intermediate cells, because they won’t be Cached and you can end up with duplicated cell names or name conflicts, where one of the cells that has the same name as the other will be replaced.
@gf.cell
def die_bad():
"""c1 is an intermediate Unnamed cell"""
c1 = gf.Component() # this is an intermediate cell, it is not named as it is not returned by the function
_ = c1 << gf.components.straight(length=10)
return gf.components.die(size=(2e3, 2e3), street_width=10)
c = die_bad()
c.show()
c.plot()
Solution Don’t use intermediate cells
import gdsfactory as gf
# @gf.cell
def die_good():
c = gf.Component()
_ = c << gf.components.straight(length=10)
return gf.components.die(size=(2000,2000), street_width=10)
c = die_good()
c.plot()