.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/scattering/05_independent_mixture.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_scattering_05_independent_mixture.py: Independent scattering from a size mixture ========================================== The independent scattering coefficient sums each cross section weighted by its number density. This approximation omits interference from particle correlations; see the structure-factor example for a correlated reference. .. GENERATED FROM PYTHON SOURCE LINES 9-38 .. image-sg:: /gallery/scattering/images/sphx_glr_05_independent_mixture_001.png :alt: Independent scattering at fixed total number density :srcset: /gallery/scattering/images/sphx_glr_05_independent_mixture_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from PackLab import scattering, ureg diameters = np.array([150, 250]) * ureg.nanometer dataset = scattering.compute_scattering_amplitudes( wavelength=532 * ureg.nanometer, diameters=diameters, material=1.59, medium=1.33, phi=np.linspace(-90, 90, 181) * ureg.degree, ) # Keep the total number density fixed while changing composition. total_density = 1e18 / ureg.meter**3 fractions = np.linspace(0, 1, 11) coefficients = [] for fraction in fractions: densities = np.array([fraction, 1 - fraction]) * total_density coefficients.append(dataset.get_mu_independant(densities).to("1 / meter").magnitude) figure, axis = plt.subplots() axis.plot(fractions, coefficients, "o-") axis.set( xlabel="number fraction of 150 nm spheres", ylabel="scattering coefficient (1/m)", title="Independent scattering at fixed total number density", ) axis.grid(alpha=0.2) figure.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.058 seconds) .. _sphx_glr_download_gallery_scattering_05_independent_mixture.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 05_independent_mixture.ipynb <05_independent_mixture.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 05_independent_mixture.py <05_independent_mixture.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 05_independent_mixture.zip <05_independent_mixture.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_