Skip to content

Commit

Permalink
Merge pull request gdsfactory#1254 from gdsfactory/6351
Browse files Browse the repository at this point in the history
max points to 4e3

Former-commit-id: a212e9c
  • Loading branch information
joamatab committed Feb 9, 2023
2 parents a1b5608 + e607c9d commit ffc715c
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 22 deletions.
93 changes: 84 additions & 9 deletions docs/components.rst
Expand Up @@ -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
----------------------------------------------------

Expand Down Expand Up @@ -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()


Expand Down Expand Up @@ -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()


Expand Down Expand Up @@ -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
----------------------------------------------------

Expand Down Expand Up @@ -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
----------------------------------------------------

Expand Down Expand Up @@ -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()


Expand All @@ -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()


Expand All @@ -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()


Expand All @@ -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()


Expand All @@ -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()


Expand Down Expand Up @@ -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
----------------------------------------------------

Expand Down Expand Up @@ -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()


Expand Down Expand Up @@ -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()
53 changes: 43 additions & 10 deletions gdsfactory/component.py
Expand Up @@ -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"
Expand Down Expand Up @@ -1597,6 +1597,8 @@ def _write_library(
logging: bool = True,
on_duplicate_cell: Optional[str] = "warn",
with_oasis: bool = False,
max_points: Optional[int] = None,
flatten_invalid_refs: bool = False,
**kwargs,
) -> Path:
"""Write component to GDS and returns gdspath.
Expand All @@ -1614,10 +1616,33 @@ 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.
"""
from gdsfactory.pdk import get_grid_size

from gdsfactory.pdk import get_grid_size, get_constant

precision = precision or get_grid_size() * 1e-6
max_points = max_points or get_constant("max_points")
flatten_invalid_refs = flatten_invalid_refs or get_constant(
"flatten_invalid_refs"
)
precision = precision or get_constant("precision")
on_duplicate_cell = on_duplicate_cell or get_constant("on_duplicate_cell")

if flatten_invalid_refs:
self = flatten_invalid_refs_recursive(self)

gdsdir = (
gdsdir or pathlib.Path(tempfile.TemporaryDirectory().name) / "gdsfactory"
Expand Down Expand Up @@ -1676,7 +1701,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
Expand All @@ -1690,6 +1715,7 @@ def write_gds(
logging: bool = True,
on_duplicate_cell: Optional[str] = "warn",
flatten_invalid_refs: bool = False,
max_points: Optional[int] = None,
) -> Path:
"""Write component to GDS and returns gdspath.
Expand All @@ -1704,18 +1730,19 @@ 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,
unit=unit,
precision=precision,
logging=logging,
on_duplicate_cell=on_duplicate_cell,
flatten_invalid_refs=flatten_invalid_refs,
max_points=max_points,
)

def write_oas(
Expand All @@ -1726,6 +1753,7 @@ def write_oas(
precision: Optional[float] = None,
logging: bool = True,
on_duplicate_cell: Optional[str] = "warn",
flatten_invalid_refs: bool = False,
**kwargs,
) -> Path:
"""Write component to GDS and returns gdspath.
Expand All @@ -1741,6 +1769,7 @@ def write_oas(
"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.
Keyword Args:
compression_level: Level of compression for cells (between 0 and 9).
Expand All @@ -1760,6 +1789,7 @@ def write_oas(
logging=logging,
on_duplicate_cell=on_duplicate_cell,
with_oasis=True,
flatten_invalid_refs=flatten_invalid_refs,
**kwargs,
)

Expand Down Expand Up @@ -2483,14 +2513,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()
gdspath = c.write_gds()
gf.show(gdspath)
# c.show()
3 changes: 2 additions & 1 deletion gdsfactory/generic_tech/__init__.py
Expand Up @@ -37,7 +37,7 @@ def get_generic_pdk():
from gdsfactory.components import cells
from gdsfactory.config import sparameters_path
from gdsfactory.cross_section import cross_sections
from gdsfactory.pdk import Pdk
from gdsfactory.pdk import Pdk, constants

return Pdk(
name="generic",
Expand All @@ -48,6 +48,7 @@ def get_generic_pdk():
layer_views=LAYER_VIEWS,
layer_transitions=LAYER_TRANSITIONS,
sparameters_path=sparameters_path,
constants=constants,
)


Expand Down
5 changes: 5 additions & 0 deletions gdsfactory/pdk.py
Expand Up @@ -42,6 +42,11 @@
"fiber_spacing": 50.0,
"fiber_input_to_output_spacing": 200.0,
"metal_spacing": 10.0,
"max_points": 4000,
"unit": 1e-6,
"precision": 1e-9,
"flatten_invalid_refs": False,
"on_duplicate_cell": "warn",
}


Expand Down
14 changes: 12 additions & 2 deletions gdsfactory/write_cells.py
Expand Up @@ -78,17 +78,27 @@ def get_import_gds_script(dirpath: PathType, module: Optional[str] = None) -> st
Args:
dirpath: fixed cell directory path.
module: if any includes plot directive.
module: Optional plot directive to plot imported component.
"""
dirpath = pathlib.Path(dirpath)
if not dirpath.exists():
raise ValueError(f"{dirpath.absolute()!r} does not exist.")

gdspaths = list(dirpath.glob("*.gds")) + list(dirpath.glob("*.GDS"))

if not gdspaths:
raise ValueError(f"No GDS files found at {dirpath.absolute()!r}.")

logger.info(f"Writing {len(gdspaths)} cells from {dirpath.absolute()!r}")

script = [script_prefix]
script += [f"gdsdir = {dirpath.absolute()!r}\n"]
script += [
"import_gds = partial(gf.import_gds, gdsdir=gdsdir, decorator=add_ports)\n"
]

cells = [get_script(gdspath, module=module) for gdspath in dirpath.glob("*.gds")]
cells = [get_script(gdspath, module=module) for gdspath in gdspaths]
script += sorted(cells)
return "\n".join(script)

Expand Down

0 comments on commit ffc715c

Please sign in to comment.