def test_Exact_Spectra_hybrid_TDDMRG_TDH(self, value):

        TDH.construct_Ham_vib(value[0], hybrid=True)
        nexciton = 1
        niterations = 20

        MPS, MPSdim, MPSQN, MPO, MPOdim, MPOQN, MPOQNidx, MPOQNtot, ephtable, pbond = \
            MPSsolver.construct_MPS_MPO_2(value[0], J, dmrg_procedure[0][0], nexciton)

        MPS, MPSQN, WFN, Etot = hybrid_TDDMRG_TDH.hybrid_DMRG_H_SCF(value[0], J, \
                nexciton, dmrg_procedure, 20, DMRGthresh=1e-5, Hthresh=1e-5)
        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(value[0],
                                                                pbond,
                                                                "a",
                                                                dipole=True)

        nsteps = 3000
        dt = 30.0
        MPS = mpslib.MPSdtype_convert(MPS)
        WFN = [wfn.astype(np.complex128) for wfn in WFN[:-1]] + [WFN[-1]]

        autocorr = hybrid_TDDMRG_TDH.Exact_Spectra_hybrid_TDDMRG_TDH("emi", value[0], J, MPS, \
                dipoleMPO, WFN, nsteps, dt)
        with open(value[1], 'rb') as f:
            hybrid_ZTemi_exact_std = np.load(f)
        self.assertTrue(
            np.allclose(autocorr, hybrid_ZTemi_exact_std, rtol=value[2]))
    def test_ZeroTcorr_hybrid_TDDMRG_TDH_emi(self, value):

        TDH.construct_Ham_vib(value[0], hybrid=True)
        nexciton = 1
        niterations = 20

        MPS, MPSdim, MPSQN, MPO, MPOdim, MPOQN, MPOQNidx, MPOQNtot, ephtable, pbond = \
            MPSsolver.construct_MPS_MPO_2(value[0], J, dmrg_procedure[0][0], nexciton)

        MPS, MPSQN, WFN, Etot = hybrid_TDDMRG_TDH.hybrid_DMRG_H_SCF(value[0], J, \
                nexciton, dmrg_procedure, 20, DMRGthresh=1e-5, Hthresh=1e-5)
        iMPS = [MPS, MPSQN, len(MPS) - 1, 1]
        QNargs = [ephtable, False]
        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(value[0],
                                                                pbond,
                                                                "a",
                                                                dipole=True,
                                                                QNargs=QNargs)

        nsteps = 1000
        dt = 30.0
        iMPS = mpslib.MPSdtype_convert(iMPS, QNargs=QNargs)
        WFN = [wfn.astype(np.complex128) for wfn in WFN[:-1]] + [WFN[-1]]
        autocorr = hybrid_TDDMRG_TDH.ZeroTcorr_hybrid_TDDMRG_TDH(value[0], J, iMPS, dipoleMPO, \
                WFN, nsteps, dt, ephtable,thresh=1e-3, TDDMRG_prop_method="C_RK4", QNargs=QNargs)
        with open(value[1], 'rb') as f:
            hybrid_ZTemi_prop_std = np.load(f)[:nsteps]
        self.assertTrue(
            np.allclose(autocorr, hybrid_ZTemi_prop_std, rtol=value[2]))
