def reset(self, psi_0=None, state_compression_kwargs=None, psi_0_compression_kwargs=None): """ Resets selected properties of the TMPS object If psi_0 is not None, we set the new initial state to psi_0, otherwise we keep the current state. If psi_0 is to be changed, we reset overlap and trotter error tracking, thus it is advisable to check the info object before the reset in this case. Checks if shape of passed psi_0 is compatible with the shape of the current propagator object :param psi_0: Optional new initial state, need not be normalized. Is normalized before propagation :param state_compression_kwargs: Optional. If not None, chamge the current parameters for state compression. If set None old compression parameters are kept, if empty, default compression is used. :param psi_0_compression_kwargs: Optional compresion kwargs for the initial state (see real time evolution factory function for details) :return: """ if psi_0 is not None: if psi_0_compression_kwargs is not None: compress_mpa(psi_0, to_cform=self.to_cform, **psi_0_compression_kwargs) else: canonicalize_to(psi_0, to_cform=self.to_cform) # Normalize current initial psi_t (=psi_0) self.normalize_state() self.last_overlap = 1 self.cumulative_overlap = 1 self.base_overlap = 1 self.trotter_error = 0 self.start = True self.stepno = 0 super().reset(psi_0=psi_0, state_compression_kwargs=state_compression_kwargs)
def __init__(self, psi_0, propagator, state_compression_kwargs=None, t0=0, psi_0_compression_kwargs=None): """ Constructor for the StarTMPO class. Time evolution for quantum states represented by mpo for a star geometry. Does required setup steps for evolve to work. Uses a pre-constructed MPPropagator object :param psi_0: Initial state as MPArray. More precisely as an MPArray with two physical legs on each site, which have the same dimension (axis 0 = axis 1). Will be normalized before propagation :param propagator: Pre-constructed compatible StarMPPropagator object. (Compatibility means, that the chain shape with which it was constructed matches the shape of psi_0 and that it was constructed without ancilla sites, but with pre-calculated adjoints) :param state_compression_kwargs: Optional compression kwargs for the state (see real time evolution factory function for details) :param t0: Initial time of the propagation :param psi_0_compression_kwargs: Optional compression kwargs for the initial state (see real time evolution factory function for details) """ super().__init__(psi_0, propagator, state_compression_kwargs=state_compression_kwargs, t0=t0) self.mpa_type = 'mpo' self.system_index = propagator.system_index # Check if propagator is valid for the selected state mpa_type assert not self.propagator.ancilla_sites assert self.propagator.build_adj self.axes = (-1, 0) self.to_cform = propagator.to_cform if psi_0_compression_kwargs is None: canonicalize_to(self.psi_t, to_cform=self.to_cform) else: compress_mpa(self.psi_t, to_cform=self.to_cform, **psi_0_compression_kwargs) # trace normalize current initial psi_t (=psi_0) self.normalize_state() # If we deal with an mpo state we want to track the L2-norm of the state. # It should be approximately conserved by the trotterized evolution assuming no significant compression losses. self.init_state_norm = mp.norm(psi_0) self.last_state_norm = self.init_state_norm self.curr_state_norm = self.init_state_norm # Contains accumulated trotter errors for each timestep self.trotter_error = 0
def __init__(self, psi_0, propagator, state_compression_kwargs=None, t0=0, psi_0_compression_kwargs=None): """ Constructor for the StarTMPS class. Time evolution for quantum states represented by mps. Does required setup steps for evolve to work. Uses a pre-constructed MPPropagator object :param psi_0: Initial state as MPArray. More precisely as an MPArray with one physical leg on each site. Will be normalized before propagation :param propagator: Compatible Pre-constructed StarMPPropagator object. (Compatibility means, that the chain shape with which it was constructed matches the shape of psi_0) :param state_compression_kwargs: Optional compression kwargs for the state (see real time evolution factory function for details) :param t0: Initial time of the propagation :param psi_0_compression_kwargs: Optional compresion kwargs for the initial state (see real time evolution factory function for details) """ super().__init__(psi_0, propagator, state_compression_kwargs=state_compression_kwargs, t0=t0) self.mpa_type = 'mps' self.system_index = propagator.system_index # Check if propagator is valid for the selected state mpa_type assert not self.propagator.ancilla_sites assert not self.propagator.build_adj self.axes = (-1, 0) self.to_cform = propagator.to_cform if psi_0_compression_kwargs is None: canonicalize_to(self.psi_t, to_cform=self.to_cform) else: compress_mpa(self.psi_t, to_cform=self.to_cform, **psi_0_compression_kwargs) # Normalize current initial psi_t (=psi_0) self.normalize_state() # Contains overlap due to compression for the last timestep and for all timesteps combined respectively self.last_overlap = 1 self.cumulative_overlap = 1 self.base_overlap = 1 # Contains accumulated trotter errors for each timestep self.trotter_error = 0