# Mean field gen d Ising lattice.py

### From Werner KRAUTH

(Difference between revisions)

Revision as of 16:01, 8 November 2016Werner (Talk | contribs) ← Previous diff |
Current revisionWerner (Talk | contribs) |
||

Line 18: |
Line 18: | ||

print 'Temperature = ', 1.0 / beta | print 'Temperature = ', 1.0 / beta | ||

for iter in range(1000 * N): | for iter in range(1000 * N): | ||

- | i = random.randint(1, N - 1) | + | i = random.randint(0, N - 1) |

m[i] = math.tanh(beta * sum(m[k] for k in neighbours_all[i])) | m[i] = math.tanh(beta * sum(m[k] for k in neighbours_all[i])) | ||

x_vec = range(L) | x_vec = range(L) |

## Current revision

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(0, 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()