.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/analysis/plot_coupled_mode_exchange.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_analysis_plot_coupled_mode_exchange.py: Coupled-mode power exchange =========================== Propagate two lossless modes coupled by a Hermitian matrix. .. GENERATED FROM PYTHON SOURCE LINES 7-24 .. image-sg:: /gallery/analysis/images/sphx_glr_plot_coupled_mode_exchange_001.png :alt: plot coupled mode exchange :srcset: /gallery/analysis/images/sphx_glr_plot_coupled_mode_exchange_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /opt/hostedtoolcache/Python/3.11.17/x64/lib/python3.11/site-packages/matplotlib/cbook.py:1408: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray. return np.asanyarray(x, float) | .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from PyFiberModes.units import ureg from PyFiberModes.propagation import CoupledModeSystem z = np.linspace(0, 40, 400) * ureg.meter system = CoupledModeSystem(betas=np.array([0, 0]) / ureg.meter, coupling=np.array([[0, 0.12], [0.12, 0]]) / ureg.meter) result = system.propagate(initial=[1, 0], z=z) figure, axis = plt.subplots() axis.plot(z.to("meter").magnitude, result.powers[:, 0], label="mode 1") axis.plot(z.to("meter").magnitude, result.powers[:, 1], label="mode 2") axis.set(xlabel="Propagation distance", ylabel="Normalized power", ylim=(0, 1)) axis.legend() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.120 seconds) .. _sphx_glr_download_gallery_analysis_plot_coupled_mode_exchange.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_coupled_mode_exchange.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_coupled_mode_exchange.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_coupled_mode_exchange.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_