.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/extras/farfields_bulk.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_extras_farfields_bulk.py: Far-field scattering simulation for bulk scatterers =================================================== .. GENERATED FROM PYTHON SOURCE LINES 8-9 Importing the package dependencies: numpy, PyMieSim .. GENERATED FROM PYTHON SOURCE LINES 9-20 .. code-block:: Python from TypedUnit import ureg import numpy import matplotlib.pyplot as plt from PyMieSim.experiment.scatterer import Sphere from PyMieSim.experiment.source import Gaussian from PyMieSim.experiment import Setup from PyMieSim.single.polarization import RightCircular from PyOptik import Material from PyMieSim.single.mesh import FibonacciMesh from PyMieSim.utils import spherical_to_cartesian .. GENERATED FROM PYTHON SOURCE LINES 21-22 Defining the source to be employed. .. GENERATED FROM PYTHON SOURCE LINES 22-28 .. code-block:: Python source = Gaussian( wavelength=1200 * ureg.nanometer, polarization=RightCircular(), optical_power=1e-3 * ureg.watt, NA=0.2 * ureg.AU, ) .. GENERATED FROM PYTHON SOURCE LINES 29-30 Defining the ranging parameters for the scatterer distribution .. GENERATED FROM PYTHON SOURCE LINES 30-37 .. code-block:: Python scatterer = Sphere( diameter=[800, 1000, 1200] * ureg.nanometer, property=Material.BK7, medium_property=1 * ureg.RIU, source=source, ) .. GENERATED FROM PYTHON SOURCE LINES 38-39 Defining the detector to be employed. .. GENERATED FROM PYTHON SOURCE LINES 39-48 .. code-block:: Python mesh = FibonacciMesh( sampling=1400, max_angle=80 * ureg.degree, min_angle=0 * ureg.degree, phi_offset=0 * ureg.radian, gamma_offset=0 * ureg.radian, ) .. GENERATED FROM PYTHON SOURCE LINES 49-50 Defining the experiment setup .. GENERATED FROM PYTHON SOURCE LINES 50-52 .. code-block:: Python experiment = Setup(scatterer=scatterer, source=source) .. GENERATED FROM PYTHON SOURCE LINES 53-54 Measuring the properties .. GENERATED FROM PYTHON SOURCE LINES 54-92 .. code-block:: Python farfields = experiment.binding._get_farfields( scatterer_set=experiment.scatterer.set, source_set=experiment.source.set, mesh=mesh, ).squeeze() spf = numpy.einsum("ijk->ik", abs(farfields) ** 2) figure, axes = plt.subplots( ncols=3, nrows=1, figsize=(12, 4), subplot_kw={"projection": "3d"}, sharex=True, sharey=True, ) for idx, ax in enumerate(axes): x, y, z = spherical_to_cartesian( phi=mesh.spherical.phi, theta=mesh.spherical.theta, r=spf[idx], ) ax.scatter(x, y, z) spf_min, spf_max = spf.min(), spf.max() ax.set( xlim=(-spf_max, spf_max), ylim=(-spf_max, spf_max), zlim=(-spf_max, spf_max), ) plt.show() .. image-sg:: /gallery/extras/images/sphx_glr_farfields_bulk_001.png :alt: farfields bulk :srcset: /gallery/extras/images/sphx_glr_farfields_bulk_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.481 seconds) .. _sphx_glr_download_gallery_extras_farfields_bulk.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: farfields_bulk.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: farfields_bulk.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: farfields_bulk.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_