other run
This commit is contained in:
parent
71b84b9ed3
commit
a015542b03
@ -173,5 +173,5 @@ class VO2_New(VO2_Lattice):
|
|||||||
# maske[1::2, :] = mask
|
# maske[1::2, :] = mask
|
||||||
# print(maske.shape)
|
# print(maske.shape)
|
||||||
# return maske
|
# return maske
|
||||||
def parse_maske(self, mask: np.ndarray):
|
def parse_mask(self, mask: np.ndarray):
|
||||||
return mask
|
return mask
|
||||||
|
@ -5,7 +5,7 @@ from scipy import signal
|
|||||||
from cache import timeit
|
from cache import timeit
|
||||||
from extractors import Rect_Evaluator
|
from extractors import Rect_Evaluator
|
||||||
import tqdm
|
import tqdm
|
||||||
from lattices import SCC_Lattice, VO2_Lattice
|
from lattices import SCC_Lattice, VO2_Lattice, VO2_New
|
||||||
import sys
|
import sys
|
||||||
from spin_image import SpinImage
|
from spin_image import SpinImage
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -21,127 +21,12 @@ ch.setFormatter(formatter)
|
|||||||
logger.addHandler(ch)
|
logger.addHandler(ch)
|
||||||
|
|
||||||
|
|
||||||
def test_mixed():
|
|
||||||
plt.style.use("one_column")
|
|
||||||
fig, axs = plt.subplots(3, 3)
|
|
||||||
LEN = 50
|
|
||||||
lat = VO2_Lattice(LEN, LEN)
|
|
||||||
plot = Plotter(lat)
|
|
||||||
si = SpinImage(lat.get_phases())
|
|
||||||
mask_misk = np.ones((LEN, LEN))
|
|
||||||
ind = np.arange(mask_misk.size)
|
|
||||||
np.random.shuffle(ind)
|
|
||||||
mask_misk[np.unravel_index(ind[:800], (LEN, LEN))] = 0
|
|
||||||
|
|
||||||
si.apply_mask(lat.parse_mask(np.zeros((LEN, LEN))))
|
|
||||||
print("Clean Rutile: ", si.get_intens(
|
|
||||||
lat.parse_mask(np.zeros((LEN, LEN)))))
|
|
||||||
si.gaussian(20)
|
|
||||||
print("Rutile: ", si.get_intens(lat.parse_mask(np.zeros((LEN, LEN)))))
|
|
||||||
intens_mono = si.fft()
|
|
||||||
intens_mono.clean()
|
|
||||||
plot.plot_spins(si=si, ax_lin=axs[0, 0])
|
|
||||||
|
|
||||||
si.apply_mask(lat.parse_mask(np.ones((LEN, LEN))))
|
|
||||||
print("Clean Mono: ", si.get_intens(lat.parse_mask(np.ones((LEN, LEN)))))
|
|
||||||
si.gaussian(20)
|
|
||||||
print("Mono: ", si.get_intens(lat.parse_mask(np.ones((LEN, LEN)))))
|
|
||||||
intens_rutile = si.fft()
|
|
||||||
intens_rutile.clean()
|
|
||||||
plot.plot_spins(si=si, ax_lin=axs[0, 2])
|
|
||||||
|
|
||||||
si.apply_mask(lat.parse_mask(mask_misk))
|
|
||||||
print("Clean Mixed: ", si.get_intens(lat.parse_mask(mask_misk)))
|
|
||||||
si.gaussian(20)
|
|
||||||
print("Mixed: ", si.get_intens(lat.parse_mask(mask_misk)))
|
|
||||||
intens_mixed = si.fft()
|
|
||||||
intens_mixed.clean()
|
|
||||||
plot.plot_spins(si=si, ax_lin=axs[0, 1])
|
|
||||||
|
|
||||||
plot.plot_fft(intens_mono,
|
|
||||||
ax_log=axs[1, 0], ax_lin=axs[2, 0])
|
|
||||||
plot.plot_fft(intens_rutile,
|
|
||||||
ax_log=axs[1, 2], ax_lin=axs[2, 2])
|
|
||||||
plot.plot_fft(intens_mixed,
|
|
||||||
ax_log=axs[1, 1], ax_lin=axs[2, 1])
|
|
||||||
|
|
||||||
plt.figure()
|
|
||||||
fig, axs = plt.subplots(1,3)
|
|
||||||
fig.set_figheight(1.7)
|
|
||||||
plot.plot_fft(intens_mixed,
|
|
||||||
ax_log=axs[1])
|
|
||||||
plot.plot_fft(intens_mono,
|
|
||||||
ax_log=axs[0])
|
|
||||||
plot.plot_fft(intens_rutile,
|
|
||||||
ax_log=axs[2])
|
|
||||||
for ax, t in zip(axs,["monoclinic", "mixed", "rutile"]):
|
|
||||||
ax.set_title(t)
|
|
||||||
ax.set_xlim(-1,1)
|
|
||||||
ax.set_ylim(-1,1)
|
|
||||||
plt.tight_layout()
|
|
||||||
fig.savefig("diff_pattern.pdf")
|
|
||||||
fig.savefig("diff_pattern.png")
|
|
||||||
# Plotting cuts
|
|
||||||
|
|
||||||
|
|
||||||
def test_pdf():
|
|
||||||
LEN = 40
|
|
||||||
lat = VO2_Lattice(LEN, LEN)
|
|
||||||
plot = Plotter(lat)
|
|
||||||
si = SpinImage(lat.get_phases())
|
|
||||||
integrate = 10
|
|
||||||
out_intens = None
|
|
||||||
already_inited = False
|
|
||||||
for i in range(integrate):
|
|
||||||
mask_misk = np.ones((LEN, LEN))
|
|
||||||
ind = np.arange(mask_misk.size)
|
|
||||||
np.random.shuffle(ind)
|
|
||||||
mask_misk[np.unravel_index(ind[:800], (LEN, LEN))] = 0
|
|
||||||
|
|
||||||
si.apply_mask(lat.parse_mask(mask_misk))
|
|
||||||
si.gaussian(20)
|
|
||||||
intens = si.fft()
|
|
||||||
intens.clean()
|
|
||||||
if not already_inited:
|
|
||||||
print("Init")
|
|
||||||
rect = Rect_Evaluator(lat.get_spots())
|
|
||||||
rect.generate_mask(intens, merge=True)
|
|
||||||
out_intens = intens
|
|
||||||
already_inited = True
|
|
||||||
else:
|
|
||||||
out_intens.intens += intens.intens
|
|
||||||
out_intens = intens
|
|
||||||
rect.purge(intens)
|
|
||||||
plt.figure()
|
|
||||||
plot.plot_fft(intens, ax_log=plt.gca())
|
|
||||||
plt.xlim(-1, 1)
|
|
||||||
plt.ylim(-1, 1)
|
|
||||||
plt.savefig("diff.png")
|
|
||||||
plt.savefig("diff.pdf")
|
|
||||||
|
|
||||||
pdf = sfft.fft2(intens.intens)
|
|
||||||
pdf = sfft.fftshift(pdf)
|
|
||||||
|
|
||||||
plt.figure()
|
|
||||||
plt.imshow(np.abs(pdf), vmax=100)
|
|
||||||
plt.xlabel("Pos")
|
|
||||||
plt.ylabel("Pos")
|
|
||||||
x = pdf.shape[1] / 2.
|
|
||||||
y = pdf.shape[0] / 2.
|
|
||||||
off = 100
|
|
||||||
plt.xlim(x-off, x+off)
|
|
||||||
plt.ylim(y-off, y+off)
|
|
||||||
plt.tight_layout()
|
|
||||||
plt.savefig("pdf.pdf")
|
|
||||||
plt.savefig("pdf.png")
|
|
||||||
|
|
||||||
|
|
||||||
def random(seed):
|
def random(seed):
|
||||||
np.random.seed(seed)
|
np.random.seed(seed)
|
||||||
LEN = 40
|
LEN = 40
|
||||||
lat = VO2_Lattice(LEN, LEN)
|
lat = VO2_New(LEN, LEN)
|
||||||
maske = np.zeros((LEN, LEN))
|
maske = np.zeros((LEN*2, LEN*2))
|
||||||
ind = np.arange(LEN * LEN)
|
ind = np.arange(maske.size)
|
||||||
np.random.shuffle(ind)
|
np.random.shuffle(ind)
|
||||||
rect = Rect_Evaluator(lat.get_spots())
|
rect = Rect_Evaluator(lat.get_spots())
|
||||||
|
|
||||||
@ -152,7 +37,7 @@ def random(seed):
|
|||||||
si = SpinImage(lat.get_phases())
|
si = SpinImage(lat.get_phases())
|
||||||
already_inited = False
|
already_inited = False
|
||||||
for i in tqdm.tqdm(ind):
|
for i in tqdm.tqdm(ind):
|
||||||
maske[np.unravel_index(i, (LEN, LEN))] = True
|
maske[np.unravel_index(i, maske.shape)] = True
|
||||||
counter += 1
|
counter += 1
|
||||||
if np.mod(counter, 100) != 0 and i != ind[-1] and i != ind[0]:
|
if np.mod(counter, 100) != 0 and i != ind[-1] and i != ind[0]:
|
||||||
continue
|
continue
|
||||||
@ -182,63 +67,6 @@ def random(seed):
|
|||||||
w_percentage=weighted_percentage, percentage=percentage, out_1=out_rect[0],
|
w_percentage=weighted_percentage, percentage=percentage, out_1=out_rect[0],
|
||||||
out_2=out_rect[1], out_3=out_rect[2], out_4=out_rect[3])
|
out_2=out_rect[1], out_3=out_rect[2], out_4=out_rect[3])
|
||||||
|
|
||||||
|
|
||||||
def sample_index(p):
|
|
||||||
i = np.random.choice(np.arange(p.size), p=p.ravel())
|
|
||||||
return np.unravel_index(i, p.shape)
|
|
||||||
|
|
||||||
|
|
||||||
def ising(seed, temp=0.5):
|
|
||||||
np.random.seed(seed)
|
|
||||||
LEN = 40
|
|
||||||
lat = VO2_Lattice(LEN, LEN)
|
|
||||||
maske = np.zeros((LEN, LEN))
|
|
||||||
rect = Rect_Evaluator(lat.get_spots())
|
|
||||||
|
|
||||||
out_rect = [[] for x in range(4)]
|
|
||||||
percentage = []
|
|
||||||
weighted_percentage = []
|
|
||||||
counter = 0
|
|
||||||
si = SpinImage(lat.get_phases())
|
|
||||||
already_inited = False
|
|
||||||
for i in tqdm.tqdm(range(LEN*LEN)):
|
|
||||||
probability = np.roll(maske, 1, axis=0).astype(float)
|
|
||||||
probability += np.roll(maske, -1, axis=0).astype(float)
|
|
||||||
probability += np.roll(maske, 1, axis=1).astype(float)
|
|
||||||
probability += np.roll(maske, -1, axis=1).astype(float)
|
|
||||||
|
|
||||||
probability = np.exp(probability/temp)
|
|
||||||
probability[maske > 0] = 0
|
|
||||||
probability /= np.sum(probability)
|
|
||||||
maske[sample_index(probability)] = True
|
|
||||||
counter += 1
|
|
||||||
if np.mod(counter, 100) != 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
si.apply_mask(lat.parse_mask(maske))
|
|
||||||
si.gaussian(20)
|
|
||||||
|
|
||||||
intens = si.fft()
|
|
||||||
if not already_inited:
|
|
||||||
rect.generate_mask(intens, merge=True)
|
|
||||||
already_inited = True
|
|
||||||
|
|
||||||
ir, vr = rect.extract(intens)
|
|
||||||
for lis, val in zip(out_rect, vr):
|
|
||||||
lis.append(val)
|
|
||||||
percentage.append(np.sum(maske))
|
|
||||||
[p1, p2] = si.get_intens(lat.parse_mask(maske))
|
|
||||||
weighted_percentage.append(p1/(p1+p2))
|
|
||||||
|
|
||||||
percentage = np.array(percentage)
|
|
||||||
weighted_percentage = np.array(weighted_percentage)
|
|
||||||
percentage /= np.max(percentage)
|
|
||||||
|
|
||||||
np.savez(f"ising_{temp}_rect_{seed}.npz",
|
|
||||||
w_percentage=weighted_percentage, percentage=percentage, out_1=out_rect[0],
|
|
||||||
out_2=out_rect[1], out_3=out_rect[2], out_4=out_rect[3])
|
|
||||||
|
|
||||||
|
|
||||||
def runner():
|
def runner():
|
||||||
np.random.seed(1234)
|
np.random.seed(1234)
|
||||||
seeds = np.random.randint(0, 10000, 200)
|
seeds = np.random.randint(0, 10000, 200)
|
||||||
@ -253,21 +81,4 @@ def runner():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
np.random.seed(1234)
|
np.random.seed(1234)
|
||||||
# runner()
|
runner()
|
||||||
# test_me()
|
|
||||||
# test_square()
|
|
||||||
test_mixed()
|
|
||||||
# test_pdf()
|
|
||||||
plt.show()
|
|
||||||
# random(1234)
|
|
||||||
# ising(1234)
|
|
||||||
# test_pdf()
|
|
||||||
# plt.show()
|
|
||||||
# exit()
|
|
||||||
# for i in np.random.randint(0, 10000, 5):
|
|
||||||
# random(i)
|
|
||||||
# ising(i, 0.5)
|
|
||||||
# ising(i, 1.0)
|
|
||||||
# ising(i, 1.5)
|
|
||||||
|
|
||||||
# plt.show()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user