Beispiel #1
0
 def __init__(self,
              mol_list,
              spectratype,
              temperature,
              freq_reg,
              m_max,
              eta,
              icompress_config=None,
              ievolve_config=None,
              insteps=None,
              method='1site',
              procedure_cv=None,
              dump_dir: str = None,
              job_name=None,
              cores=1):
     super().__init__(mol_list, spectratype, freq_reg, m_max, eta, method,
                      procedure_cv, cores)
     self.temperature = temperature
     self.evolve_config = ievolve_config
     self.compress_config = icompress_config
     if self.evolve_config is None:
         self.evolve_config = \
             EvolveConfig()
     if self.compress_config is None:
         self.compress_config = \
             CompressConfig(CompressCriteria.fixed,
                            max_bonddim=m_max)
         self.compress_config.set_bonddim(len(mol_list.pbond_list))
     self.insteps = insteps
     self.job_name = job_name
     self.dump_dir = dump_dir
Beispiel #2
0
    def __init__(
        self,
        model,
        spectratype,
        m_max,
        eta,
        temperature,
        h_mpo=None,
        method='1site',
        procedure_cv=None,
        rtol=1e-5,
        b_mps=None,
        cv_mps=None,
        icompress_config=None,
        ievolve_config=None,
        insteps=None,
        dump_dir: str = None,
        job_name=None,
    ):

        self.temperature = temperature
        self.evolve_config = ievolve_config
        self.compress_config = icompress_config
        if self.evolve_config is None:
            self.evolve_config = \
                EvolveConfig()
        if self.compress_config is None:
            self.compress_config = \
                CompressConfig(CompressCriteria.fixed,
                               max_bonddim=m_max)
            self.compress_config.set_bonddim(len(model.pbond_list))
        self.insteps = insteps
        self.job_name = job_name
        self.dump_dir = dump_dir

        super().__init__(
            model,
            spectratype,
            m_max,
            eta,
            h_mpo=h_mpo,
            method=method,
            procedure_cv=procedure_cv,
            rtol=rtol,
            b_mps=b_mps,
            cv_mps=cv_mps,
        )

        self.cv_mpo = self.cv_mps
        self.b_mpo = self.b_mps

        self.a_oper = None
 def __init__(
     self,
     mol_list: MolList,
     temperature=Quantity(0, "K"),
     compress_config=None,
     evolve_config=None,
     stop_at_edge=True,
     init_electron=InitElectron.relaxed,
     rdm=False,
     dissipation=0
 ):
     self.mol_list: MolList = mol_list
     self.temperature = temperature
     self.mpo = None
     self.init_electron = init_electron
     self.dissipation = dissipation
     if compress_config is None:
         self.compress_config: CompressConfig = CompressConfig()
     else:
         self.compress_config: CompressConfig = compress_config
     super(ChargeTransport, self).__init__(evolve_config)
     assert self.mpo is not None
     self.energies = [self.tdmps_list[0].expectation(self.mpo)]
     self.reduced_density_matrices = []
     if rdm:
         self.reduced_density_matrices.append(
             self.tdmps_list[0].calc_reduced_density_matrix()
         )
     self.elocalex_arrays = []
     self.j_arrays = []
     self.custom_dump_info = OrderedDict()
     self.stop_at_edge = stop_at_edge
Beispiel #4
0
    def __init__(self):
        # XXX: when modify theses codes, keep in mind to update `metacopy` method
        # set to a list of None upon metacopy
        self._mp: List[Union[Matrix, None]] = []
        self.dtype = backend.real_dtype

        # in mpo.quasi_boson, mol_list is not set, then _ephtable and _pbond_list should be used
        self.mol_list: MolList = None
        self._ephtable: EphTable = None
        self._pbond_list: List[int] = None

        # mpo also need to be compressed sometimes
        self.compress_config: CompressConfig = CompressConfig()

        # QN related
        self.use_dummy_qn: bool = False
        # self.use_dummy_qn = True
        self.qn: List[List[int]] = []
        self.qnidx: int = None
        self._qntot: int = None
        # sweeping from left?
        self.left: bool = None

        # compress after add?
        self.compress_add: bool = False
