.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/validation/plot_beta_DCF.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_validation_plot_beta_DCF.py: Propagation constant: DCFC ========================== .. GENERATED FROM PYTHON SOURCE LINES 7-9 Imports ~~~~~~~ .. GENERATED FROM PYTHON SOURCE LINES 9-21 .. code-block:: Python import numpy from SuPyMode.workflow import Workflow, fiber_loader, Boundaries, BoundaryValue, DomainAlignment from PyOptik import MaterialBank from PyFiberModes import LP01 from PyFiberModes.fiber import load_fiber import matplotlib.pyplot as plt wavelength = 1550e-9 fiber_name = 'DCF1300S_33' .. GENERATED FROM PYTHON SOURCE LINES 22-25 Generating the fiber structure ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Here we define the cladding and fiber structure to model the problem .. GENERATED FROM PYTHON SOURCE LINES 25-30 .. code-block:: Python fiber_list = [ fiber_loader.load_fiber(fiber_name, clad_refractive_index=MaterialBank.fused_silica.compute_refractive_index(wavelength)) # Refractive index of silica at the specified wavelength ] .. GENERATED FROM PYTHON SOURCE LINES 31-32 Defining the boundaries of the system .. GENERATED FROM PYTHON SOURCE LINES 32-37 .. code-block:: Python boundaries = [ Boundaries(right=BoundaryValue.SYMMETRIC, bottom=BoundaryValue.SYMMETRIC), Boundaries(right=BoundaryValue.SYMMETRIC, bottom=BoundaryValue.ANTI_SYMMETRIC) ] .. GENERATED FROM PYTHON SOURCE LINES 38-41 Generating the computing workflow ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Workflow class to define all the computation parameters before initializing the solver .. GENERATED FROM PYTHON SOURCE LINES 41-61 .. code-block:: Python workflow = Workflow( fiber_list=fiber_list, # List of fiber to be added in the mesh, the order matters. wavelength=wavelength, # Wavelength used for the mode computation. resolution=80, # Number of point in the x and y axis [is divided by half if symmetric or anti-symmetric boundaries]. x_bounds=DomainAlignment.LEFT, # Mesh x-boundary structure. y_bounds=DomainAlignment.TOP, # Mesh y-boundary structure. air_padding_factor=1.3, boundaries=boundaries, # Set of symmetries to be evaluated, each symmetry add a round of simulation n_sorted_mode=3, # Total computed and sorted mode. n_added_mode=4, # Additional computed mode that are not considered later except for field comparison [the higher the better but the slower]. debug_mode=0, # Print the iteration step for the solver plus some other important steps. auto_label=True, # Auto labeling the mode. Label are not always correct and should be verified afterwards. itr_final=0.2, # Final value of inverse taper ratio to simulate n_step=70, ) workflow.initialize_geometry() # Initialize the geometry and plot it workflow.run_solver() # Run the solver to compute the modes .. GENERATED FROM PYTHON SOURCE LINES 62-63 Plotting the geometry .. GENERATED FROM PYTHON SOURCE LINES 63-65 .. code-block:: Python workflow.geometry.plot() .. image-sg:: /gallery/validation/images/sphx_glr_plot_beta_DCF_001.png :alt: Fiber structure, Fiber structure :srcset: /gallery/validation/images/sphx_glr_plot_beta_DCF_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. GENERATED FROM PYTHON SOURCE LINES 66-67 Plotting the field distribution .. GENERATED FROM PYTHON SOURCE LINES 67-71 .. code-block:: Python workflow.plot('field') itr_list = workflow.superset.model_parameters.itr_list .. image-sg:: /gallery/validation/images/sphx_glr_plot_beta_DCF_002.png :alt: $LP01$ slice: 0 itr: 1.000, $LP21_a$ slice: 0 itr: 1.000, $LP02$ slice: 0 itr: 1.000, $LP11_b$ slice: 0 itr: 1.000, $LP31_b$ slice: 0 itr: 1.000, $LP12_b$ slice: 0 itr: 1.000, $LP01$ slice: -1 itr: 0.200, $LP21_a$ slice: -1 itr: 0.200, $LP02$ slice: -1 itr: 0.200, $LP11_b$ slice: -1 itr: 0.200, $LP31_b$ slice: -1 itr: 0.200, $LP12_b$ slice: -1 itr: 0.200 :srcset: /gallery/validation/images/sphx_glr_plot_beta_DCF_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 72-73 Computing the analytical values using FiberModes solver. .. GENERATED FROM PYTHON SOURCE LINES 73-79 .. code-block:: Python dcf_fiber = load_fiber( fiber_name=fiber_name, wavelength=wavelength, add_air_layer=True ) .. GENERATED FROM PYTHON SOURCE LINES 80-81 Preparing the figure .. GENERATED FROM PYTHON SOURCE LINES 81-119 .. code-block:: Python figure, ax = plt.subplots(1, 1) ax.set( xlabel='Inverse taper ratio', ylabel='Effective index', ) pyfibermodes_mode = LP01 supymode_mode = workflow.superset.LP01 analytical = numpy.empty(itr_list.shape) for idx, itr in enumerate(itr_list): _fiber = dcf_fiber.scale(factor=itr) analytical[idx] = _fiber.get_effective_index(mode=pyfibermodes_mode) ax.plot( itr_list, analytical, label=str(pyfibermodes_mode) + ": PyFiberModes", linestyle='-', linewidth=2, color='red', ) ax.scatter( itr_list, supymode_mode.index.data, label=str(supymode_mode) + ": SuPyMode", color='black', s=80, linestyle='-', ) ax.legend() plt.show() # - .. image-sg:: /gallery/validation/images/sphx_glr_plot_beta_DCF_003.png :alt: plot beta DCF :srcset: /gallery/validation/images/sphx_glr_plot_beta_DCF_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 34.794 seconds) .. _sphx_glr_download_gallery_validation_plot_beta_DCF.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_beta_DCF.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_beta_DCF.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_beta_DCF.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_