.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/monte_carlo_poly_disperse.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_poly_disperse.py: A full workflow example with PackLab ==================================== This example shows the complete workflow of using PackLab to perform a Random Sequential Addition (RSA) simulation in three dimensions. It demonstrates the following steps: 1. Create a simulation domain 2. Define a radius sampler for particle sizes 3. Configure simulation options 4. Construct and run the RSA simulator 5. Access the simulation statistics 6. Visualize the resulting configuration and pair correlation function This is the recommended starting point when learning how to use PackLab. .. GENERATED FROM PYTHON SOURCE LINES 19-21 .. code-block:: Python from PackLab import monte_carlo, samplers from PackLab import ureg .. GENERATED FROM PYTHON SOURCE LINES 22-26 Simulation domain ----------------- The domain defines the physical volume of the simulation. Here we use periodic boundary conditions on a cubic box. .. GENERATED FROM PYTHON SOURCE LINES 26-67 .. code-block:: Python domain = monte_carlo.MCDomain( length_x=6.0 * ureg.millimeter, length_y=6.0 * ureg.millimeter, length_z=6.0 * ureg.millimeter, use_periodic_boundaries=True ) radius_sampler = samplers.Discrete( radii=[0.1, 0.2] * ureg.millimeter, weights=[0.5, 0.5], ) options = monte_carlo.Options() options.random_seed = 123 options.maximum_attempts = 2_500_000 options.maximum_consecutive_rejections = 50_000 options.target_packing_fraction = 0.3 options.minimum_center_separation_addition = 0.0 rsa_simulator = monte_carlo.Simulator( domain=domain, radius_sampler=radius_sampler, options=options ) result = rsa_simulator.run() result.statistics.print() result.plot_slice_2d( slice_axis="z", slice_center_fraction=0.5, slice_thickness_fraction=0.08, maximum_circles_in_slice=2500, ) result.plot_pair_correlation( n_bins=150, maximum_pairs=20_000_000 ) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /gallery/images/sphx_glr_monte_carlo_poly_disperse_001.png :alt: 2D slice at z≈0.00 meter, thickness 0.00 meter | showing 283 spheres :srcset: /gallery/images/sphx_glr_monte_carlo_poly_disperse_001.png :class: sphx-glr-multi-img * .. image-sg:: /gallery/images/sphx_glr_monte_carlo_poly_disperse_002.png :alt: Partial pair correlation functions g_ij(r), K=2, periodic=True :srcset: /gallery/images/sphx_glr_monte_carlo_poly_disperse_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/MPSPlots/helper.py:77: UserWarning: Glyph 8776 (\N{ALMOST EQUAL TO}) missing from font(s) cmr10. figure.tight_layout()
.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.426 seconds) .. _sphx_glr_download_gallery_monte_carlo_poly_disperse.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: monte_carlo_poly_disperse.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: monte_carlo_poly_disperse.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: monte_carlo_poly_disperse.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_