Beispiel #5
0
def test_pyr_4mode(multi_e, translator):

    order, basis, vibronic_model = construct_vibronic_model(multi_e)
    if translator is ModelTranslator.vibronic_model:
        model = vibronic_model
    elif translator is ModelTranslator.general_model:
        model = vibronic_to_general(vibronic_model)
    else:
        assert False
    mol_list2 = MolList2(order, basis, model, model_translator=translator)
    mpo = Mpo(mol_list2)
    logger.info(f"mpo_bond_dims:{mpo.bond_dims}")
    mps = Mps.hartree_product_state(mol_list2, condition={"e_1": 1})
    # for multi-e case the `expand bond dimension` routine is currently not working
    # because creation operator is not defined yet
    mps.use_dummy_qn = True
    mps.build_empty_qn()

    compress_config = CompressConfig(CompressCriteria.fixed, max_bonddim=10)

    evolve_config = EvolveConfig(EvolveMethod.tdvp_ps)
    job = VibronicModelDynamics(mol_list2,
                                mps0=mps,
                                h_mpo=mpo,
                                compress_config=compress_config,
                                evolve_config=evolve_config)
    time_step_fs = 2
    job.evolve(evolve_dt=time_step_fs * fs2au, nsteps=59)

    from renormalizer.vibronic.tests.mctdh_data import mctdh_data
    assert np.allclose(mctdh_data[::round(time_step_fs / 0.5)][:, 1:],
                       job.e_occupations_array,
                       atol=5e-2)
Beispiel #6
0
    def __init__(self,
                 mol_list,
                 temperature: Quantity,
                 insteps: int = None,
                 ievolve_config=None,
                 compress_config=None,
                 evolve_config=None,
                 dump_dir: str = None,
                 job_name: str = None):
        self.mol_list = mol_list
        self.h_mpo = Mpo(mol_list)
        self.j_oper = self._construct_flux_operator()
        self.temperature = temperature

        # imaginary time evolution config
        if ievolve_config is None:
            self.ievolve_config = EvolveConfig()
            if insteps is None:
                self.ievolve_config.adaptive = True
                # start from a small step
                self.ievolve_config.evolve_dt = temperature.to_beta() / 1e5j
                self.ievolve_config.d_energy = 1
        else:
            self.ievolve_config = ievolve_config
        self.insteps = insteps

        if compress_config is None:
            logger.debug("using default compress config")
            self.compress_config = CompressConfig()
        else:
            self.compress_config = compress_config

        self.impdm = None
        super().__init__(evolve_config, dump_dir, job_name)
Beispiel #7
0
def test_pyr_4mode(multi_e, dvr):

    basis, ham_terms = construct_vibronic_model(multi_e, dvr)
    model = Model(basis, ham_terms)
    mpo = Mpo(model)
    logger.info(f"mpo_bond_dims:{mpo.bond_dims}")
    # same form whether multi_e is True or False
    init_condition = {"s2": 1}
    if dvr:
        for dof in model.v_dofs:
            idx = model.order[dof]
            init_condition[dof] = basis[idx].dvr_v[0]
    mps = Mps.hartree_product_state(model, condition=init_condition)

    compress_config = CompressConfig(CompressCriteria.fixed, max_bonddim=10)

    evolve_config = EvolveConfig(EvolveMethod.tdvp_ps)
    job = VibronicModelDynamics(model,
                                mps0=mps,
                                h_mpo=mpo,
                                compress_config=compress_config,
                                evolve_config=evolve_config,
                                expand=True)
    time_step_fs = 2
    job.evolve(evolve_dt=time_step_fs * fs2au, nsteps=60)

    from renormalizer.vibronic.tests.mctdh_data import mctdh_data
    assert np.allclose(mctdh_data[::round(time_step_fs / 0.5)][:61, 1:],
                       job.e_occupations_array,
                       atol=2e-2)
