API Reference
Ising model on a periodic Bravais lattice with Monte Carlo sampling.
Supports ferromagnets and spin glasses on hypercubic, triangular, FCC, BCC, or any custom lattice defined by neighbor offsets. Multiple replicas enable overlap-based spin glass order parameters.
Attributes:
| Name | Type | Description |
|---|---|---|
lattice_shape |
Shape of the lattice as a tuple of ints. |
|
n_dims |
Number of spatial dimensions. |
|
n_neighbors |
Number of nearest neighbors per site. |
|
temperatures |
Array of temperatures for parallel tempering. |
|
n_temps |
Number of temperature points. |
|
n_replicas |
Number of replicas per temperature. |
|
n_disorder |
Number of disorder realizations. |
|
couplings |
Coupling array with shape |
|
binder_cumulant |
Binder cumulant |
|
heat_capacity |
Heat capacity per spin |
|
sg_binder |
Spin glass Binder parameter |
__init__(lattice_shape, couplings='ferro', temperatures=np.geomspace(0.1, 10, 32), n_replicas=1, n_disorder=1, neighbor_offsets=None, geometry=None, seed=None)
Create an Ising model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lattice_shape
|
Shape of the periodic lattice, e.g. |
required | |
couplings
|
Coupling configuration. One of |
'ferro'
|
|
temperatures
|
Array of temperatures for the simulation. Defaults to 32 points log-spaced from 0.1 to 10. |
geomspace(0.1, 10, 32)
|
|
n_replicas
|
Number of independent replicas per temperature. Must be
|
1
|
|
n_disorder
|
Number of disorder realizations. Each realization gets its own coupling array. |
1
|
|
neighbor_offsets
|
List of integer offset vectors defining nearest
neighbors, e.g. |
None
|
|
geometry
|
Named lattice geometry. One of |
None
|
|
seed
|
Optional non-negative integer controlling built-in random
couplings and initial dynamics. |
None
|
reset(seed=None)
Reset dynamics while keeping the model's couplings fixed.
A bare reset replays the constructor's initial dynamics. Passing a seed performs a deterministic one-off reset without replacing that seed.
sample(n_sweeps, sweep_mode='metropolis', cluster_update_interval=None, cluster_mode='sw', cluster_action='update', pt_interval=None, pt_schedule='single_random_edge', overlap_cluster_update_interval=None, overlap_cluster_build_mode='houdayer', overlap_cluster_mode='wolff', overlap_cluster_action='update', overlap_cluster_max_temperature=None, warmup_ratio=0.25, collect_cluster_stats=False, autocorrelation_max_lag=None, autocorrelation_backend='ring', sequential=False, equilibration_diagnostic=False, snapshot_interval=None, collect_physics=False, displacements=None, block_size=None)
Run Monte Carlo sampling and compute observables.
After sampling, the following attributes are set on the instance:
binder_cumulant— Binder cumulant per temperature.heat_capacity— Heat capacity per spin and temperature, from the disorder-averaged thermal energy varianceenergy_variance.sg_binder— Spin glass Binder parameter (only withn_replicas >= 2).fk_csd— FK cluster size distribution (only withcollect_cluster_stats=Trueorcluster_action="observe").top_cluster_sizes— List of arrays (one per overlap mode), each shape(n_temps, 4), giving average relative sizes of the 4 largest overlap clusters per temperature (only withcollect_cluster_stats=Trueoroverlap_cluster_action="observe").
Optional attributes from an earlier call that this call does not produce are removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_sweeps
|
Total number of Monte Carlo sweeps (including warmup). |
required | |
sweep_mode
|
Single-spin update algorithm. |
'metropolis'
|
|
cluster_update_interval
|
If set, perform a cluster update every this many sweeps. |
None
|
|
cluster_mode
|
Cluster algorithm. |
'sw'
|
|
cluster_action
|
|
'update'
|
|
pt_interval
|
If set, attempt parallel tempering swaps every this many sweeps. |
None
|
|
pt_schedule
|
|
'single_random_edge'
|
|
overlap_cluster_update_interval
|
If set, attempt overlap cluster
moves every this many sweeps. Requires |
None
|
|
overlap_cluster_build_mode
|
Overlap cluster algorithm. |
'houdayer'
|
|
overlap_cluster_mode
|
Cluster type used inside the overlap move.
|
'wolff'
|
|
overlap_cluster_action
|
|
'update'
|
|
overlap_cluster_max_temperature
|
If set, apply overlap moves only at
temperatures up to this value (for |
None
|
|
warmup_ratio
|
Fraction of sweeps discarded as warmup before collecting statistics. Default 0.25. |
0.25
|
|
collect_cluster_stats
|
If |
False
|
|
autocorrelation_max_lag
|
If set, estimate the integrated
autocorrelation times |
None
|
|
autocorrelation_backend
|
|
'ring'
|
|
sequential
|
If |
False
|
|
equilibration_diagnostic
|
If |
False
|
|
snapshot_interval
|
Every this many sweeps, record overlap-cluster
snapshots of disorder realization 0 in
|
None
|
|
collect_physics
|
If |
False
|
|
displacements
|
Spin correlation displacements for |
None
|
|
block_size
|
Also keep |
None
|
Returns:
| Type | Description |
|---|---|
|
Raw results dictionary with keys like |
|
|
With |
|
|
holds this call's PT edge attempts, edge acceptances and completed |
|
|
round trips (not running totals); a round trip that began in an |
|
|
earlier call counts when it completes. |
|
|
indexed by the walker that started in replica row r at slot t. |
equilibration_delta(j_squared=1.0)
Compute the equilibration diagnostic Δ = e - J²β (N_b/N) (1 - q_l).
For Gaussian couplings of variance J², integrating by parts over the
disorder gives the equilibrium identity [n_neighbors bonds per spin (Katzgraber,
Palassini & Young, PRB 63, 184422 (2001)). The identity does not hold for
bimodal couplings, so Δ need not vanish there even in equilibrium.
Each checkpoint t averages over the last ⌈t/2⌉ sweeps, i.e. the log-binned window [2^(k-1), 2^k) at t = 2^k. From random initial states both e and q_l rise toward equilibrium, so Δ approaches zero from below; the simulation is considered thermalized once Δ agrees with zero within error bars for the last few windows (Zhu, Ochoa & Katzgraber, PRL 115, 077201 (2015)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
j_squared
|
Coupling variance J². 1.0 for |
1.0
|
Returns:
| Type | Description |
|---|---|
|
Tuple of (sweeps, delta) where sweeps has shape |
|
|
and delta has shape |
get_energies()
Return the mean energies per temperature from the last sample run.
Zero-field XY model on a periodic hypercubic lattice, with signed bonds.
All physical reductions use float64. Extensive observables are normalized
by the original lattice volume, including vacant sites. Uniform magnetic
observables do not measure spin-glass order. See docs/xy.md for moments,
disorder averaging, update clocks and the finite-size validation recipe.
reset(seed=None)
Reset spins, random streams and tempering; retain couplings and masks.
sample(n_sweeps, sweep_mode='metropolis', cluster_update_interval=1, cluster_mode='sw', cluster_updates=1, overrelaxation_sweeps=0, pt_interval=None, pt_schedule='single_random_edge', warmup_ratio=0.25, displacements=None, vortices=False, collect_blocks=False, block_size=128, autocorrelation_max_lag=None, autocorrelation_backend='ring', sequential=False)
Sample physical moments, with Metropolis plus embedded SW by default.
n_sweeps includes warmup. sweep_mode="gibbs" uses an exact
heat-bath (von Mises) local pass. Set sweep_mode="none" for
cluster-only sampling, or cluster_update_interval=None for local
updates only.
cluster_updates is a fixed count per scheduled event. Overrelaxation
and tempering are off by default. Blocks retain sums and counts over
block_size measured sweeps; autocorrelation diagnostics use measured
energy and m², averaged over replicas at each temperature.
Returns arrays indexed by temperature (and then direction/displacement).
per_disorder retains individual moments, derived quantities and work
counters; optional blocks and PT diagnostics are nested there.
angle_vortex_density is geometric angle winding on intact plaquettes,
not frustration-adjusted vorticity or chirality.