Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Solutions · 14. Percolation: critical thresholds and cluster connectivity

School of Engineering, Nazarbayev University

Worked solutions to the three exercises of Lecture 14. Each solution is computed here and checked with assert statements against an exact identity or an independent calculation. The first code cell sets up the notebook and runs Demonstration 1 of the lecture without showing its output, because some of the solutions use its variables.

Exercise 1

Problem. Generate an ensemble of M=150M = 150 fixed uniform threshold fields U = rng.random((150, 50, 50)) (L=50L = 50). Prove that pixelwise coupling grid = (U[k] < p) makes the ensemble spanning probability P^span(p)\hat{P}_{\mathrm{span}}(p) strictly non-decreasing in pp, then pass predicate = lambda p: ensemble_p_span(p) >= 0.5 into divide_spatial.parametric_binary_search_min(predicate, lo=0.45, hi=0.75, tol=1e-4) to locate pc(50)p_c(50) automatically and compare against pc∞=0.592746p_c^\infty = 0.592746.


Exercise 1: Automated percolation threshold discovery via common-random-number bisection
========================================================================================
Bisection converged in 14 ensemble evaluations: p_c(L=50) = 0.59414
Infinite-lattice benchmark p_c = 0.59275  (|error| = 0.00139)
<Figure size 825x451 with 1 Axes>

Figure S14.1. Ensemble spanning probability on 50 × 50 lattices with common random numbers (line), the points evaluated by bisection, and the bisected threshold 0.5941 against pc=0.5927p_c = 0.5927.

Explanation. If you re-seeded a fresh random generator inside predicate(p), Monte Carlo jitter near Pspan≈0.5P_{\mathrm{span}} \approx 0.5 would violate monotonicity (for example True at 0.591 and False at 0.592) and corrupt binary search. Coupling all pp evaluations to the same underlying uniform matrix U (Common Random Numbers, coupling Mental Moves #11 and #23) turns the noisy simulation into a deterministic, monotone step function, and bisection narrows the interval by a factor of 3,000 in 14 ensemble evaluations. The result, pc(50)=0.5941p_c(50) = 0.5941, differs from the infinite-lattice value by 0.0014.


Exercise 2

Problem. Audit the 4-Connectivity vs. 8-Connectivity Lattice Stencil Trap: implement 8-connected (Moore neighborhood: orthogonal + diagonal) percolation alongside 4-connected percolation on L=48L = 48. Verify exact matching-lattice topological duality across 200 random realizations (top-to-bottom 4-connected occupied path exists   ⟺  \iff NO left-to-right 8-connected vacant path exists), proving pc,8=1−pc,4≈0.4073p_{c,8} = 1 - p_{c,4} \approx 0.4073 and exposing the 18.5 percentage-point prediction error at p=0.50p = 0.50.


Exercise 2: Exact 4- against 8-connectivity topological duality and 18.5% threshold shift
=========================================================================================
Topological duality verified on 200/200 random realizations (0 exceptions)
At p = 0.50: 4-connected P_span = 0.0% (insulating) vs. 8-connected P_span = 100.0% (percolating)
<Figure size 836x451 with 1 Axes>

Figure S14.2. Spanning probability on 48×4848 \times 48 lattices with 4- and 8-neighbour connectivity. The thresholds differ by 18.5 percentage points (shaded).

Explanation. On a 2-D square grid, a 4-connected river of occupied cells from North to South is blocked if and only if a continuous wall of vacant cells stretches from West to East—and because two diagonal wall stones block a 4-connected orthogonal step (corner-touching blocks orthogonal crossing), the blocking wall is 8-connected. By symmetry at L→∞L \to \infty, Pspan,4(p)+Pspan,8(1−p)=1P_{\mathrm{span},4}(p) + P_{\mathrm{span},8}(1 - p) = 1, forcing pc,8=1−pc,4=0.407254p_{c,8} = 1 - p_{c,4} = 0.407254. Allowing diagonal neighbours in image segmentation or pore-network code without thought shifts the threshold by 18.5 percentage points: at p=0.50p = 0.50 the 4-connected lattice never spans and the 8-connected lattice always does.


Exercise 3

Problem. Implement random_resistor_network_conductance(perc_grid) in NumPy solving Kirchhoff’s current law ∑v∼uguv(Vu−Vv)=0\sum_{v \sim u} g_{uv}(V_u - V_v) = 0 on interior occupied sites of an L×LL \times L lattice with V=1 VV = 1\ \mathrm{V} on occupied top-row sites, V=0 VV = 0\ \mathrm{V} on occupied bottom-row sites, and unit conductance guv=1 Sg_{uv} = 1\ \mathrm{S} between 4-connected occupied neighbors. Verify exact current conservation Itop,in==Ibottom,outI_{\mathrm{top,in}} == I_{\mathrm{bottom,out}}, separate the spanning cluster into the current-carrying backbone (Inode>10−8I_{\mathrm{node}} > 10^{-8}) vs. dead-end dangling mass (Inode≤10−8I_{\mathrm{node}} \le 10^{-8}), and verify that near p≈0.605p \approx 0.605 more than half of the spanning cluster carries no current.


Exercise 3: Implement it yourself — Kirchhoff random resistor network (backbone against dangling ends)
======================================================================================================
Near-critical lattice (L=34, p=0.605): G_eff = 0.0336 S
  Spanning cluster sites = 373 | Active backbone = 120 | Zero-current dangling = 67.8%
<Figure size 1265x462 with 2 Axes>

Figure S14.3. Random resistor network. (a) Spanning cluster at p=0.605p = 0.605 with the current-carrying backbone (red) and the dead ends (gold), 68 % of the cluster. (b) Mass of the spanning cluster and conductance against pp; the conductance rises much more slowly.

Summary. The mass of the spanning cluster rises steeply above pcp_c, with the small exponent β=5/36≈0.14\beta = 5/36 \approx 0.14, whereas the conductance Geff(p)∼(p−pc)tG_{\mathrm{eff}}(p) \sim (p - p_c)^t rises far more slowly (in two dimensions t≈1.30t \approx 1.30). The reason is visible in the gold pixels: near pcp_c most of the spanning cluster consists of dead ends attached by a single site, where Kirchhoff’s law makes the current zero. At p=0.605p = 0.605 and L=34L = 34, 67.8 %67.8\,\% of the spanning cluster carries no current.