.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/benchmarks/plot_field_grid_scaling.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_benchmarks_plot_field_grid_scaling.py: Field-grid scaling ================== Measure the cost of evaluating three vector components on increasing grids. .. GENERATED FROM PYTHON SOURCE LINES 7-30 .. image-sg:: /gallery/benchmarks/images/sphx_glr_plot_field_grid_scaling_001.png :alt: Field evaluation :srcset: /gallery/benchmarks/images/sphx_glr_plot_field_grid_scaling_001.png :class: sphx-glr-single-img .. code-block:: Python from PyFiberModes.units import ureg from time import perf_counter import matplotlib.pyplot as plt from PyFiberModes import HE11 from PyFiberModes.fiber import load_fiber fiber = load_fiber("SMF28", wavelength=1550e-9 * ureg.meter) sizes = (51, 101, 151, 201) elapsed = [] for size in sizes: field = fiber.get_mode_field(HE11, limit=12e-6 * ureg.meter, n_point=size) start = perf_counter() field.get_components(("Ex", "Ey", "Ez")) elapsed.append(perf_counter() - start) figure, axis = plt.subplots() axis.plot(sizes, elapsed, marker="o") axis.set(xlabel="Grid width [points]", ylabel="Elapsed time [s]", title="Field evaluation") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.564 seconds) .. _sphx_glr_download_gallery_benchmarks_plot_field_grid_scaling.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_field_grid_scaling.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_field_grid_scaling.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_field_grid_scaling.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_