FDTD tidy3d#

gdsfactory simulation plugin for tidy3d tidy3D is a FDTD web based software

Materials#

tidy3d provides you with a material database of dispersive materials.

[1]:
# basic ipython configuration (reload source code automatically and plots inline)
%load_ext autoreload
%autoreload 2
%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt

import tidy3d as td
from tidy3d import web

import gdsfactory as gf
import gdsfactory.simulation.gtidy3d as gt
import gdsfactory.simulation as sim
[17:07:55] INFO     NumExpr defaulting to 2 threads.                             utils.py:160
2022-06-28 17:07:55.897 | INFO     | gdsfactory.config:<module>:52 - Load '/home/runner/work/gdsfactory/gdsfactory/gdsfactory' 5.11.4
2022-06-28 17:07:56.575 | INFO     | gdsfactory.simulation.gtidy3d:<module>:52 - Tidy3d '1.4.1' installed at ['/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/tidy3d']
[2]:
nm = 1e-3
wavelength = np.linspace(1500, 1600) * nm
f = td.C_0 / wavelength
eps_complex = gt.materials.material_library["cSi"]["Li1993_293K"].eps_model(f)
n, k = td.Medium.eps_complex_to_nk(eps_complex)
plt.plot(wavelength, n)
plt.title("cSi crystalline silicon")
plt.xlabel("wavelength")
plt.ylabel("n")
Text(0, 0.5, 'n')
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_2_2.png
[3]:
eps_complex = gt.materials.material_library["Si3N4"]["Luke2015"].eps_model(f)
n, k = td.Medium.eps_complex_to_nk(eps_complex)
plt.plot(wavelength, n)
plt.title("SiN")
plt.xlabel("wavelength")
plt.ylabel("n")
Text(0, 0.5, 'n')
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_3_2.png
[4]:
eps_complex = gt.materials.material_library["SiO2"]["Horiba"].eps_model(f)
n, k = td.Medium.eps_complex_to_nk(eps_complex)
plt.plot(wavelength, n)
plt.title("SiO2")
plt.xlabel("wavelength")
plt.ylabel("n")
Text(0, 0.5, 'n')
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_4_2.png

get_simulation#

You can run get_simulation to convert a gdsfactory planar Component into a tidy3d simulation and make sure the simulation looks correct before running it

get_simulation also has a plot_modes option so you can make sure you are monitoring the desired mode.

2D#

2D planar simulations run faster than 3D. When running in 2D we don’t consider the component thickness in the z dimension

[5]:
c = gf.components.mmi1x2()
s = gt.get_simulation(c, is_3d=False)
fig = gt.plot_simulation(s)
2022-06-28 17:07:56.991 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0, zmax = 0
[17:07:56] WARNING  Structure at structures[1] has bounds that extend       simulation.py:314
                    exactly to simulation edges. This can cause unexpected                   
                    behavior. If intending to extend the structure to                        
                    infinity along one dimension, use td.inf as a size                       
                    variable instead to make this explicit.                                  
           WARNING  Structure at structures[1] has bounds that extend       simulation.py:314
                    exactly to simulation edges. This can cause unexpected                   
                    behavior. If intending to extend the structure to                        
                    infinity along one dimension, use td.inf as a size                       
                    variable instead to make this explicit.                                  
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
[17:07:57] INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/tidy3d/components/grid/mesher.py:30: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
  self.str_ind = None
<Figure size 792x288 with 2 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_7_7.png

3D#

By default all simulations run in 3D unless indicated otherwise with the is_3d argument. 3D simulations still run quite fast thanks to the GPU solver on the server side.

[6]:
help(gt.get_simulation)
Help on cython_function_or_method in module gdsfactory.simulation.gtidy3d.get_simulation:

