.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/scattering/02_structure_factor_phase_function.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_02_structure_factor_phase_function.py: Mixture phase function with a structure factor ============================================== Combine optical sphere amplitudes with the Percus--Yevick reciprocal-space correlation tensor of a binary hard-sphere mixture. The resulting phase function includes the analytical mixture structure; it does not represent an RSA configuration. .. GENERATED FROM PYTHON SOURCE LINES 10-16 .. code-block:: Python import numpy as np from PackLab import analytical, scattering, ureg .. GENERATED FROM PYTHON SOURCE LINES 17-19 Calculate the Percus--Yevick mixture structure ----------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 19-35 .. code-block:: Python radii = np.array([75, 125]) * ureg.nanometer domain = analytical.PercusYevickDomain( size=100 * ureg.micrometer, radii=radii, volume_fraction=0.12, number_fractions=np.array([0.6, 0.4]), ) distances = np.linspace(0.0, 2.0, 240) * ureg.micrometer structure = analytical.PercusYevickSolver( densities=domain.particle_densities_per_radius, radii=domain.radii, wavenumber="auto", ).compute(distances) .. GENERATED FROM PYTHON SOURCE LINES 36-38 Evaluate optical amplitudes for the same size classes ------------------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 38-49 .. code-block:: Python dataset = scattering.compute_scattering_amplitudes( wavelength=532 * ureg.nanometer, diameters=2 * radii, material=1.59, medium=1.33, phi=np.linspace(-90, 90, 181) * ureg.degree, ) dataset.process() .. GENERATED FROM PYTHON SOURCE LINES 50-52 Project the structure-corrected phase function into two dimensions ------------------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 52-69 .. code-block:: Python phi, theta, phase_function = dataset.get_phase_function( densities=structure.densities, H=structure.H, wavenumber=structure.wavenumber, theta_points=120, ) phase_function_values = ( phase_function.magnitude if hasattr(phase_function, "magnitude") else phase_function ) _ = scattering.plottings.plot_phase_function_2d_projection( phi=phi, theta=theta, phase_function=phase_function_values, projection="azimuth_average", normalize=True, ) .. image-sg:: /gallery/scattering/images/sphx_glr_02_structure_factor_phase_function_001.png :alt: Azimuth averaged phase function :srcset: /gallery/scattering/images/sphx_glr_02_structure_factor_phase_function_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.151 seconds) .. _sphx_glr_download_gallery_scattering_02_structure_factor_phase_function.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 02_structure_factor_phase_function.ipynb <02_structure_factor_phase_function.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 02_structure_factor_phase_function.py <02_structure_factor_phase_function.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 02_structure_factor_phase_function.zip <02_structure_factor_phase_function.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_