.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/validation/bohren_huffman/figure_87.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_87.py: InfiniteCylinder Scatterer Bohren-Huffman figure 8.7 ==================================================== .. GENERATED FROM PYTHON SOURCE LINES 8-9 Importing the dependencies: numpy, matplotlib, PyMieSim .. GENERATED FROM PYTHON SOURCE LINES 9-62 .. code-block:: Python import numpy import matplotlib.pyplot as plt from PyMieSim.units import ureg from PyMieSim.directories import validation_data_path from PyMieSim.experiment.scatterer_set import InfiniteCylinderSet from PyMieSim.experiment.source_set import GaussianSet from PyMieSim.experiment.polarization_set import PolarizationSet from PyMieSim.experiment import Setup theoretical = numpy.genfromtxt( f"{validation_data_path}/bohren_huffman/figure_87.csv", delimiter="," ) diameter = numpy.geomspace(10, 6000, 800) * ureg.nanometer volume = numpy.pi * (diameter.to_base_units().magnitude / 2) ** 2 source = GaussianSet( wavelength=[632.8] * ureg.nanometer, polarization=PolarizationSet(angles=[0, 90] * ureg.degree), optical_power=[1e-3] * ureg.watt, numerical_aperture=[0.2], ) scatterer = InfiniteCylinderSet( diameter=diameter, material=[1.55], medium=[1], ) experiment = Setup( scatterer_set=scatterer, source_set=source, ) values = experiment.get("Csca", as_numpy=True) data = values / volume * 1e-4 / 100 plt.figure(figsize=(8, 4)) plt.plot(diameter, data[0], "b--", linewidth=3, label="PyMieSim") plt.plot(diameter, data[1], "r-", linewidth=3, label="PyMieSim") plt.plot(diameter, theoretical[0], "k--", linewidth=1, label="BH 8.8") plt.plot(diameter, theoretical[1], "k--", linewidth=1, label="BH 8.8") plt.xlabel(r"Diameter [$\mu$m]") plt.ylabel("Scattering cross section [cylinder]") plt.grid(True) plt.legend() plt.tight_layout() plt.show() .. image-sg:: /gallery/validation/bohren_huffman/images/sphx_glr_figure_87_001.png :alt: figure 87 :srcset: /gallery/validation/bohren_huffman/images/sphx_glr_figure_87_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.347 seconds) .. _sphx_glr_download_gallery_validation_bohren_huffman_figure_87.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: figure_87.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: figure_87.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: figure_87.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_