Beispiel #8
0
    def __init__(self, model: Model, temperature: Quantity, distance_matrix: np.ndarray = None,
                 insteps: int=1, ievolve_config=None, compress_config=None,
                 evolve_config=None, dump_dir: str=None, job_name: str=None, properties: Property = None):
        self.model = model
        self.distance_matrix = distance_matrix
        self.h_mpo = Mpo(model)
        logger.info(f"Bond dim of h_mpo: {self.h_mpo.bond_dims}")
        self._construct_current_operator()
        if temperature == 0:
            raise ValueError("Can't set temperature to 0.")
        self.temperature = temperature

        # imaginary time evolution config
        if ievolve_config is None:
            self.ievolve_config = EvolveConfig()
            if insteps is None:
                self.ievolve_config.adaptive = True
                # start from a small step
                self.ievolve_config.guess_dt = temperature.to_beta() / 1e5j
                insteps = 1
        else:
            self.ievolve_config = ievolve_config
        self.insteps = insteps

        if compress_config is None:
            logger.debug("using default compress config")
            self.compress_config = CompressConfig()
        else:
            self.compress_config = compress_config

        self.properties = properties
        self._auto_corr = []
        self._auto_corr_deomposition = []
        super().__init__(evolve_config=evolve_config, dump_dir=dump_dir,
                job_name=job_name)
Beispiel #9
0
 def __init__(
     self,
     mol_list,
     spectratype,
     temperature,
     insteps,
     offset,
     evolve_config=None,
     icompress_config=None,
     ievolve_config=None,
     gs_shift=0,
     dump_dir: str = None,
     job_name=None,
 ):
     self.temperature = temperature
     self.insteps = insteps
     self.gs_shift = gs_shift
     self.icompress_config = icompress_config
     self.ievolve_config = ievolve_config
     if self.icompress_config is None:
         self.icompress_config = CompressConfig()
     if self.ievolve_config is None:
         self.ievolve_config = EvolveConfig()
     self.dump_dir = dump_dir
     self.job_name = job_name
     super(SpectraFiniteT, self).__init__(mol_list,
                                          spectratype,
                                          temperature,
                                          evolve_config=evolve_config,
                                          offset=offset,
                                          dump_dir=dump_dir,
                                          job_name=job_name)
def test_FT_dynamics_hybrid_TDDMRG_TDH(n_dmrg_phs, scheme):

    mol_list = parameter_PBI.construct_mol(4, n_dmrg_phs, 10 - n_dmrg_phs).switch_scheme(scheme)
    mpdm = MpDm.max_entangled_gs(mol_list)
    tentative_mpo = Mpo(mol_list)
    temperature = Quantity(2000, "K")
    tp = ThermalProp(mpdm, tentative_mpo, exact=True, space="GS")
    tp.evolve(None, 1, temperature.to_beta() / 2j)
    mpdm = (
        Mpo.onsite(mol_list, r"a^\dagger", mol_idx_set={0}).apply(tp.latest_mps).normalize(1.0)
    )
    mpdm.compress_config = CompressConfig(threshold=5e-4)
    offset = mpdm.expectation(tentative_mpo)
    mpo = Mpo(mol_list, offset=Quantity(offset, "a.u."))

    # do the evolution
    # nsteps = 90  # too many steps, may take hours to finish
    nsteps = 40
    dt = 10.0

    occ = [mpdm.e_occupations]
    for i in range(nsteps):
        mpdm = mpdm.evolve(mpo, dt)
        occ.append(mpdm.e_occupations)
    # make it compatible with std data
    occ = np.array(occ[:nsteps]).transpose()

    with open(os.path.join(cur_dir, "FT_occ" + str(n_dmrg_phs) + ".npy"), "rb") as f:
        std = np.load(f)
    assert np.allclose(occ[:, :nsteps], std[:, :nsteps], atol=1e-3, rtol=1e-3)
