numerics
Loading...
Searching...
No Matches
num::markov Namespace Reference

Namespaces

namespace  backends
 

Classes

struct  MetropolisStats
 Statistics returned by a single Metropolis sweep. More...
 
struct  UmbrellaStats
 Statistics returned by an umbrella sampling sweep. More...
 
struct  UmbrellaWindow
 Window constraint for umbrella sampling. More...
 

Functions

double boltzmann_accept (double dE, double beta) noexcept
 Metropolis acceptance probability min(1, exp(-β ΔE)).
 
std::vector< doublemake_boltzmann_table (const std::vector< double > &dEs, double beta)
 Precompute a table of acceptance probabilities for a discrete set of dE values.
 
template<typename DeltaE , typename Apply , typename RNG >
MetropolisStats metropolis_sweep (idx n_sites, DeltaE delta_energy, Apply apply_flip, real beta, RNG &rng)
 Single Metropolis sweep: n_sites random single-site updates.
 
template<typename ProbFn , typename Apply , typename RNG >
MetropolisStats metropolis_sweep_prob (idx n_sites, ProbFn acceptance_prob, Apply apply_flip, RNG &rng)
 Metropolis sweep with caller-supplied acceptance probabilities.
 
template<typename DeltaE , typename Apply , typename Save , typename Restore , typename Measure , typename RNG >
UmbrellaStats umbrella_sweep (idx n_sites, DeltaE delta_energy, Apply apply_flip, Save save_state, Restore restore_state, Measure measure_order, UmbrellaWindow window, real beta, RNG &rng)
 Umbrella-sampled Metropolis sweep (dE variant).
 
template<typename ProbFn , typename Apply , typename Save , typename Restore , typename Measure , typename RNG >
UmbrellaStats umbrella_sweep_prob (idx n_sites, ProbFn acceptance_prob, Apply apply_flip, Save save_state, Restore restore_state, Measure measure_order, UmbrellaWindow window, RNG &rng)
 Umbrella-sampled Metropolis sweep (precomputed probability variant).
 
template<typename RNG = std::mt19937>
RNG make_seeded_rng ()
 Construct an RNG seeded from hardware entropy.
 
template<typename RNG = std::mt19937>
RNG make_rng (typename RNG::result_type seed)
 Construct an RNG from a fixed seed (for reproducible runs).
 

Function Documentation

◆ boltzmann_accept()

double num::markov::boltzmann_accept ( double  dE,
double  beta 
)
inlinenoexcept

Metropolis acceptance probability min(1, exp(-β ΔE)).

Definition at line 20 of file boltzmann_table.hpp.

References num::beta(), and num::ipow().

Referenced by make_boltzmann_table(), and IsingLattice::rebuild_boltz().

◆ make_boltzmann_table()

std::vector< double > num::markov::make_boltzmann_table ( const std::vector< double > &  dEs,
double  beta 
)
inline

Precompute a table of acceptance probabilities for a discrete set of dE values.

Definition at line 25 of file boltzmann_table.hpp.

References num::beta(), boltzmann_accept(), and num::ipow().

◆ make_rng()

template<typename RNG = std::mt19937>
RNG num::markov::make_rng ( typename RNG::result_type  seed)

Construct an RNG from a fixed seed (for reproducible runs).

Definition at line 23 of file rng.hpp.

References num::ipow().

◆ make_seeded_rng()

template<typename RNG = std::mt19937>
RNG num::markov::make_seeded_rng ( )

Construct an RNG seeded from hardware entropy.

Equivalent to RNG(std::random_device{}()). Use this at simulation startup for non-deterministic seeds.

Template Parameters
RNGAny standard-library-compatible random number engine. Defaults to std::mt19937.

Definition at line 16 of file rng.hpp.

References num::ipow().

◆ metropolis_sweep()

MetropolisStats num::markov::metropolis_sweep ( idx  n_sites,
DeltaE  delta_energy,
Apply  apply_flip,
real  beta,
RNG rng 
)

Single Metropolis sweep: n_sites random single-site updates.

The acceptance probability is min(1, exp(-beta * dE)) computed from the value returned by delta_energy(i).

Template Parameters
DeltaECallable: idx -> real. Returns dE for proposing a flip at i.
ApplyCallable: idx -> void. Applies the flip at site i.
RNGRandom number generator (e.g., std::mt19937).

Definition at line 20 of file mcmc_impl.hpp.

References num::markov::MetropolisStats::accepted, num::beta(), num::ipow(), and num::markov::MetropolisStats::total.

Referenced by umbrella_sweep().

◆ metropolis_sweep_prob()

MetropolisStats num::markov::metropolis_sweep_prob ( idx  n_sites,
ProbFn  acceptance_prob,
Apply  apply_flip,
RNG rng 
)

Metropolis sweep with caller-supplied acceptance probabilities.

Use this variant when acceptance probabilities are precomputed (e.g. a Boltzmann table for a discrete-dE system like the Ising model), avoiding a runtime exp() call per proposed flip.

Template Parameters
ProbFnCallable: idx -> real. Returns min(1, exp(-beta*dE)) for site i.
ApplyCallable: idx -> void. Applies the flip at site i.
RNGRandom number generator.

Definition at line 55 of file mcmc_impl.hpp.

References num::markov::MetropolisStats::accepted, num::ipow(), and num::markov::MetropolisStats::total.

Referenced by IsingLattice::sweep(), and umbrella_sweep_prob().

◆ umbrella_sweep()

UmbrellaStats num::markov::umbrella_sweep ( idx  n_sites,
DeltaE  delta_energy,
Apply  apply_flip,
Save  save_state,
Restore  restore_state,
Measure  measure_order,
UmbrellaWindow  window,
real  beta,
RNG rng 
)

Umbrella-sampled Metropolis sweep (dE variant).

Performs a sweep, measures the order parameter, then restores the saved state if the order parameter falls outside [window.lo, window.hi].

Template Parameters
DeltaECallable: idx -> real
ApplyCallable: idx -> void
SaveCallable: () -> void. Saves system state before the sweep.
RestoreCallable: () -> void. Restores saved state.
MeasureCallable: () -> idx. Returns the order parameter.
RNGRandom number generator.

Definition at line 92 of file mcmc_impl.hpp.

References num::beta(), num::ipow(), num::markov::UmbrellaStats::mc, metropolis_sweep(), num::markov::UmbrellaStats::order_param, and num::markov::UmbrellaStats::reverted.

◆ umbrella_sweep_prob()

UmbrellaStats num::markov::umbrella_sweep_prob ( idx  n_sites,
ProbFn  acceptance_prob,
Apply  apply_flip,
Save  save_state,
Restore  restore_state,
Measure  measure_order,
UmbrellaWindow  window,
RNG rng 
)

Umbrella-sampled Metropolis sweep (precomputed probability variant).

Same as umbrella_sweep but uses caller-supplied acceptance probabilities.

Template Parameters
ProbFnCallable: idx -> real
ApplyCallable: idx -> void
SaveCallable: () -> void
RestoreCallable: () -> void
MeasureCallable: () -> idx
RNGRandom number generator.

Definition at line 132 of file mcmc_impl.hpp.

References num::ipow(), num::markov::UmbrellaStats::mc, metropolis_sweep_prob(), num::markov::UmbrellaStats::order_param, and num::markov::UmbrellaStats::reverted.

Referenced by IsingLattice::sweep_umbrella().