get_simulation(component: Union[str, Callable[..., gdsfactory.component.Component], gdsfactory.component.Component, Dict[str, Any]], port_extension: Optional[float] = 4.0, layer_stack: Optional[gdsfactory.tech.LayerStack] = None, thickness_pml: float = 1.0, xmargin: float = 0, ymargin: float = 0, xmargin_left: float = 0, xmargin_right: float = 0, ymargin_top: float = 0, ymargin_bot: float = 0, zmargin: float = 1.0, clad_material: str = 'sio2', port_source_name: str = 'o1', port_margin: float = 0.5, port_source_offset: float = 0.1, distance_source_to_monitors: float = 0.2, wavelength_start: float = 1.5, wavelength_stop: float = 1.6, wavelength_points: int = 50, plot_modes: bool = False, num_modes: int = 2, run_time_ps: float = 10.0, dispersive: bool = False, material_name_to_tidy3d_index: Dict[str, float] = {'si': 3.47, 'sio2': 1.44, 'sin': 2.0}, material_name_to_tidy3d_name: Dict[str, str] = {'si': 'cSi', 'sio2': 'SiO2', 'sin': 'Si3N4'}, is_3d: bool = True, with_all_monitors: bool = False, boundary_spec: Optional[tidy3d.components.boundary.BoundarySpec] = None, grid_spec: Optional[tidy3d.components.grid.grid_spec.GridSpec] = None, sidewall_angle_deg: float = 0, dilation: float = 0.0, **kwargs) -> tidy3d.components.simulation.Simulation
    Returns tidy3d Simulation object from a gdsfactory Component.

    based on GDS example
    https://simulation.cloud/docs/html/examples/ParameterScan.html

    .. code::

         top view
              ________________________________
             |                               |
             | xmargin_left                  | port_extension
             |<------>          port_margin ||<-->
          ___|___________          _________||___
             |           \        /          |
             |            \      /           |
             |             ======            |
             |            /      \           |
          ___|___________/        \__________|___
             |   |                 <-------->|
             |   |ymargin_bot   xmargin_right|
             |   |                           |
             |___|___________________________|

        side view
              ________________________________
             |                     |         |
             |                     |         |
             |                   zmargin_top |
             |xmargin_left         |         |
             |<---> _____         _|___      |
             |     |     |       |     |     |
             |     |     |       |     |     |
             |     |_____|       |_____|     |
             |       |                       |
             |       |                       |
             |       |zmargin_bot            |
             |       |                       |
             |_______|_______________________|


    Args:
        component: gdsfactory Component.
        port_extension: extend ports beyond the PML.
        layer_stack: contains layer to thickness, zmin and material.
            Defaults to active pdk.layer_stack.
        thickness_pml: PML thickness (um).
        xmargin: left/right distance from component to PML.
        xmargin_left: left distance from component to PML.
        xmargin_right: right distance from component to PML.
        ymargin: left/right distance from component to PML.
        ymargin_top: top distance from component to PML.
        ymargin_bot: bottom distance from component to PML.
        zmargin: thickness for cladding above and below core.
        clad_material: material for cladding.
        port_source_name: input port name.
        port_margin: margin on each side of the port.
        distance_source_to_monitors: in (um) source goes before monitors.
        port_source_offset: mode solver workaround.
            positive moves source forward, negative moves source backward.
        wavelength_start: in (um).
        wavelength_stop: in (um).
        wavelength_points: number of wavelengths.
        plot_modes: plot source modes.
        num_modes: number of modes to plot.
        run_time_ps: make sure it's sufficient for the fields to decay.
            defaults to 10ps and counts on automatic shutoff to stop earlier if needed.
        dispersive: False uses constant refractive index materials.
            True adds wavelength depending materials.
            Dispersive materials require more computation.
        material_name_to_tidy3d_index: not dispersive materials have a constant index.
        material_name_to_tidy3d_name: dispersive materials have a wavelength
            dependent index. Maps layer_stack names with tidy3d material database names.
        is_3d: if False, does not consider Z dimension for faster simulations.
        with_all_monitors: True includes field monitors which increase results filesize.
        grid_spec: defaults to automatic td.GridSpec.auto(wavelength=wavelength)
            td.GridSpec.uniform(dl=20*nm)
            td.GridSpec(
                grid_x = td.UniformGrid(dl=0.04),
                grid_y = td.AutoGrid(min_steps_per_wvl=20),
                grid_z = td.AutoGrid(min_steps_per_wvl=20),
                wavelength=wavelength,
                override_structures=[refine_box]
            )
        boundary_spec: Specification of boundary conditions along each dimension.
            Defaults to td.BoundarySpec.all_sides(boundary=td.PML())

        dilation: float = 0.0
            Dilation of the polygon in the base by shifting each edge along its
            normal outwards direction by a distance;
            a negative value corresponds to erosion.
        sidewall_angle_deg : float = 0
            Angle of the sidewall.
            ``sidewall_angle=0`` (default) specifies vertical wall,
            while ``0<sidewall_angle_deg<90`` for the base to be larger than the top.

    keyword Args:
        symmetry: Define Symmetries.
            Tuple of integers defining reflection symmetry across a plane
            bisecting the simulation domain normal to the x-, y-, and z-axis
            at the simulation center of each axis, respectvely.
            Each element can be `0` (no symmetry), `1` (even, i.e. 'PMC' symmetry) or
            `-1` (odd, i.e. 'PEC' symmetry).
            Note that the vectorial nature of the fields must be taken into account
            to correctly determine the symmetry value.
        medium: Background medium of simulation, defaults to vacuum if not specified.
        shutoff: shutoff condition
            Ratio of the instantaneous integrated E-field intensity to the maximum value
            at which the simulation will automatically terminate time stepping.
            prevents extraneous run time of simulations with fully decayed fields.
            Set to ``0`` to disable this feature.
        subpixel: subpixel averaging.If ``True``, uses subpixel averaging of the permittivity
            based on structure definition,
            resulting in much higher accuracy for a given grid size.
        courant: courant factor.
            Courant stability factor, controls time step to spatial step ratio.
            Lower values lead to more stable simulations for dispersive materials,
            but result in longer simulation times.
        version: String specifying the front end version number.


    .. code::

        import matplotlib.pyplot as plt
        import gdsfactory as gf
        import gdsfactory.simulation.tidy3d as gt

        c = gf.components.bend_circular()
        sim = gt.get_simulation(c)
        gt.plot_simulation(sim)

[7]:
c = gf.components.mmi1x2()
s = gt.get_simulation(c)
fig = gt.plot_simulation(s)
2022-06-28 17:07:57.338 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
           INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_10_3.png