Beispiel #11
0
def test_autocorr(scheme, mollist2):
    ph = Phonon.simple_phonon(Quantity(1), Quantity(1), 2)
    mol = Mol(Quantity(0), [ph])
    mol_list1 = MolList([mol] * 5, Quantity(1), scheme)
    if mollist2:
        mol_list = MolList2.MolList_to_MolList2(mol_list1)
    else:
        mol_list = mol_list1
    temperature = Quantity(50000, 'K')
    compress_config = CompressConfig(CompressCriteria.fixed, max_bonddim=24)
    evolve_config = EvolveConfig(EvolveMethod.tdvp_ps,
                                 adaptive=True,
                                 guess_dt=0.5,
                                 adaptive_rtol=1e-3)
    ievolve_config = EvolveConfig(EvolveMethod.tdvp_ps,
                                  adaptive=True,
                                  guess_dt=-0.1j)
    ac = TransportAutoCorr(mol_list,
                           temperature,
                           compress_config=compress_config,
                           ievolve_config=ievolve_config,
                           evolve_config=evolve_config)
    ac.evolve(nsteps=5, evolve_time=5)
    corr_real = ac.auto_corr.real
    exact_real = get_exact_autocorr(mol_list1, temperature,
                                    ac.evolve_times_array).real
    atol = 1e-2
    # direct comparison may fail because of different sign
    assert np.allclose(corr_real, exact_real, atol=atol) or np.allclose(
        corr_real, -exact_real, atol=atol)
Beispiel #12
0
def test_dynamics(dissipation, dt, nsteps):
    tentative_mpo = Mpo(band_limit_mol_list)
    gs_mp = MpDm.max_entangled_gs(band_limit_mol_list)
    # subtract the energy otherwise might cause numeric error because of large offset * dbeta
    energy = Quantity(gs_mp.expectation(tentative_mpo))
    mpo = Mpo(band_limit_mol_list, offset=energy)
    tp = ThermalProp(gs_mp, mpo, exact=True, space="GS")
    tp.evolve(None, 50, low_t.to_beta() / 2j)
    gs_mp = tp.latest_mps
    center_mol_idx = band_limit_mol_list.mol_num // 2
    creation_operator = Mpo.onsite(
        band_limit_mol_list, r"a^\dagger", mol_idx_set={center_mol_idx}
    )
    mpdm = creation_operator.apply(gs_mp)
    mpdm_full = MpDmFull.from_mpdm(mpdm)
    # As more compression is involved higher threshold is necessary
    mpdm_full.compress_config = CompressConfig(threshold=1e-4)
    liouville = SuperLiouville(mpo, dissipation)
    r_square_list = [calc_r_square(mpdm_full.e_occupations)]
    time_series = [0]
    for i in range(nsteps - 1):
        logger.info(mpdm_full)
        mpdm_full = mpdm_full.evolve(liouville, dt)
        r_square_list.append(calc_r_square(mpdm_full.e_occupations))
        time_series.append(time_series[-1] + dt)
    time_series = np.array(time_series)
    if dissipation == 0:
        assert np.allclose(get_analytical_r_square(time_series), r_square_list, rtol=1e-2, atol=1e-3)
    else:
        # not much we can do, just basic sanity check
        assert (np.array(r_square_list)[1:] < get_analytical_r_square(time_series)[1:]).all()
Beispiel #13
0
def test_dump(method, dt):
    mps = init_mps.copy()
    mps.evolve_config = EvolveConfig(method)
    # dump all matrices
    mps.compress_config = CompressConfig(CompressCriteria.fixed, dump_matrix_size=1)
    evolved_mps = check_result(mps, mpo, dt, 5)
    # check all matrices are actually dumped
    for mt in evolved_mps._mp:
        assert isinstance(mt, str)
Beispiel #14
0
def test_gaussian_bond_dim():
    compress_config = CompressConfig(
        criteria=CompressCriteria.fixed,
        bonddim_distri=BondDimDistri.center_gauss,
        max_bonddim=10,
    )
    evolve_config = EvolveConfig(guess_dt=0.1, adaptive=True)
    ct = ChargeTransport(
        band_limit_mol_list,
        compress_config=compress_config,
        evolve_config=evolve_config,
    )
    ct.stop_at_edge = True
    ct.evolve(evolve_dt=2.)
    assert_band_limit(ct, 1e-2)
