1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! # Wang-Landau Monte Carlo Sampling
//!
//! `wanglandau` is a model-agnostic implementation of the Wang-Landau algorithm
//! for efficiently sampling systems with rugged energy landscapes and estimating
//! density of states.
//!
//! ## Overview
//!
//! The Wang-Landau algorithm is an adaptive importance sampling technique that
//! helps overcome energy barriers in complex systems by dynamically modifying
//! the acceptance probabilities during simulation. This ensures uniform sampling
//! across the entire energy range, making it particularly useful for:
//!
//! - Calculating the density of states
//! - Estimating thermodynamic properties
//! - Sampling complex systems with energy barriers
//! - Rare event sampling
//!
//! ## Features
//!
//! - Generic implementation that works with any system
//! - Configurable modification factor schedules
//! - Multiple histogram flatness criteria
//! - Deterministic seeding for reproducibility
//!
//! ## Example
//!
//! ```no_run
//! use wanglandau::prelude::*;
//! use rand::SeedableRng;
//!
//! // Define your system state
//! #[derive(Clone)]
//! struct MyState {}
//! impl State for MyState {}
//!
//! // Define a move proposal
//! struct MyMoves;
//! impl<R: rand::RngCore> Move<MyState, R> for MyMoves {
//! fn propose(&mut self, state: &mut MyState, rng: &mut R) {
//! // Propose a move to state using rng
//! }
//! }
//!
//! // Define how states map to energy bins
//! struct MyMapper;
//! impl Macrospace<MyState> for MyMapper {
//! type Bin = usize;
//! fn locate(&self, state: &MyState) -> usize {
//! // Return the bin index for this state
//! 0
//! }
//! fn bins(&self) -> &[usize] {
//! // Return all possible bins
//! &[0]
//! }
//! }
//!
//! // Create and run a Wang-Landau simulation
//! let params = Params::default();
//! let mut driver = WLDriver::new(
//! MyState {},
//! MyMoves,
//! MyMapper,
//! params,
//! Geometric { alpha: 0.5, tol: 1e-8 },
//! Fraction,
//! Rng64::seed_from_u64(42), // For reproducibility
//! );
//!
//! // Run for a fixed number of steps
//! driver.run(1_000_000);
//!
//! // Get the estimated ln(density of states)
//! let ln_g = driver.ln_g();
//! ```
/// Commonly used items, exported for convenience.