Skip to content

Commit

Permalink
Added parabolic width_type to taper_cross_section
Browse files Browse the repository at this point in the history
  • Loading branch information
bsnyder committed Sep 25, 2022
1 parent 5a7abfd commit 55210a1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions gdsfactory/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
)
from gdsfactory.components.taper_cross_section import (
taper_cross_section_linear,
taper_cross_section_parabolic,
taper_cross_section_sine,
)
from gdsfactory.components.taper_from_csv import (
Expand Down Expand Up @@ -270,6 +271,7 @@
crossing45=crossing45,
taper_cross_section_linear=taper_cross_section_linear,
taper_cross_section_sine=taper_cross_section_sine,
taper_cross_section_parabolic=taper_cross_section_parabolic,
taper=taper,
taper2=taper2,
taper_0p5_to_3_l36=taper_0p5_to_3_l36,
Expand Down
7 changes: 6 additions & 1 deletion gdsfactory/components/taper_cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def taper_cross_section(
length: float = 10,
npoints: int = 100,
linear: bool = False,
width_type: str = "sine",
**kwargs
) -> Component:
r"""Returns taper transition between cross_section1 and cross_section2.
Expand All @@ -22,6 +23,7 @@ def taper_cross_section(
length: transition length.
npoints: number of points.
linear: shape of the transition, sine when False.
width_type: shape of the transition ONLY IF linear is False
kwargs: cross_section settings for section2.
Expand All @@ -42,7 +44,7 @@ def taper_cross_section(
transition = gf.path.transition(
cross_section1=gf.get_cross_section(cross_section1),
cross_section2=gf.get_cross_section(cross_section2, **kwargs),
width_type="linear" if linear else "sine",
width_type="linear" if linear else width_type,
)
taper_path = gf.path.straight(length=length, npoints=npoints)

Expand All @@ -54,6 +56,9 @@ def taper_cross_section(

taper_cross_section_linear = gf.partial(taper_cross_section, linear=True, npoints=2)
taper_cross_section_sine = gf.partial(taper_cross_section, linear=False, npoints=101)
taper_cross_section_parabolic = gf.partial(
taper_cross_section, linear=False, width_type="parabolic", npoints=101
)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion gdsfactory/cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
LAYER = TECH.layer
Layer = Tuple[int, int]
Layers = Tuple[Layer, ...]
WidthTypes = Literal["sine", "linear"]
WidthTypes = Literal["sine", "linear", "parabolic"]

LayerSpec = Union[Layer, int, str, None]
LayerSpecs = Union[List[LayerSpec], Tuple[LayerSpec, ...]]
Expand Down
15 changes: 14 additions & 1 deletion gdsfactory/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ def sine(t):
return sine


def _parabolic_transition(y1, y2):
dy = y2 - y1

def parabolic(t):
return y1 + np.sqrt(t) * dy

return parabolic


def _linear_transition(y1, y2):
dy = y2 - y1

Expand Down Expand Up @@ -225,8 +234,12 @@ def transition(
width_fun = _linear_transition(width1, width2)
elif width_type == "sine":
width_fun = _sinusoidal_transition(width1, width2)
elif width_type == "parabolic":
width_fun = _parabolic_transition(width1, width2)
else:
raise ValueError(f"width_type={width_type!r} must be {'sine','linear'}")
raise ValueError(
f"width_type={width_type!r} must be {'sine','linear','parabolic'}"
)

if section1.layer != section2.layer:
hidden = True
Expand Down
2 changes: 1 addition & 1 deletion gdsfactory/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
]
Axis = Literal["x", "y"]
NSEW = Literal["N", "S", "E", "W"]
WidthTypes = Literal["sine", "linear"]
WidthTypes = Literal["sine", "linear", "parabolic"]


class Label(LabelPhidl):
Expand Down

0 comments on commit 55210a1

Please sign in to comment.