.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/scattering/01_single_particle_amplitudes.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_scattering_01_single_particle_amplitudes.py: Single-particle scattering amplitudes ======================================== Evaluate the far-field amplitudes of a dielectric sphere and inspect its scattering cross section. This example uses PackLab's optional PyMieSim integration and does not require a packing configuration. .. GENERATED FROM PYTHON SOURCE LINES 9-16 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from PackLab import scattering, ureg .. GENERATED FROM PYTHON SOURCE LINES 17-19 Evaluate amplitude functions for two sphere diameters ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 19-30 .. code-block:: Python diameters = np.array([150, 300]) * ureg.nanometer dataset = scattering.compute_scattering_amplitudes( wavelength=532 * ureg.nanometer, diameters=diameters, material=1.59, medium=1.33, phi=np.linspace(-90, 90, 181) * ureg.degree, ) .. GENERATED FROM PYTHON SOURCE LINES 31-33 Plot the polarisation-resolved amplitudes for one diameter ----------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 33-38 .. code-block:: Python figure = dataset[0].plot() _ = figure.suptitle("Amplitude functions for a 150 nm sphere") .. image-sg:: /gallery/scattering/images/sphx_glr_01_single_particle_amplitudes_001.png :alt: Amplitude functions for a 150 nm sphere :srcset: /gallery/scattering/images/sphx_glr_01_single_particle_amplitudes_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 39-41 Compare scattering cross sections across the diameter grid ----------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 41-56 .. code-block:: Python dataset.process() figure, axis = plt.subplots(figsize=(6, 4)) _ = axis.plot( diameters.to("nanometer").magnitude, dataset.Csca.to("nanometer**2").magnitude, "o-", ) _ = axis.set( xlabel="sphere diameter (nm)", ylabel=r"scattering cross section (nm$^2$)", title="Single-particle scattering cross section", ) axis.grid(alpha=0.25) figure.tight_layout() .. image-sg:: /gallery/scattering/images/sphx_glr_01_single_particle_amplitudes_002.png :alt: Single-particle scattering cross section :srcset: /gallery/scattering/images/sphx_glr_01_single_particle_amplitudes_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.172 seconds) .. _sphx_glr_download_gallery_scattering_01_single_particle_amplitudes.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 01_single_particle_amplitudes.ipynb <01_single_particle_amplitudes.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01_single_particle_amplitudes.py <01_single_particle_amplitudes.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 01_single_particle_amplitudes.zip <01_single_particle_amplitudes.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_