.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/monte_carlo/02_periodic_boundaries.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_02_periodic_boundaries.py: Periodic-boundary RSA packing ============================= Periodic boundaries identify opposite faces of the simulation box. They are a good default when measuring bulk quantities because a sphere near one face interacts with spheres near the opposing face. .. GENERATED FROM PYTHON SOURCE LINES 9-37 .. image-sg:: /gallery/monte_carlo/images/sphx_glr_02_periodic_boundaries_001.png :alt: Periodic RSA configuration, RSA centers (subsampled) :srcset: /gallery/monte_carlo/images/sphx_glr_02_periodic_boundaries_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Accepted 885 spheres at phi=0.100. | .. code-block:: Python from PackLab import monte_carlo, samplers from PackLab.units import ureg domain = monte_carlo.PackingDomain( length_x=5 * ureg.micrometer, length_y=5 * ureg.micrometer, length_z=5 * ureg.micrometer, use_periodic_boundaries=True, ) radius_sampler = samplers.ConstantRadiusSampler(150 * ureg.nanometer, bins=1) options = monte_carlo.RSAOptions() options.random_seed = 8 options.maximum_attempts = 30_000 options.maximum_consecutive_rejections = 8_000 options.target_packing_fraction = 0.10 result = monte_carlo.RSASimulator(domain, radius_sampler, options).run() print( f"Accepted {result.statistics.sphere_count} spheres at " f"phi={result.statistics.packing_fraction_geometry:.3f}." ) figure = result.plot_centers_3d(show=False) _ = figure.suptitle("Periodic RSA configuration") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.098 seconds) .. _sphx_glr_download_gallery_monte_carlo_02_periodic_boundaries.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 02_periodic_boundaries.ipynb <02_periodic_boundaries.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 02_periodic_boundaries.py <02_periodic_boundaries.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 02_periodic_boundaries.zip <02_periodic_boundaries.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_