SpinToolkit python documentation
Classes
- class spintoolkit_py.mc_base
Bases:
pybind11_builtins.pybind11_objectBase class of Monte Carlo sampler.
- __init__(self)
Default constructor.
- __init__(self, *, seed_global: int, seed_local: int, Ti: float, dump_dir: str = 'dump')
Constructor.
- Parameters:
seed_global – Global random seed. Random sequences are guaranteed to be independent as long as the pair (seed_global, seed_local) is unique.
seed_local – Local random seed. Random sequences are guaranteed to be independent as long as the pair (seed_global, seed_local) is unique.
Ti – Initial temperature.
dump_dir – Directory for saving/loading states. (Default: “dump”)
- Energy(self: spintoolkit_py.mc_base) float
Return current energy of the system.
- change_beta(self: spintoolkit_py.mc_base, beta: SupportsFloat, *, log: bool = True) None
Change inverse temperature.
- Parameters:
beta – The new inverse temperature \(\beta=1/T\).
log – If true, the new temperature will be recorded in the file “kT.dat”. (Default: True)
- change_dump_dir(self: spintoolkit_py.mc_base, dump_dir: str) None
Change the directory for saving/loading states.
- Parameters:
dump_dir – New directory for saving/loading states.
- load_state_SUN(self: spintoolkit_py.mc_base, *, lattice: spintoolkit_py.lattice, Z: spintoolkit_py.VecZList, sweeps_per_dump: int) tuple[int, int]
Load a list of SU(N) coherent states from the last snapshot in the folder dump_dir.
- Parameters:
lattice – Underlying lattice.
Z – List of SU(N) coherent states to be loaded from file (modified in-place).
sweeps_per_dump – Number of sweeps per dump interval.
- Returns:
info (int) – Whether loading succeeded (0) or not (1).
n_sweeps (int) – Sweep number from file.
- load_state_dipole(self: spintoolkit_py.mc_base, *, lattice: spintoolkit_py.lattice, s: spintoolkit_py.Vec3List, sweeps_per_dump: int) tuple[int, int]
Load a list of spin dipoles from the last snapshot in the folder dump_dir.
- Parameters:
lattice – Underlying lattice.
s – List of spin dipoles to be loaded from file (modified in-place).
sweeps_per_dump – Number of sweeps per dump interval.
- Returns:
info (int) – Whether loading succeeded (0) or not (1).
n_sweeps (int) – Sweep number from file.
- save_state_SUN(self: spintoolkit_py.mc_base, *, lattice: spintoolkit_py.lattice, Z: spintoolkit_py.VecZList, n_sweeps: int, sweeps_per_dump: int) None
Save a list of SU(N) coherent states to a gzip compressed file.
- Parameters:
lattice – Underlying lattice.
Z – List of SU(N) coherent states to be saved to file.
n_sweeps – Current number of sweeps.
sweeps_per_dump – Number of sweeps per dump interval.
- save_state_dipole(self: spintoolkit_py.mc_base, *, lattice: spintoolkit_py.lattice, s: spintoolkit_py.Vec3List, n_sweeps: int, sweeps_per_dump: int) None
Save a list of spin dipoles to a gzip compressed file.
- Parameters:
lattice – Underlying lattice.
s – List of spin dipoles to be saved to file.
n_sweeps – Current number of sweeps.
sweeps_per_dump – Number of sweeps per dump interval.
- specific_heat_bootstrap(self: spintoolkit_py.mc_base, *, L: int, Energy_list: collections.abc.Sequence[SupportsFloat], offset: int, n: int = 100, p: int = 100) tuple[float, float]
Calculate specific heat using bootstrap resampling.
Picks n numbers randomly from Energy_list[offset:] to compute specific heat, and repeats this p times to estimate the mean and error.
- Parameters:
L – Total number of lattice sites.
Energy_list – A list of recorded energies.
offset – Number of initial energies to skip (for thermalization).
n – Number of samples per bootstrap. (Default: 100)
p – Number of bootstrap repetitions. (Default: 100)
- Returns:
c (float) – Mean specific heat.
c_err (float) – Error of the specific heat.
- property beta
Inverse temperature \(\beta = 1/T\).
- property dump_dir
Folder for saving/loading states.
- property ratio_accept
Acceptance ratio.
- class spintoolkit_py.mc_Ising
Bases:
spintoolkit_py.mc_baseMonte Carlo Sampler for Ising spins.
- __init__(self)
Default constructor.
- __init__(self, *, seed_global: int, seed_local: int, Ti: float, dump_dir: str = 'dump')
Constructor.
- Parameters:
seed_global – Global random seed. Random sequences are guaranteed to be independent as long as the pair (seed_global, seed_local) is unique.
seed_local – Local random seed. Random sequences are guaranteed to be independent as long as the pair (seed_global, seed_local) is unique.
Ti – Initial temperature.
dump_dir – Directory for saving/loading states. (Default: “dump”)
- set_random(self: spintoolkit_py.mc_Ising, *, model: spintoolkit_py.model_spin, s: spintoolkit_py.Vec3List) None
Randomly flip a list of spin dipoles along input Ising axes.
- Parameters:
model – Underlying model.
s – List of spin dipoles to be flipped (normalization \(|\vec{s}_i| = 1\) required and fulfilled) (modified in-place).
- update_heatbath(self: spintoolkit_py.mc_Ising, *, model: spintoolkit_py.model_spin, s: spintoolkit_py.Vec3List) None
Perform L steps of heat-bath updates.
- Parameters:
model – Underlying model.
s – List of spin dipoles to be updated (normalization \(|\vec{s}_i| = 1\) required and fulfilled) (modified in-place).
- update_metropolis(self: spintoolkit_py.mc_Ising, *, model: spintoolkit_py.model_spin, s: spintoolkit_py.Vec3List) None
Perform L steps of Metropolis updates.
- Parameters:
model – Underlying model.
s – List of spin dipoles to be updated (normalization \(|\vec{s}_i| = 1\) required and fulfilled) (modified in-place).
- class spintoolkit_py.mc_dipole
Bases:
spintoolkit_py.mc_baseMonte Carlo Sampler for spin dipoles.
- __init__(self)
Default constructor.
- __init__(self, *, seed_global: int, seed_local: int, Ti: float, dump_dir: str = 'dump')
Constructor.
- Parameters:
seed_global – Global random seed. Random sequences are guaranteed to be independent as long as the pair (seed_global, seed_local) is unique.
seed_local – Local random seed. Random sequences are guaranteed to be independent as long as the pair (seed_global, seed_local) is unique.
Ti – Initial temperature.
dump_dir – Directory for saving/loading states. (Default: “dump”)
- set_random(self: spintoolkit_py.mc_dipole, *, model: spintoolkit_py.model_spin, s: spintoolkit_py.Vec3List) None
Randomize a list of spin dipoles on the \(S^2\) sphere uniformly.
- Parameters:
model – Underlying model.
s – List of spin dipoles to be randomized (normalization \(|\vec{s}_i| = 1\) fulfilled) (modified in-place).
- update_heatbath(self: spintoolkit_py.mc_dipole, *, model: spintoolkit_py.model_spin, s: spintoolkit_py.Vec3List) None
Perform L steps of heat-bath updates (currently does not support single-ion anisotropy yet).
- Parameters:
model – Underlying model.
s – List of spin dipoles to be updated (normalization \(|\vec{s}_i| = 1\) required and fulfilled) (modified in-place).
- update_metropolis(self: spintoolkit_py.mc_dipole, *, model: spintoolkit_py.model_spin, s: spintoolkit_py.Vec3List) None
Perform L steps of Metropolis updates.
- Parameters:
model – Underlying model.
s – List of spin dipoles to be updated (normalization \(|\vec{s}_i| = 1\) required and fulfilled) (modified in-place).
- update_overrelax(self: spintoolkit_py.mc_dipole, *, model: spintoolkit_py.model_spin, s: spintoolkit_py.Vec3List, random_visit: bool = True) None
Perform L steps of over-relaxation updates (reflect a spin wrt to its local field, i.e., precess by \(\pi\)).
- Parameters:
model – Underlying model.
s – List of spin dipoles to be updated (normalization \(|\vec{s}_i| = 1\) required and fulfilled) (modified in-place).
random_visit – If true, visit sites randomly; otherwise, visit sites sequentially. (Default: True)
- class spintoolkit_py.mc_SUN
Bases:
spintoolkit_py.mc_baseMonte Carlo Sampler for SU(N) coherent states.
- __init__(self)
Default constructor.
- __init__(self, *, seed_global: int, seed_local: int, Ti: float, dump_dir: str = 'dump')
Constructor.
- Parameters:
seed_global – Global random seed. Random sequences are guaranteed to be independent as long as the pair (seed_global, seed_local) is unique.
seed_local – Local random seed. Random sequences are guaranteed to be independent as long as the pair (seed_global, seed_local) is unique.
Ti – Initial temperature.
dump_dir – Directory for saving/loading states. (Default: “dump”)
- set_random(self: spintoolkit_py.mc_SUN, *, model: spintoolkit_py.model_spin, Z: spintoolkit_py.VecZList) None
Randomize a list of SU(N) coherent states on the \(S^{2N-2}\) sphere uniformly.
- Parameters:
model – Underlying model.
Z – List of SU(N) coherent states to be randomized (normalization \(|\vec{Z}_i|=1\) fulfilled) (modified in-place).
- update_metropolis(self: spintoolkit_py.mc_SUN, *, model: spintoolkit_py.model_spin, Z: spintoolkit_py.VecZList) None
Perform L steps of Metropolis updates.
- Parameters:
model – Underlying model.
Z – List of SU(N) coherent states to be updated (normalization \(|\vec{Z}_i|=1\) required and fulfilled) (modified in-place).