.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/basic/plot_neff_tapered_fiber.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_basic_plot_neff_tapered_fiber.py: Effective index for tapered multi-mode fiber ============================================ .. GENERATED FROM PYTHON SOURCE LINES 7-9 Imports ~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 9-15 .. code-block:: Python import numpy from PyFiberModes.fiber import Fiber from PyFiberModes import LP01, LP11, LP21, LP02 import matplotlib.pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 16-17 Computing the analytical values using FiberModes solver. .. GENERATED FROM PYTHON SOURCE LINES 17-31 .. code-block:: Python def get_mode_beta(fiber, mode_list: list, itr_list: list) -> dict: data_dict = {} for mode in mode_list: data_list = [] for j, itr in enumerate(itr_list): _fiber = fiber.scale(factor=itr) data = _fiber.get_effective_index(mode=mode) data_list.append(data) data_dict[mode.__repr__()] = numpy.asarray(data_list) return data_dict .. GENERATED FROM PYTHON SOURCE LINES 32-33 Constructing fiber .. GENERATED FROM PYTHON SOURCE LINES 33-46 .. code-block:: Python fiber = Fiber(wavelength=1550e-9) fiber.add_layer(name='core', radius=20e-6, index=1.4494) fiber.add_layer(name='clad', radius=62.5e-6, index=1.4444) fiber.initialize_layers() itr_list = numpy.linspace(1, 0.1, 50) data_dict = get_mode_beta( fiber=fiber, mode_list=[LP01, LP11, LP21, LP02], itr_list=itr_list ) .. GENERATED FROM PYTHON SOURCE LINES 47-48 Preparing the figure .. GENERATED FROM PYTHON SOURCE LINES 48-68 .. code-block:: Python figure, ax = plt.subplots(1, 1) ax.set( title='Mode fields for vectorial mode if x-direction', xlabel='Inverse taper ratio', ylabel='Effective index' ) for mode, data in data_dict.items(): ax.plot( itr_list, data, label=mode, linestyle='-', linewidth=2 ) plt.show() # - .. image-sg:: /gallery/basic/images/sphx_glr_plot_neff_tapered_fiber_001.png :alt: Mode fields for vectorial mode if x-direction :srcset: /gallery/basic/images/sphx_glr_plot_neff_tapered_fiber_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.393 seconds) .. _sphx_glr_download_gallery_basic_plot_neff_tapered_fiber.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_neff_tapered_fiber.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_neff_tapered_fiber.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_