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))
def construct_mol(nlevels, nqboson=[1], qbtrunc=[0.0], force3rd=[None], D_value=D_value): D = [{0: 0.0, 1: D_value[0]}] phinfo = [ list(a) for a in zip(omega, D, nlevels, force3rd, nqboson, qbtrunc) ] mol = [] for imol in xrange(nmols): mol_local = obj.Mol(elocalex, nphs, dipole_abs) mol_local.create_ph(phinfo) mol.append(mol_local) return mol
def test_nonlinear_omega_1(self): nmols = 1 J = np.zeros([1,1]) nlevels = [10,10] mol = [] phinfo = [list(a) for a in zip(omega, D, nlevels)] for imol in xrange(nmols): mol_local = obj.Mol(elocalex, nphs, dipole_abs) mol_local.create_ph(phinfo) mol.append(mol_local) MPS, MPSdim, MPSQN, MPO, MPOdim, MPOQN, MPOQNidx, MPOQNtot, ephtable, pbond = \ MPSsolver.construct_MPS_MPO_2(mol, J, procedure[0][0], nexciton, MPOscheme=2) energy = MPSsolver.optimization(MPS, MPSdim, MPSQN, MPO, MPOdim, ephtable, pbond, nexciton, procedure, method="2site") print "omega_diff_std", omega_diff/constant.cm2au print "omega_diff_cal", (np.min(energy)-elocalex)/constant.cm2au*2 self.assertAlmostEqual((np.min(energy)-elocalex)*2, omega_diff)
def construct_mol(nmols, nphs=10): elocalex = 2.13/au2ev dipole_abs = 1.0 # cm^-1 J = np.zeros((nmols,nmols)) J += np.diag([-500.0]*(nmols-1),k=1) J += np.diag([-500.0]*(nmols-1),k=-1) J = J * cm2au print "J=", J # 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])*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 = [{0:x,1:x} for x in omega_value] D_value = np.sqrt(S_value)/np.sqrt(omega_value/2.) D = [{0:0.0,1:x} for x in D_value] nphs_hybrid = 10-nphs nlevels = [5]*10 print nphs, nphs_hybrid phinfo = [list(a) for a in zip(omega[:nphs], D[:nphs], nlevels[:nphs])] phinfo_hybrid = [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) return mol, J
def test_nonlinear_omega_2(self): nmols = 2 J = np.array([[0.0, 1000],[1000, 0.0]])*constant.cm2au nlevels = [5,5] mol = [] phinfo = [list(a) for a in zip(omega, D, nlevels)] for imol in xrange(nmols): mol_local = obj.Mol(elocalex, nphs, dipole_abs) mol_local.create_ph(phinfo) mol.append(mol_local) MPS, MPSdim, MPSQN, MPO, MPOdim, MPOQN, MPOQNidx, MPOQNtot, ephtable, pbond = \ MPSsolver.construct_MPS_MPO_2(mol, J, procedure[0][0], nexciton, MPOscheme=2) energy = MPSsolver.optimization(MPS, MPSdim, MPSQN, MPO, MPOdim, ephtable, pbond, nexciton, procedure, method="2site") fx, fy, fph_dof_list, fnconfigs = exact_solver.pre_Hmat(nexciton, mol) fHmat = exact_solver.construct_Hmat(fnconfigs, mol, J, indirect=[fph_dof_list, fx, fy]) fe, fc = exact_solver.Hmat_diagonalization(fHmat, method="full") print np.min(energy), fe[0] self.assertAlmostEqual(np.min(energy),fe[0])
# cm^-1 omega_value = np.array([1555.55]) * constant.cm2au omega = [{0: omega_value[0], 1: omega_value[0]}] # a.u. D_value = np.array([8.7729]) D = [{0: 0.0, 1: D_value[0]}] nphs = 1 nlevels = [4] 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) def construct_mol(nlevels, nqboson=[1], qbtrunc=[0.0], force3rd=[None], D_value=D_value): D = [{0: 0.0, 1: D_value[0]}] phinfo = [ list(a) for a in zip(omega, D, nlevels, force3rd, nqboson, qbtrunc) ] mol = []
def test_force3rd(self,value): elocalex = 1.e4 * constant.cm2au dipole_abs = 1.0 nmols = 1 J = np.zeros([nmols, nmols]) omega_value = np.array([100.])*constant.cm2au omega = [{0:omega_value[0],1:omega_value[0]}] S_value = 2.0 if value[1] == "+": phase = 1.0 elif value[1] == "-": phase = -1.0 D_value = phase * np.sqrt(S_value)*np.sqrt(2.0/omega_value) D = [{0:0.0,1:D_value[0]}] force3rd = [{0:abs(omega_value[0]**2/D_value[0]*0.2/2.), \ 1:abs(omega_value[0]**2/D_value[0]*0.2/2.0)}] print "alpha", omega_value[0]**2/2. print "beta", omega_value[0]**2/D_value[0]*0.2/2. print "D", D_value[0] nphs = 1 nlevels = [30] phinfo = [list(a) for a in zip(omega, D, nlevels, force3rd)] mol = [] for imol in xrange(nmols): mol_local = obj.Mol(elocalex, nphs, dipole_abs) mol_local.create_ph(phinfo) mol.append(mol_local) if value[0] == "abs": nexciton = 0 opera = "a^\dagger" elif value[0] == "emi": nexciton = 1 opera = "a" procedure = [[50,0.4],[50,0.2],[50,0.1],[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] -= elocalex dipoleMPO, dipoleMPOdim = MPSsolver.construct_onsiteMPO(mol, pbond, opera, dipole=True) nsteps = 10000 dt = 30.0 print "energy dE", 1.0/dt/ nsteps / constant.cm2au * 2.0 * np.pi print "energy E", 1.0/dt / constant.cm2au * 2.0 * np.pi temperature = 0 autocorr = tMPS.Exact_Spectra(value[0], mol, pbond, iMPS, dipoleMPO, nsteps, dt, temperature) autocorr = np.array(autocorr) print mol[0].e0 np.save(value[0]+value[1],autocorr) autocorr_std = np.load("std_data/force3rd/"+value[0]+str(value[1])+".npy") self.assertTrue(np.allclose(autocorr,autocorr_std,rtol=1e-2, atol=1e-03))
def test_Chain_Map_discrete(self, value): elocalex = 2.67 / constant.au2ev dipole_abs = 15.45 nmols = 3 # eV J = np.array([[0.0, -0.1, -0.2], [-0.1, 0.0, -0.3], [-0.2, -0.3, 0.0] ]) / constant.au2ev omega_value = np.array([106.51, 1555.55, 1200.0]) * constant.cm2au D_value = np.array([30.1370, 8.7729, 20.0]) D = [{0: 0.0, 1: x} for x in D_value] omega = [{0:omega_value[0], 1:omega_value[0]},{0:omega_value[1], \ 1:omega_value[1]},{0:omega_value[2], 1:omega_value[2]}] nexciton = 1 nphs = 3 procedure = [[10, 0.4], [20, 0.3], [30, 0.2], [40, 0.1], [40, 0]] nlevels = [8] * nphs nqboson = [value[0]] * nphs qbtrunc = [1e-7] * nphs force3rd = [None] * nphs phinfo = [ list(a) for a in zip(omega, D, nlevels, force3rd, nqboson, qbtrunc) ] mol = [] for imol in xrange(nmols): mol_local = obj.Mol(elocalex, nphs, dipole_abs) mol_local.create_ph(phinfo) mol.append(mol_local) MPS, MPSdim, MPSQN, MPO, MPOdim, MPOQN, MPOQNidx, MPOQNtot, ephtable, pbond = \ MPSsolver.construct_MPS_MPO_2(mol, J, procedure[0][0], nexciton, \ MPOscheme=2) energy1 = MPSsolver.optimization(MPS, MPSdim, MPSQN, MPO, MPOdim, ephtable, pbond, nexciton, procedure, method="2site") Chain = chainmap.Chain_Map_discrete(mol) molnew = chainmap.Chain_Mol(Chain, mol) MPS, MPSdim, MPSQN, MPO, MPOdim, MPOQN, MPOQNidx, MPOQNtot, ephtable, pbond = \ MPSsolver.construct_MPS_MPO_2(molnew, J, procedure[0][0], nexciton, \ MPOscheme=2, rep="chain") energy2 = MPSsolver.optimization(MPS, MPSdim, MPSQN, MPO, MPOdim, ephtable, pbond, nexciton, procedure, method="2site") print np.min(energy1), np.min(energy2) self.assertAlmostEqual(np.min(energy1), np.min(energy2))
1: omega_value[1] }] # a.u. D_value = np.array([30.1370, 8.7729]) D = [{0: 0.0, 1: D_value[0]}, {0: 0.0, 1: D_value[1]}] nlevels = [4, 4] 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) def construct_mol(nlevels, nqboson=[1, 1], qbtrunc=[0.0, 0.0], force3rd=[None, None], D_value=D_value): D = [{0: 0.0, 1: D_value[0]}, {0: 0.0, 1: D_value[1]}] phinfo = [ list(a) for a in zip(omega, D, nlevels, force3rd, nqboson, qbtrunc) ]