|
numerics 0.1.0
|
include/stochastic/boltzmann_table.hpp provides two small utilities in num::markov for computing Metropolis acceptance probabilities.
Every Metropolis sweep must decide whether to accept a proposed spin flip. The acceptance probability is \(\min(1,\, e^{-\beta \Delta E})\).
In a typical Ising sweep over \(N^2 = 90\,000\) sites this is evaluated millions of times per second. Calling std::exp at runtime is avoidable because \(\Delta E\) is discrete: for the 2D Ising model,
\[ \Delta E = 2J s \cdot \sum_{\text{nbrs}} s_j - 2F s, \qquad s,\,s_j \in \{-1,+1\},\; \sum_{\text{nbrs}} \in \{-4,-2,0,2,4\} \]
so only 10 distinct values of \(\Delta E\) occur. Pre-computing a \(2 \times 5\) lookup table eliminates exp from the hot path entirely.
boltzmann_accept replaces the inline ternary (dE <= 0.0) ? 1.0 : std::exp(-beta*dE) that previously appeared directly in rebuild_boltz().
Used by: Ising IsingLattice::rebuild_boltz.