コード例 #1
0
def test_FT_dynamics_TDH():

    log.init_log(logging.WARNING)

    mol_list = parameter_PBI.construct_mol(4, dmrg_nphs=0, hartree_nphs=10)

    operators = []
    for imol in range(len(mol_list)):
        dipoleO = tdh.construct_onsiteO(mol_list,
                                        r"a^\dagger a",
                                        dipole=False,
                                        mol_idx_set={imol})
        operators.append(dipoleO)

    T = Quantity(2000, "K")
    insteps = 1
    dynamics = tdh.Dynamics(mol_list,
                            property_ops=operators,
                            temperature=T,
                            insteps=insteps)
    nsteps = 300 - 1
    dt = 10.0
    dynamics.evolve(dt, nsteps)

    with open(os.path.join(cur_dir, "FT_occ10.npy"), "rb") as f:
        std = np.load(f)
    assert np.allclose(dynamics.properties, std, atol=1e-2)
コード例 #2
0
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)
コード例 #3
0
def test_ZT_dynamics_TDH():

    log.init_log(logging.INFO)
    sites = 4
    mol_list = parameter_PBI.construct_mol(sites, dmrg_nphs=0, hartree_nphs=10)

    nsteps = 100 - 1
    dt = 10.0
    dynamics = tdh.Dynamics(mol_list, init_idx=0)
    dynamics.info_interval = 50
    dynamics.evolve(dt, nsteps)
    with open(os.path.join(cur_dir, "ZT_occ10.npy"), "rb") as f:
        std = np.load(f)
    assert np.allclose(dynamics.e_occupations_array, std.T, atol=1e-2)
コード例 #4
0
def test_FT_dynamics_TDH():

    log.init_log(logging.WARNING)

    mol_list = parameter_PBI.construct_mol(4, dmrg_nphs=0, hartree_nphs=10)

    T = Quantity(2000, "K")
    insteps = 1
    dynamics = tdh.Dynamics(mol_list, temperature=T, insteps=insteps)
    nsteps = 300 - 1
    dt = 10.0
    dynamics.evolve(dt, nsteps)

    with open(os.path.join(cur_dir, "FT_occ10.npy"), "rb") as f:
        std = np.load(f)
    assert np.allclose(dynamics.e_occupations_array, std.T, atol=1e-2)
コード例 #5
0
def test_ZT_dynamics_TDH():

    log.init_log(logging.INFO)
    sites = 4
    mol_list = parameter_PBI.construct_mol(sites, dmrg_nphs=0, hartree_nphs=10)

    operators = []
    nsteps = 100 - 1
    dt = 10.0
    dynamics = tdh.Dynamics(mol_list, property_ops=operators, init_idx=0)
    dynamics.info_interval = 50
    dynamics.evolve(dt, nsteps)
    electrons = np.array([wfn[0] for wfn in dynamics.tdmps_list])
    electrons = (electrons.conj() * electrons).real
    # debug code to calculate r
    # r_list = []
    # for electron in electrons:
    #     r = np.average(np.arange(sites)**2, weights=electron) - np.average(np.arange(sites), weights=electron) ** 2
    #     r_list.append(r)
    with open(os.path.join(cur_dir, "ZT_occ10.npy"), "rb") as f:
        std = np.load(f)
    assert np.allclose(electrons.T, std, atol=1e-2)
コード例 #6
0
def test_zt(n_dmrg_phs, scheme):

    mol_list = parameter_PBI.construct_mol(4, n_dmrg_phs, 10 - n_dmrg_phs).switch_scheme(scheme)
    mps = Mps.gs(mol_list, False)
    # create electron
    mps = Mpo.onsite(mol_list, r"a^\dagger", mol_idx_set={0}).apply(mps).normalize(1.0)
    tentative_mpo = Mpo(mol_list)
    offset = mps.expectation(tentative_mpo)
    mpo = Mpo(mol_list, offset=Quantity(offset, "a.u."))
    # do the evolution
    nsteps = 30
    dt = 30.0

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

    with open(os.path.join(cur_dir, "ZT_occ" + str(n_dmrg_phs) + ".npy"), "rb") as f:
        std = np.load(f)
    assert np.allclose(occ, std, rtol=1e-2, atol=1e-4)
コード例 #7
0
ファイル: test_mpo.py プロジェクト: liwt31/Renormalizer
    gs = Mps.gs(mol_list, max_entangled=False)
    assert not gs.ph_occupations.any()
    b2 = Mpo.ph_onsite(mol_list, r"b^\dagger", 0, 0)
    p1 = b2.apply(gs).normalize()
    assert np.allclose(p1.ph_occupations, [1, 0, 0, 0, 0, 0])
    p2 = b2.apply(p1).normalize()
    assert np.allclose(p2.ph_occupations, [2, 0, 0, 0, 0, 0])
    b = b2.conj_trans()
    assert b.distance(Mpo.ph_onsite(mol_list, r"b", 0, 0)) == 0
    assert b.apply(p2).normalize().distance(p1) == pytest.approx(0, abs=1e-5)


from renormalizer.tests.parameter_PBI import construct_mol


@pytest.mark.parametrize("mol_list", (mol_list, construct_mol(10, 10, 0)))
@pytest.mark.parametrize("scheme", (
    123,
    4,
))
def test_general_mpo_MolList(mol_list, scheme):

    if scheme == 4:
        mol_list1 = mol_list.switch_scheme(4)
    else:
        mol_list1 = mol_list

    mol_list1.mol_list2_para()
    mpo = Mpo.general_mpo(mol_list1,
                          const=Quantity(-mol_list1[0].gs_zpe *
                                         mol_list1.mol_num))
コード例 #8
0
def test_symmetry():
    assert not mol_list.is_symmetric
    assert construct_mol(10, 10, 0).is_symmetric