Skip to main content

High-performance 2D Ising model Monte Carlo simulation with topological analysis

Project description

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 visualization

Installation

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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

isingenerator-3.1.2-cp313-cp313-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

isingenerator-3.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (407.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

isingenerator-3.1.2-cp312-cp312-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

isingenerator-3.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (407.6 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

isingenerator-3.1.2-cp311-cp311-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

isingenerator-3.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (405.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

isingenerator-3.1.2-cp310-cp310-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

isingenerator-3.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (403.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

isingenerator-3.1.2-cp39-cp39-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

isingenerator-3.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (404.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file isingenerator-3.1.2-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for isingenerator-3.1.2-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ec293fb11cd9a4800ad5ae7fe56cfcb6e7970204b9b18e410a55823a0f441902
MD5 f15a941d7fe4821b66ae24296065f2d7
BLAKE2b-256 60261ecae4350e719eba080eacd4196e4f67de670dae6bcdc5655fb70a23ceec

See more details on using hashes here.

File details

Details for the file isingenerator-3.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for isingenerator-3.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a6c131970ed78dfae0fb8c93b0368bbb0bfbe4a1a889679ee74c215e796b969a
MD5 e115b0a3323bf90adb3080bccd2794fc
BLAKE2b-256 409b01ba09597a35e54c07cf4d9bb1c55d0bac185cfe23716b9a9e7cdf808f1b

See more details on using hashes here.

File details

Details for the file isingenerator-3.1.2-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for isingenerator-3.1.2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6b67620dfd2f861708b1dce2727bd64b8bf61068c449e3781d7792ec97472a87
MD5 23ddbfb7adc4796de214d3ab0c1ec3f2
BLAKE2b-256 7954e19bf8bd8e408e1e3d358ec9d812d82640dff488c4fab8f0d21114f94933

See more details on using hashes here.

File details

Details for the file isingenerator-3.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for isingenerator-3.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 66baea4a8273fada41d0813adb653cb4f3cff42c2637c19e59565bba03f48d4a
MD5 e333fe39206d07e49ae2f98696666035
BLAKE2b-256 076d3a6b557f19e91e2f75f899fb8dcfc469ce89518996d39ea5c47f32ac593d

See more details on using hashes here.

File details

Details for the file isingenerator-3.1.2-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for isingenerator-3.1.2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6b2bb8c147c8a75cc4aec76afc8555524f2aca9dec8590c6b931ac2e85845b10
MD5 c9ba06f6147697f0522194d8e074d06e
BLAKE2b-256 b33bb8ad025946095853f009adda32f22093b35e905d81310a3704f644f42b99

See more details on using hashes here.

File details

Details for the file isingenerator-3.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for isingenerator-3.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f9bc6451ebaceea6e7b285295e2018b883b26f68a5ed5e1be63880412409010
MD5 033f0b21462b986f6912732762526d17
BLAKE2b-256 cbc3f1074092bd80219c6ba157e49412fe027555345e5dd601d678aaad445c2f

See more details on using hashes here.

File details

Details for the file isingenerator-3.1.2-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for isingenerator-3.1.2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9d65cc25ee0640a2066f5ad99d4e19c179f44743e7da0c5336bf8bb8a7ff3374
MD5 4ab7b50660cf5c851b35c2951a76affa
BLAKE2b-256 e57d9fd97bc2b8ba934cae98fc4665e3606e17c2557bb3f618e0467fb5e849ca

See more details on using hashes here.

File details

Details for the file isingenerator-3.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for isingenerator-3.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f98483e6c31048c77f0dae50fad09549f9c1e66b02df97d9570179cfa86c8c6f
MD5 e0d6fb000ae546e93d3924069278f581
BLAKE2b-256 78794cd4bd218badcf35c4e1587004718112c92104ff5e7a12d4a6e9260989bc

See more details on using hashes here.

File details

Details for the file isingenerator-3.1.2-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for isingenerator-3.1.2-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f6e689297fc23a7519038e68b5e7a464607bea4ffd3c35b28ddae8281b7bcce6
MD5 7164fe70f7da0536e05ce2b008a1991e
BLAKE2b-256 7cf31228da28719df0d1597fe26cce88eabb99b997fc3c9f44593f59b6326ff4

See more details on using hashes here.

File details

Details for the file isingenerator-3.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for isingenerator-3.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3a71ce9dd2c2d87229236df3ae4ba399593ff7ee8856b244288ee604c7e0b4c0
MD5 ce3c65da7188c6f36e432826ba0921e8
BLAKE2b-256 ba0d626debce3a91a962882903d81feb2ea30e93ff77842ae113ae7d37dabf09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page