I'm having a bit of trouble with matplotlib.animation in the code shown:
# creates grid of 1's/-1's of dimensions specified.
arr1 = np.random.choice([1.,-1.],[xarray,yarray])
# arr will be the 2-d array iterated.
arr = arr1
# time, row and column loops.
for t in range(0,time1):
for i in range(0,x):
for j in range(0,y):
Echange=energy_change(arr,i,j) # change in energy for this flip.
P_flip = np.exp(-Echange / kT) # probability of this flip occurring.
if random.random() < P_flip: # condition to accept flip.
arr[i][j]=-1*arr[i][j]
image = plt.imshow(arr) # plots image of Ising model after (time) iterations.
if t==0:
plt.show()
else:
plt.draw()
I have removed my animation attempt for clarity. Basically I want to make a windowed animation that stops after the time specified, without any lag from computation (Running this code shows an animation but is not consistent or smooth running). Is there any way of computing through all the iterations, and then displaying an animated window? I would be thankful for any contribution!