def get_propagator(beta, mpa_type, system_index, h_site, h_bond, rank=1, state_compression_kwargs=None, op_compression_kwargs=None, psi_0_compression_kwargs=None, second_order_trotter=False, seed=102): """ Returns the propagator object for imaginary time evolution ground state generation :param beta: Decay coefficient :param mpa_type: Type of mpa to evolve (allowed are 'mps', 'pmps' and 'mpo') :param system_index: Index of the system site in the chain (place of the system site operator in h_site) :param h_site: local operators of hamiltonian as list or tuple :param h_bond: iterator over bond (coupling) operators of the Hamiltonian :param rank: Rank of the random initial state (default is 1) :param state_compression_kwargs: Arguments for mps compression after each second order trotter step U(tau_i). (see real time evolution factory function for details) :param op_compression_kwargs: Arguments for trotter step operator precompression (see real time evolution factory function for details) :param second_order_trotter: Uses second order trotter steps for the propagation :param seed: Seed for the initial random state :param psi_0_compression_kwargs: Optional compression kwargs for the initial state (see real time evolution factory function for details) """ tau = -beta axis_0 = [] for index, site in enumerate(h_site): assert site.shape[0] == site.shape[1] axis_0.append(site.shape[0]) psi_0 = get_random_mpa(mpa_type, axis_0, seed=seed, rank=rank) return propagator_from_hamiltonian(psi_0, mpa_type, system_index, h_site, h_bond, tau=tau, state_compression_kwargs=state_compression_kwargs, op_compression_kwargs=op_compression_kwargs, psi_0_compression_kwargs=psi_0_compression_kwargs, second_order_trotter=second_order_trotter, t0=0, track_trace=False)
def get_propagator_from_hi(beta, mpa_type, system_index, dims, hi_list, rank=1, state_compression_kwargs=None, op_compression_kwargs=None, second_order_trotter=False, seed=102, psi_0_compression_kwargs=None): """ Returns the propagator object for imaginary time evolution ground state generation :param beta: Decay coefficient :param mpa_type: Type of mpa to evolve (allowed are 'mps', 'pmps' and 'mpo') :param system_index: Index of the system site in the chain (place of the system site operator in the hi_list) :param dims: Physical dimensions in the chain :param hi_list: List/Tuple of all terms in the Hamiltonian H = sum_i hi, where hi is local to one bond :param rank: Rank of the random initial state (default is 1) :param state_compression_kwargs: Arguments for mps compression after each second order trotter step U(tau_i). (see real time evolution factory function for details) :param op_compression_kwargs: Arguments for trotter step operator precompression (see real time evolution factory function for details) :param second_order_trotter: Uses second order trotter steps for the propagation :param seed: Seed for the initial random state :param psi_0_compression_kwargs: Optional compression kwargs for the initial state (see real time evolution factory function for details) """ tau = -beta psi_0 = get_random_mpa(mpa_type, dims, seed=seed, rank=rank) return propagator_from_hi(psi_0, mpa_type, system_index, hi_list, tau=tau, state_compression_kwargs=state_compression_kwargs, op_compression_kwargs=op_compression_kwargs, psi_0_compression_kwargs=psi_0_compression_kwargs, second_order_trotter=second_order_trotter, t0=0, track_trace=False)
def test_regular_chain_random(L, sot, nof_steps, tau): """ Pytest test for time evolution of a pure quantum state in mps form under a Hamiltonian of the form: sum_i^L H_{i} + sum_i^(L-1) H_{i, i+1} where the H_(i) are called site ops and the H_{i, i+1} are called bond ops, both are randomized. The physical dimension of each site (site_dim) is constant d! Tests are performed for different chain lengths and different time discretizations. The initial state is randomized. :param L: Chain L :param nof_steps: Number of time evolution steps :param tau: Timestep in each step of the time evolution :return: """ # Parameters site_dim = 2 site_dims = [site_dim] * L mps_psi_0 = get_random_mpa('mps', site_dims, rank=2, seed=103) psi_0 = mp.MPArray.to_array(mps_psi_0).reshape(site_dim**L) site_op = pauli.Z bond_op = np.kron(pauli.Z, pauli.X) # Setup for exact diagonalization exdiag_propagator = exdiag.ExDiagPropagator(psi_0, site_dims, repeat(site_op, L), repeat(bond_op, L - 1), tau) # Setup for tMPS evolution state_compress_kwargs = {'method': 'svd', 'relerr': 1e-10} op_compression_kwargs = {'method': 'svd', 'relerr': 1e-13} tmps_propagator = from_hamiltonian( mps_psi_0, 'mps', site_op, bond_op, tau=tau, state_compression_kwargs=state_compress_kwargs, op_compression_kwargs=op_compression_kwargs, second_order_trotter=sot) normdist = [] itno = 0 for step in range(nof_steps): exdiag_propagator.evolve() tmps_propagator.fast_evolve() tmps_psi_t_array = mp.MPArray.to_array(tmps_propagator.psi_t).reshape( site_dim**L) normdist.append( np.linalg.norm(tmps_psi_t_array - exdiag_propagator.psi_t)) itno += 1 max_normdist = np.max(np.array(normdist)) if sot: assert np.max(max_normdist) < 1e-6 else: assert np.max(max_normdist) < 1e-8