Beispiel #15
0
def test_ft_emi(model):
    with open(os.path.join(cur_dir, "emi_ft.npy"), "rb") as fin:
        standard_value = np.load(fin)
    # the standard value is plotted over np.arange(-0.11, -0.05, 5.e-4)
    freq_reg = np.arange(-0.11, -0.05, 5.e-4).tolist()
    test_freq = [freq_reg[52]]
    T = Quantity(298, unit='K')
    standard_value = [standard_value[52]]
    evolve_config = EvolveConfig(method=EvolveMethod.tdvp_ps)
    compress_config = CompressConfig(criteria=CompressCriteria.fixed, max_bonddim=10)
    spectra = SpectraFtCV(model, "emi", 10,
                          5.e-3, T, ievolve_config=evolve_config,
                          icompress_config=compress_config,
                          insteps=10, rtol=1e-3)
    result = batch_run(test_freq, 1, spectra)
    assert np.allclose(result, standard_value, rtol=1.e-2)
Beispiel #16
0
def compare():
    dt_list = [0.01, 0.02, 0.05, 0.1, 0.2, 0.4]
    method_list = [EvolveMethod.prop_and_compress, EvolveMethod.tdvp_mu_vmf, EvolveMethod.tdvp_mu_cmf, EvolveMethod.tdvp_ps]
    all_values = []
    for method in method_list:
        values = []
        for dt in dt_list:
            mps = init_mps.copy()
            mps.compress_config = CompressConfig(CompressCriteria.fixed)
            mps.evolve_config  = EvolveConfig(method)
            mps.evolve_config._adjust_bond_dim_counter = True
            mps.evolve_config.force_ovlp = True
            values.append(check_result(mps, mpo, dt, 2))
        print(values)
        all_values.append(values)
    print(mps.bond_dims)
    print(all_values)
def test_autocorr(insteps, atol):
    ph = Phonon.simple_phonon(Quantity(1), Quantity(1), 2)
    mol = Mol(Quantity(0), [ph])
    mol_list = MolList([mol] * 5, Quantity(1), 3)
    temperature = Quantity(50000, 'K')
    compress_config = CompressConfig(threshold=1e-3)
    ac = TransportAutoCorr(mol_list,
                           temperature,
                           insteps,
                           compress_config=compress_config)
    ac.evolve(0.2, 50)
    corr_real = ac.auto_corr.real
    exact_real = get_exact_autocorr(mol_list, temperature,
                                    ac.evolve_times_array).real
    # direct comparison may fail because of different sign
    assert np.allclose(corr_real, exact_real, atol=atol) or np.allclose(
        corr_real, -exact_real, atol=atol)
Beispiel #18
0
def test_sbm_zt(alpha):
    raw_delta = Quantity(1)
    raw_omega_c = Quantity(20)
    n_phonons = 3

    mol_list = param2mollist(alpha, raw_delta, raw_omega_c, 5, n_phonons)

    compress_config = CompressConfig(threshold=1e-4)
    evolve_config = EvolveConfig(adaptive=True, evolve_dt=0.1)
    sbm = SpinBosonModel(mol_list,
                         Quantity(0),
                         compress_config=compress_config,
                         evolve_config=evolve_config)
    sbm.evolve(evolve_time=20)
    spin1 = sbm.sigma_z
    spin2 = get_exact_zt(mol_list[0], sbm.evolve_times)
    assert np.allclose(spin1, spin2, atol=1e-3)
Beispiel #19
0
    def __init__(
        self,
        mol_list,
        temperature: Quantity,
        j_oper: Mpo = None,
        insteps: int = 1,
        ievolve_config=None,
        compress_config=None,
        evolve_config=None,
        dump_dir: str = None,
        job_name: str = None,
        properties: Property = None,
    ):
        self.mol_list = mol_list
        self.h_mpo = Mpo(mol_list)
        logger.info(f"Bond dim of h_mpo: {self.h_mpo.bond_dims}")
        if j_oper is None:
            self.j_oper = self._construct_flux_operator()
        else:
            self.j_oper = j_oper
        self.temperature = temperature

        # imaginary time evolution config
        if ievolve_config is None:
            self.ievolve_config = EvolveConfig()
            if insteps is None:
                self.ievolve_config.adaptive = True
                # start from a small step
                self.ievolve_config.guess_dt = temperature.to_beta() / 1e5j
                insteps = 1
        else:
            self.ievolve_config = ievolve_config
        self.insteps = insteps

        if compress_config is None:
            logger.debug("using default compress config")
            self.compress_config = CompressConfig()
        else:
            self.compress_config = compress_config

        self.properties = properties
        self._auto_corr = []
        super().__init__(evolve_config=evolve_config,
                         dump_dir=dump_dir,
                         job_name=job_name)
