Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix delay length #912

Merged
merged 3 commits into from Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -33,7 +33,7 @@ repos:
hooks:
- id: blacken-docs
additional_dependencies: [black==22.3.0]
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 21d3c70d676007470908d39b73f0521d39b3b997
hooks:
- id: flake8
Expand Down
4 changes: 2 additions & 2 deletions docs/components.rst
Expand Up @@ -991,7 +991,7 @@ delay_snake

import gdsfactory as gf

c = gf.components.delay_snake(total_length=1600.0, L0=5.0, n=2, bend='bend_euler', cross_section='strip')
c = gf.components.delay_snake(length=1600.0, L0=5.0, n=2, bend='bend_euler', cross_section='strip')
c.plot()


Expand Down Expand Up @@ -3105,7 +3105,7 @@ version_stamp

import gdsfactory as gf

c = gf.components.version_stamp(labels=['demo_label'], with_qr_code=False, layer='WG', pixel_size=1, version='6.1.1', text_size=10)
c = gf.components.version_stamp(labels=['demo_label'], with_qr_code=False, layer='WG', pixel_size=1, version='6.2.3', text_size=10)
c.plot()


Expand Down
21 changes: 15 additions & 6 deletions gdsfactory/components/delay_snake.py
@@ -1,4 +1,4 @@
from numpy import pi
import numpy as np

import gdsfactory as gf
from gdsfactory.component import Component
Expand All @@ -8,7 +8,7 @@

@gf.cell
def delay_snake(
total_length: float = 1600.0,
length: float = 1600.0,
L0: float = 5.0,
n: int = 2,
bend: ComponentSpec = "bend_euler",
Expand All @@ -18,8 +18,8 @@ def delay_snake(
"""Snake input facing west output facing east.

Args:
total_length: of the delay.
L0: initial xoffset.
length: delay length in um.
L0: initial xoffset in um.
n: number of loops.
bend: bend spec.
cross_section: cross_section spec.
Expand All @@ -40,7 +40,7 @@ def delay_snake(
epsilon = 0.1
bend90 = gf.get_component(bend, cross_section=cross_section, **kwargs)
dy = bend90.info["dy"]
DL = (total_length + L0 - n * (pi * dy + epsilon)) / (2 * n + 1)
DL = (length + L0 - n * (np.pi * dy + epsilon)) / (2 * n + 1)
L2 = DL - L0
assert (
L2 > 0
Expand All @@ -67,6 +67,15 @@ def delay_snake(
return c


def test_delay_snake_length():
length = 200.0
c = delay_snake(n=1, length=length, cross_section="strip_no_pins")
length_computed = c.area() / 0.5
np.isclose(length, length_computed)
return c


if __name__ == "__main__":
c = delay_snake(cross_section="strip_auto_widen", auto_widen_minimum_length=50)
c = test_delay_snake_length()
# c = delay_snake(cross_section="strip_auto_widen", auto_widen_minimum_length=50)
c.show(show_ports=True)
17 changes: 15 additions & 2 deletions gdsfactory/components/delay_snake3.py
Expand Up @@ -45,7 +45,7 @@ def delay_snake3(
n = n // 2 * 2
bend180 = gf.get_component(bend180, cross_section=cross_section, **kwargs)

delta_length = (length - length0 - n * bend180.info["length"]) / (n + 1)
delta_length = (length - length0 - n * bend180.info["length"]) / n
assert (
delta_length > 0
), "Snake is too short: either reduce length0, increase the total length,\
Expand All @@ -70,8 +70,21 @@ def delay_snake3(
)


def test_length():
import numpy as np

length = 200.0
c = delay_snake3(n=2, length=length, length0=50, cross_section="strip_no_pins")
length_computed = c.area() / 0.5
np.isclose(length, length_computed)


if __name__ == "__main__":
# c = test_delay_snake3_length()
import numpy as np

length = 200.0
c = delay_snake3(n=2, length=length, length0=50)
c = delay_snake3(n=2, length=length, length0=50, cross_section="strip_no_pins")
length_computed = c.area() / 0.5
np.isclose(length, length_computed)
c.show(show_ports=True)
31 changes: 21 additions & 10 deletions gdsfactory/components/delay_snake_sbend.py
Expand Up @@ -23,10 +23,10 @@ def delay_snake_sbend(

Args:
length: total length.
length1: first straight section length.
length3: third straight section length.
radius: u bend radius.
waveguide_spacing: waveguide pitch.
length1: first straight section length in um.
length3: third straight section length in um.
radius: u bend radius in um.
waveguide_spacing: waveguide pitch in um.
bend: bend spec.
sbend: sbend spec.
sbend_size: sbend size.
Expand Down Expand Up @@ -105,11 +105,22 @@ def delay_snake_sbend(
return c


def test_delay_snake_sbend_length():
import numpy as np

length = 200.0
c = delay_snake_sbend(length=length, cross_section="strip_no_pins")
length_computed = c.area() / 0.5
np.isclose(length, length_computed)
return c


if __name__ == "__main__":
c = gf.grid(
[
delay_snake_sbend(length=length, cross_section="rib")
for length in [500, 3000]
]
)
c = test_delay_snake_sbend_length()
# c = gf.grid(
# [
# delay_snake_sbend(length=length, cross_section="rib")
# for length in [500, 3000]
# ]
# )
c.show(show_ports=True)
15 changes: 9 additions & 6 deletions gdsfactory/components/mzi.py
Expand Up @@ -205,11 +205,14 @@ def mzi(
# c = gf.components.mzi2x2_2x2(straight_x_top="straight_heater_metal")
# c.show(show_ports=True)

c1 = gf.components.mzi2x2_2x2(straight_x_top="straight_heater_metal")
c1.write_gds("a.gds")
c = gf.components.mzi2x2_2x2(straight_x_top="straight_heater_metal")
c2 = gf.routing.add_fiber_array(c)
c2.show()

c2 = gf.read.import_gds("a.gds")
c2 = c2.flatten()
# c1.write_gds("a.gds")

c3 = gf.grid([c2, c1])
c3.show(show_ports=False)
# c2 = gf.read.import_gds("a.gds")
# c2 = c2.flatten()

# c3 = gf.grid([c2, c1])
# c3.show(show_ports=False)
4 changes: 3 additions & 1 deletion gdsfactory/cross_section.py
Expand Up @@ -325,7 +325,9 @@ def cross_section(
cladding_offsets=(0,), # for SiEPIC verification
)
strip_auto_widen = partial(strip, width_wide=0.9, auto_widen=True)
strip_no_pins = partial(strip, add_pins=None, add_bbox=None)
strip_no_pins = partial(
strip, add_pins=None, add_bbox=None, cladding_layers=None, cladding_offsets=None
)

# Rib with rectangular slab
rib = partial(
Expand Down
2 changes: 1 addition & 1 deletion gdsfactory/install.py
Expand Up @@ -11,7 +11,7 @@
def remove_path_or_dir(dest: pathlib.Path):
if dest.is_dir():
if dest.is_symlink():
os.rmdir(dest)
os.unlink(dest)
else:
shutil.rmtree(dest)
else:
Expand Down
Expand Up @@ -6,14 +6,14 @@ settings:
L0: 5.0
bend: bend_euler
cross_section: strip
length: 1600.0
n: 2
total_length: 1600.0
full:
L0: 5.0
bend: bend_euler
cross_section: strip
length: 1600.0
n: 2
total_length: 1600.0
function_name: delay_snake
info: {}
info_version: 2
Expand Down