Mean field gen d Ising lattice.py

From Werner KRAUTH

Revision as of 11:00, 8 November 2016; view current revision
←Older revision | Newer revision→
Jump to: navigation, search
import math, random, pylab

dim = 2 

L = 100
N = L ** dim
Tc = 2 * dim

neighbours_all = [[site + ((site // L ** ind + i) % L -
                             (site // L ** ind) % L) * L ** ind
                              for ind in range(dim)
                              for i in [1, -1]]
                              for site in range(N)]
t = 0.01
beta = (t * Tc + Tc) ** (-1)
m = [1.0] * N
print 'Temperature = ', 1.0 / beta
for iter in range(1000 * N):
    i = random.randint(1, N - 1)
    m[i] =  math.tanh(beta * sum(m[k] for k in neighbours_all[i]))
x_vec = range(L)
y_vec = [abs(m[k]) for k in range(L)]
pylab.title('Mean-field lattice self-consistency, $L, d, T =$ ' + str(L) + ' ' +
str(dim) + ' ' + str(1 / beta))
pylab.semilogy(x_vec, y_vec)
pylab.xlabel('$k$ (Lattice site in $(1,0,0)$ direction) ', fontsize=18)
pylab.ylabel('$m(k)$ (spin magnetization)', fontsize=18)
pylab.legend(loc='lower left')
pylab.savefig('mean_field_gen_d_Ising.png')
pylab.show()
Personal tools