Пример #3
0
    def test_discrete_mean(self):
        xpos, ephcoup = discrete_mean(spectral_density_Lorentzian, \
                (eta, gamma, omega_v), 0.0, omega_c, 10)
        print "discrete", xpos, ephcoup

        dipole_abs = 1.0
        nmols = 1
        elocalex = 100000. * constant.cm2au
        J = np.array([[0.]]) * constant.cm2au
        omega_value = xpos * constant.cm2au
        omega = [{0: x, 1: x} for x in omega_value]
        D = [{
            0: 0.0,
            1: ephcoup[i] * np.sqrt(2. / omega_value[i])
        } for i in range(len(ephcoup))]

        nphs = len(xpos)
        nlevels = [10] * nphs

        phinfo = [list(a) for a in zip(omega, D, nlevels)]

        mol = []
        for imol in xrange(nmols):
            mol_local = obj.Mol(elocalex, nphs, dipole_abs)
            mol_local.create_ph(phinfo)
            mol.append(mol_local)

        nexciton = 0
        procedure = [[20, 0.1], [10, 0], [1, 0]]

        iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, HMPOQN, HMPOQNidx, HMPOQNtot, ephtable, pbond = \
        MPSsolver.construct_MPS_MPO_2(mol, J, procedure[0][0], nexciton)

        MPSsolver.optimization(iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, ephtable, pbond,\
                        nexciton, procedure, method="2site")

        # if in the EX space, MPO minus E_e to reduce osillation
        for ibra in xrange(pbond[0]):
            HMPO[0][0, ibra, ibra, 0] -= elocalex

        iMPS = [iMPS, iMPSQN, len(iMPS) - 1, 0]
        QNargs = [ephtable, False]
        HMPO = [HMPO, HMPOQN, HMPOQNidx, HMPOQNtot]

        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol, pbond, \
                "a^\dagger", dipole=True, QNargs=QNargs)
        iMPS = mpslib.MPSdtype_convert(iMPS, QNargs=QNargs)

        nsteps = 1000
        dt = 30.

        autocorr = tMPS.ZeroTCorr(iMPS, HMPO, dipoleMPO, nsteps, dt, ephtable, \
                thresh=1.0e-4, cleanexciton=1-nexciton, algorithm=2, compress_method="svd", QNargs=QNargs)

        with open("std_data/discretization/mean.npy", 'rb') as f:
            mean_std = np.load(f)

        self.assertTrue(np.allclose(autocorr, mean_std, rtol=1.e-3))
Пример #4
0
    def test_FiniteT_spectra_emi(self, value):
        print "data", value
        nexciton = 1
        procedure = [[10, 0.4], [20, 0.2], [30, 0.1], [40, 0], [40, 0]]
        mol = construct_mol(*value[3])

        iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, HMPOQN, HMPOQNidx, HMPOQNtot, ephtable, pbond = \
            MPSsolver.construct_MPS_MPO_2(mol, J, procedure[0][0], nexciton)

        # if in the EX space, MPO minus E_e to reduce osillation
        for ibra in xrange(pbond[0]):
            HMPO[0][0, ibra, ibra, 0] -= 2.28614053 / constant.au2ev

        if value[2] != None:
            QNargs = [ephtable, False]
            HMPO = [HMPO, HMPOQN, HMPOQNidx, HMPOQNtot]
        else:
            QNargs = None

        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol,
                                                                pbond,
                                                                "a",
                                                                dipole=True,
                                                                QNargs=QNargs)
        nsteps = 30
        dt = 30.0
        EXMPO, EXMPOdim = tMPS.Max_Entangled_EX_MPO(mol,
                                                    pbond,
                                                    norm=True,
                                                    QNargs=QNargs)
        EXMPO = mpslib.MPSdtype_convert(EXMPO, QNargs=QNargs)

        insteps = 50
        autocorr = tMPS.FiniteT_spectra("emi",
                                        mol,
                                        pbond,
                                        EXMPO,
                                        HMPO,
                                        dipoleMPO,
                                        nsteps,
                                        dt,
                                        ephtable,
                                        insteps,
                                        thresh=1.0e-3,
                                        temperature=298,
                                        algorithm=value[0],
                                        compress_method=value[1],
                                        QNargs=QNargs)

        autocorr = np.array(autocorr)
        with open(
                "std_data/tMPS/TTemi_" + str(value[0]) + str(value[1]) +
                ".npy", 'rb') as f:
            TTemi_std = np.load(f)
        self.assertTrue(
            np.allclose(autocorr, TTemi_std[0:nsteps], rtol=value[4]))
