def H2(J, g): I = np.eye(2) H = Hamiltonian({"ZZ": J, "X": g}).to_matrix() return 1 / 3 * sum( [tensor([H, I, I]), tensor([I, H, I]), tensor([I, I, H])])
def obj3(p, init_p, U, Rep, C): # calcultate the states psi1 = state_from_params(init_p, 3) psi2 = state_from_params(p, 3) # claculate the environmet Mr and Ml U1, U2 = C.paramU(init_p) U1_, U2_ = C.paramU(p) Mres = Rep.optimize(r(U1), r(U2), r(U1_.conj().T), r(U2_.conj().T)) Mr = Rep.M(Mres.x[1:]) U_ev = tensor([Mr.conj().T, U, Mr]) return -np.sqrt(2 * np.abs(psi2.conj().T @ U_ev @ psi1)**2)
def obj(p, U1, h_): LE = LeftEnvironment() RE = RightEnvironment() psi1 = bwMPS([np.eye(4), U1], 2).state() U1_ = U4(p) _, Ml = LE.exact_environment(r(U1), r(np.eye(4)), r(U1_.conj().T), r(np.eye(4))) _, Mr = RE.exact_environment(r(U1), r(np.eye(4)), r(U1_.conj().T), r(np.eye(4))) Ut = expm(1j * h_ * 0.01) Ut_m = tensor([Ml, Ut, Mr]) psi2 = bwMPS([np.eye(4), U1_], 2).state() return np.abs(psi2.conj().T @ Ut_m @ psi1)**2
def loschmidt(): J, g0, g1 = -1, 1.5, 0.2 I = np.eye(2) H2_ = H2(J, g0) H2_ = tensor([I, H2_, I]) gs = ground_state(H2_) H2_ = H2(J, g1) te = time_evolve(gs, H2_) plot_loschmidt(te) with open("Loschmidt_results.pkl", "wb") as f: pickle.dump(te, f) return te
def obj(p, init_p, U, Re, Le, C): # calcultate the states psi1 = state_from_params(init_p, 3) psi2 = state_from_params(p, 3) # claculate the environmet Mr and Ml U1, U2 = C.paramU(init_p) U1_, U2_ = C.paramU(p) eta_l, Ml = Le.exact_environment(r(U1), r(U2), r(U1_.conj().T), r(U2_.conj().T)) eta_r, Mr = Re.exact_environment(r(U1), r(U2), r(U1_.conj().T), r(U2_.conj().T)) U_ev = tensor([eta_l * Ml, U, eta_r * Mr]) return -np.sqrt(2 * np.abs(psi2.conj().T @ U_ev @ psi1))
def evolve_U2(): hh = HH(1) I = np.eye(4) h = tensor([I, hh, I]) Ut = expm(1j * h * 0.01) U1 = np.eye(4) U2 = np.array([[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]]) def obj(p, U2, Ut): psi1 = bwMPS([U2, np.eye(4)], 3).state() U2_ = OO_unitary(p) psi2 = bwMPS([U2_, np.eye(4)], 3).state() return np.abs(psi2.conj().T @ Ut @ psi1)**2 STEPS = 500 init_params = np.random.rand(7) results = [] for i in range(STEPS): print(i) res = minimize(obj, x0=init_params, args=(U2, Ut), method="Nelder-Mead", tol=1e-8, options={ "maxiter": 20000, "disp": True, "adaptive": True }) init_params = res.x U2 = OO_unitary(res.x) results.append(res.x) return results
def circuit(self, Ml, Mr): C = tensor([Ml, [np.eye(4)] * (self.l - 1), Mr]) psi = self.state() return C @ psi