[8]:
c = gf.components.coupler_ring()
s = gt.get_simulation(c)
fig = gt.plot_simulation(s)
2022-06-28 17:07:57.703 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
           INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_11_3.png
[9]:
c = gf.components.bend_circular(radius=2)
s = gt.get_simulation(c)
fig = gt.plot_simulation(s)
2022-06-28 17:07:58.162 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
[17:07:58] INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_12_3.png
[10]:
c = gf.components.straight()
s = gt.get_simulation(c)
fig = gt.plot_simulation(s)
2022-06-28 17:07:58.652 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
           INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_13_3.png

Sidewall angle#

You can define the sidewall angle in degrees with respect to normal. Lets exaggerate the sidewall angle so we can clearly see it.

[11]:
c = gf.components.straight()
s = gt.get_simulation(c, sidewall_angle_deg=45, plot_modes=True)
fig = gt.plot_simulation(s)
2022-06-28 17:07:59.005 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
[17:07:59] INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
Effective index of computed modes:  [[1.66757963 1.48286154]]
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
<Figure size 864x864 with 8 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_15_5.png
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_15_8.png

Erosion / dilation#

[12]:
c = gf.components.straight()
s = gt.get_simulation(c, is_3d=False, dilation=0)
fig = gt.plot_simulation(s)
2022-06-28 17:08:00.303 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0, zmax = 0
[17:08:00] WARNING  Structure at structures[1] has bounds that extend       simulation.py:314
                    exactly to simulation edges. This can cause unexpected                   
                    behavior. If intending to extend the structure to                        
                    infinity along one dimension, use td.inf as a size                       
                    variable instead to make this explicit.                                  
           WARNING  Structure at structures[1] has bounds that extend       simulation.py:314
                    exactly to simulation edges. This can cause unexpected                   
                    behavior. If intending to extend the structure to                        
                    infinity along one dimension, use td.inf as a size                       
                    variable instead to make this explicit.                                  
           INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/tidy3d/components/grid/mesher.py:30: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
  self.str_ind = None
<Figure size 792x288 with 2 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_17_6.png
[13]:
c = gf.components.straight()
s = gt.get_simulation(c, is_3d=False, dilation=0.5)
fig = gt.plot_simulation(s)
2022-06-28 17:08:00.534 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0, zmax = 0
           WARNING  Structure at structures[1] has bounds that extend       simulation.py:314
                    exactly to simulation edges. This can cause unexpected                   
                    behavior. If intending to extend the structure to                        
                    infinity along one dimension, use td.inf as a size                       
                    variable instead to make this explicit.                                  
           WARNING  Structure at structures[1] has bounds that extend       simulation.py:314
                    exactly to simulation edges. This can cause unexpected                   
                    behavior. If intending to extend the structure to                        
                    infinity along one dimension, use td.inf as a size                       
                    variable instead to make this explicit.                                  
           WARNING  Structure at structures[1] was detected as being less   simulation.py:339
                    than half of a central wavelength from a PML on side                     
                    y-min. To avoid inaccurate results, please increase gap                  
                    between any structures and PML or fully extend                           
                    structure through the pml.                                               
           WARNING  Structure at structures[1] was detected as being less   simulation.py:339
                    than half of a central wavelength from a PML on side                     
                    y-max. To avoid inaccurate results, please increase gap                  
                    between any structures and PML or fully extend                           
                    structure through the pml.                                               
           INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 792x288 with 2 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_18_7.png
[14]:
0.5 * 1.5
0.75

A dilation = 0.5 makes a 0.5um waveguide 0.75um

[15]:
0.5 * 0.8
0.4

A dilation = -0.2 makes a 0.5um eroded down to 0.1um

[16]:
0.2 * 0.5
0.1
[17]:
c = gf.components.straight()
s = gt.get_simulation(c, is_3d=False, dilation=-0.2)
fig = gt.plot_simulation(s)
2022-06-28 17:08:00.861 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0, zmax = 0
           WARNING  Structure at structures[1] has bounds that extend       simulation.py:314
                    exactly to simulation edges. This can cause unexpected                   
                    behavior. If intending to extend the structure to                        
                    infinity along one dimension, use td.inf as a size                       
                    variable instead to make this explicit.                                  
           WARNING  Structure at structures[1] has bounds that extend       simulation.py:314
                    exactly to simulation edges. This can cause unexpected                   
                    behavior. If intending to extend the structure to                        
                    infinity along one dimension, use td.inf as a size                       
                    variable instead to make this explicit.                                  
           INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 792x288 with 2 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_24_5.png

Plot source and monitor modes#

[18]:
import numpy as np
import matplotlib.pyplot as plt

import tidy3d as td
from tidy3d import web
import gdsfactory as gf
import gdsfactory.simulation.gtidy3d as gt

