.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/monte_carlo/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_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-23 .. code-block:: Python from PackLab import monte_carlo, samplers from PackLab import ureg .. GENERATED FROM PYTHON SOURCE LINES 24-28 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 28-58 .. code-block:: Python domain = monte_carlo.PackingDomain( 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.DiscreteRadiusSampler( radii=[0.1, 0.2] * ureg.millimeter, weights=[0.5, 0.5], ) options = monte_carlo.RSAOptions() options.random_seed = 123 options.maximum_attempts = 150_000 options.maximum_consecutive_rejections = 20_000 options.target_packing_fraction = 0.15 options.minimum_center_separation_addition = 0.0 rsa_simulator = monte_carlo.RSASimulator( domain=domain, radius_sampler=radius_sampler, options=options ) result = rsa_simulator.run() result.statistics.print() .. GENERATED FROM PYTHON SOURCE LINES 59-61 Visualise a central slice ------------------------- .. GENERATED FROM PYTHON SOURCE LINES 61-69 .. code-block:: Python _ = result.plot_slice_2d( slice_axis="z", slice_center_fraction=0.5, slice_thickness_fraction=0.08, maximum_circles_in_slice=2500, ) .. image-sg:: /gallery/monte_carlo/images/sphx_glr_monte_carlo_poly_disperse_001.png :alt: 2D slice at z≈0.00 meter, thickness 0.00 meter | showing 143 spheres :srcset: /gallery/monte_carlo/images/sphx_glr_monte_carlo_poly_disperse_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 70-72 Plot the pair correlation ------------------------- .. GENERATED FROM PYTHON SOURCE LINES 72-77 .. code-block:: Python _ = result.plot_pair_correlation( n_bins=150, maximum_pairs=200_000 ) .. image-sg:: /gallery/monte_carlo/images/sphx_glr_monte_carlo_poly_disperse_002.png :alt: Partial pair correlation functions g_ij(r), K=2, periodic=True :srcset: /gallery/monte_carlo/images/sphx_glr_monte_carlo_poly_disperse_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.462 seconds) .. _sphx_glr_download_gallery_monte_carlo_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 `_