Skip to content

Commit e4e278d

Browse files
authored
Merge pull request #611 from gdsfactory/improve-path-length-extraction-notebook
Improve path-length extraction notebook
2 parents c207e49 + 1212eb1 commit e4e278d

File tree

4 files changed

+192
-92
lines changed

4 files changed

+192
-92
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ test:
2727
pytest
2828

2929
uv-test:
30-
@for plugin in femwell gmsh meow sax tidy3d klayout vlsir; do \
30+
@for plugin in femwell gmsh meow sax tidy3d klayout vlsir path_length_analysis; do \
3131
uv run pytest gplugins/$$plugin; \
3232
done
3333

3434
cov:
35-
uv run pytest gplugins/femwell gplugins/gmsh gplugins/meow gplugins/sax gplugins/tidy3d gplugins/klayout gplugins/vlsir --cov=gplugins/femwell --cov=gplugins/gmsh --cov=gplugins/meow --cov=gplugins/sax --cov=gplugins/tidy3d --cov=gplugins/klayout --cov=gplugins/vlsir
35+
uv run pytest gplugins/femwell gplugins/gmsh gplugins/meow gplugins/sax gplugins/tidy3d gplugins/klayout gplugins/vlsir gplugins/path_length_analysis --cov=gplugins/femwell --cov=gplugins/gmsh --cov=gplugins/meow --cov=gplugins/sax --cov=gplugins/tidy3d --cov=gplugins/klayout --cov=gplugins/vlsir --cov=gplugins/path_length_analysis
3636

3737
test-data:
3838
git clone https://github.com/gdsfactory/gdsfactory-test-data.git -b test-data test-data
@@ -73,4 +73,4 @@ clean:
7373
rm -rf .ruff_cache
7474
rm -rf .venv
7575

76-
.PHONY: drc doc docs
76+
.PHONY: drc doc docs dev