c = gf.components.straight(length=3)
sim = gt.get_simulation(c, plot_modes=True, port_margin=1, ymargin=1)
fig = gt.plot_simulation_xz(sim)
2022-06-28 17:08:01.240 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
[17:08:01] INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
Effective index of computed modes:  [[2.46068402 1.78938873]]
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
<Figure size 864x864 with 8 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_26_5.png
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_26_8.png
[19]:
c = gf.components.straight_rib(length=3)
sim = gt.get_simulation(c, plot_modes=True)
fig = gt.plot_simulation_xz(sim)
2022-06-28 17:08:02.513 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
2022-06-28 17:08:02.515 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (3, 0), 3.47, index = 3.470, thickness = 0.09, zmin = 0.0, zmax = 0.09
[17:08:02] INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/tidy3d/components/grid/mesher.py:30: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
  self.str_ind = None
           WARNING  Mode field at frequency index 0, mode index 1 does not mode_solver.py:481
                    decay at the plane boundaries.                                           
Effective index of computed modes:  [[2.5900185  2.14527173]]
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
<Figure size 864x864 with 8 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_27_7.png
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_27_10.png
[20]:
import numpy as np
import matplotlib.pyplot as plt

import tidy3d as td
from tidy3d import web

import gdsfactory as gf
import gdsfactory.simulation.gtidy3d as gt
import gdsfactory.simulation as sim
from gdsfactory.components.taper import taper_sc_nc

c = taper_sc_nc(length=10)
s = gt.get_simulation(c, plot_modes=True)
fig = gt.plot_simulation_xz(s)
2022-06-28 17:08:03.830 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
2022-06-28 17:08:03.832 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (34, 0), 2.0, index = 2.000, thickness = 0.35000000000000003, zmin = 0.32, zmax = 0.67
[17:08:03] INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/tidy3d/components/grid/mesher.py:30: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
  self.str_ind = None
Effective index of computed modes:  [[2.40706607 1.7567328 ]]
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
<Figure size 864x864 with 8 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_28_6.png
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_28_9.png

Lets make sure the mode also looks correct on the Nitride side

[21]:
c = taper_sc_nc(length=10)
s = gt.get_simulation(c, port_source_name="o2", plot_modes=True)
fig = gt.plot_simulation_xz(s)
2022-06-28 17:08:05.182 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
2022-06-28 17:08:05.184 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (34, 0), 2.0, index = 2.000, thickness = 0.35000000000000003, zmin = 0.32, zmax = 0.67
[17:08:05] INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/tidy3d/components/grid/mesher.py:30: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
  self.str_ind = None
           WARNING  Mode field at frequency index 0, mode index 1 does not mode_solver.py:481
                    decay at the plane boundaries.                                           
Effective index of computed modes:  [[1.61925395 1.54080044]]
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
<Figure size 864x864 with 8 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_30_7.png
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_30_10.png
[22]:
components = [
    "bend_euler",
    "bend_s",
    "coupler",
    "coupler_ring",
    "crossing",
    "mmi1x2",
    "mmi2x2",
    "taper",
    "straight",
]

for component_name in components:
    print(component_name)
    plt.figure()
    c = gf.components.cells[component_name]()
    s = gt.get_simulation(c)
    fig = gt.plot_simulation(s)
2022-06-28 17:08:06.437 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
bend_euler
[17:08:06] INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/tidy3d/components/grid/mesher.py:30: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
  self.str_ind = None
<Figure size 432x288 with 0 Axes>
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_31_6.png
2022-06-28 17:08:06.984 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
bend_s
[17:08:07] INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 432x288 with 0 Axes>
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_31_12.png
2022-06-28 17:08:07.347 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
coupler
           INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 432x288 with 0 Axes>
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_31_18.png
2022-06-28 17:08:07.735 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
coupler_ring
<Figure size 432x288 with 0 Axes>
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_31_23.png
2022-06-28 17:08:08.156 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
2022-06-28 17:08:08.159 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (2, 0), 3.47, index = 3.470, thickness = 0.15, zmin = 0.0, zmax = 0.15
crossing
[17:08:08] INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 432x288 with 0 Axes>
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_31_29.png
2022-06-28 17:08:08.517 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
mmi1x2
<Figure size 432x288 with 0 Axes>
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_31_34.png
2022-06-28 17:08:08.830 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
mmi2x2
           INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 432x288 with 0 Axes>
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_31_40.png
2022-06-28 17:08:09.297 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
taper
<Figure size 432x288 with 0 Axes>
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_31_45.png
2022-06-28 17:08:09.620 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
straight
<Figure size 432x288 with 0 Axes>
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_31_50.png

write_sparameters#

You can write Sparameters from a simulation as well as a group of simulations in parallel.

Each Sparameter runs on a different thread as it needs to monitor each job sent to the tidy3d server.

c = gf.components.straight()
s = gt.get_sparameters(c)
for component_name, component_factory in gf.components._factory_passives.items():
    c = component_factory()
    s = gt.get_sparameters(c)
[23]:
c = gf.components.bend_circular(radius=2)
s = gt.get_simulation(c)
fig = gt.plot_simulation(s)
2022-06-28 17:08:09.968 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_34_2.png

For a 2 port reciprocal passive component you can always assume s21 = s12

Another approximation you can make for planar devices is that s11 = s22, which saves 1 extra simulation

This approximation only works well for straight and bends

