.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/experiment/cylinder/cylinder_Qsca_vs_wavelength.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_experiment_cylinder_cylinder_Qsca_vs_wavelength.py: Cylinder: Qsca vs Wavelength ============================ This example demonstrates how to compute and visualize the scattering efficiency (Qsca) as a function of wavelength for cylindrical scatterers using PyMieSim, considering cylinders with different diameters and refractive indices. .. GENERATED FROM PYTHON SOURCE LINES 9-10 Importing the package dependencies: numpy, PyMieSim .. GENERATED FROM PYTHON SOURCE LINES 10-17 .. code-block:: Python import numpy as np from TypedUnit import ureg from PyMieSim.experiment.scatterer import Cylinder from PyMieSim.experiment.source import Gaussian from PyMieSim.experiment import Setup .. GENERATED FROM PYTHON SOURCE LINES 18-20 Defining the source Studying the scattering efficiency across a range of wavelengths. .. GENERATED FROM PYTHON SOURCE LINES 20-28 .. code-block:: Python source = Gaussian( wavelength=np.linspace(400, 1000, 150) * ureg.nanometer, # Wavelengths ranging from 400 nm to 1000 nm polarization=0 * ureg.degree, # Linear polarization angle in radians optical_power=1e-3 * ureg.watt, # 1 milliureg.watt NA=0.2 * ureg.AU, # Numerical Aperture ) .. GENERATED FROM PYTHON SOURCE LINES 29-31 Defining the scatterer distribution Considering cylinders with specific diameters and refractive indices. .. GENERATED FROM PYTHON SOURCE LINES 31-38 .. code-block:: Python scatterer = Cylinder( diameter=[200, 150] * ureg.nanometer, # Array of diameters: 200 nm, 150 nm, 100 nm property=[2, 3, 4] * ureg.RIU, # Array of refractive indices: 2, 3, 4 medium_property=[1] * ureg.RIU, # Refractive index of the surrounding medium source=source, ) .. GENERATED FROM PYTHON SOURCE LINES 39-40 Setting up the experiment .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: Python experiment = Setup(scatterer=scatterer, source=source) .. GENERATED FROM PYTHON SOURCE LINES 43-45 Measuring the scattering efficiency (Qsca) Averaging the data across the different indices to simplify visualization. .. GENERATED FROM PYTHON SOURCE LINES 45-47 .. code-block:: Python dataframe = experiment.get("Qsca") .. GENERATED FROM PYTHON SOURCE LINES 48-50 Plotting the results Visualizing how the Qsca varies with wavelength for the given cylinder configurations. .. GENERATED FROM PYTHON SOURCE LINES 50-51 .. code-block:: Python dataframe.plot(x="source:wavelength", std="scatterer:property") .. image-sg:: /gallery/experiment/cylinder/images/sphx_glr_cylinder_Qsca_vs_wavelength_001.png :alt: cylinder Qsca vs wavelength :srcset: /gallery/experiment/cylinder/images/sphx_glr_cylinder_Qsca_vs_wavelength_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none
.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.342 seconds) .. _sphx_glr_download_gallery_experiment_cylinder_cylinder_Qsca_vs_wavelength.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: cylinder_Qsca_vs_wavelength.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: cylinder_Qsca_vs_wavelength.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: cylinder_Qsca_vs_wavelength.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_