docs/bibliography.bib

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
11
@article{marxer_long-distance_2023,
2-
title = {Long-Distance Transmon Coupler with cz-Gate Fidelity above 99.8 \%},
3-
author = {Marxer, Fabian and Veps\"{a}l\"{a}inen, Antti and Jolin, Shan W. and Tuorila, Jani and Landra, Alessandro and Ockeloen-Korppi, Caspar and Liu, Wei and Ahonen, Olli and Auer, Adrian and Belzane, Lucien and Bergholm, Ville and Chan, Chun Fai and Chan, Kok Wai and Hiltunen, Tuukka and Hotari, Juho and Hyypp\"{a}, Eric and Ikonen, Joni and Janzso, David and Koistinen, Miikka and Kotilahti, Janne and Li, Tianyi and Luus, Jyrgen and Papic, Miha and Partanen, Matti and R\"{a}bin\"{a}, Jukka and Rosti, Jari and Savytskyi, Mykhailo and Sepp\"{a}l\"{a}, Marko and Sevriuk, Vasilii and Takala, Eelis and Tarasinski, Brian and Thapa, Manish J. and Tosto, Francesca and Vorobeva, Natalia and Yu, Liuqi and Tan, Kuan Yen and Hassel, Juha and M\"{o}tt\"{o}nen, Mikko and Heinsoo, Johannes},
4-
year = {2023},
5-
journal = {{PRX} Quantum},
6-
volume = {4},
7-
number = {1},
8-
pages = {010314},
9-
doi = {10.1103/PRXQuantum.4.010314},
10-
issn = {2691-3399},
11-
url = {https://link.aps.org/doi/10.1103/PRXQuantum.4.010314},
12-
urldate = {2023-08-17},
13-
shortjournal = {{PRX} Quantum},
14-
date = {2023-02-06},
15-
langid = {english}
2+
title = {Long-Distance Transmon Coupler with cz-Gate Fidelity above 99.8 \%},
3+
author = {Marxer, Fabian and Veps\"{a}l\"{a}inen, Antti and Jolin, Shan W. and Tuorila, Jani and Landra, Alessandro and Ockeloen-Korppi, Caspar and Liu, Wei and Ahonen, Olli and Auer, Adrian and Belzane, Lucien and Bergholm, Ville and Chan, Chun Fai and Chan, Kok Wai and Hiltunen, Tuukka and Hotari, Juho and Hyypp\"{a}, Eric and Ikonen, Joni and Janzso, David and Koistinen, Miikka and Kotilahti, Janne and Li, Tianyi and Luus, Jyrgen and Papic, Miha and Partanen, Matti and R\"{a}bin\"{a}, Jukka and Rosti, Jari and Savytskyi, Mykhailo and Sepp\"{a}l\"{a}, Marko and Sevriuk, Vasilii and Takala, Eelis and Tarasinski, Brian and Thapa, Manish J. and Tosto, Francesca and Vorobeva, Natalia and Yu, Liuqi and Tan, Kuan Yen and Hassel, Juha and M\"{o}tt\"{o}nen, Mikko and Heinsoo, Johannes},
4+
year = {2023},
5+
journal = {{PRX} Quantum},
6+
volume = {4},
7+
number = {1},
8+
pages = {010314},
9+
doi = {10.1103/PRXQuantum.4.010314},
10+
issn = {2691-3399},
11+
url = {https://link.aps.org/doi/10.1103/PRXQuantum.4.010314},
12+
urldate = {2023-08-17},
13+
shortjournal = {{PRX} Quantum},
14+
date = {2023-02-06},
15+
langid = {english}
1616
}
1717
@article{smolic_capacitance_2021,
18-
title = {Capacitance matrix revisited},
19-
author = {Smoli\'{c}, Ivica and Klajn, Bruno},
20-
year = {2021},
21-
journal = {Progress In Electromagnetics Research B},
22-
volume = {92},
23-
pages = {1--18},
24-
doi = {10.2528/PIERB21011501},
25-
issn = {1937-6472},
26-
url = {http://www.jpier.org/PIERB/pier.php?paper=21011501},
27-
urldate = {2023-08-17},
28-
shortjournal = {{PIER} B},
29-
date = {2021},
30-
langid = {english}
18+
title = {Capacitance matrix revisited},
19+
author = {Smoli\'{c}, Ivica and Klajn, Bruno},
20+
year = {2021},
21+
journal = {Progress In Electromagnetics Research B},
22+
volume = {92},
23+
pages = {1--18},
24+
doi = {10.2528/PIERB21011501},
25+
issn = {1937-6472},
26+
url = {http://www.jpier.org/PIERB/pier.php?paper=21011501},
27+
urldate = {2023-08-17},
28+
shortjournal = {{PIER} B},
29+
date = {2021},
30+
langid = {english}
31+
}
32+
@misc{weisstein_radius,
33+
type = {Text},
34+
title = {Radius of {Curvature}},
35+
copyright = {Copyright 1999-2025 Wolfram Research, Inc. See https://mathworld.wolfram.com/about/terms.html for a full terms of use statement.},
36+
url = {https://mathworld.wolfram.com/RadiusofCurvature.html},
37+
abstract = {The radius of curvature is given by R=1/({\textbar}kappa{\textbar}), (1) where kappa is the curvature. At a given point on a curve, R is the radius of the osculating circle. The symbol rho is sometimes used instead of R to denote the radius of curvature (e.g., Lawrence 1972, p. 4). Let x and y be given parametrically by x = x(t) (2) y = y(t), (3) then R=((x{\textasciicircum}('2)+y{\textasciicircum}('2)){\textasciicircum}(3/2))/({\textbar}x{\textasciicircum}'y{\textasciicircum}('')-y{\textasciicircum}'x{\textasciicircum}(''){\textbar}), (4) where x{\textasciicircum}'=dx/dt and y{\textasciicircum}'=dy/dt. Similarly, if the curve is written in the form y=f(x), then the...},
38+
language = {en},
39+
urldate = {2025-06-25},
40+
journal = {MathWorld--A Wolfram Resource.},
41+
author = {Weisstein, Eric W.}
3142
}

gplugins/path_length_analysis/path_length_analysis_from_gds.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
filter_points_by_std_distance,
1616
resample_polygon_points_w_interpolator,
1717
sort_points_nearest_neighbor,
18+
smoothed_savgol_filter,
1819
)
1920

2021
fix_values = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]
@@ -80,6 +81,8 @@ def centerline_voronoi_2_ports(
8081
"port_list must be a list of 2 ports, got: "
8182
f"{port_list} with length {len(port_list)}"
8283
)
84+
port_list = [p.to_itype() for p in port_list]
85+
8386
# Simplify points that are too close to each other
8487
r = gf.kdb.Region(poly)
8588
r = r.smoothed(0.05, True)
@@ -96,6 +99,7 @@ def centerline_voronoi_2_ports(
9699
shapely_poly_original = sh.Polygon(points)
97100

98101
# Infer port widths to be 2x the distance between the port center and the nearest point on the polygon
102+
# This is done such that port_positions is supported
99103
port_widths = []
100104
for port in port_list:
101105
# Compute distances from each point to port center
@@ -655,7 +659,7 @@ def extract_paths(
655659
centerline.points[:, 0],
656660
centerline.points[:, 1],
657661
"x--",
658-
label=ports,
662+
label=f"Ports {ports}",
659663
)
660664
plt.legend()
661665
plt.title("Direct paths")
@@ -675,13 +679,14 @@ def extract_paths(
675679
centerline.points[:, 0],
676680
centerline.points[:, 1],
677681
"--",
678-
label=ports,
682+
label=f"Ports {ports}",
679683
)
680684
plt.legend()
681685
plt.title("Evanescent paths")
682686
plt.xlabel("X-coordinate")
683687
plt.ylabel("Y-coordinate")
684688
plt.grid(True)
689+
plt.gca().set_aspect("equal", adjustable="box") # Force equilateral axes
685690

686691
plt.show()
687692

@@ -708,7 +713,7 @@ def get_min_radius_and_length(path: gf.Path) -> tuple[float, float]:
708713
return min_radius, path.length()
709714

710715

711-
def plot_curvature(path: gf.Path, rmax: int | float = 200) -> None:
716+
def plot_curvature(path: gf.Path, rmax: int | float = 200) -> plt.Figure:
712717
"""Plot the curvature of a path.
713718
714719
Args:
@@ -721,11 +726,14 @@ def plot_curvature(path: gf.Path, rmax: int | float = 200) -> None:
721726
curvature2 = K[valid_indices]
722727
s2 = s[valid_indices]
723728

729+
smoothed_curvature = smoothed_savgol_filter(curvature2)
730+
724731
plt.figure(figsize=(10, 5))
725-
plt.plot(s2, curvature2, ".-")
726-
plt.xlabel("Position along curve (arc length)")
732+
plt.plot(s2, curvature2, ".-", label="Raw")
733+
plt.plot(s2, smoothed_curvature, ".-", label="Savitzky–Golay filtered")
734+
plt.xlabel("Position along arc length (units)")
727735
plt.ylabel("Curvature (units⁻¹)")
728-
plt.show()
736+
plt.legend()
729737
return plt
730738

731739

@@ -744,7 +752,7 @@ def plot_radius(path: gf.Path, rmax: float = 200) -> plt.Figure:
744752

745753
fig, ax = plt.subplots(1, 1, figsize=(15, 5))
746754
ax.plot(s2, radius2, ".-")
747-
ax.set_xlabel("Position along curve (arc length)")
755+
ax.set_xlabel("Position along arc length (units)")
748756
ax.set_ylabel("Radius of curvature (units)")
749757
ax.grid(True)
750758
return fig

0 commit comments

Comments
 (0)