def calc_K(self): """Generates the right K matrices used to calculate the B's K[n] contains 'column-vectors' such that <l[n]|K[n]> = trace(l[n].dot(K[n])). K_l[n] contains 'bra-vectors' such that <K_l[n]|r[n]> = trace(K_l[n].dot(r[n])). """ self.h_expect = sp.zeros((self.N + 1), dtype=self.typ) self.uni_r.calc_AA() self.uni_r.calc_C() self.uni_r.calc_K() self.K[self.N + 1][:] = self.uni_r.K[0] self.uni_l.calc_AA() self.uni_l.calc_C() K_left, h_left_uni = self.uni_l.calc_K_l() self.K_l[0][:] = K_left[-1] for n in xrange(self.N, self.N_centre - 1, -1): self.K[n], he = tm.calc_K(self.K[n + 1], self.C[n], self.get_l(n - 1), self.r[n + 1], self.A[n], self.get_AA(n)) self.h_expect[n] = he for n in xrange(1, self.N_centre + 1): self.K_l[n], he = tm.calc_K_l(self.K_l[n - 1], self.C[n - 1], self.get_l(n - 2), self.r[n], self.A[n], self.get_AA(n - 1)) self.h_expect[n - 1] = he self.dH_expect = (mm.adot_noconj(self.K_l[self.N_centre], self.r[self.N_centre]) + mm.adot(self.l[self.N_centre - 1], self.K[self.N_centre]) - (self.N + 1) * self.uni_r.h_expect)
def calc_K(self): """Generates the right K matrices used to calculate the B's K[n] contains 'column-vectors' such that <l[n]|K[n]> = trace(l[n].dot(K[n])). K_l[n] contains 'bra-vectors' such that <K_l[n]|r[n]> = trace(K_l[n].dot(r[n])). """ self.h_expect = sp.zeros((self.N + 1), dtype=self.typ) self.uni_r.calc_AA() self.uni_r.calc_C() self.uni_r.calc_K() self.K[self.N + 1][:] = self.uni_r.K self.uni_l.calc_AA() self.uni_l.calc_C() K_left, h_left_uni = self.uni_l.calc_K_l() self.K_l[0][:] = K_left for n in xrange(self.N, self.N_centre - 1, -1): self.K[n], he = tm.calc_K(self.K[n + 1], self.C[n], self.get_l(n - 1), self.r[n + 1], self.A[n], self.A[n + 1], sanity_checks=self.sanity_checks) self.h_expect[n] = he for n in xrange(1, self.N_centre + 1): self.K_l[n], he = tm.calc_K_l(self.K_l[n - 1], self.C[n - 1], self.get_l(n - 2), self.r[n], self.A[n], self.A[n - 1], sanity_checks=self.sanity_checks) self.h_expect[n - 1] = he self.dH_expect = ( mm.adot_noconj(self.K_l[self.N_centre], self.r[self.N_centre]) + mm.adot(self.l[self.N_centre - 1], self.K[self.N_centre]) - (self.N + 1) * self.uni_r.h_expect)
def calc_K(self, n_low=-1, n_high=-1): """Generates the K matrices used to calculate the B's. This is called automatically by self.update(). K[n] is contains the action of the Hamiltonian on sites n to N. K[n] is recursively defined. It depends on C[m] and A[m] for all m >= n. It directly depends on A[n], A[n + 1], r[n], r[n + 1], C[n] and K[n + 1]. This is equivalent to K on p. 14 of arXiv:1103.0936v2 [cond-mat.str-el], except that it is for the non-norm-preserving case. K[1] is, assuming a normalized state, the expectation value H of Ĥ. """ if n_low < 1: n_low = 1 if n_high < 1: n_high = self.N for n in reversed(xrange(n_low, n_high + 1)): if n <= self.N - self.ham_sites + 1: if self.ham_sites == 2: self.K[n], ex = tm.calc_K(self.K[n + 1], self.C[n], self.l[n - 1], self.r[n + 1], self.A[n], self.A[n + 1], sanity_checks=self.sanity_checks) else: self.K[n], ex = tm.calc_K_3s(self.K[n + 1], self.C[n], self.l[n - 1], self.r[n + 2], self.A[n], self.A[n + 1], self.A[n + 2], sanity_checks=self.sanity_checks) self.h_expect[n] = ex else: self.K[n].fill(0) if n_low == 1: self.H_expect = sp.asscalar(self.K[1])