Krypf’s Diary

暇なときに書く

Simulation of two-dimensional Ising model with Julia & Python

Hamiltonian

The Hamiltonian of the Ising model, which is a model of ferromagnetism, is defined by spins (now +1 or -1)  (S_i) and constants  J,\, K as

 \displaystyle{
H = -J \sum_{\langle i,j \rangle}^{} S_{i} S_{j} - K \sum_{i}^{} S_{i} \, ,
}

where  \langle i,j \rangle represents the nearest neighbors.

I will solve this by the Metropolis method under a periodic boundary condition.

Parameters

The Boltzmann constant  k = 1,

the temperature  T = 1,

the initial condition: An  N \times N random matrix,  N = 2^6 = 64.

 J = 1

 K = 0

The number of cells whose spin values are inverted at once: 1.

The critical temperature here is  2.269\cdots (exact solution) or more roughly 4 (mean-field approximation) and it is proportional to the constant  J.

Result

Matrix calculation: Julia,

plot: Python.

The result below is a GIF composed of 204 png images taken and saved at the appropriate moments. Due to file size (<10 MB) restriction, the original file was split and only 165 shots were uploaded.

f:id:Krypf:20210509034000g:plain
2D Ising model Metropolis method simulation

We can see how the spins, which were disordered and entropy dominant, are converging into a large-scale structure.