occupy_index ) #beta :correspoding position in D matrix or the particle index if conf[0][i] != 0: occupy_index.append(i) D = M[occupy_index] det_old = np.linalg.det(D) D[beta, :] = M[after, :] det_new = np.linalg.det(D) print det_old, det_new return det_new / det_old def Det(conf, L, u): #h,dia,u=H(L) M = u[:, np.arange(0, L, 1)] occupy_index = [] for i in range(np.size(conf)): if conf[0][i] != 0: occupy_index.append(i) D = M[occupy_index] return np.linalg.det(D) if __name__ == '__main__': L = 32 h, dia, u = H(L) conf = conf_initial(L, 16) #conf=np.array([[1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1]]) #print Ratio(conf,15,8,L,u) print Ratio1(conf, 3, 4, L, u) #print Ratio2(conf,15,8,L,u)
hop_index = random.choice(neighbour) if conf[0][hop_index] == 1: return "reject" ratio = Ratio(conf, select, hop_index, L)[0] rho = (ratio * ratio.conjugate()).real print rho if random.uniform(0, 1) < min(1, rho): conf[0][select] = 0 conf[0][hop_index] = 1 return [conf, ratio] else: return "reject" conf = conf_initial(L, N_up) samples = 0 E_total = 0 while True: samples = samples + 1 try_hop = hop(conf, L) if try_hop != "reject": conf, ratio = try_hop Eloc = E_loc1(conf, L) E_total = E_total + Eloc if samples == sample_goal: break E = E_total / samples E_site = E / L
conf[0][after] = conf[0][before] conf[0][before] = 0 occupy_index = [] for i in range(np.size(conf)): if conf[0][i] != 0: occupy_index.append(i) D1 = M[occupy_index] ratio = np.linalg.det(D1) / np.linalg.det(D) print ratio return [ratio, 0, 0, 0, 0] def Det(conf, L): h, dia, u = H(L) M = u[:, np.arange(0, L, 1)] occupy_index = [] for i in range(np.size(conf)): if conf[0][i] != 0: occupy_index.append(i) D = M[occupy_index] return np.linalg.det(D) if __name__ == '__main__': L = 10 h, dia, u = H(L) conf = conf_initial(L, 5) conf = np.array( [[0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1]]) Ratio(conf, 4, 3, L) Ratio1(conf, 4, 3, L)