.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/monte_carlo/01_minimal_rsa.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_monte_carlo_01_minimal_rsa.py: Minimal random sequential adsorption ==================================== This example creates a small periodic RSA packing from a uniform radius distribution. It then visualises a central two-dimensional slice of the accepted sphere configuration. .. GENERATED FROM PYTHON SOURCE LINES 9-40 .. image-sg:: /gallery/monte_carlo/images/sphx_glr_01_minimal_rsa_001.png :alt: Central slice of a periodic RSA packing, 2D slice at z≈0.00 meter, thickness 0.00 meter | showing 89 spheres :srcset: /gallery/monte_carlo/images/sphx_glr_01_minimal_rsa_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Packing fraction: 0.080 | .. code-block:: Python from PackLab import monte_carlo, samplers from PackLab.units import ureg domain = monte_carlo.PackingDomain( length_x=4 * ureg.micrometer, length_y=4 * ureg.micrometer, length_z=4 * ureg.micrometer, use_periodic_boundaries=True, ) radius_sampler = samplers.UniformRadiusSampler( minimum_radius=80 * ureg.nanometer, maximum_radius=120 * ureg.nanometer, bins=8, ) options = monte_carlo.RSAOptions() options.random_seed = 12 options.maximum_attempts = 20_000 options.maximum_consecutive_rejections = 5_000 options.target_packing_fraction = 0.08 result = monte_carlo.RSASimulator(domain, radius_sampler, options).run() print(result) print(f"Packing fraction: {result.statistics.packing_fraction_geometry:.3f}") figure = result.plot_slice_2d(show=False) _ = figure.suptitle("Central slice of a periodic RSA packing") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.271 seconds) .. _sphx_glr_download_gallery_monte_carlo_01_minimal_rsa.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 01_minimal_rsa.ipynb <01_minimal_rsa.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 01_minimal_rsa.py <01_minimal_rsa.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 01_minimal_rsa.zip <01_minimal_rsa.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_