Beispiel #20
0
def test_zt():
    mol = get_mol()
    mol_list = MolList([mol], Quantity(0))

    mps = Mps.gs(mol_list, False)
    mps.compress_config = CompressConfig(threshold=1e-6)
    mps.evolve_config = EvolveConfig(adaptive=True, guess_dt=0.1)
    mps.use_dummy_qn = True
    mpo = Mpo(mol_list)
    time_series = [0]
    spin = [1]
    for i in range(30):
        dt = mps.evolve_config.guess_dt
        mps = mps.evolve(mpo, evolve_dt=dt)
        time_series.append(time_series[-1] + dt)
        spin.append(1 - 2 * mps.e_occupations[0])
    exact = get_exact_zt(mol, time_series)
    assert np.allclose(exact, spin, atol=1e-3)
Beispiel #21
0
def test_zt():
    model = get_model()

    mps = Mps.ground_state(model, False)
    mps.compress_config = CompressConfig(threshold=1e-6)
    mps.evolve_config = EvolveConfig(adaptive=True, guess_dt=0.1)
    mps.use_dummy_qn = True
    mpo = Mpo(model)
    time_series = [0]
    spin = [1]
    sigma_z_oper = Mpo(model, Op("sigma_z", "spin"))
    for i in range(30):
        dt = mps.evolve_config.guess_dt
        mps = mps.evolve(mpo, evolve_dt=dt)
        time_series.append(time_series[-1] + dt)
        spin.append(mps.expectation(sigma_z_oper))
    qutip_res = get_qutip_zt(model, time_series)
    assert np.allclose(qutip_res, spin, atol=1e-3)
Beispiel #22
0
    def __init__(
        self,
        mol_list: MolList,
        temperature: Quantity = Quantity(0, "K"),
        compress_config: CompressConfig = None,
        evolve_config: EvolveConfig = None,
        stop_at_edge: bool = True,
        init_electron=InitElectron.relaxed,
        rdm: bool = False,
        dissipation: float = 0,
        dump_dir: str = None,
        job_name: str = None,
    ):
        self.mol_list: MolList = mol_list
        self.temperature = temperature
        self.mpo = None
        self.init_electron = init_electron
        self.dissipation = dissipation
        if compress_config is None:
            self.compress_config: CompressConfig = CompressConfig()
        else:
            self.compress_config: CompressConfig = compress_config
        self.energies = []
        self.r_square_array = []
        self.e_occupations_array = []
        self.ph_occupations_array = []
        self.reduced_density_matrices = [] if rdm else None
        self.k_occupations_array = []
        # von Neumann entropy between e and ph
        self.eph_vn_entropy_array = []
        # entropy at each bond
        self.bond_vn_entropy_array = []
        self.coherent_length_array = []
        super(ChargeTransport, self).__init__(evolve_config=evolve_config,
                dump_dir=dump_dir, job_name=job_name)
        assert self.mpo is not None

        self.elocalex_arrays = []
        self.j_arrays = []
        self.custom_dump_info = OrderedDict()
        self.stop_at_edge = stop_at_edge
