def load_thermal_state(mol_list, path: str): """ Load thermal propagated state from disk. Return None if the file is not found. Args: mol_list (:class:`MolList`): system information path (str): the path to load thermal state from. Should be an `npz` file. Returns: Loaded MpDm """ try: logger.info(f"Try load from {path}") mpdm = MpDm.load(mol_list, path) logger.info(f"Init mpdm loaded: {mpdm}") except FileNotFoundError: logger.info(f"No file found in {path}") mpdm = None return mpdm
def init_mps(self): beta = self.temperature.to_beta() self.h_mpo = Mpo(self.mol_list) if self.spectratype == "abs": dipole_mpo = Mpo.onsite(self.mol_list, r"a^\dagger", dipole=True) i_mpo = MpDm.max_entangled_gs(self.mol_list) tp = ThermalProp(i_mpo, self.h_mpo, exact=True, space='GS') tp.evolve(None, 1, beta / 2j) ket_mpo = tp.latest_mps else: impo = MpDm.max_entangled_ex(self.mol_list) dipole_mpo = Mpo.onsite(self.mol_list, "a", dipole=True) if self.job_name is None: job_name = None else: job_name = self.job_name + "_thermal_prop" impo.compress_config = self.compress_config tp = ThermalProp(impo, self.h_mpo, evolve_config=self.evolve_config, dump_dir=self.dump_dir, job_name=job_name) self._defined_output_path = tp._defined_output_path if tp._defined_output_path: try: logger.info( f"load density matrix from {self._thermal_dump_path}") ket_mpo = MpDm.load(self.mol_list, self._thermal_dump_path) logger.info(f"density matrix loaded: {ket_mpo}") except FileNotFoundError: logger.debug(f"no file found in {self._thermal_dump_path}") tp.evolve(None, self.insteps, beta / 2j) ket_mpo = tp.latest_mps ket_mpo.dump(self._thermal_dump_path) self.a_ket_mpo = dipole_mpo.apply(ket_mpo, canonicalise=True) self.cv_mpo = Mpo.finiteT_cv(self.mol_list, 1, self.m_max, self.spectratype, percent=1.0) self.cv_mps = self.cv_mpo
def init_mps(self): # first try to load if self._defined_output_path: try: logger.info(f"Try load from {self._thermal_dump_path}") mpdm = MpDm.load(self.mol_list, self._thermal_dump_path) logger.info(f"Init mpdm loaded: {mpdm}") mpdm.compress_config = self.compress_config except FileNotFoundError: logger.debug(f"No file found in {self._thermal_dump_path}") mpdm = None else: mpdm = None # then try to calculate if mpdm is None: i_mpdm = MpDm.max_entangled_ex(self.mol_list) i_mpdm.compress_config = self.compress_config if self.job_name is None: job_name = None else: job_name = self.job_name + "_thermal_prop" tp = ThermalProp(i_mpdm, self.h_mpo, evolve_config=self.ievolve_config, dump_dir=self.dump_dir, job_name=job_name) # only propagate half beta tp.evolve(None, self.insteps, self.temperature.to_beta() / 2j) mpdm = tp.latest_mps if self._defined_output_path: mpdm.dump(self._thermal_dump_path) self.impdm = mpdm e = mpdm.expectation(self.h_mpo) self.h_mpo = Mpo(self.mol_list, offset=Quantity(e)) mpdm.evolve_config = self.evolve_config ket_mpdm = self.j_oper.contract(mpdm).canonical_normalize() bra_mpdm = mpdm.copy() return BraKetPair(bra_mpdm, ket_mpdm, self.j_oper)
def init_mps_emi(self): dipole_mpo = Mpo.onsite(self.mol_list, "a", dipole=True) i_mpo = MpDm.max_entangled_ex(self.mol_list) i_mpo.compress_config = self.icompress_config if self.job_name is None: job_name = None else: job_name = self.job_name + "_thermal_prop" # only propagate half beta tp = ThermalProp(i_mpo, self.h_mpo, evolve_config=self.ievolve_config, dump_dir=self.dump_dir, job_name=job_name) if tp._defined_output_path: try: logger.info( f"load density matrix from {self._thermal_dump_path}") ket_mpo = MpDm.load(self.mol_list, self._thermal_dump_path) logger.info(f"density matrix loaded:{ket_mpo}") except FileNotFoundError: logger.debug(f"no file found in {self._thermal_dump_path}") tp.evolve(None, self.insteps, self.temperature.to_beta() / 2j) ket_mpo = tp.latest_mps ket_mpo.dump(self._thermal_dump_path) else: tp.evolve(None, self.insteps, self.temperature.to_beta() / 2j) ket_mpo = tp.latest_mps ket_mpo.evolve_config = self.evolve_config # e^{\-beta H/2} \Psi dipole_mpo_dagger = dipole_mpo.conj_trans() dipole_mpo_dagger.build_empty_qn() a_ket_mpo = ket_mpo.apply(dipole_mpo_dagger, canonicalise=True) a_ket_mpo.canonical_normalize() a_bra_mpo = a_ket_mpo.copy() return BraKetPairEmiFiniteT(a_bra_mpo, a_ket_mpo)