def test_scheme4(): ph = Phonon.simple_phonon(Quantity(3.33), Quantity(1), 2) m1 = Mol(Quantity(0), [ph]) m2 = Mol(Quantity(0), [ph] * 2) model4 = HolsteinModel([m1, m2], Quantity(17), 4) model3 = HolsteinModel([m1, m2], Quantity(17), 3) mpo4 = Mpo(model4) assert mpo4.is_hermitian() # for debugging f = mpo4.full_operator() mpo3 = Mpo(model3) assert mpo3.is_hermitian() # makeup two states mps4 = Mps() mps4.model = model4 mps4.append(np.array([1, 0]).reshape((1, 2, 1))) mps4.append(np.array([0, 0, 1]).reshape((1, -1, 1))) mps4.append(np.array([0.707, 0.707]).reshape((1, 2, 1))) mps4.append(np.array([1, 0]).reshape((1, 2, 1))) mps4.build_empty_qn() e4 = mps4.expectation(mpo4) mps3 = Mps() mps3.model = model3 mps3.append(np.array([1, 0]).reshape((1, 2, 1))) mps3.append(np.array([1, 0]).reshape((1, 2, 1))) mps3.append(np.array([0, 1]).reshape((1, 2, 1))) mps3.append(np.array([0.707, 0.707]).reshape((1, 2, 1))) mps3.append(np.array([1, 0]).reshape((1, 2, 1))) e3 = mps3.expectation(mpo3) assert pytest.approx(e4) == e3
def test_offset(scheme): ph = Phonon.simple_phonon(Quantity(3.33), Quantity(1), 2) m = Mol(Quantity(0), [ph] * 2) mlist = HolsteinModel( [m] * 2, Quantity(17), ) mpo1 = Mpo(mlist) assert mpo1.is_hermitian() f1 = mpo1.full_operator() evals1, _ = np.linalg.eigh(f1) offset = Quantity(0.123) mpo2 = Mpo(mlist, offset=offset) f2 = mpo2.full_operator() evals2, _ = np.linalg.eigh(f2) assert np.allclose(evals1 - offset.as_au(), evals2)
def custom_model( custom_j_matrix=None, n_phys_dim=None, dis=None, nmols=3, ) -> HolsteinModel: if custom_j_matrix is None: custom_j_matrix = _j_matrix if n_phys_dim is None: n_phys_dim = ph_phys_dim if dis is None: dis = displacement_quantities displacement = [[Quantity(0), dis[0]], [Quantity(0), dis[1]]] ph_list = [Phonon(*args) for args in zip(omega, displacement, n_phys_dim)] return HolsteinModel( [Mol(elocalex, ph_list, dipole_abs)] * nmols, custom_j_matrix, )
def construct_model(nmols, dmrg_nphs, hartree_nphs) -> HolsteinModel: assert dmrg_nphs + hartree_nphs == 10 elocalex = Quantity(2.13 / constant.au2ev) dipole_abs = 1.0 # cm^-1 omega_value = (np.array([ 206.0, 211.0, 540.0, 552.0, 751.0, 1325.0, 1371.0, 1469.0, 1570.0, 1628.0 ]) * constant.cm2au) S_value = np.array( [0.197, 0.215, 0.019, 0.037, 0.033, 0.010, 0.208, 0.042, 0.083, 0.039]) # sort from large to small gw = np.sqrt(S_value) * omega_value idx = np.argsort(gw)[::-1] omega_value = omega_value[idx] S_value = S_value[idx] omega = [[Quantity(x), Quantity(x)] for x in omega_value] D_value = np.sqrt(S_value) / np.sqrt(omega_value / 2.0) displacement = [[Quantity(0), Quantity(x)] for x in D_value] ph_phys_dim = [5] * 10 # print(dmrg_nphs, hartree_nphs) is_hartree = [False] * dmrg_nphs + [True] * hartree_nphs ph_list = [ Phonon(*args[:3], hartree=args[3]) for args in zip(omega, displacement, ph_phys_dim, is_hartree) ] model = HolsteinModel( [Mol(elocalex, ph_list, dipole_abs)] * nmols, Quantity(500, "cm-1"), ) return model
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)
f"lambda:{lambda_value*constant.au2ev}ev,{lambda_value*constant.au2cm}cm^-1" ) logger.info(f"J:{j_value*constant.au2ev}ev, {j_value*constant.au2cm}cm^-1") j_matrix = np.diag(np.ones(nmols - 1) * j_value, k=-1) j_matrix += j_matrix.T ph_phys_dim = 5 omega = [Quantity(omega_value), Quantity(omega_value)] D = [Quantity(0.), Quantity(D_value)] ph = Phonon(omega, D, ph_phys_dim) model = HolsteinModel( [Mol(Quantity(elocalex), [ph], dipole_abs)] * nmols, j_matrix, ) # periodic nearest-neighbour interaction mpo = Mpo(model) periodic = Mpo.intersite(model, { 0: r"a^\dagger", nmols - 1: "a" }, {}, Quantity(j_value)) mpo = mpo.add(periodic).add(periodic.conj_trans()) @pytest.mark.parametrize("periodic", (True, False)) def test_thermal_equilibrium(periodic): if periodic:
# -*- coding: utf-8 -*- import numpy as np from renormalizer.model import Phonon, Mol, HolsteinModel from renormalizer.utils import Quantity from renormalizer.transport import EDGE_THRESHOLD mol_num = 13 ph_list = [ Phonon.simple_phonon(Quantity(omega, "cm^{-1}"), Quantity(displacement, "a.u."), 4) for omega, displacement in [[1e-10, 1e-10]] ] j_constant = Quantity(0.8, "eV") band_limit_model = HolsteinModel([Mol(Quantity(0), ph_list)] * mol_num, j_constant, 3) # the temperature should be compatible with the low vibration frequency in TestBandLimitFiniteT # otherwise underflow happens in exact propagator low_t = Quantity(1e-7, "K") def get_analytical_r_square(time_series: np.ndarray): return 2 * (j_constant.as_au()) ** 2 * time_series ** 2 def assert_band_limit(ct, rtol): analytical_r_square = get_analytical_r_square(ct.evolve_times_array) # has evolved to the edge but not too large assert EDGE_THRESHOLD < ct.latest_mps.e_occupations[0] < 0.1 # value OK assert np.allclose(analytical_r_square, ct.r_square_array, rtol=rtol)
# -*- coding: utf-8 -*- import numpy as np from renormalizer.model import Phonon, Mol, HolsteinModel from renormalizer.utils import Quantity from renormalizer.utils.qutip_utils import get_clist, get_blist, get_holstein_hamiltonian, get_gs OMEGA = 1 DISPLACEMENT = 1 N_LEVELS = 2 N_SITES = 3 J = 1 ph = Phonon.simple_phonon(Quantity(OMEGA), Quantity(DISPLACEMENT), N_LEVELS) mol = Mol(Quantity(0), [ph]) model = HolsteinModel([mol] * N_SITES, Quantity(J), 3) qutip_clist = get_clist(N_SITES, N_LEVELS) qutip_blist = get_blist(N_SITES, N_LEVELS) G = np.sqrt(DISPLACEMENT**2 * OMEGA / 2) qutip_h = get_holstein_hamiltonian(N_SITES, J, OMEGA, G, qutip_clist, qutip_blist) qutip_gs = get_gs(N_SITES, N_LEVELS)
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 model = HolsteinModel( list(np.array(mlist)[mol_arangement]), j_matrix_au[mol_arangement][:, mol_arangement], ) evolve_dt = 160 evolve_config = EvolveConfig(EvolveMethod.tdvp_ps, guess_dt=evolve_dt) compress_config = CompressConfig(CompressCriteria.fixed, max_bonddim=32) ct = ChargeDiffusionDynamics(model, evolve_config=evolve_config, compress_config=compress_config, init_electron=InitElectron.fc) ct.dump_dir = "./" ct.job_name = 'fmo' ct.stop_at_edge = False ct.evolve(evolve_dt=evolve_dt, evolve_time=40000)
omega_quantities = [Quantity(106.51, "cm^{-1}"), Quantity(1555.55, "cm^{-1}")] omega = [ [omega_quantities[0], omega_quantities[0]], [omega_quantities[1], omega_quantities[1]], ] displacement_quantities = [Quantity(30.1370, "a.u."), Quantity(8.7729, "a.u.")] displacement = [ [Quantity(0), displacement_quantities[0]], [Quantity(0), displacement_quantities[1]], ] ph_phys_dim = [4, 4] ph_list = [Phonon(*args) for args in zip(omega, displacement, ph_phys_dim)] holstein_model = HolsteinModel( [Mol(elocalex, ph_list, dipole_abs)] * nmols, _j_matrix, ) holstein_model4 = holstein_model.switch_scheme(4) offset = Quantity(2.28614053, "ev") + Quantity(holstein_model.gs_zpe) def custom_model( custom_j_matrix=None, n_phys_dim=None, dis=None, nmols=3, ) -> HolsteinModel: if custom_j_matrix is None: custom_j_matrix = _j_matrix if n_phys_dim is None: