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 0x7fbba253c9b0>, 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 0x7fbba253c050>, factories={'taper': <function taper at 0x7fbb94df7f60>, 'bend_s_bezier': <function bend_s_bezier_factory.<locals>.bend_s_bezier at 0x7fbb972067a0>, 'bend_circular': <function bend_circular at 0x7fbb94df63e0>, 'bend_euler': <function bend_euler at 0x7fbb94df6de0>, 'bend_s_euler': <function bend_s_euler_factory.<locals>.bend_s_euler at 0x7fbb9721cd60>, 'straight': <function straight at 0x7fbb94983740>, 'rotate': <function rotate at 0x7fbb95498f40>, 'from_image': <function from_image at 0x7fbb953b6de0>, 'floorplan_with_block_letters': <function floorplan_with_block_letters at 0x7fbb94d699e0>, 'bend_circular_heater': <function bend_circular_heater at 0x7fbb94df6660>, 'bend_euler_s': <function bend_euler_s at 0x7fbb94df6ca0>, 'bezier': <function bezier at 0x7fbb94df7380>, 'bend_s': <function bend_s at 0x7fbb94df7560>, 'add_fiber_array_optical_south_electrical_north': <function add_fiber_array_optical_south_electrical_north at 0x7fbb94df77e0>, 'ramp': <function ramp at 0x7fbb94df7ce0>, 'taper_strip_to_ridge': <function taper_strip_to_ridge at 0x7fbb94920040>, 'taper_strip_to_ridge_trenches': <function taper_strip_to_ridge_trenches at 0x7fbb949202c0>, 'taper_sc_nc': <function taper_sc_nc at 0x7fbb94920400>, 'taper_adiabatic': <function taper_adiabatic at 0x7fbb94920720>, 'taper_cross_section': <function taper_cross_section at 0x7fbb94920900>, 'taper_from_csv': <function taper_from_csv at 0x7fbb94920ae0>, 'taper_parabolic': <function taper_parabolic at 0x7fbb94920c20>, 'add_termination': <function add_termination at 0x7fbb94df7920>, 'add_trenches': <function add_trenches at 0x7fbb94920a40>, 'array': <function array at 0x7fbb94920e00>, 'copy_layers': <function copy_layers at 0x7fbb94921300>, 'extend_ports_list': <function extend_ports_list at 0x7fbb94921440>, 'extend_ports': <function extend_ports at 0x7fbb94921760>, 'pack_doe': <function pack_doe at 0x7fbb94921f80>, 'pack_doe_grid': <function pack_doe_grid at 0x7fbb949220c0>, 'splitter_chain': <function splitter_chain at 0x7fbb94922200>, 'mzi': <function mzi at 0x7fbb949227a0>, 'mzi_lattice': <function mzi_lattice at 0x7fbb94922ac0>, 'mzi_lattice_mmi': <function mzi_lattice_mmi at 0x7fbb94922c00>, 'mzi_pads_center': <function mzi_pads_center at 0x7fbb94922e80>, 'mzit': <function mzit at 0x7fbb94923060>, 'mzit_lattice': <function mzit_lattice at 0x7fbb949231a0>, 'splitter_tree': <function splitter_tree at 0x7fbb94922d40>, 'coupler_symmetric': <function coupler_symmetric at 0x7fbb94923380>, 'coupler_straight': <function coupler_straight at 0x7fbb949234c0>, 'coupler': <function coupler at 0x7fbb94923600>, 'coupler90': <function coupler90 at 0x7fbb949237e0>, 'coupler90bend': <function coupler90bend at 0x7fbb94923880>, 'coupler_adiabatic': <function coupler_adiabatic at 0x7fbb94923ba0>, 'coupler_asymmetric': <function coupler_asymmetric at 0x7fbb94923e20>, 'coupler_bent_half': <function coupler_bent_half at 0x7fbb9494c180>, 'coupler_bent': <function coupler_bent at 0x7fbb9494c2c0>, 'coupler_broadband': <function coupler_broadband at 0x7fbb9494c540>, 'coupler_full': <function coupler_full at 0x7fbb9494c720>, 'coupler_ring': <function coupler_ring at 0x7fbb9494c9a0>, 'coupler_straight_asymmetric': <function coupler_straight_asymmetric at 0x7fbb9494cc20>, 'align_wafer': <function align_wafer at 0x7fbb9494cfe0>, 'add_frame': <function add_frame at 0x7fbb9494d080>, 'die': <function die at 0x7fbb9494d3a0>, 'die_with_pads': <function die_with_pads at 0x7fbb9494d580>, 'seal_ring': <function seal_ring at 0x7fbb9494d760>, 'seal_ring_segmented': <function seal_ring_segmented at 0x7fbb9494d8a0>, 'wafer': <function wafer at 0x7fbb9494da80>, 'free_propagation_region': <function free_propagation_region at 0x7fbb9494dee0>, 'awg': <function awg at 0x7fbb9494df80>, 'dbr_cell': <function dbr_cell at 0x7fbb9494e2a0>, 'dbr': <function dbr at 0x7fbb9494e3e0>, 'dbr_tapered': <function dbr_tapered at 0x7fbb9494e660>, 'bbox': <function bbox at 0x7fbb9494ede0>, 'C': <function C at 0x7fbb9494efc0>, 'circle': <function circle at 0x7fbb9494f1a0>, 'compass': <function compass at 0x7fbb9494f420>, 'cross': <function cross at 0x7fbb9494f600>, 'ellipse': <function ellipse at 0x7fbb9494f7e0>, 'fiducial_squares': <function fiducial_squares at 0x7fbb9494f920>, 'L': <function L at 0x7fbb9494fb00>, 'nxn': <function nxn at 0x7fbb9494fce0>, 'rectangle': <function rectangle at 0x7fbb9494fec0>, 'rectangles': <function rectangles at 0x7fbb9494ff60>, 'regular_polygon': <function regular_polygon at 0x7fbb94980180>, 'triangle': <function triangle at 0x7fbb94980360>, 'triangle2': <function triangle2 at 0x7fbb949804a0>, 'triangle4': <function triangle4 at 0x7fbb949805e0>, 'fiber': <function fiber at 0x7fbb9494e980>, 'fiber_array': <function fiber_array at 0x7fbb94980680>, 'crossing_arm': <function crossing_arm at 0x7fbb94983060>, 'crossing': <function crossing at 0x7fbb949831a0>, 'crossing_linear_taper': <function crossing_linear_taper at 0x7fbb949832e0>, 'crossing_etched': <function crossing_etched at 0x7fbb94983420>, 'crossing45': <function crossing45 at 0x7fbb94983560>, 'straight_array': <function straight_array at 0x7fbb949839c0>, 'wire_straight': <function wire_straight at 0x7fbb94983b00>, 'straight_heater_doped_rib': <function straight_heater_doped_rib at 0x7fbb94983ec0>, 'straight_heater_doped_strip': <function straight_heater_doped_strip at 0x7fbb949ac0e0>, 'straight_heater_meander': <function straight_heater_meander at 0x7fbb949ac400>, 'via': <function via at 0x7fbb949acc20>, 'via_circular': <function via_circular at 0x7fbb949acd60>, 'via_chain': <function via_chain at 0x7fbb949ad080>, 'via_corner': <function via_corner at 0x7fbb949ad260>, 'via_stack': <function via_stack at 0x7fbb949ad440>, 'via_stack_corner45': <function via_stack_corner45 at 0x7fbb949ad580>, 'via_stack_corner45_extended': <function via_stack_corner45_extended at 0x7fbb949ad6c0>, 'via_stack_with_offset': <function via_stack_with_offset at 0x7fbb949ad800>, 'straight_heater_meander_doped': <function straight_heater_meander_doped at 0x7fbb949ac900>, 'straight_heater_metal_undercut': <function straight_heater_metal_undercut at 0x7fbb949ad760>, 'straight_heater_metal_simple': <function straight_heater_metal_simple at 0x7fbb949ada80>, 'straight_piecewise': <function straight_piecewise at 0x7fbb949adbc0>, 'straight_pin': <function straight_pin at 0x7fbb949adc60>, 'straight_pin_slot': <function straight_pin_slot at 0x7fbb949adee0>, 'wire_corner': <function wire_corner at 0x7fbb949ae160>, 'wire_corner45': <function wire_corner45 at 0x7fbb949ae2a0>, 'wire_corner_sections': <function wire_corner_sections at 0x7fbb949ae340>, 'loop_mirror': <function loop_mirror at 0x7fbb94980860>, 'mode_converter': <function mode_converter at 0x7fbb949afd80>, 'polarization_splitter_rotator': <function polarization_splitter_rotator at 0x7fbb949d80e0>, 'terminator': <function terminator at 0x7fbb949d8680>, 'grating_coupler_array': <function grating_coupler_array at 0x7fbb949d8900>, 'grating_coupler_dual_pol': <function grating_coupler_dual_pol at 0x7fbb949d8c20>, 'grating_coupler_elliptical': <function grating_coupler_elliptical at 0x7fbb949d9260>, 'grating_coupler_elliptical_arbitrary': <function grating_coupler_elliptical_arbitrary at 0x7fbb949d94e0>, 'grating_coupler_elliptical_uniform': <function grating_coupler_elliptical_uniform at 0x7fbb949d9760>, 'grating_coupler_elliptical_lumerical': <function grating_coupler_elliptical_lumerical at 0x7fbb949d98a0>, 'grating_coupler_elliptical_trenches': <function grating_coupler_elliptical_trenches at 0x7fbb949d8cc0>, 'grating_coupler_loss': <function grating_coupler_loss at 0x7fbb949d9a80>, 'grating_coupler_rectangular': <function grating_coupler_rectangular at 0x7fbb949d9c60>, 'grating_coupler_rectangular_arbitrary': <function grating_coupler_rectangular_arbitrary at 0x7fbb949d9ee0>, 'grating_coupler_tree': <function grating_coupler_tree at 0x7fbb949da160>, 'mmi': <function mmi at 0x7fbb949da480>, 'mmi1x2': <function mmi1x2 at 0x7fbb949da7a0>, 'mmi1x2_with_sbend': <function mmi1x2_with_sbend at 0x7fbb949da980>, 'mmi2x2': <function mmi2x2 at 0x7fbb949daca0>, 'mmi2x2_with_sbend': <function mmi2x2_with_sbend at 0x7fbb949dade0>, 'mmi_90degree_hybrid': <function mmi_90degree_hybrid at 0x7fbb949dafc0>, 'mmi_tapered': <function mmi_tapered at 0x7fbb949db2e0>, 'pad': <function pad at 0x7fbb949db560>, 'pad_array': <function pad_array at 0x7fbb949db7e0>, 'pad_gsg_short': <function pad_gsg_short at 0x7fbb949dba60>, 'pads_shorted': <function pads_shorted at 0x7fbb949dbce0>, 'rectangle_with_slits': <function rectangle_with_slits at 0x7fbb949dbe20>, 'cavity': <function cavity at 0x7fbb948000e0>, 'cdsem_all': <function cdsem_all at 0x7fbb94800360>, 'cdsem_bend180': <function cdsem_bend180 at 0x7fbb94800540>, 'cdsem_coupler': <function cdsem_coupler at 0x7fbb94800680>, 'cdsem_straight': <function cdsem_straight at 0x7fbb948009a0>, 'cdsem_straight_density': <function cdsem_straight_density at 0x7fbb94800ae0>, 'bendu_double': <function bendu_double at 0x7fbb94800d60>, 'straight_double': <function straight_double at 0x7fbb94800ea0>, 'cutback_2x2': <function cutback_2x2 at 0x7fbb94800fe0>, 'cutback_bend': <function cutback_bend at 0x7fbb948013a0>, 'cutback_bend90': <function cutback_bend90 at 0x7fbb948014e0>, 'staircase': <function staircase at 0x7fbb94801620>, 'cutback_bend180': <function cutback_bend180 at 0x7fbb94801760>, 'cutback_component': <function cutback_component at 0x7fbb948018a0>, 'cutback_splitter': <function cutback_splitter at 0x7fbb94801c60>, 'greek_cross': <function greek_cross at 0x7fbb94801da0>, 'greek_cross_with_pads': <function greek_cross_with_pads at 0x7fbb94802020>, 'litho_calipers': <function litho_calipers at 0x7fbb94802200>, 'litho_ruler': <function litho_ruler at 0x7fbb94802520>, 'litho_steps': <function litho_steps at 0x7fbb94802700>, 'resistance_meander': <function resistance_meander at 0x7fbb94802840>, 'resistance_sheet': <function resistance_sheet at 0x7fbb94802a20>, 'verniers': <function verniers at 0x7fbb94802c00>, 'text': <function text at 0x7fbb94803920>, 'text_lines': <function text_lines at 0x7fbb94803b00>, 'text_klayout': <function text_klayout at 0x7fbb94803c40>, 'text_freetype': <function text_freetype at 0x7fbb94803f60>, 'pixel_array': <function pixel_array at 0x7fbb94848220>, 'text_rectangular': <function text_rectangular at 0x7fbb94848360>, 'text_rectangular_multi_layer': <function text_rectangular_multi_layer at 0x7fbb948484a0>, 'pixel': <function pixel at 0x7fbb94802f20>, 'qrcode': <function qrcode at 0x7fbb94803ba0>, 'version_stamp': <function version_stamp at 0x7fbb94848540>, 'disk': <function disk at 0x7fbb94848ae0>, 'disk_heater': <function disk_heater at 0x7fbb94848c20>, 'ring': <function ring at 0x7fbb94848ea0>, 'ring_crow': <function ring_crow at 0x7fbb94849080>, 'ring_crow_couplers': <function ring_crow_couplers at 0x7fbb948491c0>, 'ring_double': <function ring_double at 0x7fbb948493a0>, 'ring_double_bend_coupler': <function ring_double_bend_coupler at 0x7fbb948496c0>, 'ring_double_heater': <function ring_double_heater at 0x7fbb94849800>, 'ring_double_pn': <function ring_double_pn at 0x7fbb94849b20>, 'ring_single_pn': <function ring_single_pn at 0x7fbb94849c60>, 'ring_single': <function ring_single at 0x7fbb94849e40>, 'ring_single_array': <function ring_single_array at 0x7fbb94849f80>, 'coupler_bend': <function coupler_bend at 0x7fbb9484a0c0>, 'coupler_ring_bend': <function coupler_ring_bend at 0x7fbb9484a200>, 'ring_single_bend_coupler': <function ring_single_bend_coupler at 0x7fbb9484a340>, 'ring_single_dut': <function ring_single_dut at 0x7fbb9484a520>, 'delay_snake': <function delay_snake at 0x7fbb9484a7a0>, 'delay_snake2': <function delay_snake2 at 0x7fbb9484a980>, 'delay_snake_sbend': <function delay_snake_sbend at 0x7fbb9484ac00>, 'spiral': <function spiral at 0x7fbb9484ae80>, 'spiral_double': <function spiral_double at 0x7fbb9484b060>, 'spiral_racetrack': <function spiral_racetrack at 0x7fbb9484b2e0>, 'spiral_racetrack_fixed_length': <function spiral_racetrack_fixed_length at 0x7fbb9484b420>, 'spiral_racetrack_heater_metal': <function spiral_racetrack_heater_metal at 0x7fbb9484b600>, 'spiral_racetrack_heater_doped': <function spiral_racetrack_heater_doped at 0x7fbb9484b740>, 'spiral_inductor': <function spiral_inductor at 0x7fbb9484b880>, 'hline': <function hline at 0x7fbb9484bb00>, 'optimal_90deg': <function optimal_90deg at 0x7fbb9484bc40>, 'optimal_hairpin': <function optimal_hairpin at 0x7fbb9484bf60>, 'optimal_step': <function optimal_step at 0x7fbb9487c0e0>, 'snspd': <function snspd at 0x7fbb9487c2c0>, 'interdigital_capacitor': <function interdigital_capacitor at 0x7fbb9487c4a0>, 'ge_detector_straight_si_contacts': <function ge_detector_straight_si_contacts at 0x7fbb9487c720>, 'edge_coupler_silicon': <function edge_coupler_silicon at 0x7fbb9487c9a0>, 'edge_coupler_array': <function edge_coupler_array at 0x7fbb9487cae0>, 'edge_coupler_array_with_loopback': <function edge_coupler_array_with_loopback at 0x7fbb9487cc20>, 'mzi_with_bend': <function mzi_with_bend at 0x7fbb78029f80>}, virtual_factories={'virtual_bend_circular': <function virtual_bend_circular_factory.<locals>.virtual_bend_circular at 0x7fbb9721dc60>, 'bend_euler': <function virtual_bend_euler_factory.<locals>.bend_euler at 0x7fbb9721dee0>, 'virtual_straight': <function virtual_straight_factory.<locals>.virtual_straight at 0x7fbb9721e160>, 'bend_circular_all_angle': <function bend_circular_all_angle at 0x7fbb94df6520>, 'bend_euler_all_angle': <function bend_euler_all_angle at 0x7fbb94df7060>, 'straight_all_angle': <function straight_all_angle at 0x7fbb94983880>}, 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 0x7fbba272afc0>, info=Info(), settings=KCellSettings(version='0.23.1', klayout_version='0.29.11', meta_format='v3'), future_cell_name='mzi_with_bend_R10', decorators=<kfactory.decorators.Decorators object at 0x7fbba27ea7d0>) function_name='mzi_with_bend' basename=None boundary=None insts=<gdsfactory.component.ComponentReferences object at 0x7fbb6bf39090> size_info=<kfactory.kcell.SizeInfo object at 0x7fbb897a2750> dsize_info=<kfactory.kcell.DSizeInfo object at 0x7fbb897a2950> routes={}
second time you get this cell from the cache
vinsts=[] info=Info() kcl=KCLayout(name='DEFAULT', layout=<klayout.dbcore.Layout object at 0x7fbba253c9b0>, 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 0x7fbba253c050>, factories={'taper': <function taper at 0x7fbb94df7f60>, 'bend_s_bezier': <function bend_s_bezier_factory.<locals>.bend_s_bezier at 0x7fbb972067a0>, 'bend_circular': <function bend_circular at 0x7fbb94df63e0>, 'bend_euler': <function bend_euler at 0x7fbb94df6de0>, 'bend_s_euler': <function bend_s_euler_factory.<locals>.bend_s_euler at 0x7fbb9721cd60>, 'straight': <function straight at 0x7fbb94983740>, 'rotate': <function rotate at 0x7fbb95498f40>, 'from_image': <function from_image at 0x7fbb953b6de0>, 'floorplan_with_block_letters': <function floorplan_with_block_letters at 0x7fbb94d699e0>, 'bend_circular_heater': <function bend_circular_heater at 0x7fbb94df6660>, 'bend_euler_s': <function bend_euler_s at 0x7fbb94df6ca0>, 'bezier': <function bezier at 0x7fbb94df7380>, 'bend_s': <function bend_s at 0x7fbb94df7560>, 'add_fiber_array_optical_south_electrical_north': <function add_fiber_array_optical_south_electrical_north at 0x7fbb94df77e0>, 'ramp': <function ramp at 0x7fbb94df7ce0>, 'taper_strip_to_ridge': <function taper_strip_to_ridge at 0x7fbb94920040>, 'taper_strip_to_ridge_trenches': <function taper_strip_to_ridge_trenches at 0x7fbb949202c0>, 'taper_sc_nc': <function taper_sc_nc at 0x7fbb94920400>, 'taper_adiabatic': <function taper_adiabatic at 0x7fbb94920720>, 'taper_cross_section': <function taper_cross_section at 0x7fbb94920900>, 'taper_from_csv': <function taper_from_csv at 0x7fbb94920ae0>, 'taper_parabolic': <function taper_parabolic at 0x7fbb94920c20>, 'add_termination': <function add_termination at 0x7fbb94df7920>, 'add_trenches': <function add_trenches at 0x7fbb94920a40>, 'array': <function array at 0x7fbb94920e00>, 'copy_layers': <function copy_layers at 0x7fbb94921300>, 'extend_ports_list': <function extend_ports_list at 0x7fbb94921440>, 'extend_ports': <function extend_ports at 0x7fbb94921760>, 'pack_doe': <function pack_doe at 0x7fbb94921f80>, 'pack_doe_grid': <function pack_doe_grid at 0x7fbb949220c0>, 'splitter_chain': <function splitter_chain at 0x7fbb94922200>, 'mzi': <function mzi at 0x7fbb949227a0>, 'mzi_lattice': <function mzi_lattice at 0x7fbb94922ac0>, 'mzi_lattice_mmi': <function mzi_lattice_mmi at 0x7fbb94922c00>, 'mzi_pads_center': <function mzi_pads_center at 0x7fbb94922e80>, 'mzit': <function mzit at 0x7fbb94923060>, 'mzit_lattice': <function mzit_lattice at 0x7fbb949231a0>, 'splitter_tree': <function splitter_tree at 0x7fbb94922d40>, 'coupler_symmetric': <function coupler_symmetric at 0x7fbb94923380>, 'coupler_straight': <function coupler_straight at 0x7fbb949234c0>, 'coupler': <function coupler at 0x7fbb94923600>, 'coupler90': <function coupler90 at 0x7fbb949237e0>, 'coupler90bend': <function coupler90bend at 0x7fbb94923880>, 'coupler_adiabatic': <function coupler_adiabatic at 0x7fbb94923ba0>, 'coupler_asymmetric': <function coupler_asymmetric at 0x7fbb94923e20>, 'coupler_bent_half': <function coupler_bent_half at 0x7fbb9494c180>, 'coupler_bent': <function coupler_bent at 0x7fbb9494c2c0>, 'coupler_broadband': <function coupler_broadband at 0x7fbb9494c540>, 'coupler_full': <function coupler_full at 0x7fbb9494c720>, 'coupler_ring': <function coupler_ring at 0x7fbb9494c9a0>, 'coupler_straight_asymmetric': <function coupler_straight_asymmetric at 0x7fbb9494cc20>, 'align_wafer': <function align_wafer at 0x7fbb9494cfe0>, 'add_frame': <function add_frame at 0x7fbb9494d080>, 'die': <function die at 0x7fbb9494d3a0>, 'die_with_pads': <function die_with_pads at 0x7fbb9494d580>, 'seal_ring': <function seal_ring at 0x7fbb9494d760>, 'seal_ring_segmented': <function seal_ring_segmented at 0x7fbb9494d8a0>, 'wafer': <function wafer at 0x7fbb9494da80>, 'free_propagation_region': <function free_propagation_region at 0x7fbb9494dee0>, 'awg': <function awg at 0x7fbb9494df80>, 'dbr_cell': <function dbr_cell at 0x7fbb9494e2a0>, 'dbr': <function dbr at 0x7fbb9494e3e0>, 'dbr_tapered': <function dbr_tapered at 0x7fbb9494e660>, 'bbox': <function bbox at 0x7fbb9494ede0>, 'C': <function C at 0x7fbb9494efc0>, 'circle': <function circle at 0x7fbb9494f1a0>, 'compass': <function compass at 0x7fbb9494f420>, 'cross': <function cross at 0x7fbb9494f600>, 'ellipse': <function ellipse at 0x7fbb9494f7e0>, 'fiducial_squares': <function fiducial_squares at 0x7fbb9494f920>, 'L': <function L at 0x7fbb9494fb00>, 'nxn': <function nxn at 0x7fbb9494fce0>, 'rectangle': <function rectangle at 0x7fbb9494fec0>, 'rectangles': <function rectangles at 0x7fbb9494ff60>, 'regular_polygon': <function regular_polygon at 0x7fbb94980180>, 'triangle': <function triangle at 0x7fbb94980360>, 'triangle2': <function triangle2 at 0x7fbb949804a0>, 'triangle4': <function triangle4 at 0x7fbb949805e0>, 'fiber': <function fiber at 0x7fbb9494e980>, 'fiber_array': <function fiber_array at 0x7fbb94980680>, 'crossing_arm': <function crossing_arm at 0x7fbb94983060>, 'crossing': <function crossing at 0x7fbb949831a0>, 'crossing_linear_taper': <function crossing_linear_taper at 0x7fbb949832e0>, 'crossing_etched': <function crossing_etched at 0x7fbb94983420>, 'crossing45': <function crossing45 at 0x7fbb94983560>, 'straight_array': <function straight_array at 0x7fbb949839c0>, 'wire_straight': <function wire_straight at 0x7fbb94983b00>, 'straight_heater_doped_rib': <function straight_heater_doped_rib at 0x7fbb94983ec0>, 'straight_heater_doped_strip': <function straight_heater_doped_strip at 0x7fbb949ac0e0>, 'straight_heater_meander': <function straight_heater_meander at 0x7fbb949ac400>, 'via': <function via at 0x7fbb949acc20>, 'via_circular': <function via_circular at 0x7fbb949acd60>, 'via_chain': <function via_chain at 0x7fbb949ad080>, 'via_corner': <function via_corner at 0x7fbb949ad260>, 'via_stack': <function via_stack at 0x7fbb949ad440>, 'via_stack_corner45': <function via_stack_corner45 at 0x7fbb949ad580>, 'via_stack_corner45_extended': <function via_stack_corner45_extended at 0x7fbb949ad6c0>, 'via_stack_with_offset': <function via_stack_with_offset at 0x7fbb949ad800>, 'straight_heater_meander_doped': <function straight_heater_meander_doped at 0x7fbb949ac900>, 'straight_heater_metal_undercut': <function straight_heater_metal_undercut at 0x7fbb949ad760>, 'straight_heater_metal_simple': <function straight_heater_metal_simple at 0x7fbb949ada80>, 'straight_piecewise': <function straight_piecewise at 0x7fbb949adbc0>, 'straight_pin': <function straight_pin at 0x7fbb949adc60>, 'straight_pin_slot': <function straight_pin_slot at 0x7fbb949adee0>, 'wire_corner': <function wire_corner at 0x7fbb949ae160>, 'wire_corner45': <function wire_corner45 at 0x7fbb949ae2a0>, 'wire_corner_sections': <function wire_corner_sections at 0x7fbb949ae340>, 'loop_mirror': <function loop_mirror at 0x7fbb94980860>, 'mode_converter': <function mode_converter at 0x7fbb949afd80>, 'polarization_splitter_rotator': <function polarization_splitter_rotator at 0x7fbb949d80e0>, 'terminator': <function terminator at 0x7fbb949d8680>, 'grating_coupler_array': <function grating_coupler_array at 0x7fbb949d8900>, 'grating_coupler_dual_pol': <function grating_coupler_dual_pol at 0x7fbb949d8c20>, 'grating_coupler_elliptical': <function grating_coupler_elliptical at 0x7fbb949d9260>, 'grating_coupler_elliptical_arbitrary': <function grating_coupler_elliptical_arbitrary at 0x7fbb949d94e0>, 'grating_coupler_elliptical_uniform': <function grating_coupler_elliptical_uniform at 0x7fbb949d9760>, 'grating_coupler_elliptical_lumerical': <function grating_coupler_elliptical_lumerical at 0x7fbb949d98a0>, 'grating_coupler_elliptical_trenches': <function grating_coupler_elliptical_trenches at 0x7fbb949d8cc0>, 'grating_coupler_loss': <function grating_coupler_loss at 0x7fbb949d9a80>, 'grating_coupler_rectangular': <function grating_coupler_rectangular at 0x7fbb949d9c60>, 'grating_coupler_rectangular_arbitrary': <function grating_coupler_rectangular_arbitrary at 0x7fbb949d9ee0>, 'grating_coupler_tree': <function grating_coupler_tree at 0x7fbb949da160>, 'mmi': <function mmi at 0x7fbb949da480>, 'mmi1x2': <function mmi1x2 at 0x7fbb949da7a0>, 'mmi1x2_with_sbend': <function mmi1x2_with_sbend at 0x7fbb949da980>, 'mmi2x2': <function mmi2x2 at 0x7fbb949daca0>, 'mmi2x2_with_sbend': <function mmi2x2_with_sbend at 0x7fbb949dade0>, 'mmi_90degree_hybrid': <function mmi_90degree_hybrid at 0x7fbb949dafc0>, 'mmi_tapered': <function mmi_tapered at 0x7fbb949db2e0>, 'pad': <function pad at 0x7fbb949db560>, 'pad_array': <function pad_array at 0x7fbb949db7e0>, 'pad_gsg_short': <function pad_gsg_short at 0x7fbb949dba60>, 'pads_shorted': <function pads_shorted at 0x7fbb949dbce0>, 'rectangle_with_slits': <function rectangle_with_slits at 0x7fbb949dbe20>, 'cavity': <function cavity at 0x7fbb948000e0>, 'cdsem_all': <function cdsem_all at 0x7fbb94800360>, 'cdsem_bend180': <function cdsem_bend180 at 0x7fbb94800540>, 'cdsem_coupler': <function cdsem_coupler at 0x7fbb94800680>, 'cdsem_straight': <function cdsem_straight at 0x7fbb948009a0>, 'cdsem_straight_density': <function cdsem_straight_density at 0x7fbb94800ae0>, 'bendu_double': <function bendu_double at 0x7fbb94800d60>, 'straight_double': <function straight_double at 0x7fbb94800ea0>, 'cutback_2x2': <function cutback_2x2 at 0x7fbb94800fe0>, 'cutback_bend': <function cutback_bend at 0x7fbb948013a0>, 'cutback_bend90': <function cutback_bend90 at 0x7fbb948014e0>, 'staircase': <function staircase at 0x7fbb94801620>, 'cutback_bend180': <function cutback_bend180 at 0x7fbb94801760>, 'cutback_component': <function cutback_component at 0x7fbb948018a0>, 'cutback_splitter': <function cutback_splitter at 0x7fbb94801c60>, 'greek_cross': <function greek_cross at 0x7fbb94801da0>, 'greek_cross_with_pads': <function greek_cross_with_pads at 0x7fbb94802020>, 'litho_calipers': <function litho_calipers at 0x7fbb94802200>, 'litho_ruler': <function litho_ruler at 0x7fbb94802520>, 'litho_steps': <function litho_steps at 0x7fbb94802700>, 'resistance_meander': <function resistance_meander at 0x7fbb94802840>, 'resistance_sheet': <function resistance_sheet at 0x7fbb94802a20>, 'verniers': <function verniers at 0x7fbb94802c00>, 'text': <function text at 0x7fbb94803920>, 'text_lines': <function text_lines at 0x7fbb94803b00>, 'text_klayout': <function text_klayout at 0x7fbb94803c40>, 'text_freetype': <function text_freetype at 0x7fbb94803f60>, 'pixel_array': <function pixel_array at 0x7fbb94848220>, 'text_rectangular': <function text_rectangular at 0x7fbb94848360>, 'text_rectangular_multi_layer': <function text_rectangular_multi_layer at 0x7fbb948484a0>, 'pixel': <function pixel at 0x7fbb94802f20>, 'qrcode': <function qrcode at 0x7fbb94803ba0>, 'version_stamp': <function version_stamp at 0x7fbb94848540>, 'disk': <function disk at 0x7fbb94848ae0>, 'disk_heater': <function disk_heater at 0x7fbb94848c20>, 'ring': <function ring at 0x7fbb94848ea0>, 'ring_crow': <function ring_crow at 0x7fbb94849080>, 'ring_crow_couplers': <function ring_crow_couplers at 0x7fbb948491c0>, 'ring_double': <function ring_double at 0x7fbb948493a0>, 'ring_double_bend_coupler': <function ring_double_bend_coupler at 0x7fbb948496c0>, 'ring_double_heater': <function ring_double_heater at 0x7fbb94849800>, 'ring_double_pn': <function ring_double_pn at 0x7fbb94849b20>, 'ring_single_pn': <function ring_single_pn at 0x7fbb94849c60>, 'ring_single': <function ring_single at 0x7fbb94849e40>, 'ring_single_array': <function ring_single_array at 0x7fbb94849f80>, 'coupler_bend': <function coupler_bend at 0x7fbb9484a0c0>, 'coupler_ring_bend': <function coupler_ring_bend at 0x7fbb9484a200>, 'ring_single_bend_coupler': <function ring_single_bend_coupler at 0x7fbb9484a340>, 'ring_single_dut': <function ring_single_dut at 0x7fbb9484a520>, 'delay_snake': <function delay_snake at 0x7fbb9484a7a0>, 'delay_snake2': <function delay_snake2 at 0x7fbb9484a980>, 'delay_snake_sbend': <function delay_snake_sbend at 0x7fbb9484ac00>, 'spiral': <function spiral at 0x7fbb9484ae80>, 'spiral_double': <function spiral_double at 0x7fbb9484b060>, 'spiral_racetrack': <function spiral_racetrack at 0x7fbb9484b2e0>, 'spiral_racetrack_fixed_length': <function spiral_racetrack_fixed_length at 0x7fbb9484b420>, 'spiral_racetrack_heater_metal': <function spiral_racetrack_heater_metal at 0x7fbb9484b600>, 'spiral_racetrack_heater_doped': <function spiral_racetrack_heater_doped at 0x7fbb9484b740>, 'spiral_inductor': <function spiral_inductor at 0x7fbb9484b880>, 'hline': <function hline at 0x7fbb9484bb00>, 'optimal_90deg': <function optimal_90deg at 0x7fbb9484bc40>, 'optimal_hairpin': <function optimal_hairpin at 0x7fbb9484bf60>, 'optimal_step': <function optimal_step at 0x7fbb9487c0e0>, 'snspd': <function snspd at 0x7fbb9487c2c0>, 'interdigital_capacitor': <function interdigital_capacitor at 0x7fbb9487c4a0>, 'ge_detector_straight_si_contacts': <function ge_detector_straight_si_contacts at 0x7fbb9487c720>, 'edge_coupler_silicon': <function edge_coupler_silicon at 0x7fbb9487c9a0>, 'edge_coupler_array': <function edge_coupler_array at 0x7fbb9487cae0>, 'edge_coupler_array_with_loopback': <function edge_coupler_array_with_loopback at 0x7fbb9487cc20>, 'mzi_with_bend': <function mzi_with_bend at 0x7fbb78029f80>}, virtual_factories={'virtual_bend_circular': <function virtual_bend_circular_factory.<locals>.virtual_bend_circular at 0x7fbb9721dc60>, 'bend_euler': <function virtual_bend_euler_factory.<locals>.bend_euler at 0x7fbb9721dee0>, 'virtual_straight': <function virtual_straight_factory.<locals>.virtual_straight at 0x7fbb9721e160>, 'bend_circular_all_angle': <function bend_circular_all_angle at 0x7fbb94df6520>, 'bend_euler_all_angle': <function bend_euler_all_angle at 0x7fbb94df7060>, 'straight_all_angle': <function straight_all_angle at 0x7fbb94983880>}, 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 0x7fbba272afc0>, info=Info(), settings=KCellSettings(version='0.23.1', klayout_version='0.29.11', meta_format='v3'), future_cell_name='mzi_with_bend_R10', decorators=<kfactory.decorators.Decorators object at 0x7fbba27ea7d0>) function_name='mzi_with_bend' basename=None boundary=None insts=<gdsfactory.component.ComponentReferences object at 0x7fbb6bf39090> size_info=<kfactory.kcell.SizeInfo object at 0x7fbb897a2750> dsize_info=<kfactory.kcell.DSizeInfo object at 0x7fbb897a2950> 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 0x7fbba253c9b0>, 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 0x7fbba253c050>, factories={'taper': <function taper at 0x7fbb94df7f60>, 'bend_s_bezier': <function bend_s_bezier_factory.<locals>.bend_s_bezier at 0x7fbb972067a0>, 'bend_circular': <function bend_circular at 0x7fbb94df63e0>, 'bend_euler': <function bend_euler at 0x7fbb94df6de0>, 'bend_s_euler': <function bend_s_euler_factory.<locals>.bend_s_euler at 0x7fbb9721cd60>, 'straight': <function straight at 0x7fbb94983740>, 'rotate': <function rotate at 0x7fbb95498f40>, 'from_image': <function from_image at 0x7fbb953b6de0>, 'floorplan_with_block_letters': <function floorplan_with_block_letters at 0x7fbb94d699e0>, 'bend_circular_heater': <function bend_circular_heater at 0x7fbb94df6660>, 'bend_euler_s': <function bend_euler_s at 0x7fbb94df6ca0>, 'bezier': <function bezier at 0x7fbb94df7380>, 'bend_s': <function bend_s at 0x7fbb94df7560>, 'add_fiber_array_optical_south_electrical_north': <function add_fiber_array_optical_south_electrical_north at 0x7fbb94df77e0>, 'ramp': <function ramp at 0x7fbb94df7ce0>, 'taper_strip_to_ridge': <function taper_strip_to_ridge at 0x7fbb94920040>, 'taper_strip_to_ridge_trenches': <function taper_strip_to_ridge_trenches at 0x7fbb949202c0>, 'taper_sc_nc': <function taper_sc_nc at 0x7fbb94920400>, 'taper_adiabatic': <function taper_adiabatic at 0x7fbb94920720>, 'taper_cross_section': <function taper_cross_section at 0x7fbb94920900>, 'taper_from_csv': <function taper_from_csv at 0x7fbb94920ae0>, 'taper_parabolic': <function taper_parabolic at 0x7fbb94920c20>, 'add_termination': <function add_termination at 0x7fbb94df7920>, 'add_trenches': <function add_trenches at 0x7fbb94920a40>, 'array': <function array at 0x7fbb94920e00>, 'copy_layers': <function copy_layers at 0x7fbb94921300>, 'extend_ports_list': <function extend_ports_list at 0x7fbb94921440>, 'extend_ports': <function extend_ports at 0x7fbb94921760>, 'pack_doe': <function pack_doe at 0x7fbb94921f80>, 'pack_doe_grid': <function pack_doe_grid at 0x7fbb949220c0>, 'splitter_chain': <function splitter_chain at 0x7fbb94922200>, 'mzi': <function mzi at 0x7fbb949227a0>, 'mzi_lattice': <function mzi_lattice at 0x7fbb94922ac0>, 'mzi_lattice_mmi': <function mzi_lattice_mmi at 0x7fbb94922c00>, 'mzi_pads_center': <function mzi_pads_center at 0x7fbb94922e80>, 'mzit': <function mzit at 0x7fbb94923060>, 'mzit_lattice': <function mzit_lattice at 0x7fbb949231a0>, 'splitter_tree': <function splitter_tree at 0x7fbb94922d40>, 'coupler_symmetric': <function coupler_symmetric at 0x7fbb94923380>, 'coupler_straight': <function coupler_straight at 0x7fbb949234c0>, 'coupler': <function coupler at 0x7fbb94923600>, 'coupler90': <function coupler90 at 0x7fbb949237e0>, 'coupler90bend': <function coupler90bend at 0x7fbb94923880>, 'coupler_adiabatic': <function coupler_adiabatic at 0x7fbb94923ba0>, 'coupler_asymmetric': <function coupler_asymmetric at 0x7fbb94923e20>, 'coupler_bent_half': <function coupler_bent_half at 0x7fbb9494c180>, 'coupler_bent': <function coupler_bent at 0x7fbb9494c2c0>, 'coupler_broadband': <function coupler_broadband at 0x7fbb9494c540>, 'coupler_full': <function coupler_full at 0x7fbb9494c720>, 'coupler_ring': <function coupler_ring at 0x7fbb9494c9a0>, 'coupler_straight_asymmetric': <function coupler_straight_asymmetric at 0x7fbb9494cc20>, 'align_wafer': <function align_wafer at 0x7fbb9494cfe0>, 'add_frame': <function add_frame at 0x7fbb9494d080>, 'die': <function die at 0x7fbb9494d3a0>, 'die_with_pads': <function die_with_pads at 0x7fbb9494d580>, 'seal_ring': <function seal_ring at 0x7fbb9494d760>, 'seal_ring_segmented': <function seal_ring_segmented at 0x7fbb9494d8a0>, 'wafer': <function wafer at 0x7fbb9494da80>, 'free_propagation_region': <function free_propagation_region at 0x7fbb9494dee0>, 'awg': <function awg at 0x7fbb9494df80>, 'dbr_cell': <function dbr_cell at 0x7fbb9494e2a0>, 'dbr': <function dbr at 0x7fbb9494e3e0>, 'dbr_tapered': <function dbr_tapered at 0x7fbb9494e660>, 'bbox': <function bbox at 0x7fbb9494ede0>, 'C': <function C at 0x7fbb9494efc0>, 'circle': <function circle at 0x7fbb9494f1a0>, 'compass': <function compass at 0x7fbb9494f420>, 'cross': <function cross at 0x7fbb9494f600>, 'ellipse': <function ellipse at 0x7fbb9494f7e0>, 'fiducial_squares': <function fiducial_squares at 0x7fbb9494f920>, 'L': <function L at 0x7fbb9494fb00>, 'nxn': <function nxn at 0x7fbb9494fce0>, 'rectangle': <function rectangle at 0x7fbb9494fec0>, 'rectangles': <function rectangles at 0x7fbb9494ff60>, 'regular_polygon': <function regular_polygon at 0x7fbb94980180>, 'triangle': <function triangle at 0x7fbb94980360>, 'triangle2': <function triangle2 at 0x7fbb949804a0>, 'triangle4': <function triangle4 at 0x7fbb949805e0>, 'fiber': <function fiber at 0x7fbb9494e980>, 'fiber_array': <function fiber_array at 0x7fbb94980680>, 'crossing_arm': <function crossing_arm at 0x7fbb94983060>, 'crossing': <function crossing at 0x7fbb949831a0>, 'crossing_linear_taper': <function crossing_linear_taper at 0x7fbb949832e0>, 'crossing_etched': <function crossing_etched at 0x7fbb94983420>, 'crossing45': <function crossing45 at 0x7fbb94983560>, 'straight_array': <function straight_array at 0x7fbb949839c0>, 'wire_straight': <function wire_straight at 0x7fbb94983b00>, 'straight_heater_doped_rib': <function straight_heater_doped_rib at 0x7fbb94983ec0>, 'straight_heater_doped_strip': <function straight_heater_doped_strip at 0x7fbb949ac0e0>, 'straight_heater_meander': <function straight_heater_meander at 0x7fbb949ac400>, 'via': <function via at 0x7fbb949acc20>, 'via_circular': <function via_circular at 0x7fbb949acd60>, 'via_chain': <function via_chain at 0x7fbb949ad080>, 'via_corner': <function via_corner at 0x7fbb949ad260>, 'via_stack': <function via_stack at 0x7fbb949ad440>, 'via_stack_corner45': <function via_stack_corner45 at 0x7fbb949ad580>, 'via_stack_corner45_extended': <function via_stack_corner45_extended at 0x7fbb949ad6c0>, 'via_stack_with_offset': <function via_stack_with_offset at 0x7fbb949ad800>, 'straight_heater_meander_doped': <function straight_heater_meander_doped at 0x7fbb949ac900>, 'straight_heater_metal_undercut': <function straight_heater_metal_undercut at 0x7fbb949ad760>, 'straight_heater_metal_simple': <function straight_heater_metal_simple at 0x7fbb949ada80>, 'straight_piecewise': <function straight_piecewise at 0x7fbb949adbc0>, 'straight_pin': <function straight_pin at 0x7fbb949adc60>, 'straight_pin_slot': <function straight_pin_slot at 0x7fbb949adee0>, 'wire_corner': <function wire_corner at 0x7fbb949ae160>, 'wire_corner45': <function wire_corner45 at 0x7fbb949ae2a0>, 'wire_corner_sections': <function wire_corner_sections at 0x7fbb949ae340>, 'loop_mirror': <function loop_mirror at 0x7fbb94980860>, 'mode_converter': <function mode_converter at 0x7fbb949afd80>, 'polarization_splitter_rotator': <function polarization_splitter_rotator at 0x7fbb949d80e0>, 'terminator': <function terminator at 0x7fbb949d8680>, 'grating_coupler_array': <function grating_coupler_array at 0x7fbb949d8900>, 'grating_coupler_dual_pol': <function grating_coupler_dual_pol at 0x7fbb949d8c20>, 'grating_coupler_elliptical': <function grating_coupler_elliptical at 0x7fbb949d9260>, 'grating_coupler_elliptical_arbitrary': <function grating_coupler_elliptical_arbitrary at 0x7fbb949d94e0>, 'grating_coupler_elliptical_uniform': <function grating_coupler_elliptical_uniform at 0x7fbb949d9760>, 'grating_coupler_elliptical_lumerical': <function grating_coupler_elliptical_lumerical at 0x7fbb949d98a0>, 'grating_coupler_elliptical_trenches': <function grating_coupler_elliptical_trenches at 0x7fbb949d8cc0>, 'grating_coupler_loss': <function grating_coupler_loss at 0x7fbb949d9a80>, 'grating_coupler_rectangular': <function grating_coupler_rectangular at 0x7fbb949d9c60>, 'grating_coupler_rectangular_arbitrary': <function grating_coupler_rectangular_arbitrary at 0x7fbb949d9ee0>, 'grating_coupler_tree': <function grating_coupler_tree at 0x7fbb949da160>, 'mmi': <function mmi at 0x7fbb949da480>, 'mmi1x2': <function mmi1x2 at 0x7fbb949da7a0>, 'mmi1x2_with_sbend': <function mmi1x2_with_sbend at 0x7fbb949da980>, 'mmi2x2': <function mmi2x2 at 0x7fbb949daca0>, 'mmi2x2_with_sbend': <function mmi2x2_with_sbend at 0x7fbb949dade0>, 'mmi_90degree_hybrid': <function mmi_90degree_hybrid at 0x7fbb949dafc0>, 'mmi_tapered': <function mmi_tapered at 0x7fbb949db2e0>, 'pad': <function pad at 0x7fbb949db560>, 'pad_array': <function pad_array at 0x7fbb949db7e0>, 'pad_gsg_short': <function pad_gsg_short at 0x7fbb949dba60>, 'pads_shorted': <function pads_shorted at 0x7fbb949dbce0>, 'rectangle_with_slits': <function rectangle_with_slits at 0x7fbb949dbe20>, 'cavity': <function cavity at 0x7fbb948000e0>, 'cdsem_all': <function cdsem_all at 0x7fbb94800360>, 'cdsem_bend180': <function cdsem_bend180 at 0x7fbb94800540>, 'cdsem_coupler': <function cdsem_coupler at 0x7fbb94800680>, 'cdsem_straight': <function cdsem_straight at 0x7fbb948009a0>, 'cdsem_straight_density': <function cdsem_straight_density at 0x7fbb94800ae0>, 'bendu_double': <function bendu_double at 0x7fbb94800d60>, 'straight_double': <function straight_double at 0x7fbb94800ea0>, 'cutback_2x2': <function cutback_2x2 at 0x7fbb94800fe0>, 'cutback_bend': <function cutback_bend at 0x7fbb948013a0>, 'cutback_bend90': <function cutback_bend90 at 0x7fbb948014e0>, 'staircase': <function staircase at 0x7fbb94801620>, 'cutback_bend180': <function cutback_bend180 at 0x7fbb94801760>, 'cutback_component': <function cutback_component at 0x7fbb948018a0>, 'cutback_splitter': <function cutback_splitter at 0x7fbb94801c60>, 'greek_cross': <function greek_cross at 0x7fbb94801da0>, 'greek_cross_with_pads': <function greek_cross_with_pads at 0x7fbb94802020>, 'litho_calipers': <function litho_calipers at 0x7fbb94802200>, 'litho_ruler': <function litho_ruler at 0x7fbb94802520>, 'litho_steps': <function litho_steps at 0x7fbb94802700>, 'resistance_meander': <function resistance_meander at 0x7fbb94802840>, 'resistance_sheet': <function resistance_sheet at 0x7fbb94802a20>, 'verniers': <function verniers at 0x7fbb94802c00>, 'text': <function text at 0x7fbb94803920>, 'text_lines': <function text_lines at 0x7fbb94803b00>, 'text_klayout': <function text_klayout at 0x7fbb94803c40>, 'text_freetype': <function text_freetype at 0x7fbb94803f60>, 'pixel_array': <function pixel_array at 0x7fbb94848220>, 'text_rectangular': <function text_rectangular at 0x7fbb94848360>, 'text_rectangular_multi_layer': <function text_rectangular_multi_layer at 0x7fbb948484a0>, 'pixel': <function pixel at 0x7fbb94802f20>, 'qrcode': <function qrcode at 0x7fbb94803ba0>, 'version_stamp': <function version_stamp at 0x7fbb94848540>, 'disk': <function disk at 0x7fbb94848ae0>, 'disk_heater': <function disk_heater at 0x7fbb94848c20>, 'ring': <function ring at 0x7fbb94848ea0>, 'ring_crow': <function ring_crow at 0x7fbb94849080>, 'ring_crow_couplers': <function ring_crow_couplers at 0x7fbb948491c0>, 'ring_double': <function ring_double at 0x7fbb948493a0>, 'ring_double_bend_coupler': <function ring_double_bend_coupler at 0x7fbb948496c0>, 'ring_double_heater': <function ring_double_heater at 0x7fbb94849800>, 'ring_double_pn': <function ring_double_pn at 0x7fbb94849b20>, 'ring_single_pn': <function ring_single_pn at 0x7fbb94849c60>, 'ring_single': <function ring_single at 0x7fbb94849e40>, 'ring_single_array': <function ring_single_array at 0x7fbb94849f80>, 'coupler_bend': <function coupler_bend at 0x7fbb9484a0c0>, 'coupler_ring_bend': <function coupler_ring_bend at 0x7fbb9484a200>, 'ring_single_bend_coupler': <function ring_single_bend_coupler at 0x7fbb9484a340>, 'ring_single_dut': <function ring_single_dut at 0x7fbb9484a520>, 'delay_snake': <function delay_snake at 0x7fbb9484a7a0>, 'delay_snake2': <function delay_snake2 at 0x7fbb9484a980>, 'delay_snake_sbend': <function delay_snake_sbend at 0x7fbb9484ac00>, 'spiral': <function spiral at 0x7fbb9484ae80>, 'spiral_double': <function spiral_double at 0x7fbb9484b060>, 'spiral_racetrack': <function spiral_racetrack at 0x7fbb9484b2e0>, 'spiral_racetrack_fixed_length': <function spiral_racetrack_fixed_length at 0x7fbb9484b420>, 'spiral_racetrack_heater_metal': <function spiral_racetrack_heater_metal at 0x7fbb9484b600>, 'spiral_racetrack_heater_doped': <function spiral_racetrack_heater_doped at 0x7fbb9484b740>, 'spiral_inductor': <function spiral_inductor at 0x7fbb9484b880>, 'hline': <function hline at 0x7fbb9484bb00>, 'optimal_90deg': <function optimal_90deg at 0x7fbb9484bc40>, 'optimal_hairpin': <function optimal_hairpin at 0x7fbb9484bf60>, 'optimal_step': <function optimal_step at 0x7fbb9487c0e0>, 'snspd': <function snspd at 0x7fbb9487c2c0>, 'interdigital_capacitor': <function interdigital_capacitor at 0x7fbb9487c4a0>, 'ge_detector_straight_si_contacts': <function ge_detector_straight_si_contacts at 0x7fbb9487c720>, 'edge_coupler_silicon': <function edge_coupler_silicon at 0x7fbb9487c9a0>, 'edge_coupler_array': <function edge_coupler_array at 0x7fbb9487cae0>, 'edge_coupler_array_with_loopback': <function edge_coupler_array_with_loopback at 0x7fbb9487cc20>, 'mzi_with_bend': <function mzi_with_bend at 0x7fbb78029f80>}, virtual_factories={'virtual_bend_circular': <function virtual_bend_circular_factory.<locals>.virtual_bend_circular at 0x7fbb9721dc60>, 'bend_euler': <function virtual_bend_euler_factory.<locals>.bend_euler at 0x7fbb9721dee0>, 'virtual_straight': <function virtual_straight_factory.<locals>.virtual_straight at 0x7fbb9721e160>, 'bend_circular_all_angle': <function bend_circular_all_angle at 0x7fbb94df6520>, 'bend_euler_all_angle': <function bend_euler_all_angle at 0x7fbb94df7060>, 'straight_all_angle': <function straight_all_angle at 0x7fbb94983880>}, 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 0x7fbba272afc0>, info=Info(), settings=KCellSettings(version='0.23.1', klayout_version='0.29.11', meta_format='v3'), future_cell_name='mzi_with_bend_R10', decorators=<kfactory.decorators.Decorators object at 0x7fbba27ea7d0>) function_name='mzi_with_bend' basename=None boundary=None insts=<gdsfactory.component.ComponentReferences object at 0x7fbb6ad05690> size_info=<kfactory.kcell.SizeInfo object at 0x7fbb6ad54310> dsize_info=<kfactory.kcell.DSizeInfo object at 0x7fbb6bf2aa10> 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
140443634576720
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)
140443634576720
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()