Skip to content

Ring resonator with plugging tidy3D gdsfactory #565

@juanferv

Description

@juanferv

Describe the bug
Once we are generating a ring resonator and exported to tidy3D, the ring is filling completly

To Reproduce

from functools import partial
from pydantic import validate_call
import gdsfactory as gf
import matplotlib.pyplot as plt
import numpy as np
import tidy3d as td
from tidy3d import web
import gdstk
import os
from gdsfactory.generic_tech import LAYER_STACK, get_generic_pdk
import gplugins as gp
import gplugins.tidy3d as gt
from gplugins import plot
from gplugins.common.config import PATH
# Ring
rad = 4.5
gap1 = 0.18
gap2 = 0.2
wg_width = 0.3
ring = gf.components.ring(radius=rad, width=wg_width, angle_resolution=1, layer= "WG")
ring.plot()
left_turn = gf.path.euler(radius=5, angle=37)
arco_izquierda = gf.path.arc(radius=wg_width+gap1+rad, angle=-37)
recta = gf.path.straight(length=3)
right_turn = gf.path.euler(radius=5, angle=37)
arco_derecha = gf.path.arc(radius=wg_width+gap1+rad, angle=-37)
p = recta + left_turn + arco_izquierda + arco_derecha + right_turn + recta
f = p.plot()
l = p.xmax/2
acoplo_up = gf.path.extrude(p, layer="WG", width=wg_width)
acoplo_down = gf.path.extrude(p, layer="WG", width=wg_width)
acoplo_down.rotate(180)
acoplo_up.ymax = ring.ymax + gap1 + wg_width
acoplo_down.ymin = ring.ymin - gap2 - wg_width

acoplo_up.movex(-l)
acoplo_down.movex(l)
k = gf.Component()
acoplo_refup = k << acoplo_up
ring_ref = k << ring
acoplo_refdown = k << acoplo_down

k.plot()
k.add_ports(acoplo_refup.ports, prefix="Up")
k.add_ports(acoplo_refdown.ports, prefix="Down")
k.pprint_ports()
k.draw_ports()
k.plot()
nm = 1e-3
freq0 = td.C_0 / 1310*nm
wavelength = np.linspace(1260, 1360) * nm
f = td.C_0 / wavelength

mapping = {
    "si": td.Medium.from_nk(n=3.5, k=2e-2, freq=freq0,),
    "sio2": td.material_library["SiO2"]["Horiba"],
}
# LAYER_STACK.layers.pop("substrate", None)
# Use the function
componente = gt.Tidy3DComponent(
    component= k,
    layer_stack=LAYER_STACK,
    material_mapping=mapping,
    pad_xy_inner=1.0,
    pad_xy_outer=1.0,
    pad_z_inner=0.0,
    pad_z_outer=0.0,
    extend_ports=0.0,
    port_offset = 1.0,
)
# representamos el componente y el layer stack generado
fig = plt.figure(constrained_layout=True)
gs = fig.add_gridspec(ncols=2, nrows=3, width_ratios=(3, 1))
ax0 = fig.add_subplot(gs[0, 0])
ax1 = fig.add_subplot(gs[1, 0])
ax2 = fig.add_subplot(gs[2, 0])
axl = fig.add_subplot(gs[1, 1])
componente.plot_slice(x="core", ax=ax0)
componente.plot_slice(y="core", ax=ax1)
componente.plot_slice(z=0.1, ax=ax2)
axl.legend(*ax0.get_legend_handles_labels(), loc="center")
axl.axis("off")
plt.show()

Image

Expected behavior
What would you like to happen?
To have the ring as was created in python. and now it is totally filled
Suggested fix
How could we fix the bug?
No idea

Versions
What version of gplugins and each gplugin are you using? Notice that we only may be able help you if you are using the latest version.
You can find the version by running:
Package Version


