-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.py
More file actions
65 lines (51 loc) · 1.11 KB
/
test.py
File metadata and controls
65 lines (51 loc) · 1.11 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import numpy as np
lattice = np.array([
[1, 1, 1],
[-1, -1, -1],
[-1, -1, -1]
])
prob = np.array([
[0.5, 0.5, 0.5],
[0.5, 0.5, 0.5],
[0.8, 0.8, 0.8]
])
X_prob_c = np.exp(- lattice)
print(X_prob_c)
# new = lattice.copy()
# new[(lattice < 0) & (prob < 0.6)] = 0
# print(lattice)
# print(new)
# add = lattice + prob
# print(add)
# print()
# print()
# row = lattice[0]
# probrow = prob[0]
# newrow = row.copy()
# newrow[probrow < 0.6] = 0
# print(row)
# print(newrow)
# np.random.seed(0)
# size = (3, 3)
# # X_lattice = np.random.choice([-1, 1], size=size)
# X_lattice = np.array([
# [1, 1, 1],
# [-1, -1, -1],
# [-1, -1, -1]
# ])
# # X_result = X_lattice.copy()
# X_deltaE = - X_lattice
# # If deltaE < 0 (spin is currently down), flip up.
# X_lattice[X_deltaE < 0] = 1
# # If deltaE > 0 (spin is currently up), flip down with probability
# # given by Boltzmann factor.
# X_prob = np.random.rand(*X_lattice.shape)
# X_lattice[(X_deltaE > 0) & (X_prob < 0.6)] = -1
# print(X_lattice)
# print("energy")
# print(X_deltaE)
# print()
# print("prob")
# print(X_prob)
# print()
# print(X_lattice)