Equilibrating an RSA configuration with Metropolis moves#

Random sequential addition (RSA) creates a valid hard-sphere packing, but it is irreversible and does not sample the equilibrium hard-sphere ensemble. This example uses that RSA configuration only as an initial state for single-particle Metropolis moves. The Metropolis sampler keeps every radius, class label, and the particle count fixed; it only changes sphere centres.

For a production equilibrium calculation, check that observables have reached stationarity and estimate their uncertainty from independent samples. The acceptance rate printed below helps tune the proposal displacement.

from PackLab import monte_carlo, samplers
from PackLab.units import ureg
import matplotlib.pyplot as plt

Create a convenient non-overlapping initial state with RSA#

domain = monte_carlo.PackingDomain(
    5 * ureg.micrometer,
    5 * ureg.micrometer,
    5 * ureg.micrometer,
    use_periodic_boundaries=True,
)
radius_sampler = samplers.ConstantRadiusSampler(150 * ureg.nanometer, bins=1)

rsa_options = monte_carlo.RSAOptions()
rsa_options.random_seed = 12
rsa_options.maximum_attempts = 50_000
rsa_options.target_packing_fraction = 0.08
initial_result = monte_carlo.RSASimulator(domain, radius_sampler, rsa_options).run()

Equilibrate with fixed-volume Metropolis sampling#

Hard-sphere configuration after Metropolis equilibration, 2D slice at z≈0.00 meter, thickness 0.00 meter | showing 61 spheres
Metropolis acceptance rate: 0.910
Completed sweeps: 500
Packing fraction: 0.080

Total running time of the script: (0 minutes 6.077 seconds)

Gallery generated by Sphinx-Gallery