aenum 3.1.15
annotated-types 0.7.0
antlr4-python3-runtime 4.9.3
argcomplete 3.6.1
asttokens 3.0.0
attrs 25.3.0
autograd 1.7.0
boto3 1.37.18
botocore 1.37.18
cachetools 5.5.2
certifi 2025.1.31
charset-normalizer 3.4.1
click 8.1.8
cloudpickle 3.1.1
colorama 0.4.6
comm 0.2.2
contourpy 1.3.1
cycler 0.12.1
dask 2025.2.0
debugpy 1.8.13
decorator 5.2.1
et_xmlfile 2.0.0
executing 2.2.0
flatdict 4.0.1
flexcache 0.3
flexparser 0.4
fonttools 4.56.0
freetype-py 2.5.1
fsspec 2025.3.0
gdsfactory 9.3.5
gdstk 0.9.59
gitdb 4.0.12
GitPython 3.1.44
gmsh 4.13.1
gplugins 1.3.2
graphviz 0.20.3
h5netcdf 1.0.2
h5py 3.13.0
idna 3.10
imageio 2.37.0
importlib_metadata 8.6.1
ipycytoscape 1.3.3
ipyevents 2.0.2
ipykernel 6.29.5
ipympl 0.9.7
ipython 9.0.2
ipython_pygments_lexers 1.1.1
ipytree 0.2.2
ipywidgets 8.1.5
jedi 0.19.2
Jinja2 3.1.6
jmespath 1.0.1
joblib 1.4.2
jupyter_client 8.6.3
jupyter_core 5.7.2
jupyterlab_widgets 3.0.13
kfactory 1.4.2
kiwisolver 1.4.8
klayout 0.30.0
lazy_loader 0.4
locket 1.0.0
loguru 0.7.3
mapbox_earcut 1.0.3
markdown-it-py 3.0.0
MarkupSafe 3.0.2
matplotlib 3.10.1
matplotlib-inline 0.1.7
mdurl 0.1.2
meshio 5.3.5
meshwell 1.0.9
nest-asyncio 1.6.0
networkx 3.4.2
numpy 1.26.4
omegaconf 2.3.0
openpyxl 3.1.5
orjson 3.10.15
packaging 24.2
pandas 2.2.3
parso 0.8.4
partd 1.4.2
pillow 11.1.0
Pint 0.24.4
pip 25.0.1
pipx 1.7.1
platformdirs 4.3.7
prompt_toolkit 3.0.50
psutil 7.0.0
pure_eval 0.2.3
pydantic 2.11.3
pydantic_core 2.33.1
pydantic-extra-types 2.10.3
pydantic-settings 2.2.1
pyglet 1.5.31
Pygments 2.19.1
PyJWT 2.10.1
pyparsing 3.2.1
pyroots 0.5.0
python-dateutil 2.9.0.post0
python-dotenv 1.0.1
pytz 2025.1
pywin32 310
PyYAML 6.0.2
pyzmq 26.3.0
qrcode 8.0
rectangle-packer 2.0.4
rectpack 0.2.2
requests 2.32.3
responses 0.25.7
rich 13.9.4
ruamel.yaml 0.18.10
ruamel.yaml.clib 0.2.12
ruamel.yaml.string 0.1.1
s3transfer 0.11.4
scikit-image 0.25.2
scipy 1.15.2
setuptools 75.8.2
shapely 2.0.7
shellingham 1.5.4
six 1.17.0
smmap 5.0.2
spectate 1.0.1
stack-data 0.6.3
tidy3d 2.7.9
tifffile 2025.3.13
toml 0.10.2
tomli 2.2.1
toolz 1.0.0
tornado 6.4.2
tqdm 4.67.1
traitlets 5.14.3
trimesh 4.6.6
typer 0.15.2
types-PyYAML 6.0.12.20241230
typing_extensions 4.12.2
typing-inspection 0.4.0
tzdata 2025.1
urllib3 2.3.0
userpath 1.9.2
watchdog 3.0.0
wcwidth 0.2.13
wheel 0.45.1
widgetsnbextension 4.0.13
win32_setctime 1.2.0
xarray 2025.1.2
xlrd 2.0.1
zipp 3.21.0

Then copy paste the table so that we know which version of python and plugins you are using.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions