ISINGenerator
High-performance 2D Ising model Monte Carlo simulation with topological and geometrical analysis
Written in C++17 with OpenMP parallelism, exposed to Python via pybind11.
Features
Spin configuration (left) and nearest neighbors curvature (right) representation.
- Metropolis algorithm with checkerboard parallelism (OpenMP) - Domain labeling via Union-Find Disjoint Set - **Forman-Ricci curvature** of the +1 spin subgraph - PPM frame generation for animations - LaTex matplotlib visualizationInstallation
pip install isingenerator
Quick start
from isingenerator import Simulation, IsingVisualization
sim = Simulation(rows=500, cols=500, J=1.0, B=0.0)
# Temperature sweep
data = sim.run_temperature_range(
min_temperature=1.0,
max_temperature=4.0,
temperature_step=0.1,
equilibration_sweeps=50_000,
measurement_blocks=1_000,
sweeps_per_block=100,
threads=8,
output_csv="results.csv",
)
# Plot
viz = IsingVisualization()
viz.plot_dashboard(data, save="summary.pdf")
# Single temperature
result = sim.run_single_temperature(
temperature=2.269,
equilibration_sweeps=100_000,
measurement_blocks=2_000,
sweeps_per_block=100,
threads=8,
)
print(f"M = {result['magnetization']:.4f}")
print(f"FRC mean curvature = {result['forman_ricci_mean_curvature']:.4f}")
# Spin animation
sim.save_frames(
temperature=2.3,
measurement_blocks=500,
sweeps_per_block=100,
folder="frames")
# ffmpeg -framerate 30 -i frames/frame_%06d.ppm -pix_fmt yuv420p spin.mp4
# Forman-Ricci animation
sim.save_frames_forman_ricci(
temperature=2.3,
measurement_blocks=500,
sweeps_per_block=100,
folder="frames_ricci"
)
Observables returned
| Key | Description |
|---|---|
magnetization |
Magnetization per spin: $\langle M \rangle$ |
energy |
Energy per spin: $\langle E \rangle$ |
total_domains |
Total number of connected components |
positive_domains / negative_domains |
Number of connected components for $s_i = \pm 1$ |
positive_avg_size / negative_avg_size |
Mean component size: $\langle |
forman_ricci_mean_curvature |
Mean edge curvature: $\langle F(e) \rangle$ |
forman_ricci_total_curvature |
Total curvature: $\sum_{e \in E} F(e)$ |
forman_ricci_positive_nodes |
Cardinality of vertex set: $V$ |
forman_ricci_edges |
Cardinality of edge set: $E$ |
Physics background
The Hamiltonian of the 2D Ising model is
$$ H = -J \sum_{\langle i,j \rangle} s_i s_j ;- B \sum_i s_i $$
The critical temperature (for $B = 0$ and $J = 1$ ) is given by
$$ T_c = \frac{2J}{\ln\left(1 + \sqrt{2}\right)} \approx 2.269 , \frac{J}{k_B} $$
The Forman–Ricci curvature of an edge $e_{uv}$ in the $+1$ spin subgraph is
$$ F(e_{uv}) = -\deg(u) - \deg(v) $$
where $\deg(\cdot)$ denotes the degree of a vertex in the induced subgraph of positive spins.
Near the critical temperature $T_c$, the mean curvature exhibits a clear signature of the percolation transition.
References:
- Joshua Romero, Mauro Bisson, Massimiliano Fatica, Massimo Bernaschi, High performance implementations of the 2D Ising model on GPUs, Computer Physics Communications, Volume 256, 2020, 107473, ISSN 0010-4655,
- Sedgewick, R., & Wayne, K. (2011). Algorithms. Addison-wesley professional.
Documentation
Full documentation, examples, and API reference are available at:
-
GitHub repository:
https://github.com/erick-rios/ISINGenerator -
PyPI package:
https://pypi.org/project/isingenerator/
Metadata
Release files for isingenerator 3.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 8.8 MB
Release files / isingenerator-3.1.2-cp313-cp313-musllinux_1_2_x86_64.whl
| Download URL | isingenerator-3.1.2-cp313-cp313-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.13 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
ec293fb11cd9a4800ad5ae7fe56cfcb6e7970204b9b18e410a55823a0f441902
|
|
BLAKE2b-256 checksum How to use checksums |
60261ecae4350e719eba080eacd4196e4f67de670dae6bcdc5655fb70a23ceec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|
Release files / isingenerator-3.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | isingenerator-3.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 407.7 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
a6c131970ed78dfae0fb8c93b0368bbb0bfbe4a1a889679ee74c215e796b969a
|
|
BLAKE2b-256 checksum How to use checksums |
409b01ba09597a35e54c07cf4d9bb1c55d0bac185cfe23716b9a9e7cdf808f1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|
Release files / isingenerator-3.1.2-cp312-cp312-musllinux_1_2_x86_64.whl
| Download URL | isingenerator-3.1.2-cp312-cp312-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
6b67620dfd2f861708b1dce2727bd64b8bf61068c449e3781d7792ec97472a87
|
|
BLAKE2b-256 checksum How to use checksums |
7954e19bf8bd8e408e1e3d358ec9d812d82640dff488c4fab8f0d21114f94933
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|
Release files / isingenerator-3.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | isingenerator-3.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 407.6 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
66baea4a8273fada41d0813adb653cb4f3cff42c2637c19e59565bba03f48d4a
|
|
BLAKE2b-256 checksum How to use checksums |
076d3a6b557f19e91e2f75f899fb8dcfc469ce89518996d39ea5c47f32ac593d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|
Release files / isingenerator-3.1.2-cp311-cp311-musllinux_1_2_x86_64.whl
| Download URL | isingenerator-3.1.2-cp311-cp311-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
6b2bb8c147c8a75cc4aec76afc8555524f2aca9dec8590c6b931ac2e85845b10
|
|
BLAKE2b-256 checksum How to use checksums |
b33bb8ad025946095853f009adda32f22093b35e905d81310a3704f644f42b99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|
Release files / isingenerator-3.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | isingenerator-3.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 405.8 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
3f9bc6451ebaceea6e7b285295e2018b883b26f68a5ed5e1be63880412409010
|
|
BLAKE2b-256 checksum How to use checksums |
cbc3f1074092bd80219c6ba157e49412fe027555345e5dd601d678aaad445c2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|
Release files / isingenerator-3.1.2-cp310-cp310-musllinux_1_2_x86_64.whl
| Download URL | isingenerator-3.1.2-cp310-cp310-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
9d65cc25ee0640a2066f5ad99d4e19c179f44743e7da0c5336bf8bb8a7ff3374
|
|
BLAKE2b-256 checksum How to use checksums |
e57d9fd97bc2b8ba934cae98fc4665e3606e17c2557bb3f618e0467fb5e849ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|
Release files / isingenerator-3.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | isingenerator-3.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 403.9 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
f98483e6c31048c77f0dae50fad09549f9c1e66b02df97d9570179cfa86c8c6f
|
|
BLAKE2b-256 checksum How to use checksums |
78794cd4bd218badcf35c4e1587004718112c92104ff5e7a12d4a6e9260989bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|
Release files / isingenerator-3.1.2-cp39-cp39-musllinux_1_2_x86_64.whl
| Download URL | isingenerator-3.1.2-cp39-cp39-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.9 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
f6e689297fc23a7519038e68b5e7a464607bea4ffd3c35b28ddae8281b7bcce6
|
|
BLAKE2b-256 checksum How to use checksums |
7cf31228da28719df0d1597fe26cce88eabb99b997fc3c9f44593f59b6326ff4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|
Release files / isingenerator-3.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | isingenerator-3.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 404.3 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
3a71ce9dd2c2d87229236df3ae4ba399593ff7ee8856b244288ee604c7e0b4c0
|
|
BLAKE2b-256 checksum How to use checksums |
ba0d626debce3a91a962882903d81feb2ea30e93ff77842ae113ae7d37dabf09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.18
|