Skip to content

Commit

Permalink
Merge pull request #682 from gdsfactory/5263
Browse files Browse the repository at this point in the history
fix tidy3d mode solver sweep width
  • Loading branch information
joamatab committed Sep 8, 2022
2 parents 7175f2b + 491ecb9 commit 95f24dc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
13 changes: 11 additions & 2 deletions fixme/netlist_hierarchical.py
@@ -1,4 +1,7 @@
"""FIXME."""
"""FIXME.
Where is the light going?
"""
import numpy as np
import matplotlib.pyplot as plt
import jax.numpy as jnp
Expand Down Expand Up @@ -78,6 +81,8 @@ def phase_shifter(
"straight": straight,
"taper": straight,
"straight_heater_metal_undercut": phase_shifter,
"compass": sax.models.passthru(10),
"via": sax.models.passthru(10),
}


Expand All @@ -95,7 +100,11 @@ def phase_shifter(

plt.figure(figsize=(14, 4))
plt.title("MZI")
plt.plot(1e3 * wl, jnp.abs(S["o1", "o2"]) ** 2)

plt.plot(1e3 * wl, jnp.abs(S["o1_0_0", "o2_1_9"]) ** 2)
plt.plot(1e3 * wl, jnp.abs(S["o1_0_0", "o3_1_6"]) ** 2)
plt.plot(1e3 * wl, jnp.abs(S["o1_0_0", "o2_1_5"]) ** 2)
plt.plot(1e3 * wl, jnp.abs(S["o1_0_0", "o3_1_10"]) ** 2)
plt.xlabel("λ [nm]")
plt.ylabel("T")
plt.grid(True)
Expand Down
2 changes: 1 addition & 1 deletion gdsfactory/simulation/gtidy3d/modes.py
Expand Up @@ -657,7 +657,7 @@ def sweep_width(
wg = Waveguide(nmodes=nmodes, wg_width=wg_width, **kwargs)
wg.compute_modes()
for mode_number in range(1, nmodes + 1):
neff[mode_number].append(np.real(wg.neffs[mode_number]))
neff[mode_number].append(np.real(wg.neffs[mode_number - 1]))

df = pd.DataFrame(neff)
df["width"] = width
Expand Down
20 changes: 20 additions & 0 deletions gdsfactory/simulation/gtidy3d/tests/test_modes.py
@@ -1,7 +1,10 @@
import numpy as np

import gdsfactory.simulation.gtidy3d as gt
from gdsfactory.simulation.gtidy3d.modes import Waveguide, group_index, si, sio2

nm = 1e-3


def test_neff_cached():
c = Waveguide(
Expand Down Expand Up @@ -46,5 +49,22 @@ def test_ng_no_cache():
assert np.isclose(ng, 4.169, rtol=0.01), ng


def test_sweep_width(dataframe_regression) -> None:
df = gt.modes.sweep_width(
width1=200 * nm,
width2=1000 * nm,
steps=1,
wavelength=1.55,
wg_thickness=220 * nm,
slab_thickness=0 * nm,
ncore=gt.modes.si,
nclad=gt.modes.sio2,
cache=None,
)

if dataframe_regression:
dataframe_regression.check(df)


if __name__ == "__main__":
test_ng_no_cache()

0 comments on commit 95f24dc

Please sign in to comment.