Beispiel #23
0
def test_2site():
    ph = Phonon.simple_phonon(Quantity(1), Quantity(1), 2)
    m = Mol(Quantity(0), [ph])
    mol_list = MolList([m] * 2, Quantity(1), scheme=3)
    gs_mp = Mpo.onsite(mol_list, opera=r"a^\dagger", mol_idx_set={0}).apply(Mps.gs(mol_list, max_entangled=False))
    mpdm = MpDm.from_mps(gs_mp)
    mpdm_full = MpDmFull.from_mpdm(mpdm)
    mpdm_full.compress_config = CompressConfig(threshold=1e-4)
    liouville = SuperLiouville(Mpo(mol_list), dissipation=1)
    ph_occupations_array = []
    energies = []
    for i in range(51):
        logger.info(mpdm_full)
        logger.info(mpdm_full.ph_occupations)
        ph_occupations_array.append(mpdm_full.ph_occupations)
        logger.info(mpdm_full.expectation(liouville))
        energies.append(mpdm_full.expectation(liouville))
        mpdm_full = mpdm_full.evolve(liouville, 0.4)
    ph_occupations_array = np.array(ph_occupations_array)
    assert energies[-1] == pytest.approx(-0.340162, rel=1e-2)
    assert np.allclose(ph_occupations_array[-1], [0.0930588, 0.099115], rtol=1e-2)
Beispiel #24
0
    def __init__(self):
        # XXX: when modify theses codes, keep in mind to update `metacopy` method
        # set to a list of None upon metacopy. String is used when the matrix is
        # stored in disks
        self._mp: List[Union[Matrix, None, str]] = []
        self.dtype = backend.real_dtype

        self.model: Model = None

        # mpo also need to be compressed sometimes
        self.compress_config: CompressConfig = CompressConfig()

        # QN related
        self.qn: List[List[int]] = []
        self.qnidx: int = None
        self.qntot: int = None
        # if sweeping to right: True else False
        self.to_right: bool = None

        # compress after add?
        self.compress_add: bool = False
Beispiel #25
0
    def __init__(self,
                 mol_list: MolList,
                 temperature: Quantity,
                 compress_config=None,
                 evolve_config=None,
                 dump_dir=None,
                 job_name=None):
        self.mol_list = mol_list
        self.h_mpo = Mpo(mol_list)
        self.temperature = temperature

        if compress_config is None:
            self.compress_config = CompressConfig()
        else:
            self.compress_config = compress_config

        self.sigma_x = []
        self.sigma_z = []

        super().__init__(evolve_config=evolve_config,
                         dump_dir=dump_dir,
                         job_name=job_name)
Beispiel #26
0
    def __init__(
            self, 
            model: Model,
            compress_config: CompressConfig = None,
            evolve_config: EvolveConfig = None,
            h_mpo = None,
            mps0 = None,
            properties: Property = None,
            init_condition = None, 
            dump_mps: bool = False,
            dump_dir: str = None,
            job_name: str = None,
            expand: bool = False
        ):

        self.model = model
        
        if compress_config is None:
            self.compress_config = CompressConfig()
        else:
            self.compress_config = compress_config
        
        if h_mpo is None:
            self.h_mpo = Mpo(model)
        else:
            self.h_mpo = h_mpo

        self.mps0 = mps0
        self.init_condition = init_condition
        self.properties = properties
        self.expand = expand
        
        self.e_occupations_array = []
        self.autocorr_array = []
        self.energies = []
        self.autocorr_time = []

        super().__init__(evolve_config=evolve_config, dump_mps=dump_mps, dump_dir=dump_dir,
                job_name=job_name)
Beispiel #27
0
def test_ft():
    model = get_model()
    mpo = Mpo(model)
    impdm = MpDm.max_entangled_gs(model)
    impdm.compress_config = CompressConfig(threshold=1e-6)
    temperature = Quantity(3)
    evolve_config = EvolveConfig(adaptive=True, guess_dt=-0.001j)
    tp = ThermalProp(impdm, mpo, evolve_config=evolve_config)
    tp.evolve(nsteps=1, evolve_time=temperature.to_beta() / 2j)
    mpdm = tp.latest_mps
    mpdm = Mpo(model, Op("sigma_x", "spin")).contract(mpdm)
    mpdm.evolve_config = EvolveConfig(adaptive=True, guess_dt=0.1)
    time_series = [0]
    sigma_z_oper = Mpo(model, Op("sigma_z", "spin"))
    spin = [mpdm.expectation(sigma_z_oper)]
    for i in range(29):
        dt = mpdm.evolve_config.guess_dt
        mpdm = mpdm.evolve(mpo, evolve_dt=dt)
        time_series.append(time_series[-1] + dt)
        spin.append(mpdm.expectation(sigma_z_oper))
    qutip_res = get_qutip_ft(model, temperature, time_series)
    assert np.allclose(qutip_res, spin, atol=1e-3)
