.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/analytical/01_monodisperse_volume_fraction.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_analytical_01_monodisperse_volume_fraction.py: Monodisperse Percus--Yevick fluid at several densities ====================================================== This example shows how the radial distribution function of an equilibrium hard-sphere fluid changes with volume fraction. At higher density, the first neighbour shell becomes more pronounced. Each curve is an independent Percus--Yevick calculation; it is not an RSA packing trajectory. .. GENERATED FROM PYTHON SOURCE LINES 10-17 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from PackLab import analytical, ureg .. GENERATED FROM PYTHON SOURCE LINES 18-20 Solve a one-radius fluid for several volume fractions ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 20-53 .. code-block:: Python radius = 100 * ureg.nanometer distances = np.linspace(0.0, 1.2, 240) * ureg.micrometer volume_fractions = (0.05, 0.20, 0.40) figure, axis = plt.subplots(figsize=(6.5, 4)) for volume_fraction in volume_fractions: domain = analytical.PercusYevickDomain( size=50 * ureg.micrometer, radii=np.array([radius.magnitude]) * radius.units, volume_fraction=volume_fraction, number_fractions=np.array([1.0]), ) result = analytical.PercusYevickSolver( densities=domain.particle_densities_per_radius, radii=domain.radii, wavenumber="auto", ).compute(distances) _ = axis.plot( distances.to("micrometer").magnitude, result.g[0, 0], label=rf"$\phi={volume_fraction:.2f}$", ) _ = axis.axvline(2 * radius.to("micrometer").magnitude, color="0.5", linestyle="--") _ = axis.set( xlabel=r"separation $r$ ($\mu$m)", ylabel=r"pair correlation $g(r)$", title="Monodisperse Percus--Yevick hard-sphere fluid", ) _ = axis.legend(title="volume fraction") axis.grid(alpha=0.2) figure.tight_layout() .. image-sg:: /gallery/analytical/images/sphx_glr_01_monodisperse_volume_fraction_001.png :alt: Monodisperse Percus--Yevick hard-sphere fluid :srcset: /gallery/analytical/images/sphx_glr_01_monodisperse_volume_fraction_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.212 seconds) .. _sphx_glr_download_gallery_analytical_01_monodisperse_volume_fraction.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 01_monodisperse_volume_fraction.ipynb <01_monodisperse_volume_fraction.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01_monodisperse_volume_fraction.py <01_monodisperse_volume_fraction.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 01_monodisperse_volume_fraction.zip <01_monodisperse_volume_fraction.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_