def __init__(self, dims, state_type='pure', ini='random', operators=None): self.dims = dims self.dim_tot = int(np.prod(self.dims)) self.l = len(self.dims) self.is_vec = True # If self.v is saved as a vector or tensor self.state_type = state_type if type(ini) is np.ndarray: self.v = ini elif ini is 'random': if state_type is 'pure': self.v = np.random.randn(self.dim_tot, ) self.v = tm.normalize_tensor(self.v)[0] else: self.v = np.random.randn(self.dim_tot, self.dim_tot) self.v = self.v + self.v.transpose((1, 0)) else: if state_type is 'pure': self.v = np.ones((self.dim_tot, 1)) / (self.dim_tot**0.5) else: self.v = np.eye(self.dim_tot) if operators is None: op = spin_operators('half') self.operators = [ op['id'], op['sx'], op['sy'], op['sz'], op['su'], op['sd'] ] else: self.operators = operators
def update_tensor_gradient(self, nt, step): # for n in self.mps.mps: # print(n) # input() self.mps.correct_orthogonal_center(nt) env = self.env_tensor((nt, 'all', 'gradient')) env = tm.normalize_tensor(env)[0] # env /= np.linalg.norm(env.reshape(-1, )) self.mps.mps[nt] = self.mps.mps[nt] * (1 - step) + step * env.reshape( self.mps.mps[nt].shape) self.mps.mps[nt] /= np.linalg.norm(self.mps.mps[nt].reshape(-1, ))
def bond_env_matrix_simple(self, nt, vb, is_symme=True, is_normalize=True): # the nb-th bond matrix of the nt-th tensor (including the phys bond) bonds = list(range(0, self.nVirtual)) bonds.remove(vb) tmp = self.absorb_lm(nt, False, bonds) bonds = list(range(0, self.nVirtual + 1)) bonds.remove(vb + 1) tmp = np.tensordot(tmp, tmp, (bonds, bonds)) if is_symme: tmp = (tmp + tmp.conj().T) / 2 if is_normalize: tmp = tm.normalize_tensor(tmp)[0] return tmp