From edb426ba2d44ca358d78be13a1fa5ae859dc2e5d Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Thu, 9 Feb 2023 05:44:28 -0800 Subject: [PATCH] max poins = 4e3 Former-commit-id: 4b6c98c71f79358776ea84b07f52333127d7ab11 --- docs/components.rst | 93 +++++++++++++++++++++++++++++++++++++---- gdsfactory/component.py | 44 +++++++++++++++---- 2 files changed, 119 insertions(+), 18 deletions(-) diff --git a/docs/components.rst b/docs/components.rst index 65e277a9147..53f34c38fc0 100644 --- a/docs/components.rst +++ b/docs/components.rst @@ -1131,6 +1131,21 @@ disk +disk_heater +---------------------------------------------------- + +.. autofunction:: gdsfactory.components.disk_heater + +.. plot:: + :include-source: + + import gdsfactory as gf + + c = gf.components.disk_heater(radius=10.0, gap=0.2, wrap_angle_deg=180.0, parity=1, cross_section='strip', heater_layer='HEATER', via_stack='via_stack_heater_mtop', heater_width=5.0, heater_extent=2.0, via_width=10.0, port_orientation=90) + c.plot_matplotlib() + + + edge_coupler_array ---------------------------------------------------- @@ -2055,7 +2070,7 @@ pad import gdsfactory as gf - c = gf.components.pad(size=[100.0, 100.0], layer='M3', port_inclusion=0) + c = gf.components.pad(size=[100.0, 100.0], layer='MTOP', port_inclusion=0) c.plot_matplotlib() @@ -2265,7 +2280,7 @@ resistance_meander import gdsfactory as gf - c = gf.components.resistance_meander(pad_size=[50.0, 50.0], num_squares=1000, width=1.0, res_layer='M3', pad_layer='M3', gnd_layer='M3') + c = gf.components.resistance_meander(pad_size=[50.0, 50.0], num_squares=1000, width=1.0, res_layer='MTOP', pad_layer='MTOP', gnd_layer='MTOP') c.plot_matplotlib() @@ -2360,6 +2375,21 @@ ring_double_heater +ring_double_pn +---------------------------------------------------- + +.. autofunction:: gdsfactory.components.ring_double_pn + +.. plot:: + :include-source: + + import gdsfactory as gf + + c = gf.components.ring_double_pn(add_gap=0.3, drop_gap=0.3, radius=5.0, doping_angle=85, doped_heater=True, doped_heater_angle_buffer=10, doped_heater_layer='NPP', doped_heater_width=0.5, doped_heater_waveguide_offset=2.175) + c.plot_matplotlib() + + + ring_single ---------------------------------------------------- @@ -2435,6 +2465,21 @@ ring_single_heater +ring_single_pn +---------------------------------------------------- + +.. autofunction:: gdsfactory.components.ring_single_pn + +.. plot:: + :include-source: + + import gdsfactory as gf + + c = gf.components.ring_single_pn(gap=0.3, radius=5.0, doping_angle=250, doped_heater=True, doped_heater_angle_buffer=10, doped_heater_layer='NPP', doped_heater_width=0.5, doped_heater_waveguide_offset=2.175) + c.plot_matplotlib() + + + seal_ring ---------------------------------------------------- @@ -2685,7 +2730,22 @@ straight_heater_meander import gdsfactory as gf - c = gf.components.straight_heater_meander(length=300.0, spacing=2.0, cross_section='strip', heater_width=2.5, extension_length=15.0, layer_heater='HEATER', radius=5.0, port_orientation1=180, port_orientation2=0, heater_taper_length=10.0, straight_widths=[0.8, 0.9, 0.8], taper_length=10) + c = gf.components.straight_heater_meander(length=300.0, spacing=2.0, cross_section='strip', heater_width=2.5, extension_length=15.0, layer_heater='HEATER', radius=5.0, via_stack='via_stack_heater_mtop', port_orientation1=180, port_orientation2=0, heater_taper_length=10.0, straight_widths=[0.8, 0.9, 0.8], taper_length=10) + c.plot_matplotlib() + + + +straight_heater_meander_doped +---------------------------------------------------- + +.. autofunction:: gdsfactory.components.straight_heater_meander_doped + +.. plot:: + :include-source: + + import gdsfactory as gf + + c = gf.components.straight_heater_meander_doped(length=300.0, spacing=2.0, cross_section='strip', heater_width=1.5, extension_length=15.0, layers_doping=['P', 'PP', 'PPP'], radius=5.0, port_orientation1=180, port_orientation2=0, straight_widths=[0.8, 0.9, 0.8], taper_length=10) c.plot_matplotlib() @@ -2700,7 +2760,7 @@ straight_heater_metal import gdsfactory as gf - c = gf.components.straight_heater_metal(length=320.0, length_undercut_spacing=6.0, length_undercut=30.0, length_straight_input=15.0, heater_width=2.5, cross_section_heater='heater_metal', cross_section_waveguide_heater='strip_heater_metal', cross_section_heater_undercut='strip_heater_metal_undercut', with_undercut=False, port_orientation1=180, port_orientation2=0, heater_taper_length=5.0) + c = gf.components.straight_heater_metal(length=320.0, length_undercut_spacing=6.0, length_undercut=30.0, length_straight_input=15.0, heater_width=2.5, cross_section_heater='heater_metal', cross_section_waveguide_heater='strip_heater_metal', cross_section_heater_undercut='strip_heater_metal_undercut', with_undercut=False, via_stack='via_stack_heater_mtop', port_orientation1=180, port_orientation2=0, heater_taper_length=5.0) c.plot_matplotlib() @@ -2715,7 +2775,7 @@ straight_heater_metal_90_90 import gdsfactory as gf - c = gf.components.straight_heater_metal_90_90(length=320.0, length_undercut_spacing=6.0, length_undercut=30.0, length_straight_input=15.0, heater_width=2.5, cross_section_heater='heater_metal', cross_section_waveguide_heater='strip_heater_metal', cross_section_heater_undercut='strip_heater_metal_undercut', with_undercut=False, port_orientation1=90, port_orientation2=90, heater_taper_length=5.0) + c = gf.components.straight_heater_metal_90_90(length=320.0, length_undercut_spacing=6.0, length_undercut=30.0, length_straight_input=15.0, heater_width=2.5, cross_section_heater='heater_metal', cross_section_waveguide_heater='strip_heater_metal', cross_section_heater_undercut='strip_heater_metal_undercut', with_undercut=False, via_stack='via_stack_heater_mtop', port_orientation1=90, port_orientation2=90, heater_taper_length=5.0) c.plot_matplotlib() @@ -2730,7 +2790,7 @@ straight_heater_metal_undercut import gdsfactory as gf - c = gf.components.straight_heater_metal_undercut(length=320.0, length_undercut_spacing=6.0, length_undercut=30.0, length_straight_input=15.0, heater_width=2.5, cross_section_heater='heater_metal', cross_section_waveguide_heater='strip_heater_metal', cross_section_heater_undercut='strip_heater_metal_undercut', with_undercut=True, port_orientation1=180, port_orientation2=0, heater_taper_length=5.0) + c = gf.components.straight_heater_metal_undercut(length=320.0, length_undercut_spacing=6.0, length_undercut=30.0, length_straight_input=15.0, heater_width=2.5, cross_section_heater='heater_metal', cross_section_waveguide_heater='strip_heater_metal', cross_section_heater_undercut='strip_heater_metal_undercut', with_undercut=True, via_stack='via_stack_heater_mtop', port_orientation1=180, port_orientation2=0, heater_taper_length=5.0) c.plot_matplotlib() @@ -2745,7 +2805,7 @@ straight_heater_metal_undercut_90_90 import gdsfactory as gf - c = gf.components.straight_heater_metal_undercut_90_90(length=320.0, length_undercut_spacing=6.0, length_undercut=30.0, length_straight_input=15.0, heater_width=2.5, cross_section_heater='heater_metal', cross_section_waveguide_heater='strip_heater_metal', cross_section_heater_undercut='strip_heater_metal_undercut', with_undercut=False, port_orientation1=90, port_orientation2=90, heater_taper_length=5.0) + c = gf.components.straight_heater_metal_undercut_90_90(length=320.0, length_undercut_spacing=6.0, length_undercut=30.0, length_straight_input=15.0, heater_width=2.5, cross_section_heater='heater_metal', cross_section_waveguide_heater='strip_heater_metal', cross_section_heater_undercut='strip_heater_metal_undercut', with_undercut=False, via_stack='via_stack_heater_mtop', port_orientation1=90, port_orientation2=90, heater_taper_length=5.0) c.plot_matplotlib() @@ -3335,6 +3395,21 @@ via_stack_heater_m3 +via_stack_heater_mtop +---------------------------------------------------- + +.. autofunction:: gdsfactory.components.via_stack_heater_mtop + +.. plot:: + :include-source: + + import gdsfactory as gf + + c = gf.components.via_stack_heater_mtop(size=[11.0, 11.0], layers=['HEATER', 'M2', 'M3']) + c.plot_matplotlib() + + + via_stack_slab_m3 ---------------------------------------------------- @@ -3435,7 +3510,7 @@ wire_corner import gdsfactory as gf - c = gf.components.wire_corner(cross_section='metal3') + c = gf.components.wire_corner(cross_section='metal_routing') c.plot_matplotlib() @@ -3465,5 +3540,5 @@ wire_straight import gdsfactory as gf - c = gf.components.wire_straight(length=10.0, npoints=2, with_bbox=True, cross_section='metal3') + c = gf.components.wire_straight(length=10.0, npoints=2, with_bbox=True, cross_section='metal_routing') c.plot_matplotlib() diff --git a/gdsfactory/component.py b/gdsfactory/component.py index 2d932f863f1..866efdc5a38 100644 --- a/gdsfactory/component.py +++ b/gdsfactory/component.py @@ -309,7 +309,7 @@ def validate(cls, v): - name characters < MAX_NAME_LENGTH - is not empty (has references or polygons) """ - MAX_NAME_LENGTH = 100 + MAX_NAME_LENGTH = 99 assert isinstance( v, Component ), f"TypeError, Got {type(v)}, expecting Component" @@ -1597,6 +1597,8 @@ def _write_library( logging: bool = True, on_duplicate_cell: Optional[str] = "warn", with_oasis: bool = False, + max_points: int = 4e3, + flatten_invalid_refs: bool = False, **kwargs, ) -> Path: """Write component to GDS and returns gdspath. @@ -1614,7 +1616,23 @@ def _write_library( "error": throw a ValueError when attempting to write a gds with duplicate cells. "overwrite": overwrite all duplicate cells with one of the duplicates, without warning. None: do not try to resolve (at your own risk!) + flatten_invalid_refs: flattens component references which have invalid transformations. + max_points: Maximal number of vertices per polygon. Polygons with more vertices that this are automatically fractured. + + Keyword Args: + outfile: Name of the output file. + compression_level: Level of compression for cells (between 0 and 9). + Setting to 0 will disable cell compression, 1 gives the best speed and 9, the best compression. + detect_rectangles: Store rectangles in compressed format. + detect_trapezoids: Store trapezoids in compressed format. + circle_tolerance: Tolerance for detecting circles. If less or equal to 0, no detection is performed. Circles are stored in compressed format. + validation ("crc32", "checksum32", None): type of validation to include in the saved file. + standard_properties: Store standard OASIS properties in the file. + """ + if flatten_invalid_refs: + self = flatten_invalid_refs_recursive(self) + from gdsfactory.pdk import get_grid_size precision = precision or get_grid_size() * 1e-6 @@ -1676,7 +1694,7 @@ def _write_library( if with_oasis: lib.write_oas(gdspath, **kwargs) else: - lib.write_gds(gdspath, timestamp=timestamp) + lib.write_gds(gdspath, timestamp=timestamp, max_points=max_points) if logging: logger.info(f"Wrote to {str(gdspath)!r}") return gdspath @@ -1690,6 +1708,7 @@ def write_gds( logging: bool = True, on_duplicate_cell: Optional[str] = "warn", flatten_invalid_refs: bool = False, + max_points: int = 4000, ) -> Path: """Write component to GDS and returns gdspath. @@ -1704,11 +1723,9 @@ def write_gds( "error": throw a ValueError when attempting to write a gds with duplicate cells. "overwrite": overwrite all duplicate cells with one of the duplicates, without warning. flatten_invalid_refs: flattens component references which have invalid transformations. + max_points: Maximal number of vertices per polygon. Polygons with more vertices that this are automatically fractured. """ - if flatten_invalid_refs: - self = flatten_invalid_refs_recursive(self) - return self._write_library( gdspath=gdspath, gdsdir=gdsdir, @@ -1716,6 +1733,8 @@ def write_gds( precision=precision, logging=logging, on_duplicate_cell=on_duplicate_cell, + flatten_invalid_refs=flatten_invalid_refs, + max_points=max_points, ) def write_oas( @@ -1726,6 +1745,8 @@ def write_oas( precision: Optional[float] = None, logging: bool = True, on_duplicate_cell: Optional[str] = "warn", + flatten_invalid_refs: bool = False, + max_points: int = 4000, **kwargs, ) -> Path: """Write component to GDS and returns gdspath. @@ -1760,6 +1781,8 @@ def write_oas( logging=logging, on_duplicate_cell=on_duplicate_cell, with_oasis=True, + flatten_invalid_refs=flatten_invalid_refs, + max_points=max_points, **kwargs, ) @@ -2483,14 +2506,17 @@ def hierarchy(): if __name__ == "__main__": - # import gdsfactory as gf + import gdsfactory as gf + # c2 = gf.Component() - # c = gf.c.mzi() + c = gf.components.mzi(delta_length=20) # r = c.ref() # c2.copy_child_info(c.named_references["sxt"]) # test_remap_layers() # c = test_get_layers() # c.plot_qt() # c.ploth() - c = test_extract() - c.show() + # c = test_extract() + c.write_oas("a.oas") + gf.show("a.oas") + # c.show()