we call this 1x1 port symmetry

[24]:
df = gt.write_sparameters_1x1(c)
sim.plot.plot_sparameters(df)
2022-06-28 17:08:10.331 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters:write_sparameters:164 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/bend_circular_radius2_c3ff7345.csv')
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_36_2.png
[25]:
sim.plot.plot_sparameters(df, keys=("s21m",))
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_37_1.png
[26]:
import gdsfactory as gf
import gdsfactory.simulation.gtidy3d as gt

c = gf.components.mmi1x2()
s = gt.get_simulation(c, plot_modes=True, port_margin=0.2, port_source_name="o2")
fig = gt.plot_simulation(s, y=0)  # see input
2022-06-28 17:08:10.593 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation:get_simulation:289 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
[17:08:10] INFO     Auto meshing using wavelength 1.5500 defined from        grid_spec.py:478
                    sources.                                                                 
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/tidy3d/components/grid/mesher.py:30: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
  self.str_ind = None
Effective index of computed modes:  [[2.46116746 1.75873934]]
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:64: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  [asarray(r)[:, :2] for r in t.interiors])
<Figure size 864x864 with 8 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_38_6.png
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_38_9.png
[27]:
fig = gt.plot_simulation(s, y=0.63)  # see output
<Figure size 792x288 with 4 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_39_1.png
[28]:
# df = gt.write_sparameters(c, wavelength_start=1.5, wavelength_stop=1.6, grid_spec=td.GridSpec.uniform(dl=50*nm))
# df = gt.write_sparameters(c)
# df = gt.write_sparameters(c, wavelength_start=1.520, wavelength_stop=1.580, port_margin=0.6, ymargin=2)
# df = gt.write_sparameters(c, wavelength_start=1.520, wavelength_stop=1.580, port_margin=0.9)
df = gt.write_sparameters(c)
2022-06-28 17:08:12.269 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters:write_sparameters:164 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/mmi1x2_c3ff7345.csv')
[29]:
import gdsfactory.simulation as sim
[30]:
sim.plot.plot_sparameters(df)
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_42_1.png
[31]:
sim.plot.plot_sparameters(df, keys=("s12m", "s13m"))
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_43_1.png

write_sparameters_batch#

You can also send a batch of component simulations in parallel to the tidy3d server.

[32]:
jobs = [dict(component=gf.c.straight(length=1.11 + i)) for i in [1, 2]]
dfs = gt.write_sparameters_batch_1x1(jobs)
2022-06-28 17:08:12.624 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters:write_sparameters:164 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/straight_length2p110000_b5b2ce7b_c3ff7345.csv')
2022-06-28 17:08:12.625 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters:write_sparameters:164 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/straight_length3p110000_e3d7b292_c3ff7345.csv')
[33]:
df1 = dfs[0]
sim.plot.plot_sparameters(df1)
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_46_1.png
[34]:
df2 = dfs[1]
sim.plot.plot_sparameters(df2)
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_47_1.png

get_simulation_grating_coupler#

You can also expand the planar component simulations to simulate an out-of-plane grating coupler.

The following simulations run in 2D but can also run in 3D.

[35]:
help(gt.get_simulation_grating_coupler)
Help on function get_simulation_grating_coupler in module gdsfactory.simulation.gtidy3d.get_simulation_grating_coupler:

