Skip to content

Commit

Permalink
Merge pull request #256 from gdsfactory/add_plot_epsilon
Browse files Browse the repository at this point in the history
Add tidy3d plot epsilon
  • Loading branch information
joamatab authored Nov 30, 2023
2 parents f5adaa1 + 6c9496c commit 2973cf5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 53 deletions.
97 changes: 47 additions & 50 deletions gplugins/tidy3d/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ def write_sparameters(
plot_simulation_x: float | None = None,
plot_mode_index: int | None = 0,
plot_mode_port_name: str | None = None,
plot_epsilon: bool = False,
filepath: PathType | None = None,
overwrite: bool = False,
) -> Sparameters:
Expand Down Expand Up @@ -534,8 +535,13 @@ def write_sparameters(
center_z=plot_simulation_layer_name, port_size_mult=(6, 4), sim_size_z=3.0
)
_, ax = plt.subplots(2, 1)
modeler.plot_sim(z=z, ax=ax[0])
modeler.plot_sim(x=x, ax=ax[1])
if plot_epsilon:
modeler.plot_sim_eps(z=z, ax=ax[0])
modeler.plot_sim_eps(x=x, ax=ax[1])

else:
modeler.plot_sim(z=z, ax=ax[0])
modeler.plot_sim(x=x, ax=ax[1])
plt.show()
return sp

Expand Down Expand Up @@ -647,55 +653,46 @@ def write_sparameters_batch(


if __name__ == "__main__":
from functools import partial

import gdsfactory as gf

pdk = gf.get_active_pdk()
layer_stack = pdk.get_layer_stack()
layer_stack.layers.pop("substrate", None)

width = 0.45
cross_section = pdk.get_cross_section("xs_sc", width=width)
coupler_sc = partial(
gf.components.coupler,
dx=4,
dy=2,
cross_section=cross_section,
) # Coupler Strip C-Band

sims = write_sparameters_batch(
[
dict(
component=coupler_sc(length=i),
# sim_size_z=0,
# filepath=PATH.sparameters_repo / f"dc_{i}.npz",
layer_stack=layer_stack,
sim_size_z=0,
# overwrite=True,
)
for i in range(2)
]
)
s_params_list = [sim.result() for sim in sims]
# c = gf.components.taper_sc_nc()

# run = False
# c = write_sparameters(c, sim_size_z=0, run=False, center_z="core")
# modeler = c.get_component_modeler()
# modeler.plot_sim(z=0)
# plt.show()

# mode_spec = td.ModeSpec(num_modes=2, filter_pol="te")
# sp = write_sparameters(c, sim_size_z=0, center_z="core", plot_simulation_layer_name='core', plot_simulation_port_index=1, mode_spec=mode_spec)
# sp = write_sparameters(
# c,
# sim_size_z=4,
# center_z="core",
# plot_simulation_x=10,
# plot_simulation_layer_name="core",
# # plot_mode_port_name="o1",
# # plot_mode_index=1,
# # mode_spec=mode_spec,
# pdk = gf.get_active_pdk()
# layer_stack = pdk.get_layer_stack()
# layer_stack.layers.pop("substrate", None)

# width = 0.45
# cross_section = pdk.get_cross_section("xs_sc", width=width)
# coupler_sc = partial(
# gf.components.coupler,
# dx=4,
# dy=2,
# cross_section=cross_section,
# ) # Coupler Strip C-Band

# sims = write_sparameters_batch(
# [
# dict(
# component=coupler_sc(length=i),
# # sim_size_z=0,
# # filepath=PATH.sparameters_repo / f"dc_{i}.npz",
# layer_stack=layer_stack,
# sim_size_z=0,
# overwrite=True,
# )
# for i in range(2)
# ]
# )
# s_params_list = [sim.result() for sim in sims]
c = gf.components.taper_sc_nc()

sp = write_sparameters(
c,
sim_size_z=4,
center_z="core",
plot_simulation_x=10,
plot_simulation_layer_name="core",
plot_epsilon=True,
# plot_mode_port_name="o1",
# plot_mode_index=1,
# mode_spec=mode_spec,
)
# gp.plot.plot_sparameters(sp)
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dev = [
devsim = [
"devsim",
"pyvista<=0.40",
"tidy3d>=2.4.0,<2.5.0"
"tidy3d==2.5.0rc3"
]
docs = [
"jupytext",
Expand Down Expand Up @@ -75,7 +75,7 @@ meow = [
"jaxlib",
"jax",
"meow-sim>0.8,<0.9",
"tidy3d>=2.4.0,<2.5.0"
"tidy3d==2.5.0rc3"
]
sax = [
"jaxlib",
Expand All @@ -88,7 +88,7 @@ schematic = [
"natsort"
]
tidy3d = [
"tidy3d>=2.4.0,<2.5.0",
"tidy3d==2.5.0rc3",
"meshio",
"meshwell>=1.0.0,<1.1"
]
Expand Down

0 comments on commit 2973cf5

Please sign in to comment.