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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-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.1-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for isingenerator-3.1.1-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 03abf8e68eb559d6c44efa98ab3a9e690c3330a8e1a006860b77cfa880f5808f
MD5 d44496ea88493a2a7729e4f3ccc35b4e
BLAKE2b-256 c32b210fc19ba74260069e4b8f066718555ec8859450064435aed2fee743b11b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for isingenerator-3.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61512b9bcd258a22aaef795c2df7ddf8056d386e4d64812271b1d0ab5eb30b9b
MD5 7193f3c0332e6421202cc50a62f07470
BLAKE2b-256 2076f52a362e3c9eadbf11240ba78beadfc36e0da6bd360505b88e710fa16a05

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for isingenerator-3.1.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2d1f2f919e4e4cfaecbd8655da6e3ec43b735711f466e812475b5328ec460df3
MD5 1d6b0cb49f2945a7cb6f3bc139355660
BLAKE2b-256 2a8b66ecd625e688923759c9b8f060a33c55964e25f4d0359e1cdcbef9d8ff9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for isingenerator-3.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 06867b388870cab3034287b0f7bf9e5a132280689e4ce2527a3f6d2e576615bd
MD5 2ba6ce96e83d44d44292b341e226f08a
BLAKE2b-256 e55c3be51fd80a2943f2397cbd3342349a283c8361de11acb8b36855523f083c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for isingenerator-3.1.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c94ce8daf7d7bf642e23e5161ba4afa9b056c585b3b73c70c8dc29b401aa204b
MD5 460c262c058e37741ddb5fb2aa443583
BLAKE2b-256 b2b53f796c1c3ad3972b0fb1ef22d2fb48e2776382710aef51c79a8be9023bfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for isingenerator-3.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3841618dcdd9a6f34f3ae4692eb9a50ddd6fc8bf043b46de96eb2f2f594894b2
MD5 52b838be0090958c449bf8fb19b4d40f
BLAKE2b-256 794111ebef25938547b9c8e193d2fae2041d91585e8878b54e42ad19a89fc020

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for isingenerator-3.1.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 afa2df2c74237a49bc71c0285cab3eb05dd87600cace993db424dbcc1bc291b2
MD5 2c78e35b24a928f5de0760472543fd51
BLAKE2b-256 fc84829206de737225d734584e4cd75d9b350052e3865fca2da7ffe952068ced

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for isingenerator-3.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bd630bc8af073bf50d91b86e140d3443dc8c9c55e476326fe76f26f3bf6d75dc
MD5 8d2844b03d82e8c5045b4e8cd92a70d9
BLAKE2b-256 d29c1d257efb41b138619a9aab9119b0041a7e3cc3d70b8589e299aca024f294

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for isingenerator-3.1.1-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 11c45206aaa4d23dc30a8c40b6930d305ceb8fffc8bddb0b6a2a6dcaab7cc8ce
MD5 efd66ec2a46f666e49abbead100c3795
BLAKE2b-256 cb1dceaf9f5c3a32da05ab762db5e0a089444918cd29915316e6ace6c5806265

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for isingenerator-3.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4b85e385257f8c750b80e4762b46092ea97679d4fa61be6cc9a09419abe8efb5
MD5 7d40eb6f29b6759d81864680c3412450
BLAKE2b-256 6af1fcbda583879aba01176792c87bfd644be21f2ab5e166c49970e28f5e9fd2

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