.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/single/nearfields.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_single_nearfields.py: Near-Fields Computation and Visualization ========================================= This example demonstrates the process of computing and visualizing the far-fields of a scatterer using PyMieSim. .. GENERATED FROM PYTHON SOURCE LINES 7-47 .. image-sg:: /gallery/single/images/sphx_glr_nearfields_001.png :alt: scattered Ex real, scattered Ex abs :srcset: /gallery/single/images/sphx_glr_nearfields_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Computing scattered near field component: Ex /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/PyMieSim/single/representations/nearfields.py:259: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray. fields[component] = numpy.asarray(values).reshape(self.X.shape)
| .. code-block:: Python from PyMieSim.units import ureg from PyMieSim.single.scatterer import Sphere from PyMieSim.single.source import Gaussian from PyMieSim.polarization import PolarizationState from PyMieSim.single.setup import Setup polarization_state = PolarizationState(angle=0 * ureg.degree) source = Gaussian( wavelength=300 * ureg.nanometer, polarization=polarization_state, optical_power=1 * ureg.watt, numerical_aperture=0.3, ) scatterer = Sphere( diameter=400 * ureg.nanometer, material=(1.4 + 5.j), medium=1., ) setup = Setup( scatterer=scatterer, source=source, ) near_field = setup.get_representation("nearfields") near_field.plot( "Ex:real", "Ex:abs", type="scattered", plane_origin=(0.0, 0.0, 0.0), plane_normal=(0.0, 1.0, 0.0), sampling=100, extent_scale=4, tight_layout=True, ) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.722 seconds) .. _sphx_glr_download_gallery_single_nearfields.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: nearfields.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: nearfields.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: nearfields.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_