Skip to content

Commit

Permalink
Merge pull request #21 from gdsfactory/kfactory09
Browse files Browse the repository at this point in the history
udpdate to kfactory09
  • Loading branch information
joamatab authored Oct 5, 2023
2 parents 3274ad1 + ef089e5 commit ad499c6
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 23 deletions.
Binary file added coupler_G0p2_L10_D5_D5_W0p5_LWG_E8a9ff7cf.gds
Binary file not shown.
11 changes: 7 additions & 4 deletions kgeneric/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
"""kgeneric - KLayout extras for KCells, PDK and generic_tech"""

__version__ = "0.0.2"
from kfactory.pdk import Pdk, get_cells

import kfactory as kf
from kfactory.kcell import get_cells

from kgeneric import cells, gpdk, layers
from kgeneric.layers import LAYER
from kgeneric.tech import TECH

cells_dict = get_cells([gpdk])
pdk = Pdk(name="generic", cell_factories=cells_dict, layers=LAYER)
cells_dict = get_cells([cells])

kf.kcl.factories.update(cells_dict)


__all__ = ("pdk", "gpdk", "cells", "layers", "TECH")
__all__ = ("gpdk", "cells", "layers", "TECH", "LAYER")
9 changes: 5 additions & 4 deletions kgeneric/cells/bezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import numpy.typing as nty
from kfactory import KCell, LayerEnum, cell, kdb
from kfactory.utils.enclosure import LayerEnclosure, extrude_path
from kfactory.enclosure import LayerEnclosure, extrude_path
from scipy.special import binom # type: ignore[import]

