.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/validation/bohren_huffman/figure_810.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_validation_bohren_huffman_figure_810.py: Cylinder Scatterer Bohren-Huffman figure 8.10 ============================================= .. GENERATED FROM PYTHON SOURCE LINES 8-9 Importing the dependencies: numpy, matplotlib, PyMieSim .. GENERATED FROM PYTHON SOURCE LINES 9-61 .. code-block:: Python import numpy import matplotlib.pyplot as plt from TypedUnit import ureg from MPSPlots.styles import mps from PyMieSim.directories import validation_data_path from PyMieSim.single.source import Gaussian from PyMieSim.single.scatterer import Cylinder theoretical = numpy.genfromtxt( f"{validation_data_path}/bohren_huffman/figure_810.csv", delimiter="," ) x = theoretical[:, 0] y = theoretical[:, 1] source = Gaussian( wavelength=470 * ureg.nanometer, polarization=90 * ureg.degree, optical_power=1e-3 * ureg.watt, NA=0.1 * ureg.AU, ) scatterer = Cylinder( diameter=3000 * ureg.nanometer, source=source, property=(1.0 + 0.07j) * ureg.RIU, medium_property=1.0 * ureg.RIU, ) S1S2 = scatterer.get_s1s2(sampling=800) data = (numpy.abs(S1S2.S1) ** 2 + numpy.abs(S1S2.S2) ** 2) * ( 0.5 / (numpy.pi * source.wavenumber.to_base_units()) ) ** (1 / 4) with plt.style.context(mps): figure, ax = plt.subplots(1, 1) ax.plot(S1S2.phi, data, "C1-", linewidth=3, label="PyMieSim") ax.plot(x, y, "k--", linewidth=1, label="B&H [8.10]") ax.set( xlabel="scatterertering angle [degree]", ylabel="Phase function", yscale="log", ) ax.legend() plt.show() # - .. image-sg:: /gallery/validation/bohren_huffman/images/sphx_glr_figure_810_001.png :alt: figure 810 :srcset: /gallery/validation/bohren_huffman/images/sphx_glr_figure_810_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.312 seconds) .. _sphx_glr_download_gallery_validation_bohren_huffman_figure_810.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: figure_810.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: figure_810.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: figure_810.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_