def test_displacement(): def get_e_occu(idx): res = np.zeros(len(mol_list)) res[idx] = 1 return res gs = Mps.gs(mol_list, max_entangled=False) gs = Mpo.onsite(mol_list, r"a^\dagger", mol_idx_set={0}).apply(gs).compress() assert np.allclose(gs.e_occupations, get_e_occu(0)) gs = Mpo.displacement(mol_list, 0, 2).apply(gs) assert np.allclose(gs.e_occupations, get_e_occu(2)) gs = Mpo.displacement(mol_list, 2, 0).apply(gs) assert np.allclose(gs.e_occupations ,get_e_occu(0))
def _construct_flux_operator(self): # construct flux operator logger.debug("constructing flux operator") j_list = [] for i in range(len(self.mol_list) - 1): j1 = Mpo.displacement(self.mol_list, i, i + 1).scale(self.mol_list.j_matrix[i, i + 1]) j1.compress_config.threshold = 1e-5 j2 = j1.conj_trans().scale(-1) j_list.extend([j1, j2]) j_oper = compressed_sum(j_list, batchsize=10) logger.debug(f"operator bond dim: {j_oper.bond_dims}") return j_oper