get_simulation_grating_coupler(component: gdsfactory.component.Component, port_extension: Optional[float] = 15.0, layer_stack: Optional[gdsfactory.tech.LayerStack] = None, thickness_pml: float = 1.0, xmargin: float = 0, ymargin: float = 0, xmargin_left: float = 0, xmargin_right: float = 0, ymargin_top: float = 0, ymargin_bot: float = 0, zmargin: float = 1.0, clad_material: str = 'sio2', box_material: str = 'sio2', box_thickness: float = 2.0, substrate_material: str = 'si', port_waveguide_name: str = 'o1', port_margin: float = 0.5, port_waveguide_offset: float = 0.1, distance_source_to_monitors: float = 0.2, wavelength: Optional[float] = 1.55, wavelength_start: float = 1.2, wavelength_stop: float = 1.8, wavelength_points: int = 256, plot_modes: bool = False, num_modes: int = 2, run_time_ps: float = 10.0, fiber_port_name: str = 'vertical_te', fiber_xoffset: float = 0, fiber_z: float = 2, fiber_mfd: float = 5.2, fiber_angle_deg: float = 20.0, dispersive: bool = False, material_name_to_tidy3d_index: Dict[str, float] = {'si': 3.47, 'sio2': 1.44, 'sin': 2.0}, material_name_to_tidy3d_name: Dict[str, str] = {'si': 'cSi', 'sio2': 'SiO2', 'sin': 'Si3N4'}, is_3d: bool = True, with_all_monitors: bool = False, boundary_spec: Optional[tidy3d.components.boundary.BoundarySpec] = None, grid_spec: Optional[tidy3d.components.grid.grid_spec.GridSpec] = None, sidewall_angle_deg: float = 0, dilation: float = 0.0, **kwargs) -> tidy3d.components.simulation.Simulation
    Returns Simulation object from a gdsfactory grating coupler component.

    injects a Gaussian beam from above and monitors the transmission into the waveguide.

    based on grating coupler example
    https://docs.simulation.cloud/projects/tidy3d/en/latest/notebooks/GratingCoupler.html

    .. code::

         top view
              ________________________________
             |                               |
             | xmargin_left                  |
             |<------>                       |
             |           ________________    |
             |          /   |  |  |  |  |    |
             |         /    |  |  |  |  |    |
             |=========     |  |  |  |  |    |
             |         \    |  |  |  |  |    |
             |   _ _ _ _\___|__|__|__|__|    |
             |   |                       <-->|
             |   |ymargin_bot   xmargin_right|
             |   |                           |
             |___|___________________________|


        side view

              fiber_xoffset
                 |<--->|
            fiber_port_name
                 |
                         fiber_angle_deg > 0
                        |  /
                        | /
                        |/
                 /              /       |
                /  fiber_mfd   /        |
               /<------------>/    _ _ _| _ _ _ _ _ _ _
                                        |
                   clad_material        | fiber_z
                    _   _   _      _ _ _|_ _ _ _ _ _ _
                   | | | | | |          ||wg_thickness
                  _| |_| |_| |__________||___
                                        || |
        waveguide            |          || | slab_thickness
              ____________________ _ _ _||_|_
                             |          |
                   box_material         |box_thickness
              _______________|____ _ _ _|_ _ _ _ _ _ _
                             |          |
                 substrate_material     |substrate_thickness
             ________________|____ _ _ _|_ _ _ _ _ _ _
                             |
        |--------------------|<-------->
                                xmargin

    Args:
        component: gdsfactory Component.
        port_extension: extend ports beyond the PML.
        layer_stack: contains layer to thickness, zmin and material.
            Defaults to active pdk.layer_stack.
        thickness_pml: PML thickness (um).
        xmargin: left/right distance from component to PML.
        xmargin_left: left distance from component to PML.
        xmargin_right: right distance from component to PML.
        ymargin: left/right distance from component to PML.
        ymargin_top: top distance from component to PML.
        ymargin_bot: bottom distance from component to PML.
        zmargin: thickness for cladding above and below core.
        clad_material: material for cladding.
        box_material:
        substrate_material:
        box_thickness: (um).
        substrate_thickness: (um).
        port_waveguide_name: input port name.
        port_margin: margin on each side of the port.
        distance_source_to_monitors: in (um) source goes before monitors.
        port_waveguide_offset: mode solver workaround.
            positive moves source forward, negative moves source backward.
        wavelength: source center wavelength (um).
            if None takes mean between wavelength_start, wavelength_stop
        wavelength_start: in (um).
        wavelength_stop: in (um).
        wavelength_points: number of wavelengths.
        plot_modes: plot source modes.
        num_modes: number of modes to plot.
        run_time_ps: make sure it's sufficient for the fields to decay.
            defaults to 10ps and automatic shutoff stops earlier if needed.
        fiber_port_name: for the component.
        fiber_xoffset: fiber center xoffset to fiber_port_name.
        fiber_z: fiber zoffset from grating zmax.
        fiber_mfd: fiber mode field diameter (um).
        fiber_angle_deg: fiber_angle in degrees with respect to normal.
            Positive for west facing, Negative for east facing sources.
        dispersive: False uses constant refractive index materials.
            True adds wavelength depending materials.
            Dispersive materials require more computation.
        material_name_to_tidy3d_index: not dispersive materials have a constant index.
        material_name_to_tidy3d_name: dispersive materials have a wavelength
            dependent index. Maps layer_stack names with tidy3d material database names.
        is_3d: if False collapses the Y direction for a 2D simulation.
        with_all_monitors: True includes field monitors which increase results filesize.
        grid_spec: defaults to automatic td.GridSpec.auto(wavelength=wavelength)
            td.GridSpec.uniform(dl=20*nm)
            td.GridSpec(
                grid_x = td.UniformGrid(dl=0.04),
                grid_y = td.AutoGrid(min_steps_per_wvl=20),
                grid_z = td.AutoGrid(min_steps_per_wvl=20),
                wavelength=wavelength,
                override_structures=[refine_box]
            )
        boundary_spec: Specification of boundary conditions along each dimension.
            Defaults to td.BoundarySpec.all_sides(boundary=td.PML())
        dilation: float = 0.0
            Dilation of the polygon in the base by shifting each edge along its
            normal outwards direction by a distance;
            a negative value corresponds to erosion.
        sidewall_angle_deg : float = 0
            Angle of the sidewall.
            ``sidewall_angle=0`` (default) specifies vertical wall,
            while ``0<sidewall_angle_deg<90`` for the base to be larger than the top.

    keyword Args:
        symmetry: Define Symmetries.
            Tuple of integers defining reflection symmetry across a plane
            bisecting the simulation domain normal to the x-, y-, and z-axis
            at the simulation center of each axis, respectvely.
            Each element can be ``0`` (no symmetry), ``1`` (even, i.e. 'PMC' symmetry) or
            ``-1`` (odd, i.e. 'PEC' symmetry).
            Note that the vectorial nature of the fields must be taken into account to correctly
            determine the symmetry value.
        medium: Background medium of simulation, defaults to vacuum if not specified.
        shutoff: shutoff condition
            Ratio of the instantaneous integrated E-field intensity to the maximum value
            at which the simulation will automatically terminate time stepping.
            Used to prevent extraneous run time of simulations with fully decayed fields.
            Set to ``0`` to disable this feature.
        subpixel: subpixel averaging.If ``True``, uses subpixel averaging of the permittivity
        based on structure definition, resulting in much higher accuracy for a given grid size.
        courant: courant factor.
            Courant stability factor, controls time step to spatial step ratio.
            Lower values lead to more stable simulations for dispersive materials,
            but result in longer simulation times.
        version: String specifying the front end version number.

    .. code::

        import matplotlib.pyplot as plt
        import gdsfactory as gf
        import gdsfactory.simulation.gtidy3d as gt

        c = gf.components.grating_coupler_elliptical_arbitrary(
            widths=[0.343] * 25, gaps=[0.345] * 25
        )
        sim = gt.get_simulation(c)
        gt.plot_simulation(sim)

