Something went wrong. Try again.
site percolation thresholds for slabs, newman-ziff in zig
Something went wrong. Try again.
Files
README.md
percolation #
site percolation thresholds for an L × L × h slab of the simple cubic lattice, measured with the Newman–Ziff algorithm: how the threshold moves from its two-dimensional value toward the three-dimensional one as the slab thickens. the slab is periodic in the two long directions and open or periodic in the thin one. the question comes from work with Robert Ziff.
install #
needs zig 0.17. no other dependencies.
git clone https://tangled.org/zzstoatzz.io/percolation
cd percolation
zig build -Doptimize=ReleaseFast
use #
$ ./zig-out/bin/slab --l 64 --h 4 --bc periodic --runs 2000
64 4 periodic 2000 1 0.379828 0.000190 0.379881 0.000225 0.379775 0.000206
the columns are l h bc runs seed, then three threshold estimates, each
followed by its standard error. the three come from three different wrapping
events and should agree.
design #
- wrapping, not spanning — the threshold is read off where a cluster first wraps the periodic torus, because that probability has an exactly known critical value in two dimensions and converges quickly with L.
- one sweep, every occupation — sites are added in random order, so one pass gives the wrapping event at every occupation count and a binomial average turns it into a function of p.
- allocate once — a lattice is allocated up front and a sweep touches nothing else, so each thread owns one and nothing is shared.
- seeded per sweep — a sweep's random stream depends only on the seed and its index, so the output does not depend on the thread count.
- built around cache misses — a sweep is a walk of random memory, so the data layout is chosen to keep it in cache.
develop #
zig build test --summary all # unit tests, including a brute-force check of wrap detection
zig build bench # cpu time per sweep on one thread
zig fmt --check src build.zig # formatting
docs #
docs/ holds the method and its assumptions, the measured thresholds, and the benchmark numbers.