SpinMC
SpinMC is an open-source Monte Carlo simulation package for classical spin models, designed for studying magnetic systems and phase transitions in statistical physics.
✨ Features
-
Multiple Spin Models:
- Ising model
- XY model
- Heisenberg model
-
Support Interactions:
- Exchange coupling (isotropic)
- Automatic exchange neighbor generation by coordination shell or distance range
- Single-ion anisotropy
- [Planned] Anisotropic exchange coupling
- [Planned] External magnetic field
-
Support Algorithms:
- Metropolis
- Wolff cluster algorithm
- [Planned] Parallel Tempering (Replica Exchange)
-
Simulation Capabilities:
- Energy, Heat capacity
- Magnetization, Susceptibility
- Absolute magnetization, absolute susceptibility
- Group-wise (sublattice) magnetization & susceptibility
- Group-wise (sublattice) Absolute magnetization & susceptibility
- [planned] magnetic hysteresis loop
- [planned] binder cumulant (u4)
📦 Installation
Requirements
- Python 3.9+ (for pip installation)
- Rust 1.88+ (for source compilation)
From PyPI
pip install spinmc
From Pre-built Releases
- Visit the Releases page
- Download the package for your OS
- Unpack the archive and run the executable
From source:
git clone https://github.com/mxmf/spinmc.git
cd spinmc
cargo build --release
🚀 Quick Start
- Create a configuration file (e.g.,
ising.toml):
[grid]
dimensions = [50, 50, 1]
sublattices = 1
spin_magnitudes = [1.0]
periodic_boundary = [true, true, false]
[simulation]
initial_state = "random"
boltzmann_constant = 1
model = "ising"
equilibration_steps = 10000
measurement_steps = 100000
algorithm = "wolff"
num_threads = 10
temperature_range = [
{ start = 1, end = 3, step = 0.1 },
]
[output]
savefile = "result.txt"
energy = true
heat_capacity = true
magnetization = true
susceptibility = true
magnetization_abs = true
susceptibility_abs = true
[[exchange]]
from_sublattice = 0
to_sublattice = 0
offsets = [[0, -1, 0], [0, 1, 0], [-1, 0, 0], [1, 0, 0]]
strength = 1.0
Exchange interactions can also be generated from the [structure] section instead of listing every offset manually. The structure can be written directly with cell and positions, or loaded from an external structure file:
[structure]
file = "POSCAR"
# format = "poscar" # Optional; currently only POSCAR/CONTCAR and .vasp files are supported.
# magnetic_indices = [0, 2] # Optional; select magnetic atoms when the file also contains non-magnetic atoms.
tolerance = 0.0001
Use neighbor_order = 1 for the first coordination shell, or distance_range = [min, max] to include every pair whose distance falls within the given range in Å. Specify both from_sublattice and to_sublattice to target one pair, only from_sublattice to target all destinations from one source sublattice, or neither to apply the rule to all sublattice pairs.
See examples/heisenberg_2d_cri3_poscar for a CrI3 monolayer example loaded from a POSCAR file.
- Run the simulation:
spinmc run -i ising.toml
-
Results will be saved in
result.txtwith the requested measurements. -
If
spinmcis installed via Python, you can plot the results with:
spinmc plot -i result.txt
📚 See more examples in the examples folder.
Metadata
Release files for spinmc 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| spinmc-0.3.0.tar.gz | 147.7 kB | Details |
Built distributions (wheels)
Total release size: 7.4 MB
Release files / spinmc-0.3.0.tar.gz
| Download URL | spinmc-0.3.0.tar.gz |
|---|---|
| Size | 147.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d01e14e8f1f6d251d68e9ed0d4b503b7c92334fb11ccc6693a36bb9a4cdc1b6
|
|
BLAKE2b-256 checksum How to use checksums |
1dacc542c47bdb139516f590b976ad16d91d144718e5813292cc585112f81dc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-py3-none-musllinux_1_2_x86_64.whl
| Download URL | spinmc-0.3.0-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 290.9 kB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
a5d15084255e8db74588a7811cf3afebb559c7953cdf7b045274a9d37b12feb0
|
|
BLAKE2b-256 checksum How to use checksums |
4572cb06e5bd4d187d05b5c51f78a6dbabc7f902d59ff38d574157a1669b9503
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-py3-none-musllinux_1_2_i686.whl
| Download URL | spinmc-0.3.0-py3-none-musllinux_1_2_i686.whl |
|---|---|
| Size | 311.2 kB |
| Tags | Linux musl 1.2+ x86-32 Python 3 |
|
SHA-256 checksum How to use checksums |
78cf455ea1213ca3711b13fbb90bce846a334613cff50d4c160c2772e70cb038
|
|
BLAKE2b-256 checksum How to use checksums |
f2ec1adf8b9d8c2b69fa558a14e498c6749efa966cf1cd4ab988ddabb5d8485d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-py3-none-musllinux_1_2_armv7l.whl
| Download URL | spinmc-0.3.0-py3-none-musllinux_1_2_armv7l.whl |
|---|---|
| Size | 492.3 kB |
| Tags | Linux musl 1.2+ ARMv7l Python 3 |
|
SHA-256 checksum How to use checksums |
8b7fed022878928c25f049318dc44fdff10f92a00b19a965e46f507ffb93f207
|
|
BLAKE2b-256 checksum How to use checksums |
3b5566c64ac5d086f4a2648e7e7fa01bd5c67c7aa8b923a015672b88fc8f9bf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-py3-none-musllinux_1_2_aarch64.whl
| Download URL | spinmc-0.3.0-py3-none-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 259.7 kB |
| Tags | Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
1b5408feb9480e5169c1e37d61b0e23d80cb8385941edee0c557e50c9c7f03d0
|
|
BLAKE2b-256 checksum How to use checksums |
9a9fd9ecfd723122f92d953b6e0fe2368aacfcb776aa100796a9e3bf17489493
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-cp310-abi3-win_amd64.whl
| Download URL | spinmc-0.3.0-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 678.1 kB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f77f93f09cd735257706b479c4f9f114c86ec8be973fa201980968ed68c97a4b
|
|
BLAKE2b-256 checksum How to use checksums |
c0d4519a57718c94476db15bcfea1092e74a82fc4e6f5b75f0a8a00361ae4fd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-cp310-abi3-win32.whl
| Download URL | spinmc-0.3.0-cp310-abi3-win32.whl |
|---|---|
| Size | 653.5 kB |
| Tags | CPython 3.10 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
200bb338836050fb016cf0dd52c08d22dfd078004a89b9f4f12d975d9523bc27
|
|
BLAKE2b-256 checksum How to use checksums |
eb3f21a8cdb32088805284586bea231d53f84308bc37166bdd6a68dc6cc8805b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | spinmc-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 800.4 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1ed06a58e8f3fc37fc99073a5b7e7d904ce355d751a867b5b0f4d14e28ddb454
|
|
BLAKE2b-256 checksum How to use checksums |
5b4aab48e0512093b9066c31d28ed7d237c6fbed645800c9389d9ab0f56618e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | spinmc-0.3.0-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 829.7 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
3bf6be2a22afbe36f9a282745e7b4470f69bfe62012b409b64a63b602c915abb
|
|
BLAKE2b-256 checksum How to use checksums |
9c01b20700c1c35d5d93ffe031e14a908cbb4b48cdde765750bf1dc5c2ab3a31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
| Download URL | spinmc-0.3.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl |
|---|---|
| Size | 774.0 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARMv7l abi3 |
|
SHA-256 checksum How to use checksums |
e1b603437cbff6a39d6ee50718265bd361987125b6637122adb6726fd1e817fd
|
|
BLAKE2b-256 checksum How to use checksums |
ce441bb779df00b429e3299bae5ecd823e51be6c83edb6f4fe35603c48ff521c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | spinmc-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 756.2 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
a7d19a7edc5a071285266d4df2e9db716380fbb6579e4ea2e36a61fc78f227a7
|
|
BLAKE2b-256 checksum How to use checksums |
9fca67334233c4d2244ab88cbe3db4d13619b8334d96c6a2e9beb7e2b6e801e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | spinmc-0.3.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 687.5 kB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d48fd8b145158e3f71ee287fb34499e44b5fda056a0eacacf3fa388d63139bc6
|
|
BLAKE2b-256 checksum How to use checksums |
0adfec031d1540e3178becca1fb4695e3e1dc5076b0b7317b958ffb62a85e1cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|
Release files / spinmc-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | spinmc-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 757.1 kB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
c100221fc51f7adad79168e9663f288415984bbaeb41b72cec3e0a0c9658eeca
|
|
BLAKE2b-256 checksum How to use checksums |
2930bc70a281617e69b2aa463f97d44f6cd5e19d0b4fc4f02b5d60dd1bba608a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
maturin/1.14.1
|