[36]:
import gdsfactory as gf
import gdsfactory.simulation.gtidy3d as gt
import numpy as np
import matplotlib.pyplot as plt
[37]:
c = (
    gf.components.grating_coupler_elliptical_lumerical()
)  # inverse design grating apodized
fiber_angle_deg = 5
s = gt.get_simulation_grating_coupler(
    c, is_3d=False, fiber_angle_deg=fiber_angle_deg, fiber_xoffset=0
)
f = gt.plot_simulation(s)
2022-06-28 17:08:12.987 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation_grating_coupler:get_simulation_grating_coupler:342 - Add (2, 0), 3.47, index = 3.470, thickness = 0.15, zmin = 0.0, zmax = 0.15
2022-06-28 17:08:12.990 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation_grating_coupler:get_simulation_grating_coupler:342 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
[17:08:13] INFO     Auto meshing using wavelength 1.5000 defined from        grid_spec.py:478
                    sources.                                                                 
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/tidy3d/components/grid/mesher.py:30: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
  self.str_ind = None
<Figure size 792x288 with 2 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_51_4.png
[38]:
f = c.plot()
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_52_1.png

Lets compare the xtolerance of a constant pitch vs an apodized grating.

We run simulations in 2D for faster.

Lets simulate 2 different grating couplers:

  • apodized inverse design example from lumerical website (5 degrees fiber angle)

  • constant pitch grating from gdsfactory generic PDK (20 degrees fiber angle)

[39]:
sim = gt.get_simulation_grating_coupler(
    c, is_3d=False, fiber_angle_deg=fiber_angle_deg, fiber_xoffset=-5
)
f = gt.plot_simulation(sim)
2022-06-28 17:08:13.560 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation_grating_coupler:get_simulation_grating_coupler:342 - Add (2, 0), 3.47, index = 3.470, thickness = 0.15, zmin = 0.0, zmax = 0.15
2022-06-28 17:08:13.563 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation_grating_coupler:get_simulation_grating_coupler:342 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
           INFO     Auto meshing using wavelength 1.5000 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 792x288 with 2 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_54_3.png
[40]:
sim = gt.get_simulation_grating_coupler(
    c, is_3d=False, fiber_angle_deg=fiber_angle_deg, fiber_xoffset=+5
)
f = gt.plot_simulation(sim)
2022-06-28 17:08:13.984 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation_grating_coupler:get_simulation_grating_coupler:342 - Add (2, 0), 3.47, index = 3.470, thickness = 0.15, zmin = 0.0, zmax = 0.15
2022-06-28 17:08:13.987 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation_grating_coupler:get_simulation_grating_coupler:342 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
[17:08:14] INFO     Auto meshing using wavelength 1.5000 defined from        grid_spec.py:478
                    sources.                                                                 
<Figure size 792x288 with 2 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_55_3.png
[41]:
offsets = np.arange(-5, 6, 5)
[42]:
jobs = [
    dict(
        component=c,
        is_3d=False,
        fiber_angle_deg=fiber_angle_deg,
        fiber_xoffset=fiber_xoffset,
    )
    for fiber_xoffset in offsets
]
dfs = gt.write_sparameters_grating_coupler_batch(jobs)
2022-06-28 17:08:14.425 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_8de6986b.csv')
2022-06-28 17:08:14.425 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_51afdab7.csv')
2022-06-28 17:08:14.426 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_1aa2deeb.csv')
[43]:
import numpy as np

log = lambda x: 20 * np.log10(x)
[44]:
for offset in offsets:
    df = gt.write_sparameters_grating_coupler(
        c, is_3d=False, fiber_angle_deg=fiber_angle_deg, fiber_xoffset=offset
    )
    plt.plot(df.wavelengths, log(df.s21m), label=str(offset))

