.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/benchmarks/analytical_distance_scaling.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_benchmarks_analytical_distance_scaling.py: Analytical evaluation scaling ============================= This benchmark measures the wall-clock time required to evaluate a fixed binary Percus--Yevick mixture at increasingly dense real-space distance grids. It measures computational cost only; it is not a numerical-convergence or physical-validation test. Run it on the target machine and report the Python environment, processor, and the median of several repetitions when comparing results between systems. .. GENERATED FROM PYTHON SOURCE LINES 13-22 .. code-block:: Python from time import perf_counter import matplotlib.pyplot as plt import numpy as np from PackLab import analytical, ureg .. GENERATED FROM PYTHON SOURCE LINES 23-25 Define a fixed physical mixture ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 25-40 .. code-block:: Python radii = np.array([0.75, 1.5]) * ureg.micrometer domain = analytical.PercusYevickDomain( size=100_000 * ureg.micrometer, radii=radii, volume_fraction=0.20, number_fractions=np.array([0.5, 0.5]), ) solver = analytical.PercusYevickSolver( densities=domain.particle_densities_per_radius, radii=domain.radii, wavenumber="auto", ) .. GENERATED FROM PYTHON SOURCE LINES 41-43 Time evaluations at different distance-grid sizes ------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 43-58 .. code-block:: Python point_counts = np.array([120, 180, 240, 360, 480, 720, 960, 1440, 1920, 2880]) elapsed_seconds = [] for point_count in point_counts: distances = np.linspace(0.0, 12.0, point_count) * ureg.micrometer started = perf_counter() result = solver.compute(distances) elapsed_seconds.append(perf_counter() - started) print( f"{point_count:4d} distances: {elapsed_seconds[-1]:.3f} s " f"({len(result.wavenumber)} wavenumber points)" ) .. rst-class:: sphx-glr-script-out .. code-block:: none 120 distances: 0.027 s (1922 wavenumber points) 180 distances: 0.040 s (1922 wavenumber points) 240 distances: 0.053 s (1922 wavenumber points) 360 distances: 0.080 s (1922 wavenumber points) 480 distances: 0.106 s (1922 wavenumber points) 720 distances: 0.159 s (1922 wavenumber points) 960 distances: 0.213 s (1922 wavenumber points) 1440 distances: 0.318 s (1922 wavenumber points) 1920 distances: 0.423 s (1922 wavenumber points) 2880 distances: 0.636 s (1922 wavenumber points) .. GENERATED FROM PYTHON SOURCE LINES 59-61 Display the workload and timing result --------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 61-71 .. code-block:: Python figure, axis = plt.subplots(figsize=(6, 4)) _ = axis.loglog(point_counts, elapsed_seconds, "o-", color="#1677b8") _ = axis.set( xlabel="requested real-space distance points", ylabel="wall-clock time (s)", title="Percus--Yevick evaluation scaling", ) axis.grid(alpha=0.25, which="both") figure.tight_layout() .. image-sg:: /gallery/benchmarks/images/sphx_glr_analytical_distance_scaling_001.png :alt: Percus--Yevick evaluation scaling :srcset: /gallery/benchmarks/images/sphx_glr_analytical_distance_scaling_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.226 seconds) .. _sphx_glr_download_gallery_benchmarks_analytical_distance_scaling.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: analytical_distance_scaling.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: analytical_distance_scaling.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: analytical_distance_scaling.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_