pub struct Wolff { /* private fields */ }Expand description
Wolff single-cluster sampler.
Precomputes a per-site neighbour table from the geometry so the flood-fill
can enumerate neighbours in O(degree) without re-deriving lattice indices.
Implementations§
Source§impl Wolff
impl Wolff
Sourcepub fn new(cfg: WolffConfig) -> Self
pub fn new(cfg: WolffConfig) -> Self
Build a sampler from a validated configuration.
Sourcepub fn square(
rows: usize,
cols: usize,
coupling: f64,
periodic: bool,
) -> SeqResult<Self>
pub fn square( rows: usize, cols: usize, coupling: f64, periodic: bool, ) -> SeqResult<Self>
Convenience constructor for a square lattice.
Sourcepub fn from_graph(adjacency: Vec<Vec<usize>>, coupling: f64) -> SeqResult<Self>
pub fn from_graph(adjacency: Vec<Vec<usize>>, coupling: f64) -> SeqResult<Self>
Convenience constructor for a general graph.
Sourcepub fn last_cluster_size(&self) -> usize
pub fn last_cluster_size(&self) -> usize
Size of the cluster flipped on the most recent Wolff::step.
Sourcepub fn bond_probability(&self, beta: f64) -> f64
pub fn bond_probability(&self, beta: f64) -> f64
Bond / addition probability p = 1 − exp(−2 β J). See
super::swendsen_wang::SwendsenWang::bond_probability for the
clamping rationale.
Sourcepub fn step(
&mut self,
spins: &mut [i8],
beta: f64,
rng: &mut LcgRng,
) -> SeqResult<()>
pub fn step( &mut self, spins: &mut [i8], beta: f64, rng: &mut LcgRng, ) -> SeqResult<()>
Perform one Wolff single-cluster update in place.
Seeds at a uniformly random site, grows the aligned cluster by stack
flood-fill (each aligned neighbour joins with probability
p = 1 − exp(−2 β J)), then flips the whole cluster.
§Errors
SeqError::ShapeMismatch on a site-count mismatch,
SeqError::InvalidParameter for non-finite beta or non-±1 spins.
Sourcepub fn magnetization(&self, spins: &[i8]) -> SeqResult<f64>
pub fn magnetization(&self, spins: &[i8]) -> SeqResult<f64>
Mean magnetisation (1/N) Σ s_i ∈ [−1, +1].
§Errors
SeqError::ShapeMismatch on a site-count mismatch.