plt.xlabel("wavelength (um")
plt.ylabel("Transmission (dB)")
plt.title("transmission vs fiber xoffset")
plt.legend()
2022-06-28 17:08:14.483 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_1aa2deeb.csv')
2022-06-28 17:08:14.497 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_8de6986b.csv')
2022-06-28 17:08:14.502 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_51afdab7.csv')
<matplotlib.legend.Legend object at 0x7f4c5e7d85b0>
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_59_3.png
[45]:
fiber_angles = [3, 5, 7]
jobs = [
    dict(component=c, is_3d=False, fiber_angle_deg=fiber_angle_deg)
    for fiber_angle_deg in fiber_angles
]
dfs = gt.write_sparameters_grating_coupler_batch(jobs)
2022-06-28 17:08:14.631 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_cbcef604.csv')
2022-06-28 17:08:14.631 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_0b6befc7.csv')
2022-06-28 17:08:14.631 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_e3ac5bee.csv')
[46]:
for fiber_angle_deg in fiber_angles:
    df = gt.write_sparameters_grating_coupler(
        c, is_3d=False, fiber_angle_deg=fiber_angle_deg
    )
    plt.plot(df.wavelengths, log(df.s21m), label=str(fiber_angle_deg))

plt.xlabel("wavelength (um")
plt.ylabel("Transmission (dB)")
plt.title("transmission vs fiber angle (degrees)")
plt.legend()
2022-06-28 17:08:14.665 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_e3ac5bee.csv')
2022-06-28 17:08:14.679 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_cbcef604.csv')
2022-06-28 17:08:14.683 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_9d85a0c6_0b6befc7.csv')
<matplotlib.legend.Legend object at 0x7f4c5ea5d550>
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_61_3.png
[47]:
c = gf.components.grating_coupler_elliptical_arbitrary(
    widths=[0.343] * 25, gaps=[0.345] * 25
)
f = c.plot()
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_63_1.png
[48]:
fiber_angle_deg = 20
sim = gt.get_simulation_grating_coupler(
    c, is_3d=False, fiber_angle_deg=fiber_angle_deg, fiber_xoffset=0
)
f = gt.plot_simulation(sim, figsize=(22, 8))
2022-06-28 17:08:14.975 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation_grating_coupler:get_simulation_grating_coupler:342 - Add (2, 0), 3.47, index = 3.470, thickness = 0.15, zmin = 0.0, zmax = 0.15
2022-06-28 17:08:14.979 | DEBUG    | gdsfactory.simulation.gtidy3d.get_simulation_grating_coupler:get_simulation_grating_coupler:342 - Add (1, 0), 3.47, index = 3.470, thickness = 0.22, zmin = 0.0, zmax = 0.22
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/descartes/patch.py:62: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.
  vertices = concatenate([
[17:08:15] INFO     Auto meshing using wavelength 1.5000 defined from        grid_spec.py:478
                    sources.                                                                 
/usr/share/miniconda/envs/anaconda-client-env/lib/python3.9/site-packages/tidy3d/components/grid/mesher.py:30: ShapelyDeprecationWarning: Setting custom attributes on geometry objects is deprecated, and will raise an AttributeError in Shapely 2.0
  self.str_ind = None
<Figure size 1584x576 with 2 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_64_4.png
[49]:
offsets = np.arange(-10, 11, 5)
offsets
array([-10,  -5,   0,   5,  10])
[50]:
jobs = [
    dict(
        component=c,
        is_3d=False,
        fiber_angle_deg=fiber_angle_deg,
        fiber_xoffset=fiber_xoffset,
    )
    for fiber_xoffset in offsets
]
dfs = gt.write_sparameters_grating_coupler_batch(jobs)
2022-06-28 17:08:15.604 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_3efea4b2_4c0acfc2.csv')
2022-06-28 17:08:15.605 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_3efea4b2_788015c0.csv')
2022-06-28 17:08:15.605 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_3efea4b2_d69e982a.csv')
2022-06-28 17:08:15.605 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_3efea4b2_e2a62017.csv')
2022-06-28 17:08:15.607 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_3efea4b2_31dbb27a.csv')
[51]:
for offset in offsets:
    df = gt.write_sparameters_grating_coupler(
        c, is_3d=False, fiber_angle_deg=fiber_angle_deg, fiber_xoffset=offset
    )
    plt.plot(df.wavelengths, log(df.s21m), label=str(offset))

plt.xlabel("wavelength (um")
plt.ylabel("Transmission (dB)")
plt.title("transmission vs xoffset")
plt.legend()
2022-06-28 17:08:15.646 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_3efea4b2_4c0acfc2.csv')
2022-06-28 17:08:15.661 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_3efea4b2_788015c0.csv')
2022-06-28 17:08:15.665 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_3efea4b2_d69e982a.csv')
2022-06-28 17:08:15.669 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_3efea4b2_e2a62017.csv')
2022-06-28 17:08:15.673 | INFO     | gdsfactory.simulation.gtidy3d.write_sparameters_grating_coupler:write_sparameters_grating_coupler:100 - Simulation loaded from PosixPath('/home/runner/work/gdsfactory/gdsfactory/gdslib/sp/grating_coupler_ellipti_3efea4b2_31dbb27a.csv')
<matplotlib.legend.Legend object at 0x7f4c5f138d60>
<Figure size 432x288 with 1 Axes>
../../../_images/notebooks_plugins_tidy3d_00_tidy3d_67_3.png