Пример #5
0
    def test_ZeroTcorr(self, value):

        print "data", value
        nexciton = 0
        procedure = [[1, 0], [1, 0], [1, 0]]

        mol = construct_mol(*value[3])

        iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, HMPOQN, HMPOQNidx, HMPOQNtot, ephtable, pbond = \
        MPSsolver.construct_MPS_MPO_2(mol, J, procedure[0][0], nexciton)

        MPSsolver.optimization(iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, ephtable, pbond,\
                        nexciton, procedure, method="2site")
        # if in the EX space, MPO minus E_e to reduce osillation
        for ibra in xrange(pbond[0]):
            HMPO[0][0, ibra, ibra, 0] -= 2.28614053 / constant.au2ev

        if value[2] != None:
            iMPS = [iMPS, iMPSQN, len(iMPS) - 1, 0]
            QNargs = [ephtable, False]
            HMPO = [HMPO, HMPOQN, HMPOQNidx, HMPOQNtot]
        else:
            QNargs = None

        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol,
                                                                pbond,
                                                                "a^\dagger",
                                                                dipole=True,
                                                                QNargs=QNargs)
        iMPS = mpslib.MPSdtype_convert(iMPS, QNargs=QNargs)

        nsteps = 100
        dt = 30.0

        autocorr = tMPS.ZeroTCorr(iMPS,
                                  HMPO,
                                  dipoleMPO,
                                  nsteps,
                                  dt,
                                  ephtable,
                                  thresh=1.0e-3,
                                  cleanexciton=1 - nexciton,
                                  algorithm=value[0],
                                  compress_method=value[1],
                                  QNargs=QNargs)
        autocorr = np.array(autocorr)
        with open(
                "std_data/tMPS/ZeroTabs_" + str(value[0]) + str(value[1]) +
                ".npy", 'rb') as f:
            ZeroTabs_std = np.load(f)
        self.assertTrue(np.allclose(autocorr, ZeroTabs_std, rtol=value[4]))
Пример #6
0
    def test_FiniteT_spectra_abs(self, value):
        print "data", value
        nexciton = 0
        procedure = [[1, 0], [1, 0], [1, 0]]
        mol = construct_mol(*value[3])
        iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, HMPOQN, HMPOQNidx, HMPOQNtot, ephtable, pbond = MPSsolver.construct_MPS_MPO_2(
            mol, J, procedure[0][0], nexciton)

        # if in the EX space, MPO minus E_e to reduce osillation
        for ibra in xrange(pbond[0]):
            HMPO[0][0, ibra, ibra, 0] -= 2.28614053 / constant.au2ev

        if value[2] != None:
            QNargs = [ephtable, False]
            HMPO = [HMPO, HMPOQN, HMPOQNidx, HMPOQNtot]
        else:
            QNargs = None

        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol,
                                                                pbond,
                                                                "a^\dagger",
                                                                dipole=True,
                                                                QNargs=QNargs)
        GSMPS, GSMPSdim = tMPS.Max_Entangled_GS_MPS(mol, pbond, QNargs=QNargs)
        GSMPO = tMPS.hilbert_to_liouville(GSMPS, QNargs=QNargs)
        GSMPO = mpslib.MPSdtype_convert(GSMPO, QNargs=QNargs)

        nsteps = 50
        dt = 30.0
        autocorr = tMPS.FiniteT_spectra("abs",
                                        mol,
                                        pbond,
                                        GSMPO,
                                        HMPO,
                                        dipoleMPO,
                                        nsteps,
                                        dt,
                                        ephtable,
                                        thresh=1.0e-3,
                                        temperature=298,
                                        algorithm=value[0],
                                        compress_method=value[1],
                                        QNargs=QNargs)

        autocorr = np.array(autocorr)

        with open("std_data/tMPS/TTabs_" + str(value[1] + ".npy"), 'rb') as f:
            TTabs_std = np.load(f)

        self.assertTrue(
            np.allclose(autocorr, TTabs_std[0:nsteps], rtol=value[4]))
