.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/validation/pymiescatt/coreshell_1.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_pymiescatt_coreshell_1.py: Core-Shell Particles: 1 ======================= .. GENERATED FROM PYTHON SOURCE LINES 6-90 .. image-sg:: /gallery/validation/pymiescatt/images/sphx_glr_coreshell_1_001.png :alt: Comparison of Scattering Efficiency for Core-Shell Particles :srcset: /gallery/validation/pymiescatt/images/sphx_glr_coreshell_1_001.png :class: sphx-glr-single-img .. code-block:: Python # Standard library imports import numpy as np import pandas as pd import matplotlib.pyplot as plt from PyMieSim.units import ureg # PyMieSim imports from PyMieSim.experiment.scatterer_set import CoreShellSet from PyMieSim.experiment.source_set import GaussianSet from PyMieSim.experiment.polarization_set import PolarizationSet from PyMieSim.experiment import Setup from PyMieSim.directories import validation_data_path # Define parameters wavelength = 600 * ureg.nanometer polarization = PolarizationSet(angles=0 * ureg.degree) optical_power = 1 * ureg.watt NA = 0.2 medium_index = 1.0 core_index = 1.5 shell_index = 1.4 shell_thickness = 600 * ureg.nanometer core_diameters = np.geomspace(10, 500, 400) * ureg.nanometer # Configure the Gaussian source source = GaussianSet( wavelength=[600] * ureg.nanometer, polarization=polarization, optical_power=[1] * ureg.watt, numerical_aperture=[0.2] ) # Setup core-shell scatterer scatterer = CoreShellSet( core_diameter=core_diameters, shell_thickness=shell_thickness, core_material=[1.5], shell_material=[1.4], medium=[1.0], ) # Create experimental setup experiment = Setup(scatterer_set=scatterer, source_set=source) comparison_measures = ["Qsca", "Qext", "Qabs", "g", "Qpr", "Qback"] # Simulate using PyMieSim pymiesim = experiment.get(*comparison_measures, as_numpy=True) pymiescatt_dataframe = pd.read_csv( validation_data_path / "pymiescatt/example_coreshell_1.csv" ) figure, ax = plt.subplots(1, 1) for string in comparison_measures: ax.plot( pymiescatt_dataframe["core_diameter"], pymiescatt_dataframe[string], label="PyMieScatt: " + string, linewidth=3, ) for data, string in zip(pymiesim, comparison_measures): ax.plot( core_diameters.to(ureg.nanometer).magnitude, data, label="PyMieSim: " + string, linestyle="--", color="black", linewidth=1.5, ) ax.set( xlabel="Core Diameter (μm)", ylabel="Scattering Efficiency", title="Comparison of Scattering Efficiency for Core-Shell Particles", ) plt.legend() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.473 seconds) .. _sphx_glr_download_gallery_validation_pymiescatt_coreshell_1.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: coreshell_1.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: coreshell_1.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: coreshell_1.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_