-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix_animation.py
38 lines (29 loc) · 1.29 KB
/
matrix_animation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib.colors import ListedColormap, BoundaryNorm
from random_chain import Random_chain
from tqdm import tqdm
length = 30
matrix = Random_chain(length)
fig, ax = plt.subplots()
ax.set_xticks(np.arange(-0.5, length+1, 1))
ax.set_yticks(np.arange(-0.5, length+1, 1))
ax.set_xticklabels('')
ax.set_yticklabels('')
ax.grid(color='k', linestyle='-', linewidth=0.05)
cmap = ListedColormap(["black", "white", "yellow"])
norm = BoundaryNorm([-matrix.ceiling, -1e-10, 1e-10, matrix.ceiling], cmap.N)
ims = []
img = ax.imshow(matrix.bond_matrix, interpolation='nearest', cmap=cmap, norm=norm, animated=True)
fig.savefig('Figures/Matrix/startmatrix.png', pad_inches=0, transparent=True)
for i in tqdm(range(int(length/2))):
matrix.renormalization()
img = ax.imshow(matrix.bond_matrix, interpolation='nearest', cmap=cmap, norm=norm, animated=True)
ims.append([img])
if i == 1 or i == 5 or i == 10 or i == 13:
fig.savefig('Figures/Matrix/midrg'+str(i)+'.png', pad_inches=0, transparent=True)
fig.savefig('Figures/Matrix/singlet-phase.png', pad_inches=0, transparent=True)
ani = animation.ArtistAnimation(fig, ims, interval=200, blit=True, repeat_delay=10000)
ani.save('Figures/rg.gif')
plt.show()