Пример #7
0
    def test_ZeroTcorr(self, value):

        nexciton = 0
        procedure = [[20, 0.5], [10, 0.1], [5, 0], [1, 0]]

        mol = construct_mol(*value[0])

        Chain = chainmap.Chain_Map_discrete(mol)
        mol = chainmap.Chain_Mol(Chain, mol)

        iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, HMPOQN, HMPOQNidx, HMPOQNtot, ephtable, pbond = \
        MPSsolver.construct_MPS_MPO_2(mol, J, procedure[0][0], nexciton,\
                rep="chain")

        MPSsolver.optimization(iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, ephtable, pbond,\
                        nexciton, procedure, method="2site")

        # if in the EX space, MPO minus E_e to reduce osillation
        for ibra in xrange(pbond[0]):
            HMPO[0][0, ibra, ibra, 0] -= 2.28614053 / constant.au2ev

        iMPS = [iMPS, iMPSQN, len(iMPS) - 1, 0]
        QNargs = [ephtable, False]
        HMPO = [HMPO, HMPOQN, HMPOQNidx, HMPOQNtot]

        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol,
                                                                pbond,
                                                                "a^\dagger",
                                                                dipole=True,
                                                                QNargs=QNargs)
        iMPS = mpslib.MPSdtype_convert(iMPS, QNargs=QNargs)

        nsteps = 100
        dt = 10.0

        autocorr = tMPS.ZeroTCorr(iMPS,
                                  HMPO,
                                  dipoleMPO,
                                  nsteps,
                                  dt,
                                  ephtable,
                                  thresh=1.0e-3,
                                  cleanexciton=1 - nexciton,
                                  algorithm=2,
                                  compress_method="svd",
                                  QNargs=QNargs)
        autocorr = np.array(autocorr)

        with open("std_data/quasiboson/0Tabs_std.npy", 'rb') as f:
            ZeroTabs_std = np.load(f)
        self.assertTrue(np.allclose(autocorr, ZeroTabs_std, rtol=value[1]))
Пример #8
0
    def test_FiniteT_spectra_emi(self, value):
        nexciton = 1
        procedure = [[10, 0.4], [20, 0.2], [30, 0.1], [40, 0], [40, 0]]

        iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, HMPOQN, HMPOQNidx, HMPOQNtot, ephtable, pbond = \
            MPSsolver.construct_MPS_MPO_2(mol, J, procedure[0][0], nexciton)

        # if in the EX space, MPO minus E_e to reduce osillation
        for ibra in xrange(pbond[0]):
            HMPO[0][0, ibra, ibra, 0] -= 2.28614053 / constant.au2ev

        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol,
                                                                pbond,
                                                                "a",
                                                                dipole=True)
        nsteps = value[1]
        dt = value[2]
        EXMPO, EXMPOdim = tMPS.Max_Entangled_EX_MPO(mol, pbond, norm=True)
        EXMPO = mpslib.MPSdtype_convert(EXMPO)

        for f in glob.glob("TDVP_PS*.npy"):
            os.remove(f)

        insteps = 50
        autocorr = tMPS.FiniteT_spectra("emi",
                                        mol,
                                        pbond,
                                        EXMPO,
                                        HMPO,
                                        dipoleMPO,
                                        nsteps,
                                        dt,
                                        ephtable,
                                        insteps,
                                        thresh=1.0e-3,
                                        temperature=298,
                                        compress_method="variational",
                                        scheme=value[0])

        with open("std_data/tMPS/TTemi_2svd" + value[4] + ".npy", 'rb') as f:
            TTemi_std = np.load(f)
        self.assertTrue(
            np.allclose(autocorr, TTemi_std[0:nsteps], rtol=value[3]))
