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

Pdk improvements #2694

Merged
merged 4 commits into from Apr 22, 2024
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
23 changes: 16 additions & 7 deletions gdsfactory/components/ring_crow.py
Expand Up @@ -12,24 +12,28 @@
def ring_crow(
gaps: list[float] = [0.2] * 4,
radius: list[float] = [10.0] * 3,
input_straight_cross_section: CrossSectionSpec = strip,
output_straight_cross_section: CrossSectionSpec = strip,
bends: list[ComponentSpec] = [bend_circular] * 3,
ring_cross_sections: list[CrossSectionSpec] = [strip] * 3,
length_x: float = 0,
lengths_y: list[float] = [0] * 3,
input_straight_cross_section: CrossSectionSpec | None = None,
output_straight_cross_section: CrossSectionSpec | None = None,
cross_section: CrossSectionSpec = "xs_sc",
Comment on lines +19 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code_refinement): Consider initializing input_straight_cross_section and output_straight_cross_section directly to cross_section if not provided.

This would simplify the logic and reduce redundancy in the code.

Suggested change
input_straight_cross_section: CrossSectionSpec | None = None,
output_straight_cross_section: CrossSectionSpec | None = None,
cross_section: CrossSectionSpec = "xs_sc",
input_straight_cross_section: CrossSectionSpec | None = None,
output_straight_cross_section: CrossSectionSpec | None = None,
cross_section: CrossSectionSpec = input_straight_cross_section or output_straight_cross_section or "xs_sc",

) -> Component:
"""Coupled ring resonators.

Args:
gap: gap between for coupler.
radius: for the bend and coupler.
gaps: gap between rings.
radius: for each ring.
bends: bend spec for each ring.
ring_cross_sections: cross_section spec for each ring.
length_x: ring coupler length.
length_y: vertical straight length.
coupler: ring coupler spec.
straight: straight spec.
bend: bend spec.
cross_section: cross_section spec.
input_straight_cross_section: cross_section spec for input and output straight. Defaults to cross_section.
output_straight_cross_section: cross_section spec for input and output straight. Defaults to cross_section.
cross_section: cross_section spec for input and output straight.
kwargs: cross_section settings.

.. code::
Expand Down Expand Up @@ -59,6 +63,11 @@ def ring_crow(
length_x
"""
c = Component()
input_straight_cross_section = input_straight_cross_section or cross_section
output_straight_cross_section = output_straight_cross_section or cross_section

output_straight_cross_section = gf.get_cross_section(output_straight_cross_section)
input_straight_cross_section = gf.get_cross_section(input_straight_cross_section)

# Input bus
input_straight = gf.get_component(
Expand Down Expand Up @@ -128,7 +137,7 @@ def ring_crow(
length=2 * radius[-1] + length_x,
cross_section=output_straight_cross_section,
)
output_straight_width = output_straight_cross_section().width
output_straight_width = output_straight_cross_section.width
output_straight_waveguide = (
c.add_ref(output_straight)
.movey(cum_y_dist + gaps[-1] + output_straight_width / 2)
Expand Down
6 changes: 4 additions & 2 deletions gdsfactory/components/spiral_double.py
Expand Up @@ -7,7 +7,7 @@

@gf.cell
def spiral_double(
min_bend_radius: float = 10.0,
min_bend_radius: float | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code_clarification): Clarify in the documentation the behavior when min_bend_radius is None.

separation: float = 2.0,
number_of_loops: float = 3,
npoints: int = 1000,
Expand All @@ -17,14 +17,16 @@ def spiral_double(
"""Returns a spiral double (spiral in, and then out).

Args:
min_bend_radius: inner radius of the spiral.
min_bend_radius: inner radius of the spiral. Defaults to cross_section radius.
separation: separation between the loops.
number_of_loops: number of loops per spiral.
npoints: points for the spiral.
cross_section: cross-section to extrude the structure with.
bend: factory for the bends in the middle of the double spiral.
"""
component = gf.Component()
xs = gf.get_cross_section(cross_section)
min_bend_radius = min_bend_radius or xs.radius
Comment on lines +28 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Validate xs.radius is not None before assignment to avoid potential runtime errors.


bend = gf.get_component(
bend, radius=min_bend_radius / 2, angle=180, cross_section=cross_section
Expand Down
4 changes: 0 additions & 4 deletions gdsfactory/generic_tech/simulation_settings.py
@@ -1,15 +1,11 @@
from __future__ import annotations

from functools import partial
from typing import TYPE_CHECKING

import numpy as np
from pydantic import BaseModel
from scipy import interpolate

if TYPE_CHECKING:
pass

material_name_to_lumerical_default = {
"si": "Si (Silicon) - Palik",
"sio2": "SiO2 (Glass) - Palik",
Expand Down
15 changes: 3 additions & 12 deletions test-data-regression/test_settings_ring_crow_.yml
Expand Up @@ -7,28 +7,19 @@ settings:
- function: bend_circular
- function: bend_circular
- function: bend_circular
cross_section: xs_sc
gaps:
- 0.2
- 0.2
- 0.2
- 0.2
input_straight_cross_section:
function: cross_section
module: gdsfactory.cross_section
settings:
radius: 10
radius_min: 5
input_straight_cross_section: null
length_x: 0
lengths_y:
- 0
- 0
- 0
output_straight_cross_section:
function: cross_section
module: gdsfactory.cross_section
settings:
radius: 10
radius_min: 5
output_straight_cross_section: null
radius:
- 10.0
- 10.0
Expand Down
2 changes: 1 addition & 1 deletion test-data-regression/test_settings_spiral_double_.yml
Expand Up @@ -7,7 +7,7 @@ settings:
bend:
function: bend_circular
cross_section: xs_sc
min_bend_radius: 10.0
min_bend_radius: null
npoints: 1000
number_of_loops: 3
separation: 2.0