def default_nevpt_schedule(fcisolver, maxM=500, tol=1e-7): nevptsolver = dmrgci.DMRGCI(fcisolver.mol, maxM, tol) nevptsolver.stdout = fcisolver.stdout nevptsolver.verbose = fcisolver.verbose if isinstance(fcisolver, dmrgci.DMRGCI): nevptsolver.memory = fcisolver.memory nevptsolver.outputlevel = fcisolver.outputlevel nevptsolver.executable = fcisolver.executable nevptsolver.scratchDirectory = fcisolver.scratchDirectory nevptsolver.mpiprefix = fcisolver.mpiprefix nevptsolver.spin = fcisolver.spin nevptsolver.groupname = fcisolver.groupname nevptsolver.num_thrds = fcisolver.num_thrds # runtimeDir is only used to generate the common part of the input nevptsolver.runtimeDir = nevptsolver.scratchDirectory if not os.path.exists(nevptsolver.scratchDirectory): os.makedirs(nevptsolver.scratchDirectory) nevptsolver.scheduleSweeps = [0, 4] nevptsolver.scheduleMaxMs = [maxM, maxM] nevptsolver.scheduleTols = [0.0001, tol] nevptsolver.scheduleNoises = [0.0001, 0.0] nevptsolver.twodot_to_onedot = 4 nevptsolver.maxIter = 6 return nevptsolver
def default_nevpt_schedule(mol, maxM=500, tol=1e-7): nevptsolver = dmrgci.DMRGCI(mol, maxM, tol) nevptsolver.scheduleSweeps = [0, 4] nevptsolver.scheduleMaxMs = [maxM, maxM] nevptsolver.scheduleTols = [0.0001, tol] nevptsolver.scheduleNoises = [0.0001, 0.0] nevptsolver.twodot_to_onedot = 4 nevptsolver.maxIter = 6 return nevptsolver
def default_nevpt_schedule(fcisolver, maxM=500, tol=1e-7): nevptsolver = dmrgci.DMRGCI(fcisolver.mol, maxM, tol) nevptsolver.stdout = fcisolver.stdout nevptsolver.verbose = fcisolver.verbose if isinstance(fcisolver, dmrgci.DMRGCI): nevptsolver.memory = fcisolver.memory nevptsolver.outputlevel = fcisolver.outputlevel nevptsolver.executable = fcisolver.executable nevptsolver.scratchDirectory = fcisolver.scratchDirectory nevptsolver.mpiprefix = fcisolver.mpiprefix nevptsolver.spin = fcisolver.spin nevptsolver.groupname = fcisolver.groupname nevptsolver.scheduleSweeps = [0, 4] nevptsolver.scheduleMaxMs = [maxM, maxM] nevptsolver.scheduleTols = [0.0001, tol] nevptsolver.scheduleNoises = [0.0001, 0.0] nevptsolver.twodot_to_onedot = 4 nevptsolver.maxIter = 6 return nevptsolver
''' Block code for active space N-particle density matrices. ''' b = 1.2 mol = gto.M( verbose = 4, atom = 'N 0 0 0; N 0 0 %f'%b, basis = 'cc-pvdz', symmetry = True, ) m = scf.RHF(mol) m.kernel() mc = mcscf.CASSCF(m, 8, 8) mc.fcisolver = dmrgci.DMRGCI(mol) mc.kernel() dm1 = mc.fcisolver.make_rdm1(0, mc.ncas, mc.nelecas) dm2 = mc.fcisolver.make_rdm12(0, mc.ncas, mc.nelecas)[1] dm3 = mc.fcisolver.make_rdm123(0, mc.ncas, mc.nelecas)[2] # # or computing DMs all together in one DMRG call # dm1, dm2 = mc.fcisolver.make_rdm12(0, mc.ncas, mc.nelecas) dm1, dm2, dm3 = mc.fcisolver.make_rdm123(0, mc.ncas, mc.nelecas)
def DMRG_COMPRESS_NEVPT(mc, maxM=500, root=0, nevptsolver=None, tol=1e-7): if (isinstance(mc, str)): mol = chkfile.load_mol(mc) fh5 = h5py.File(mc, 'r') ncas = fh5['mc/ncas'].value ncore = fh5['mc/ncore'].value nvirt = fh5['mc/nvirt'].value nelecas = fh5['mc/nelecas'].value nroots = fh5['mc/nroots'].value wfnsym = fh5['mc/wfnsym'].value fh5.close() mc_chk = mc else: mol = mc.mol ncas = mc.ncas ncore = mc.ncore nvirt = mc.mo_coeff.shape[1] - mc.ncas - mc.ncore nelecas = mc.nelecas nroots = mc.fcisolver.nroots wfnsym = mc.fcisolver.wfnsym mc_chk = 'nevpt_perturb_integral' write_chk(mc, root, mc_chk) if nevptsolver is None: nevptsolver = dmrgci.DMRGCI(mol, maxM, tol) nevptsolver.scheduleSweeps = [0, 4] nevptsolver.scheduleMaxMs = [maxM, maxM] nevptsolver.scheduleTols = [0.0001, tol] nevptsolver.scheduleNoises = [0.0001, 0.0] nevptsolver.twodot_to_onedot = 4 nevptsolver.maxIter = 6 nevptsolver.wfnsym = wfnsym nevptsolver.block_extra_keyword = mc.fcisolver.block_extra_keyword nevptsolver.nroots = nroots from pyscf.dmrgscf import settings nevptsolver.executable = settings.BLOCKEXE_COMPRESS_NEVPT scratch = nevptsolver.scratchDirectory nevptsolver.scratchDirectory = '' dmrgci.writeDMRGConfFile( nevptsolver, nelecas, True, with_2pdm=False, extraline=['fullrestart', 'nevpt_state_num %d' % root]) nevptsolver.scratchDirectory = scratch if nevptsolver.verbose >= logger.DEBUG1: inFile = os.path.join(nevptsolver.runtimeDir, nevptsolver.configFile) logger.debug1(nevptsolver, 'Block Input conf') logger.debug1(nevptsolver, open(inFile, 'r').read()) t0 = (time.clock(), time.time()) cmd = ' '.join( (nevptsolver.mpiprefix, '%s/nevpt_mpi.py' % os.path.dirname(os.path.realpath(__file__)), mc_chk, nevptsolver.executable, nevptsolver.configFile, nevptsolver.outputFile, nevptsolver.scratchDirectory)) logger.debug(nevptsolver, 'DMRG_COMPRESS_NEVPT cmd %s', cmd) try: output = subprocess.check_call(cmd, shell=True) except subprocess.CalledProcessError as err: logger.error(nevptsolver, cmd) raise err if nevptsolver.verbose >= logger.DEBUG1: logger.debug1( nevptsolver, open(os.path.join(nevptsolver.scratchDirectory, '0/dmrg.out')).read()) fh5 = h5py.File('Perturbation_%d' % root, 'r') Vi_e = fh5['Vi/energy'].value Vr_e = fh5['Vr/energy'].value fh5.close() logger.note(nevptsolver, 'Nevpt Energy:') logger.note(nevptsolver, 'Sr Subspace: E = %.14f' % (Vr_e)) logger.note(nevptsolver, 'Si Subspace: E = %.14f' % (Vi_e)) logger.timer(nevptsolver, 'MPS NEVPT calculation time', *t0)