Пример #9
0
    def test_FT_dynamics_hybrid_TDDMRG_TDH(self, value):

        mol, J = parameter_PBI.construct_mol(4, nphs=value[0])
        TDH.construct_Ham_vib(mol, hybrid=True)
        nexciton = 0
        dmrg_procedure = [[20, 0.5], [20, 0.3], [10, 0.2], [5, 0], [1, 0]]
        MPS, MPSdim, MPSQN, MPO, MPOdim, MPOQN, MPOQNidx, MPOQNtot, ephtable, pbond = \
            MPSsolver.construct_MPS_MPO_2(mol, J, dmrg_procedure[0][0], nexciton)

        QNargs = [ephtable, False]
        T = 2000.
        insteps = 1
        iMPS, WFN = hybrid_TDDMRG_TDH.FT_DM_hybrid_TDDMRG_TDH(mol, J, nexciton, T, \
                insteps, pbond, ephtable, thresh=1e-3, cleanexciton=nexciton,\
                QNargs=QNargs, space="GS")

        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol, pbond, "a^\dagger",\
                QNargs=QNargs, sitelist=[0])

        iMPS = mpslib.mapply(dipoleMPO, iMPS, QNargs=QNargs)
        norm = mpslib.norm(iMPS, QNargs=QNargs)
        WFN[-1] *= norm
        iMPS = mpslib.scale(iMPS, 1. / norm, QNargs=QNargs)
        iMPS = mpslib.MPSdtype_convert(iMPS, QNargs=QNargs)
        WFN = [wfn.astype(np.complex128) for wfn in WFN[:-1]] + [WFN[-1]]

        nsteps = 90
        dt = 10.0

        MPOs = []
        for imol in xrange(len(mol)):
            dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol, pbond, "a^\dagger a",\
                QNargs=QNargs, sitelist=[imol])
            MPOs.append(dipoleMPO)

        data = hybrid_TDDMRG_TDH.dynamics_hybrid_TDDMRG_TDH(mol, J, iMPS, \
                WFN, nsteps, dt, ephtable,thresh=1e-3, \
                TDDMRG_prop_method="C_RK4", QNargs=QNargs, property_MPOs=MPOs)

        with open("std_data/hybrid_TDDMRG_TDH/FT_occ" + str(value[0]) + ".npy",
                  'rb') as f:
            std = np.load(f)
        self.assertTrue(np.allclose(data, std))
Пример #10
0
    def test_ZeroTcorr_TDVP(self, value):

        nexciton = 0
        procedure = [[50, 0], [50, 0], [50, 0]]

        iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, HMPOQN, HMPOQNidx, HMPOQNtot, ephtable, pbond = \
        MPSsolver.construct_MPS_MPO_2(mol, J, procedure[0][0], nexciton)

        MPSsolver.optimization(iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, ephtable, pbond,\
                        nexciton, procedure, method="2site")
        # if in the EX space, MPO minus E_e to reduce osillation
        for ibra in xrange(pbond[0]):
            HMPO[0][0, ibra, ibra, 0] -= 2.28614053 / constant.au2ev

        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol,
                                                                pbond,
                                                                "a^\dagger",
                                                                dipole=True)
        iMPS = mpslib.MPSdtype_convert(iMPS)

        nsteps = 200
        dt = value[2]

        for f in glob.glob("TDVP_PS*.npy"):
            os.remove(f)

        autocorr = tMPS.ZeroTCorr(iMPS,
                                  HMPO,
                                  dipoleMPO,
                                  nsteps,
                                  dt,
                                  ephtable,
                                  thresh=1.0e-7,
                                  cleanexciton=1 - nexciton,
                                  algorithm=value[1],
                                  compress_method="variational",
                                  scheme=value[0])

        with open("std_data/tMPS/ZeroTabs_" + value[0] + ".npy", 'rb') as f:
            ZeroTabs_std = np.load(f)
        self.assertTrue(
            np.allclose(autocorr, ZeroTabs_std[:len(autocorr)], rtol=value[3]))
