FDTD -------------------- 90 Degree Bend - Subpixel Averaging ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This examples shows the effect using subpixel averaging on a 90 degree bend (:download:`bend90.gds <../_static/bend90.gds>`): .. image:: ../_static/bend90.svg :alt: A graphical representation of a generic layer stack. :width: 40% :align: center The simulation setup in the code snippet below. It sets four different simulation settings, by changing the space step from 50 nm to 25 nm while varying the subpixel_level from 1 (off) to 2. The post processing part consists of loading the HDF5 results file into the :class:`FDTDSimResults ` objects and then using ``matplotlib`` for visualization of the data. The code is available in the following folded section. .. dropdown:: Post Processing Code .. literalinclude:: ../_static/examples/FDTD/FDTD_bend90_post_processing.py :language: python .. dropdown:: Permittivity Profile The permittivity plots show the averaging of the material properties, specialy at curved locations. The subpixel averaging allows better description of the material properties on thos conditions, reducing the stair-casing of the permittivity profile. .. image:: ../_static/subpixel_example/subpixel_epsx_zoomed.svg :alt: A graphical representation of a generic layer stack. :width: 100% :align: center .. dropdown:: Field Profiles In the full field plots, it is possible to see that a coarse mesh without subpixel averaging presents field leakage as the mode propagates thorugh the bend. It gets reduces as we add the subpixel averaging. Increasing the subpixel averaging can provide similar results to those of almost halfing the space step. .. image:: ../_static/subpixel_example/subpixel_Hz.svg :alt: A graphical representation of a generic layer stack. :width: 100% :align: center .. dropdown:: Zoomed Field Profiles: It is more obivoues the fields looks smoother at a higher subpixel level. Usualy, level two is enough, as higher levels, might deteriorate the meshing process, without relevant increase in the results accuracy. .. image:: ../_static/subpixel_example/subpixel_Hz_zoomed.svg :alt: A graphical representation of a generic layer stack. :width: 100% :align: center .. dropdown:: Transmittance: It is clear that the 50nm mesh is not enough for properly capturing the reflection and transmission of the bend. Reducing the space-step improves the results while, increasing the subpixel average improves the accuracy of the results without sacrificing simulation time. .. raw:: html .. dropdown:: Reflecttance: Similar to the transmittance results, the reflecttance gets improved with subpixel averaging, lowering the reflection and making them more accurate as the subpixel level gets increased to two. .. raw:: html Waveguide - Run FDTD simulation from a function ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Similarly for this example, we are going to simulate a straight waveguide from a user defined function. .. literalinclude:: ../_static/examples/FDTD/FDTD_FunWaveguide_example.py :language: python It is also possible to run sweeps on the function by using :meth:`UpdateScriptParams ` which updates the parameters getting passed to the device gemoetry. Note: you still need to call the solver :meth:`SetSimSettings ` so that the device geometry update takes effect. .. literalinclude:: ../_static/examples/FDTD/FDTD_FunWaveguide_sweep_example.py :language: python Waveguide - Run FDTD simulation from a function (gdstk) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The function output can also be a gdstk library. .. literalinclude:: ../_static/examples/FDTD/FDTD_Fun_GdstkExample.py :language: python .. S-Bend - Creating a GIF from Fields .. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. For this example we are going to simulate an S-bend (:download:`bend90.gds <../_static/sbend.gds>`) and .. then create a ``.gif`` from the main component of the injected mode overlaping with the permittivity grid. .. .. image:: ../_static/sbend.svg .. :alt: A graphical representation of a generic layer stack. .. :width: 40% .. :align: center .. In this particular example we make use of the **Time Monitor** to store the fields at particular time instants, so we can animate them later. .. The python script for this simulation is presented in the following code snipet: .. .. literalinclude:: ../_static/examples/FDTD/FDTD_Sbend_example.py .. :language: python .. .. dropdown:: Post Processing Code .. .. literalinclude:: ../_static/examples/FDTD/FDTD_Sbend_post_processing.py .. :language: python .. The results is shown as follows: .. .. grid:: 1 .. .. grid-item-card:: Main Mode Component Propagation .. .. figure:: ../_static/sbend_hz.gif .. :width: 85% .. :align: center Splitter - Field over Device Strucutre Outline ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ For this example we are going to simulate a splitter (:download:`splitter.gds <../_static/splitter.gds>`) and then create an image with a DFT monitored field overlapping with the device structure outline. .. image:: ../_static/splitter.svg :alt: A graphical representation of a generic layer stack. :width: 60% :align: center In this particular example we make use of the **DFT Monitor** to monitor the frequency content of the fields, so we can plot a particular component and wavelength over the device structure outline. The python script for this simulation is presented in the following code snipet: .. literalinclude:: ../_static/examples/FDTD/FDTD_Splitter_example.py :language: python Once the simulation is over we can then use a post processing script to read the results, get the DFT Monitor data and then plot that with the outline of the device structure. .. dropdown:: Post Processing Code .. literalinclude:: ../_static/examples/FDTD/FDTD_Splitter_post_processing.py :language: python .. splitter_hz_outline .. grid:: 1 .. grid-item-card:: Real Part of the Hz .. figure:: ../_static/splitter_hz_outline.svg :width: 85% :align: center Waveguide Crossing - Using Port Symmetry ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ To accelerate simulation pyFDTD supports the specification of port symmetries. For this example we are going to use a waveguide crossing (:download:`etchedCrossing <../_static/etchedCrossing.gds>`). Due to its symmetries only one port needs to be excited and all the s-parameters can be inferred from that single run. The device geometry and its symmetry can be viewed in the following image: .. grid:: 1 .. grid-item-card:: Device Geometry View .. figure:: ../_static/etchedCrossing.svg :width: 65% :align: center Therefore we specifying ``symmetries`` in the ``SetPorts()`` method to: .. code-block:: python symmetries = {"1_2":"2_1","2_2":"1_1","3_2":"4_1","4_2":"3_1", "1_3":"3_1","2_3":"3_1","3_3":"1_1","4_3":"2_1", "1_4":"4_1","2_4":"4_1","3_4":"2_1","4_4":"1_1",} The logic is that each s-parameter is defined by a string ``i_j`` where ``i`` and ``j`` are port numbers. By convention ``i`` is the monitored port, ``j`` is the excited port. Following a python ``dictionary``, the ``key`` is the s-s-parameter reference that will receive the s-parameter results from the ``value``. For example, the first item: ``"1_2":"2_1"`` indicates that the s-parameter S12 is equal to S21. Closer look at the combinations, will see that all ``j`` in the ``value``'s are equal to ``1``. Thus, only port ``1`` will be excited. Alternatively predefined symmetry options can be used. For example waveguide crossing symmetry can be defined by setting symmetries='4x' instead of defining individual port combinations. Predefined symmetry options can be found in the :meth:`SetPorts ` method. The full simulation setup is presented in the follow code snipet: .. literalinclude:: ../_static/examples/FDTD/FDTD_WGCrossing_example.py :language: python The resulting S-Parameters can be observed in the final plotting: .. grid:: 2 .. grid-item-card:: Magnitude (Squared) .. figure:: ../_static/etchedCrossing_sparams_mag.png :width: 100% :align: center .. grid-item-card:: Phase (Deg) .. figure:: ../_static/etchedCrossing_sparams_phase.png :width: 100% :align: center Directional Coupler - Sidewall Angle ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. literalinclude:: ../_static/examples/FDTD/FDTD_Coupler_Sidewall.py :language: python .. grid:: 1 .. grid-item-card:: S31 Power .. figure:: ../_static/Coupler_Sidewall.png :width: 100% :align: center Taper - Domain Limits for GDSII/STL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Below are two examples showing how limiting the domain can be used to reduce the memory requirements and improve simulation time. .. literalinclude:: ../_static/examples/FDTD/FDTD_DomainLimit_GDSII.py :language: python .. literalinclude:: ../_static/examples/FDTD/FDTD_DomainLimit_STL.py :language: python