Skip to content

Commit

Permalink
Consitent layer stack name (#157)
Browse files Browse the repository at this point in the history
-  update to latest tidy3d 2.4 and gdsfactory, unpin jax and jaxlib
- rename `layerstack` to `layer_stack` to be consistent with gdsfactory
- rename portnames to port_names  to be consistent with python convention

* fix docs and tests
  • Loading branch information
joamatab authored Sep 20, 2023
1 parent 547d2be commit 2031f94
Show file tree
Hide file tree
Showing 50 changed files with 481 additions and 489 deletions.
1 change: 1 addition & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ execute:
- "*03_numerical_implantation*"
- "*02_model_extraction*"
- "*palace*"
- "*elmer_01_electrostatic*"
- "*fdtdz*"
# - "*sax_01_sax*"
# - "*20_schematic_driven_layout*"
Expand Down
6 changes: 3 additions & 3 deletions docs/api_design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Meshing
to_polygons
get_layer_overlaps_z
get_layers_at_z
list_unique_layerstack_z
map_unique_layerstack_z
order_layerstack
list_unique_layer_stack_z
map_unique_layer_stack_z
order_layer_stack
get_u_bounds_layers
get_u_bounds_polygons
get_uz_bounds_layers
Expand Down
8 changes: 4 additions & 4 deletions docs/notebooks/elmer_01_electrostatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
c.add_ports(cap.ports)
substrate = gf.components.bbox(bbox=simulation_box, layer=LAYER.WAFER)
c << substrate
c.flatten()
c = c.flatten()
c.plot()

# %% [markdown]
# ## Running the simulation
Expand Down Expand Up @@ -121,9 +122,8 @@
mesh_parameters=dict(
background_tag="vacuum",
background_padding=(0,) * 5 + (700,),
portnames=c.ports,
port_names=c.ports.keys(),
default_characteristic_length=200,
layer_portname_delimiter=(delimiter := "__"),
resolutions={
"bw": {
"resolution": 15,
Expand All @@ -135,7 +135,7 @@
"resolution": 40,
},
**{
f"bw{delimiter}{port}": {
f"bw{port}": {
"resolution": 20,
"DistMax": 30,
"DistMin": 10,
Expand Down
12 changes: 6 additions & 6 deletions docs/notebooks/fdtdz_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@
)
c.add_ports(gf.components.straight(length=length).get_ports_list())

c.plot_matplotlib(show_ports=True)
c.plot()
# -

# ### Define your LayerStack
#
# Here we load the generic LayerStack, but only keep the `core`, `clad`, and `box` layers:

filtered_layerstack = LayerStack(
filtered_layer_stack = LayerStack(
layers={
k: LAYER_STACK.layers[k] for k in ["clad", "box", "core", "slab90", "nitride"]
}
)
filtered_layerstack
filtered_layer_stack

# We show how to inspect the resulting permittivity below to troubleshoot.

Expand All @@ -94,7 +94,7 @@

out = get_sparameters_fdtdz(
component=c,
layerstack=filtered_layerstack,
layer_stack=filtered_layer_stack,
nm_per_pixel=20,
extend_ports_length=0.0,
zmin=-0.5,
Expand All @@ -119,7 +119,7 @@
#
# ### Permittivity distribution
#
# Pass the component, layerstack, and minz, and slice the simulation domain to inspect the permittivity.
# Pass the component, layer_stack, and minz, and slice the simulation domain to inspect the permittivity.
#
# For xy-plane visualization, set `x = y = None` and choose a z-value:

Expand All @@ -130,7 +130,7 @@
nm_per_pixel = 20

epsilon = component_to_epsilon_pjz(
component=c, layerstack=filtered_layerstack, zmin=zmin
component=c, layer_stack=filtered_layer_stack, zmin=zmin
)

fig = plot_epsilon(
Expand Down
14 changes: 7 additions & 7 deletions docs/notebooks/femwell_01_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
logging.basicConfig(level="WARNING", datefmt="[%X]", handlers=[RichHandler()])

# +
filtered_layerstack = LayerStack(
filtered_layer_stack = LayerStack(
layers={
k: LAYER_STACK.layers[k]
for k in (
Expand All @@ -44,13 +44,13 @@
}
)

filtered_layerstack.layers[
filtered_layer_stack.layers[
"core"
].thickness = 0.22 # Perturb the layerstack before simulating
].thickness = 0.22 # Perturb the layer_stack before simulating

filtered_layerstack.layers[
filtered_layer_stack.layers[
"slab90"
].thickness = 0.09 # Perturb the layerstack before simulating
].thickness = 0.09 # Perturb the layer_stack before simulating

resolutions = {
"core": {"resolution": 0.02, "distance": 2},
Expand All @@ -62,7 +62,7 @@

modes = compute_cross_section_modes(
cross_section=rib(width=0.6),
layerstack=filtered_layerstack,
layer_stack=filtered_layer_stack,
wavelength=1.55,
num_modes=4,
resolutions=resolutions,
Expand Down Expand Up @@ -90,7 +90,7 @@
for i, width in enumerate(tqdm(widths)):
modes = compute_cross_section_modes(
cross_section=gf.cross_section.strip(width=width),
layerstack=filtered_layerstack,
layer_stack=filtered_layer_stack,
wavelength=1.55,
num_modes=num_modes,
resolutions=resolutions,
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/femwell_02_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

print(LAYER_STACK.layers.keys())

filtered_layerstack = LayerStack(
filtered_layer_stack = LayerStack(
layers={
k: gf.pdk.get_layer_stack().layers[k]
for k in ("slab90", "core", "via_contact", "heater")
Expand All @@ -50,7 +50,7 @@ def mesh_with_physicals(mesh, filename):
component=heater,
type="uz",
xsection_bounds=[(4, -4), (4, 4)],
layer_stack=filtered_layerstack,
layer_stack=filtered_layer_stack,
filename=f"{filename}.msh",
)
mesh = mesh_with_physicals(mesh, filename)
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/meep_03_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
bottom=3.2,
)

component.plot_matplotlib()
component.plot()
# -

# ## Define a continuous source simulation
Expand Down
22 changes: 12 additions & 10 deletions docs/notebooks/meow_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
# You also need to explicitly provide a LayerStack to define cross-sections, for instance the generic one:

# +
layerstack = LAYER_STACK
layer_stack = LAYER_STACK

filtered_layerstack = gf.technology.LayerStack(
filtered_layer_stack = gf.technology.LayerStack(
layers={
k: layerstack.layers[k]
k: layer_stack.layers[k]
for k in (
"slab90",
"core",
Expand All @@ -45,7 +45,9 @@

# The EME simulator can be instantiated with only these two elements, alongside parameters:

eme = MEOW(component=c, layerstack=filtered_layerstack, wavelength=1.55, overwrite=True)
eme = MEOW(
component=c, layer_stack=filtered_layer_stack, wavelength=1.55, overwrite=True
)

# Plotting functions allow you to check your simulation:

Expand Down Expand Up @@ -79,11 +81,11 @@
# Lets sweep the length of the taper.

# +
layerstack = LAYER_STACK
layer_stack = LAYER_STACK

filtered_layerstack = gf.technology.LayerStack(
filtered_layer_stack = gf.technology.LayerStack(
layers={
k: layerstack.layers[k]
k: layer_stack.layers[k]
for k in (
"slab90",
"core",
Expand All @@ -106,7 +108,7 @@
for cell_length in cells_lengths:
m = MEOW(
component=c,
layerstack=filtered_layerstack,
layer_stack=filtered_layer_stack,
wavelength=1.55,
overwrite=True,
spacing_y=-3,
Expand All @@ -124,7 +126,7 @@

eme = MEOW(
component=c,
layerstack=filtered_layerstack,
layer_stack=filtered_layer_stack,
wavelength=1.55,
overwrite=True,
spacing_y=-3,
Expand Down Expand Up @@ -161,7 +163,7 @@
c = gf.components.taper(width1=0.5, width2=2, length=length)
eme = MEOW(
component=c,
layerstack=filtered_layerstack,
layer_stack=filtered_layer_stack,
wavelength=1.55,
overwrite=True,
spacing_y=-3,
Expand Down
10 changes: 5 additions & 5 deletions docs/notebooks/meshing_01_intro.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#
# While the latter method is much simpler for complex geometries, as of 2022 it does not preserve physical and mesh information, requiring manual "retagging" of the entities after the boolean operations, and driving its complexity back to bottom-up construction (especially for arbitrary geometries).
#
# As such, gdsfactory uses the first approach, where the mask layers and a layerstack are used as a guide to define the various physical entities, which are returned as tagged objects to the user.
# As such, gdsfactory uses the first approach, where the mask layers and a layer_stack are used as a guide to define the various physical entities, which are returned as tagged objects to the user.
#
# ## Installation
#
Expand All @@ -61,15 +61,15 @@
PDK.activate()

waveguide = gf.components.straight_pin(length=10, taper=None)
waveguide
waveguide.plot()
# -

# and a `LayerStack`. Here, we copy the example from `gdsfactory.generic_tech` for clarity).
# The `info` dict contains miscellaneous information about the layers, including `mesh_order`, which determines which layer will appear in the mesh if layers overlap.

# We can filter this stack to only focus on some layers:

filtered_layerstack = LayerStack(
filtered_layer_stack = LayerStack(
layers={
k: LAYER_STACK.layers[k]
for k in (
Expand All @@ -91,7 +91,7 @@ def mesh_with_physicals(mesh, filename):

# -

scene = waveguide.to_3d(layer_stack=filtered_layerstack)
scene = waveguide.to_3d(layer_stack=filtered_layer_stack)
scene.show()

# The various processing and meshing functions are located under `gplugins.gmsh` and can be called from there, but a shortcut is implemented to mesh directly from a component:
Expand All @@ -100,7 +100,7 @@ def mesh_with_physicals(mesh, filename):
component=waveguide,
type="xy",
z=0.09,
layer_stack=filtered_layerstack,
layer_stack=filtered_layer_stack,
filename="mesh.msh",
)

Expand Down
14 changes: 7 additions & 7 deletions docs/notebooks/meshing_02_2D_xy_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
PDK.activate()

waveguide = gf.components.straight_pin(length=10, taper=None)
waveguide
waveguide.plot()
# -

filtered_layerstack = LayerStack(
filtered_layer_stack = LayerStack(
layers={
k: get_layer_stack().layers[k]
for k in (
Expand Down Expand Up @@ -50,7 +50,7 @@ def mesh_with_physicals(mesh, filename):
component=waveguide,
type="xy",
z=0.09,
layer_stack=filtered_layerstack,
layer_stack=filtered_layer_stack,
filename=f"{filename}.msh",
)
mesh = mesh_with_physicals(mesh, filename)
Expand All @@ -63,7 +63,7 @@ def mesh_with_physicals(mesh, filename):
component=waveguide,
type="xy",
z=0.0,
layer_stack=filtered_layerstack,
layer_stack=filtered_layer_stack,
filename=f"{filename}.msh",
)
mesh = mesh_with_physicals(mesh, filename)
Expand All @@ -76,7 +76,7 @@ def mesh_with_physicals(mesh, filename):
component=waveguide,
type="xy",
z=1.0,
layer_stack=filtered_layerstack,
layer_stack=filtered_layer_stack,
filename=f"{filename}.msh",
)
mesh = mesh_with_physicals(mesh, filename)
Expand All @@ -96,14 +96,14 @@ def mesh_with_physicals(mesh, filename):
)
)

waveguide_trimmed
waveguide_trimmed.plot()
# -

mesh = get_mesh(
component=waveguide_trimmed,
type="xy",
z=0.09,
layer_stack=filtered_layerstack,
layer_stack=filtered_layer_stack,
filename=f"{filename}.msh",
)
mesh = mesh_with_physicals(mesh, filename)
Expand Down
10 changes: 5 additions & 5 deletions docs/notebooks/meshing_03_2D_uz_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
)
)

waveguide_trimmed
waveguide_trimmed.plot()
# -

filtered_layerstack = LayerStack(
filtered_layer_stack = LayerStack(
layers={
k: get_layer_stack().layers[k]
for k in (
Expand Down Expand Up @@ -57,7 +57,7 @@ def mesh_with_physicals(mesh, filename):
component=waveguide_trimmed,
type="uz",
xsection_bounds=[(4, -4), (4, 4)],
layer_stack=filtered_layerstack,
layer_stack=filtered_layer_stack,
filename=f"{filename}.msh",
)
mesh = mesh_with_physicals(mesh, filename)
Expand All @@ -68,13 +68,13 @@ def mesh_with_physicals(mesh, filename):

# ## Mesh background
#
# You can add a convenience argument to add a background mesh around the geometry (instead of defining a dummy polygon and layer in the layerstack with low mesh_order):
# You can add a convenience argument to add a background mesh around the geometry (instead of defining a dummy polygon and layer in the layer_stack with low mesh_order):

mesh = get_mesh(
component=waveguide_trimmed,
type="uz",
xsection_bounds=[(4, -4), (4, 4)],
layer_stack=filtered_layerstack,
layer_stack=filtered_layer_stack,
filename=f"{filename}.msh",
background_tag="oxide",
background_padding=(2.0, 2.0, 2.0, 2.0),
Expand Down
Loading

0 comments on commit 2031f94

Please sign in to comment.