Пример #11
0
    def test_ZeroTcorr_MPOscheme3(self, value):
        print "data", value
        J = np.array([[0.0, -0.1, 0.0], [-0.1, 0.0, -0.3], [0.0, -0.3, 0.0]
                      ]) / constant.au2ev
        nexciton = 0
        procedure = [[1, 0], [1, 0], [1, 0]]
        mol = construct_mol(*value[3])

        iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, HMPOQN, HMPOQNidx, HMPOQNtot, ephtable, pbond = \
        MPSsolver.construct_MPS_MPO_2(mol, J, procedure[0][0], nexciton, MPOscheme=2)

        MPSsolver.optimization(iMPS, iMPSdim, iMPSQN, HMPO, HMPOdim, ephtable, pbond,\
                        nexciton, procedure, method="2site")
        # if in the EX space, MPO minus E_e to reduce osillation
        for ibra in xrange(pbond[0]):
            HMPO[0][0, ibra, ibra, 0] -= 2.28614053 / constant.au2ev

        if value[2] != None:
            iMPS = [iMPS, iMPSQN, len(iMPS) - 1, 0]
            QNargs = [ephtable, False]
            HMPO = [HMPO, HMPOQN, HMPOQNidx, HMPOQNtot]
        else:
            QNargs = None

        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol,
                                                                pbond,
                                                                "a^\dagger",
                                                                dipole=True,
                                                                QNargs=QNargs)
        iMPS = mpslib.MPSdtype_convert(iMPS, QNargs=QNargs)

        nsteps = 50
        dt = 30.0

        autocorr = tMPS.ZeroTCorr(iMPS,
                                  HMPO,
                                  dipoleMPO,
                                  nsteps,
                                  dt,
                                  ephtable,
                                  thresh=1.0e-4,
                                  cleanexciton=1 - nexciton,
                                  algorithm=value[0],
                                  compress_method=value[1],
                                  QNargs=QNargs)
        autocorr = np.array(autocorr)

        # scheme3
        iMPS3, iMPSdim3, iMPSQN3, HMPO3, HMPOdim3, HMPOQN3, HMPOQNidx3, HMPOQNtot3, ephtable3, pbond3 = \
        MPSsolver.construct_MPS_MPO_2(mol, J, procedure[0][0], nexciton, MPOscheme=3)
        MPSsolver.optimization(iMPS3, iMPSdim3, iMPSQN3, HMPO3, HMPOdim3, ephtable3, pbond3,\
                        nexciton, procedure, method="2site")
        # if in the EX space, MPO minus E_e to reduce osillation
        for ibra in xrange(pbond3[0]):
            HMPO3[0][0, ibra, ibra, 0] -= 2.28614053 / constant.au2ev

        if value[2] != None:
            iMPS3 = [iMPS3, iMPSQN3, len(iMPS3) - 1, 0]
            QNargs3 = [ephtable3, False]
            HMPO3 = [HMPO3, HMPOQN3, HMPOQNidx3, HMPOQNtot3]
        else:
            QNargs3 = None

        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol,
                                                                pbond,
                                                                "a^\dagger",
                                                                dipole=True,
                                                                QNargs=QNargs3)

        iMPS3 = mpslib.MPSdtype_convert(iMPS3, QNargs=QNargs)

        nsteps = 50
        dt = 30.0

        autocorr3 = tMPS.ZeroTCorr(iMPS3, HMPO3, dipoleMPO, nsteps, dt, ephtable3,\
                thresh=1.0e-4, cleanexciton=1-nexciton, algorithm=value[0],
                compress_method=value[1], QNargs=QNargs3)
        autocorr3 = np.array(autocorr3)

        self.assertTrue(np.allclose(autocorr, autocorr3, rtol=value[4]))
Пример #12
0
    def test_1mol_Exact_Spectra_hybrid_TDDMRG_TDH(self, value):

        nmols = 1
        J = np.zeros([1, 1])

        if value[0] == "pure":
            nphs = 2
            phinfo = [list(a) for a in zip(omega, D, nlevels)]
            mol = []
            for imol in xrange(nmols):
                mol_local = obj.Mol(elocalex, nphs, dipole_abs)
                mol_local.create_ph(phinfo)
                mol.append(mol_local)

        elif value[0] == "hybrid":
            nphs = 1
            nphs_hybrid = 1
            phinfo_hybrid = [
                list(a) for a in zip(omega[:nphs], D[:nphs], nlevels[:nphs])
            ]
            phinfo = [
                list(a) for a in zip(omega[nphs:], D[nphs:], nlevels[nphs:])
            ]

            mol = []
            for imol in xrange(nmols):
                mol_local = obj.Mol(elocalex,
                                    nphs,
                                    dipole_abs,
                                    nphs_hybrid=nphs_hybrid)
                mol_local.create_ph(phinfo)
                mol_local.create_ph(phinfo_hybrid, phtype="hybrid")
                mol.append(mol_local)

        TDH.construct_Ham_vib(mol, hybrid=True)
        nexciton = 0
        dmrg_procedure = [[10, 0.4], [20, 0.2], [30, 0.1], [40, 0], [40, 0]]

        MPS, MPSdim, MPSQN, HMPO, HMPOdim, HMPOQN, HMPOQNidx, HMPOQNtot, ephtable, pbond \
                = MPSsolver.construct_MPS_MPO_2(mol, J, dmrg_procedure[0][0], nexciton)

        MPS, MPSQN, WFN, Etot = hybrid_TDDMRG_TDH.hybrid_DMRG_H_SCF(mol, J, \
                nexciton, dmrg_procedure, 20, DMRGthresh=1e-5, Hthresh=1e-5)
        dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol,
                                                                pbond,
                                                                "a^\dagger",
                                                                dipole=True)

        nsteps = 1000
        dt = 30.0
        MPS = mpslib.MPSdtype_convert(MPS)
        WFN = [wfn.astype(np.complex128) for wfn in WFN[:-1]] + [WFN[-1]]

        E_offset = -mol[0].elocalex - mol[0].e0 - mol[0].e0_hybrid
        autocorr = hybrid_TDDMRG_TDH.Exact_Spectra_hybrid_TDDMRG_TDH("abs", mol, J, MPS, \
                dipoleMPO, WFN, nsteps, dt, E_offset=E_offset)

        with open("std_data/tMPS/1mol_ZTabs.npy", 'rb') as f:
            mol1_ZTabs_std = np.load(f)

        self.assertTrue(np.allclose(autocorr, mol1_ZTabs_std, rtol=1e-3))