__all__ = ["bend_s"]
Expand Down Expand Up @@ -91,10 +91,11 @@ def bend_s(


if __name__ == "__main__":
from kgeneric import pdk
from kgeneric.pdk import LAYER
import kfactory as kf

um = 1 / pdk.kcl.dbu
from kgeneric import LAYER

um = 1 / kf.kcl.dbu
enclosure = LayerEnclosure(
[
(LAYER.DEEPTRENCH, 2 * um, 3 * um),
Expand Down
6 changes: 3 additions & 3 deletions kgeneric/cells/circular.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import numpy as np
from kfactory import kdb
from kfactory.enclosure import LayerEnclosure, extrude_path
from kfactory.kcell import KCell, LayerEnum, cell
from kfactory.utils.enclosure import LayerEnclosure, extrude_path

__all__ = ["bend_circular"]

Expand All @@ -26,7 +26,7 @@ def bend_circular(
width: Width of the core. [um]
radius: Radius of the backbone. [um]
layer: Layer index of the target layer.
enclosure: :py:class:`kfactory.utils.Enclosure` object to describe the
enclosure: :py:class:`kfactory.enclosure` object to describe the
claddings.
angle: Angle amount of the bend.
angle_step: Angle amount per backbone point of the bend.
Expand Down Expand Up @@ -69,7 +69,7 @@ def bend_circular(


if __name__ == "__main__":
from kgeneric.pdk import LAYER
from kgeneric import LAYER

c = bend_circular(width=1, radius=9, angle=9.0, layer=LAYER.WG)
c.draw_ports()
Expand Down
6 changes: 3 additions & 3 deletions kgeneric/cells/coupler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from kfactory import KCell, cell, kdb
from kfactory.enclosure import LayerEnclosure
from kfactory.kcell import LayerEnum
from kfactory.utils.enclosure import LayerEnclosure

from kgeneric.cells.bezier import bend_s
from kgeneric.cells.straight import straight
Expand Down Expand Up @@ -119,9 +119,9 @@ def straight_coupler(


if __name__ == "__main__":
from kgeneric import pdk
import kfactory as kf

um = 1 / pdk.kcl.dbu
um = 1 / kf.kcl.dbu
enclosure = LayerEnclosure(
[
(LAYER.DEEPTRENCH, 2 * um, 3 * um),
Expand Down
2 changes: 1 addition & 1 deletion kgeneric/cells/dbu/straight.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"""

from kfactory import KCell, LayerEnum, cell, kdb
from kfactory.enclosure import LayerEnclosure
from kfactory.kcell import Info
from kfactory.utils import LayerEnclosure

__all__ = ["straight"]

Expand Down
2 changes: 1 addition & 1 deletion kgeneric/cells/dbu/taper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from kfactory import KCell, cell, kdb
from kfactory.utils import LayerEnclosure
from kfactory.enclosure import LayerEnclosure

__all__ = ["taper"]

Expand Down
4 changes: 2 additions & 2 deletions kgeneric/cells/euler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

import numpy as np
from kfactory import kdb
from kfactory.enclosure import LayerEnclosure, extrude_path
from kfactory.kcell import KCell, LayerEnum, cell
from kfactory.utils.enclosure import LayerEnclosure, extrude_path
from scipy.optimize import brentq # type: ignore[import]
from scipy.special import fresnel # type: ignore[import]

Expand Down Expand Up @@ -267,7 +267,7 @@ def bend_s_euler(


if __name__ == "__main__":
from kgeneric.pdk import LAYER
from kgeneric import LAYER

c = bend_euler(width=1, radius=10, layer=LAYER.WG)
c.draw_ports()
Expand Down
2 changes: 1 addition & 1 deletion kgeneric/cells/mzi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

import kfactory as kf
from kfactory import cell
from kfactory.enclosure import LayerEnclosure
from kfactory.kcell import LayerEnum
from kfactory.routing.optical import route
from kfactory.typings import CellFactory
from kfactory.utils.enclosure import LayerEnclosure

from kgeneric.cells.coupler import coupler
from kgeneric.cells.dbu.straight import straight as straight_dbu
Expand Down
2 changes: 1 addition & 1 deletion kgeneric/cells/straight.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


from kfactory import KCell, LayerEnum, kcl
from kfactory.utils import LayerEnclosure
from kfactory.enclosure import LayerEnclosure

from kgeneric.cells.dbu.straight import straight as straight_dbu

Expand Down
2 changes: 1 addition & 1 deletion kgeneric/cells/taper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


from kfactory import KCell, LayerEnum, kcl
from kfactory.utils import LayerEnclosure
from kfactory.enclosure import LayerEnclosure

from kgeneric.cells.dbu.taper import taper as taper_dbu

Expand Down
2 changes: 1 addition & 1 deletion kgeneric/gpdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from kgeneric.layers import LAYER
from kgeneric.tech import TECH

enclosure_sc = kf.utils.LayerEnclosure(name="WGSTD", sections=[(LAYER.WGCLAD, 0, 2000)])
enclosure_sc = kf.LayerEnclosure(name="WGSTD", sections=[(LAYER.WGCLAD, 0, 2000)])

bend_s_sc = partial(
cells.bend_s,
Expand Down
5 changes: 5 additions & 0 deletions kgeneric/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from typing import Any

import kfactory as kf
from kfactory.kcell import LayerEnum
from pydantic import BaseModel, Field

Expand All @@ -17,6 +18,8 @@ class LAYER(LayerEnum):
You will need to create a new LayerMap with your specific foundry layers.
"""

kcl = kf.constant(kf.kcl)

WG = (1, 0)
WAFER = (50, 0)
WGCLAD = (111, 0)
Expand Down Expand Up @@ -421,6 +424,8 @@ def get_layer_stack(
)


kf.kcl.layers = LAYER

LAYER_STACK = get_layer_stack()

if __name__ == "__main__":
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/test_cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_cells(cell_name: str) -> None:
gds_ref.mkdir(parents=True, exist_ok=True)
run_cell.write(str(ref_file))
raise FileNotFoundError(f"GDS file not found. Saving it to {ref_file}")
kcl_ref = kf.KCLayout()
kcl_ref = kf.KCLayout(cell_name)
kcl_ref.read(gds_ref / f"{cell.name}.gds")
ref_cell = kcl_ref[kcl_ref.top_cell().name]

Expand Down

0 comments on commit ad499c6

Please sign in to comment.