diff --git a/.github/write_components_plot.py b/.github/write_cells_si220.py similarity index 96% rename from .github/write_components_plot.py rename to .github/write_cells_si220.py index b2dff03..10aab68 100644 --- a/.github/write_components_plot.py +++ b/.github/write_cells_si220.py @@ -3,7 +3,7 @@ from cspdk.si220 import _cells as cells from cspdk.si220.config import PATH -filepath = PATH.repo / "docs" / "cells.rst" +filepath = PATH.repo / "docs" / "cells_si220.rst" skip = {} diff --git a/.github/write_cells_sin300.py b/.github/write_cells_sin300.py new file mode 100644 index 0000000..4b52b12 --- /dev/null +++ b/.github/write_cells_sin300.py @@ -0,0 +1,65 @@ +import inspect + +from cspdk.sin300 import _cells as cells +from cspdk.sin300.config import PATH + +filepath = PATH.repo / "docs" / "cells_sin300.rst" + +skip = {} + +skip_plot: tuple[str, ...] = ("",) +skip_settings: tuple[str, ...] = () + + +with open(filepath, "w+") as f: + f.write( + """ + +Cells SiN300 +============================= +""" + ) + + for name in sorted(cells.keys()): + if name in skip or name.startswith("_"): + continue + print(name) + sig = inspect.signature(cells[name]) + kwargs = ", ".join( + [ + f"{p}={repr(sig.parameters[p].default)}" + for p in sig.parameters + if isinstance(sig.parameters[p].default, int | float | str | tuple) + and p not in skip_settings + ] + ) + if name in skip_plot: + f.write( + f""" + +{name} +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.{name} + +""" + ) + else: + f.write( + f""" + +{name} +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.{name} + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.{name}({kwargs}) + c.plot() + +""" + ) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 80e776b..ec97a5c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,9 +15,10 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.1.7" + rev: "v0.4.1" hooks: - id: ruff + args: [ --fix, --exit-non-zero-on-fix ] - id: ruff-format - repo: https://github.com/shellcheck-py/shellcheck-py diff --git a/Makefile b/Makefile index 8c5bbef..d7e1a41 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,8 @@ notebooks: jupytext docs/**/*.py --to ipynb docs: + python .github/write_cells_si220.py + python .github/write_cells_sin300.py jb build docs .PHONY: drc doc docs diff --git a/cspdk/si220/import_pdk.py b/cspdk/si220/import_pdk.py index 2e3ad07..43205d1 100644 --- a/cspdk/si220/import_pdk.py +++ b/cspdk/si220/import_pdk.py @@ -1,4 +1,4 @@ -""" From a list of GDS files, generate a script to import the cells from a pdk """ +"""From a list of GDS files, generate a script to import the cells from a pdk""" import gdsfactory as gf diff --git a/cspdk/si220/samples/get_route_sc.py b/cspdk/si220/samples/get_route_sc.py index 6343354..faffbe3 100644 --- a/cspdk/si220/samples/get_route_sc.py +++ b/cspdk/si220/samples/get_route_sc.py @@ -1,4 +1,4 @@ -"""`get_route` returns a Manhattan route between two ports. """ +"""`get_route` returns a Manhattan route between two ports.""" import gdsfactory as gf diff --git a/cspdk/si220/samples/mode_solver_r.py b/cspdk/si220/samples/mode_solver_r.py index f585b4c..9f824c1 100644 --- a/cspdk/si220/samples/mode_solver_r.py +++ b/cspdk/si220/samples/mode_solver_r.py @@ -1,4 +1,5 @@ """Silicon rib mode solver.""" + import gplugins.tidy3d as gt nm = 1e-3 diff --git a/cspdk/si220/samples/mode_solver_s.py b/cspdk/si220/samples/mode_solver_s.py index 3eabd9f..0550689 100644 --- a/cspdk/si220/samples/mode_solver_s.py +++ b/cspdk/si220/samples/mode_solver_s.py @@ -1,4 +1,5 @@ """Silicon mode solver.""" + import gplugins.tidy3d as gt nm = 1e-3 diff --git a/cspdk/sin300/import_pdk.py b/cspdk/sin300/import_pdk.py index d582cc2..26c79ec 100644 --- a/cspdk/sin300/import_pdk.py +++ b/cspdk/sin300/import_pdk.py @@ -1,4 +1,4 @@ -""" From a list of GDS files, generate a script to import the cells from a pdk """ +"""From a list of GDS files, generate a script to import the cells from a pdk""" import gdsfactory as gf diff --git a/cspdk/sin300/samples/get_route_nc.py b/cspdk/sin300/samples/get_route_nc.py index 168a817..066bd5a 100644 --- a/cspdk/sin300/samples/get_route_nc.py +++ b/cspdk/sin300/samples/get_route_nc.py @@ -1,4 +1,4 @@ -"""`get_route` returns a Manhattan route between two ports. """ +"""`get_route` returns a Manhattan route between two ports.""" import gdsfactory as gf diff --git a/cspdk/sin300/samples/mode_solver_n.py b/cspdk/sin300/samples/mode_solver_n.py index 68f1be4..7a9ebc8 100644 --- a/cspdk/sin300/samples/mode_solver_n.py +++ b/cspdk/sin300/samples/mode_solver_n.py @@ -1,4 +1,5 @@ """Nitride mode solver.""" + import gplugins.tidy3d as gt nm = 1e-3 diff --git a/docs/_toc.yml b/docs/_toc.yml index 7fc1c11..71788e3 100644 --- a/docs/_toc.yml +++ b/docs/_toc.yml @@ -11,5 +11,6 @@ parts: # - file: notebooks/demo - caption: Reference chapters: - - file: cells + - file: cells_si220 + - file: cells_sin300 - file: changelog diff --git a/docs/cells.rst b/docs/cells_si220.rst similarity index 74% rename from docs/cells.rst rename to docs/cells_si220.rst index 8bf25d4..31311b8 100644 --- a/docs/cells.rst +++ b/docs/cells_si220.rst @@ -19,36 +19,6 @@ array -bend_nc ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.bend_nc - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.bend_nc(radius=25.0, angle=90.0) - c.plot() - - - -bend_no ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.bend_no - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.bend_no(radius=25.0, angle=90.0) - c.plot() - - - bend_rc ---------------------------------------------------- @@ -124,36 +94,6 @@ bend_so -coupler_nc ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.coupler_nc - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.coupler_nc(gap=0.4, length=20.0, dx=10.0, dy=4.0) - c.plot() - - - -coupler_no ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.coupler_no - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.coupler_no(gap=0.4, length=20.0, dx=10.0, dy=4.0) - c.plot() - - - coupler_rc ---------------------------------------------------- @@ -259,36 +199,6 @@ crossing_so -die_nc ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.die_nc - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.die_nc() - c.plot() - - - -die_no ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.die_no - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.die_no() - c.plot() - - - die_rc ---------------------------------------------------- @@ -379,36 +289,6 @@ gc_elliptical_so -gc_rectangular_nc ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.gc_rectangular_nc - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.gc_rectangular_nc() - c.plot() - - - -gc_rectangular_no ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.gc_rectangular_no - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.gc_rectangular_no() - c.plot() - - - gc_rectangular_rc ---------------------------------------------------- @@ -479,7 +359,7 @@ grating_coupler_array import cspdk - c = cspdk.si220.cells.grating_coupler_array(pitch=127.0, n=6, port_name='o1', rotation=0.0, with_loopback=False, grating_coupler_spacing=0.0, cross_section='xs_nc') + c = cspdk.si220.cells.grating_coupler_array(pitch=127.0, n=6, port_name='o1', rotation=0.0, with_loopback=False, grating_coupler_spacing=0.0, cross_section='xs_sc') c.plot() @@ -499,36 +379,6 @@ heater -mmi1x2_nc ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.mmi1x2_nc - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.mmi1x2_nc() - c.plot() - - - -mmi1x2_no ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.mmi1x2_no - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.mmi1x2_no() - c.plot() - - - mmi1x2_rc ---------------------------------------------------- @@ -589,36 +439,6 @@ mmi1x2_so -mmi2x2_nc ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.mmi2x2_nc - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.mmi2x2_nc() - c.plot() - - - -mmi2x2_no ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.mmi2x2_no - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.mmi2x2_no() - c.plot() - - - mmi2x2_rc ---------------------------------------------------- @@ -679,36 +499,6 @@ mmi2x2_so -mzi_nc ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.mzi_nc - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.mzi_nc(delta_length=10.0, length_y=2.0, length_x=0.1, add_electrical_ports_bot=True) - c.plot() - - - -mzi_no ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.mzi_no - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.mzi_no(delta_length=10.0, length_y=2.0, length_x=0.1, add_electrical_ports_bot=True) - c.plot() - - - mzi_rc ---------------------------------------------------- @@ -799,36 +589,6 @@ rectangle -straight_nc ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.straight_nc - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.straight_nc(length=10.0) - c.plot() - - - -straight_no ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.straight_no - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.straight_no(length=10.0) - c.plot() - - - straight_rc ---------------------------------------------------- @@ -889,36 +649,6 @@ straight_so -taper_nc ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.taper_nc - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.taper_nc(length=10.0, width1=0.5) - c.plot() - - - -taper_no ----------------------------------------------------- - -.. autofunction:: cspdk.si220.cells.taper_no - -.. plot:: - :include-source: - - import cspdk - - c = cspdk.si220.cells.taper_no(length=10.0, width1=0.5) - c.plot() - - - taper_rc ---------------------------------------------------- diff --git a/docs/cells_sin300.rst b/docs/cells_sin300.rst new file mode 100644 index 0000000..05674fa --- /dev/null +++ b/docs/cells_sin300.rst @@ -0,0 +1,393 @@ + + +Cells SiN300 +============================= + + +array +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.array + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.array(component='pad', spacing=(150.0, 150.0), columns=6, rows=1, add_ports=True, centered=False) + c.plot() + + + +bend_nc +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.bend_nc + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.bend_nc(radius=25.0, angle=90.0) + c.plot() + + + +bend_no +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.bend_no + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.bend_no(radius=25.0, angle=90.0) + c.plot() + + + +bend_s +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.bend_s + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.bend_s(size=(11.0, 1.8), cross_section='xs_nc') + c.plot() + + + +coupler_nc +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.coupler_nc + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.coupler_nc(gap=0.4, length=20.0, dx=10.0, dy=4.0) + c.plot() + + + +coupler_no +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.coupler_no + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.coupler_no(gap=0.4, length=20.0, dx=10.0, dy=4.0) + c.plot() + + + +die_nc +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.die_nc + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.die_nc() + c.plot() + + + +die_no +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.die_no + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.die_no() + c.plot() + + + +gc_elliptical_nc +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.gc_elliptical_nc + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.gc_elliptical_nc(grating_line_width=0.343, fiber_angle=20, wavelength=1.53, neff=1.6, cross_section='xs_nc') + c.plot() + + + +gc_elliptical_no +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.gc_elliptical_no + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.gc_elliptical_no(grating_line_width=0.343, fiber_angle=20, wavelength=1.31, neff=1.63, cross_section='xs_no') + c.plot() + + + +gc_rectangular_nc +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.gc_rectangular_nc + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.gc_rectangular_nc() + c.plot() + + + +gc_rectangular_no +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.gc_rectangular_no + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.gc_rectangular_no() + c.plot() + + + +grating_coupler_array +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.grating_coupler_array + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.grating_coupler_array(pitch=127.0, n=6, port_name='o1', rotation=0.0, with_loopback=False, grating_coupler_spacing=0.0, cross_section='xs_nc') + c.plot() + + + +mmi1x2_nc +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.mmi1x2_nc + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.mmi1x2_nc() + c.plot() + + + +mmi1x2_no +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.mmi1x2_no + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.mmi1x2_no() + c.plot() + + + +mmi2x2_nc +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.mmi2x2_nc + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.mmi2x2_nc() + c.plot() + + + +mmi2x2_no +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.mmi2x2_no + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.mmi2x2_no() + c.plot() + + + +mzi_nc +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.mzi_nc + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.mzi_nc(delta_length=10.0, length_y=2.0, length_x=0.1, add_electrical_ports_bot=True) + c.plot() + + + +mzi_no +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.mzi_no + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.mzi_no(delta_length=10.0, length_y=2.0, length_x=0.1, add_electrical_ports_bot=True) + c.plot() + + + +pad +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.pad + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.pad(size=(100.0, 100.0), layer=(41, 0), port_inclusion=0.0) + c.plot() + + + +rectangle +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.rectangle + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.rectangle(size=(4.0, 2.0), layer=(99, 0), centered=False, port_type='electrical', port_orientations=(180.0, 90.0, 0.0, -90.0), round_corners_east_west=False, round_corners_north_south=False) + c.plot() + + + +straight_nc +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.straight_nc + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.straight_nc(length=10.0) + c.plot() + + + +straight_no +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.straight_no + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.straight_no(length=10.0) + c.plot() + + + +taper_nc +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.taper_nc + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.taper_nc(length=10.0, width1=0.5) + c.plot() + + + +taper_no +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.taper_no + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.taper_no(length=10.0, width1=0.5) + c.plot() + + + +wire_corner +---------------------------------------------------- + +.. autofunction:: cspdk.si220.cells.wire_corner + +.. plot:: + :include-source: + + import cspdk + + c = cspdk.si220.cells.wire_corner(cross_section='xs_metal_routing') + c.plot() diff --git a/install_tech.py b/install_tech.py index eb079e1..8782cf2 100644 --- a/install_tech.py +++ b/install_tech.py @@ -1,4 +1,5 @@ """Symlink tech to klayout.""" + import os import pathlib import shutil