Пример #13
0
def FT_DM_hybrid_TDDMRG_TDH(mol, J, nexciton, T, nsteps, pbond, ephtable, \
        thresh=0., TDDMRG_prop_method="C_RK4", cleanexciton=None, QNargs=None, space=None):
    '''
    construct the finite temperature density matrix by hybrid TDDMRG/TDH method
    '''
    # initial state infinite T density matrix
    # TDDMRG
    if nexciton == 0:
        DMMPS, DMMPSdim = tMPS.Max_Entangled_GS_MPS(mol,
                                                    pbond,
                                                    norm=True,
                                                    QNargs=QNargs)
        DMMPO = tMPS.hilbert_to_liouville(DMMPS, QNargs=QNargs)
    elif nexciton == 1:
        DMMPO, DMMPOdim = tMPS.Max_Entangled_EX_MPO(mol,
                                                    pbond,
                                                    norm=True,
                                                    QNargs=QNargs)
    DMMPO = mpslib.MPSdtype_convert(DMMPO, QNargs=QNargs)

    # TDH
    DMH = []

    nmols = len(mol)
    for imol in xrange(nmols):
        for iph in xrange(mol[imol].nphs_hybrid):
            dim = mol[imol].ph_hybrid[iph].H_vib_indep.shape[0]
            DMH.append(np.diag([1.0] * dim, k=0))
    # the coefficent a
    DMH.append(1.0)

    mflib.normalize(DMH)

    beta = constant.T2beta(T) / 2.0
    dbeta = beta / float(nsteps)

    for istep in xrange(nsteps):
        if space is None:
            DMMPO, DMH = hybrid_TDDMRG_TDH(mol, J, DMMPO, DMH, dbeta/1.0j, ephtable, \
                    thresh=thresh, cleanexciton=cleanexciton, QNargs=QNargs, \
                    TDDMRG_prop_method=TDDMRG_prop_method, normalize=1.0)
        else:
            MPOprop, HAM, Etot = ExactPropagator_hybrid_TDDMRG_TDH(mol, J, \
                    DMMPO, DMH, -1.0*dbeta, space=space, QNargs=QNargs)
            DMH[-1] *= np.exp(-1.0 * Etot * dbeta)
            TDH.unitary_propagation(HAM, DMH, dbeta / 1.0j)

            DMMPO = mpslib.mapply(MPOprop, DMMPO, QNargs=QNargs)
            # DMMPO is not normalize in the imaginary time domain
            MPOnorm = mpslib.norm(DMMPO, QNargs=QNargs)
            DMMPO = mpslib.scale(DMMPO, 1. / MPOnorm, QNargs=QNargs)

            DMH[-1] *= MPOnorm

        # normlize the dm (physical \otimes ancilla)
        mflib.normalize(DMH)

    # divided by np.sqrt(partition function)
    DMH[-1] = 1.0

    return DMMPO, DMH