Beispiel #28
0
def test_holstein_kubo(scheme):
    ph = Phonon.simple_phonon(Quantity(1), Quantity(1), 2)
    mol = Mol(Quantity(0), [ph])
    model = HolsteinModel([mol] * 5, Quantity(1), scheme)
    temperature = Quantity(50000, 'K')
    compress_config = CompressConfig(CompressCriteria.fixed, max_bonddim=24)
    evolve_config = EvolveConfig(EvolveMethod.tdvp_ps,
                                 adaptive=True,
                                 guess_dt=0.5,
                                 adaptive_rtol=1e-3)
    ievolve_config = EvolveConfig(EvolveMethod.tdvp_ps,
                                  adaptive=True,
                                  guess_dt=-0.1j)
    kubo = TransportKubo(model,
                         temperature,
                         compress_config=compress_config,
                         ievolve_config=ievolve_config,
                         evolve_config=evolve_config)
    kubo.evolve(nsteps=5, evolve_time=5)
    qutip_res = get_qutip_holstein_kubo(model, temperature,
                                        kubo.evolve_times_array)
    rtol = 5e-2
    assert np.allclose(kubo.auto_corr, qutip_res, rtol=rtol)
Beispiel #29
0
def test_ft():
    mol = get_mol()
    mol_list = MolList([mol], Quantity(0))
    mpo = Mpo(mol_list)
    impdm = MpDm.max_entangled_gs(mol_list)
    impdm.compress_config = CompressConfig(threshold=1e-6)
    impdm.use_dummy_qn = True
    temperature = Quantity(3)
    evolve_config = EvolveConfig(adaptive=True, guess_dt=-0.001j)
    tp = ThermalProp(impdm, mpo, evolve_config=evolve_config)
    tp.evolve(nsteps=1, evolve_time=temperature.to_beta() / 2j)
    mpdm = tp.latest_mps
    mpdm = Mpo.onsite(mol_list, r"sigma_x").contract(mpdm)
    mpdm.evolve_config = EvolveConfig(adaptive=True, guess_dt=0.1)
    time_series = [0]
    spin = [1 - 2 * mpdm.e_occupations[0]]
    for i in range(30):
        dt = mpdm.evolve_config.guess_dt
        mpdm = mpdm.evolve(mpo, evolve_dt=dt)
        time_series.append(time_series[-1] + dt)
        spin.append(1 - 2 * mpdm.e_occupations[0])
    exact = get_exact_ft(mol, temperature, time_series)
    assert np.allclose(exact, spin, atol=1e-3)
Beispiel #30
0
    lams = hr_factors * omegas_au
    phonons = [
        Phonon.simplest_phonon(Quantity(o), Quantity(l), lam=True)
        for o, l in zip(omegas_au, lams)
    ]

    j_matrix_au = j_matrix_cm * cm2au

    mlist = []
    for j in np.diag(j_matrix_au):
        m = Mol(Quantity(j), phonons)
        mlist.append(m)

    # starts from 1
    mol_arangement = np.array([7, 5, 3, 1, 2, 4, 6]) - 1
    mol_list = MolList(list(np.array(mlist)[mol_arangement]),
                       j_matrix_au[mol_arangement][:, mol_arangement])

    evolve_dt = 40
    evolve_config = EvolveConfig(evolve_dt=evolve_dt)
    compress_config = CompressConfig(CompressCriteria.fixed, max_bonddim=16)
    ct = ChargeTransport(mol_list,
                         evolve_config=evolve_config,
                         compress_config=compress_config)
    ct.dump_dir = "./fmo"
    ct.job_name = 'hybrid'
    ct.stop_at_edge = False
    ct.evolve(evolve_dt=evolve_dt, nsteps=10)
    new_evolve_config = EvolveConfig(EvolveMethod.tdvp_mctdh_new)
    ct.latest_mps.evolve_config = ct.evolve_config = new_evolve_config
    ct.evolve(evolve_dt=evolve_dt, nsteps=100000)