RSA cost at different target fractions#

Compare insertion times at fixed box size and radius. Each point is the median of three seeded independent runs; print achieved fractions and particle counts because stopping limits can prevent a target from being reached. Timings depend on the machine, build, and random seeds. RSA is irreversible.

RSA insertion cost
target 0.05, seed 11: achieved 0.0503, N=96, time=0.0002 s
target 0.05, seed 22: achieved 0.0503, N=96, time=0.0002 s
target 0.05, seed 33: achieved 0.0503, N=96, time=0.0002 s
target 0.10, seed 11: achieved 0.1000, N=191, time=0.0004 s
target 0.10, seed 22: achieved 0.1000, N=191, time=0.0004 s
target 0.10, seed 33: achieved 0.1000, N=191, time=0.0004 s
target 0.15, seed 11: achieved 0.1503, N=287, time=0.0009 s
target 0.15, seed 22: achieved 0.1503, N=287, time=0.0009 s
target 0.15, seed 33: achieved 0.1503, N=287, time=0.0009 s
target 0.20, seed 11: achieved 0.2000, N=382, time=0.0018 s
target 0.20, seed 22: achieved 0.2000, N=382, time=0.0019 s
target 0.20, seed 33: achieved 0.2000, N=382, time=0.0018 s

from time import perf_counter
import matplotlib.pyplot as plt
import numpy as np
from PackLab import monte_carlo, samplers, ureg

domain = monte_carlo.PackingDomain(
    3 * ureg.micrometer, 3 * ureg.micrometer, 3 * ureg.micrometer, use_periodic_boundaries=True
)
sampler = samplers.ConstantRadiusSampler(0.15 * ureg.micrometer)
targets = [0.05, 0.10, 0.15, 0.20]
timings = []
for target in targets:
    runs = []
    for seed in (11, 22, 33):
        options = monte_carlo.RSAOptions()
        options.random_seed = seed
        options.maximum_attempts = 100000
        options.maximum_consecutive_rejections = 20000
        options.target_packing_fraction = target
        start = perf_counter()
        result = monte_carlo.RSASimulator(domain, sampler, options).run()
        runs.append(perf_counter() - start)
        print(
            f"target {target:.2f}, seed {seed}: "
            f"achieved {result.statistics.packing_fraction_geometry:.4f}, "
            f"N={result.statistics.sphere_count}, time={runs[-1]:.4f} s"
        )
    timings.append(np.median(runs))
figure, axis = plt.subplots()
axis.plot(targets, timings, "o-")
axis.set(
    xlabel="target packing fraction", ylabel="median wall time (s)", title="RSA insertion cost"
)
axis.grid(alpha=0.2)
figure.tight_layout()

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

Gallery generated by Sphinx-Gallery