def writeDMRGConfFile(DMRGCI, nelec, Restart, maxIter=None, with_2pdm=True, extraline=[]): confFile = os.path.join(DMRGCI.runtimeDir, DMRGCI.configFile) f = open(confFile, 'w') if isinstance(nelec, (int, numpy.integer)): nelecb = (nelec - DMRGCI.spin) // 2 neleca = nelec - nelecb else: neleca, nelecb = nelec f.write('nelec %i\n' % (neleca + nelecb)) f.write('spin %i\n' % (neleca - nelecb)) if DMRGCI.groupname is not None: if isinstance(DMRGCI.wfnsym, str): wfnsym = dmrg_sym.irrep_name2id(DMRGCI.groupname, DMRGCI.wfnsym) else: gpname = dmrg_sym.d2h_subgroup(DMRGCI.groupname) assert (DMRGCI.wfnsym in dmrg_sym.IRREP_MAP[gpname]) wfnsym = DMRGCI.wfnsym f.write('irrep %i\n' % wfnsym) if (not Restart): #f.write('schedule\n') #f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-5, 10.0)) #f.write('1 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-5, 1e-4)) #f.write('10 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-6, 1e-5)) #f.write('16 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol/10.0, 0e-6)) #f.write('end\n') schedule = make_schedule(DMRGCI.scheduleSweeps, DMRGCI.scheduleMaxMs, DMRGCI.scheduleTols, DMRGCI.scheduleNoises, DMRGCI.twodot_to_onedot) f.write('%s\n' % schedule) else: f.write('schedule\n') #if approx == True : # f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol*10.0, 0e-6)) #else : # f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol, 0e-6)) f.write('0 %6i %8.4e %8.4e \n' % (DMRGCI.maxM, DMRGCI.tol / 10, 0e-6)) f.write('end\n') f.write('fullrestart\n') f.write('onedot \n') if DMRGCI.groupname is not None: f.write('sym %s\n' % dmrg_sym.d2h_subgroup(DMRGCI.groupname).lower()) f.write('orbitals %s\n' % DMRGCI.integralFile) if maxIter is None: maxIter = DMRGCI.maxIter f.write('maxiter %i\n' % maxIter) f.write('sweep_tol %8.4e\n' % DMRGCI.tol) f.write('outputlevel %s\n' % DMRGCI.outputlevel) f.write('hf_occ %s\n' % DMRGCI.hf_occ) if (with_2pdm and DMRGCI.twopdm): f.write('twopdm\n') if (DMRGCI.nonspinAdapted): f.write('nonspinAdapted\n') if (DMRGCI.scratchDirectory): f.write('prefix %s\n' % DMRGCI.scratchDirectory) if (DMRGCI.nroots != 1): f.write('nroots %d\n' % DMRGCI.nroots) if (DMRGCI.weights == []): DMRGCI.weights = [1.0 / DMRGCI.nroots] * DMRGCI.nroots f.write('weights ') for weight in DMRGCI.weights: f.write('%f ' % weight) f.write('\n') block_extra_keyword = DMRGCI.extraline + DMRGCI.block_extra_keyword + extraline if block_version(DMRGCI.executable).startswith('1.1'): for line in block_extra_keyword: if not ('num_thrds' in line or 'memory' in line): f.write('%s\n' % line) else: if DMRGCI.memory is not None: f.write('memory, %i, g\n' % (DMRGCI.memory)) if DMRGCI.num_thrds > 1: f.write('num_thrds %d\n' % DMRGCI.num_thrds) for line in block_extra_keyword: f.write('%s\n' % line) f.close() #no reorder #f.write('noreorder\n') return confFile
def writeDMRGConfFile(neleca, nelecb, Restart, DMRGCI, approx= False): confFile = DMRGCI.configFile #confFile = os.path.join(DMRGCI.scratchDirectory,DMRGCI.configFile) f = open(confFile, 'w') f.write('nelec %i\n'%(neleca+nelecb)) f.write('spin %i\n' %(neleca-nelecb)) if isinstance(DMRGCI.wfnsym, str): wfnsym = dmrg_sym.irrep_name2id(DMRGCI.mol.groupname, DMRGCI.wfnsym) else: wfnsym = DMRGCI.wfnsym f.write('irrep %i\n' % wfnsym) if (not Restart): #f.write('schedule\n') #f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-5, 10.0)) #f.write('1 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-5, 1e-4)) #f.write('10 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-6, 1e-5)) #f.write('16 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol/10.0, 0e-6)) #f.write('end\n') schedule = make_schedule(DMRGCI.scheduleSweeps, DMRGCI.scheduleMaxMs, DMRGCI.scheduleTols, DMRGCI.scheduleNoises) f.write('%s\n' % schedule) if (DMRGCI.twodot_to_onedot != 0): f.write('twodot_to_onedot %i\n'%DMRGCI.twodot_to_onedot) else : f.write('schedule\n') #if approx == True : # f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol*10.0, 0e-6)) #else : # f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol, 0e-6)) f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol/10, 0e-6)) f.write('end\n') f.write('fullrestart\n') f.write('onedot \n') if DMRGCI.mol.symmetry: if DMRGCI.groupname.lower() == 'dooh': f.write('sym d2h\n' ) elif DMRGCI.groupname.lower() == 'cooh': f.write('sym c2h\n' ) else: f.write('sym %s\n' % DMRGCI.groupname.lower()) f.write('orbitals %s\n' % DMRGCI.integralFile) #f.write('orbitals %s\n' % os.path.join(DMRGCI.scratchDirectory, # DMRGCI.integralFile)) if approx == True : f.write('maxiter %i\n'%DMRGCI.approx_maxIter) else : f.write('maxiter %i\n'%DMRGCI.maxIter) f.write('sweep_tol %8.4e\n'%DMRGCI.tol) f.write('outputlevel %s\n'%DMRGCI.outputlevel) f.write('hf_occ integral\n') if(DMRGCI.twopdm): f.write('twopdm\n') if(DMRGCI.nonspinAdapted): f.write('nonspinAdapted\n') if(DMRGCI.scratchDirectory): f.write('prefix %s\n'%DMRGCI.scratchDirectory) if (DMRGCI.nroots !=1): f.write('nroots %d\n'%DMRGCI.nroots) if (DMRGCI.weights==[]): DMRGCI.weights= [1.0/DMRGCI.nroots]* DMRGCI.nroots f.write('weights ') for weight in DMRGCI.weights: f.write('%f '%weight) f.write('\n') for line in DMRGCI.extraline: f.write('%s\n'%line) f.close()
def writeDMRGConfFile(neleca, nelecb, ncore, ncas, norbs, DMRGCI, maxM, perturber, memory, numthrds, reorder, extraline, root=0, approx= False, aaavsplit=1, aaavIter=0, name= "MRLCC"): virtOrbs = range(norbs-ncore-ncas) chunks = len(virtOrbs)/aaavsplit virtRange = [virtOrbs[i:i+chunks] for i in xrange(0, len(virtOrbs), chunks)] configFile = "response%s_aaav%d.conf"%(name, aaavIter) if (perturber == "AAAC"): configFile = "response%s_aaac.conf"%(name) r = open("reorder_aaac.txt", 'w') for i in range(ncas): r.write("%d "%(reorder[i]+1+ncore)) for i in range(ncore): r.write("%d "%(i+1)) r.close() else: r = open("reorder_aaav%d.txt"%(aaavIter), 'w') for i in range(ncas): r.write("%d "%(reorder[i]+1)) for i in range(len(virtRange[aaavIter])): r.write("%d "%(i+1+ncas)) r.close() f = open(configFile, 'w') if (memory is not None): f.write('memory, %i, g\n'%(memory)) ncoreE = 0 if (perturber == "AAAC"): ncoreE = 2*ncore f.write('nelec %i\n'%(neleca+nelecb+ncoreE)) f.write('spin %i\n' %(neleca-nelecb)) if isinstance(DMRGCI.wfnsym, str): wfnsym = dmrg_sym.irrep_name2id(DMRGCI.mol.groupname, DMRGCI.wfnsym) else: wfnsym = DMRGCI.wfnsym f.write('irrep %i\n' % wfnsym) f.write('schedule\n') if (maxM <= DMRGCI.maxM): maxM = DMRGCI.maxM+1 iter = 0 for M in range(DMRGCI.maxM, maxM, 1000): f.write('%6i %6i %8.4e %8.4e \n' %(iter*4, M, 1e-6, 1.0e-5)) iter += 1 f.write('%6i %6i %8.4e %8.4e \n' %(iter*4, maxM, 1e-6, 1.0e-5)) f.write('end\n') f.write('twodot \n') if DMRGCI.mol.symmetry: if DMRGCI.groupname.lower() == 'dooh': f.write('sym d2h\n' ) elif DMRGCI.groupname.lower() == 'coov': f.write('sym c2v\n' ) else: f.write('sym %s\n' % DMRGCI.groupname.lower()) integralFile = "FCIDUMP_aaav%d"%(aaavIter) if (perturber == "AAAC"): integralFile = "FCIDUMP_aaac" f.write('orbitals %s\n' % integralFile) f.write('maxiter %i\n'%(4*iter+4)) f.write('sweep_tol %8.4e\n'%DMRGCI.tol) f.write('outputlevel %s\n'%DMRGCI.outputlevel) f.write('hf_occ integral\n') if(DMRGCI.scratchDirectory): f.write('prefix %s\n'%DMRGCI.scratchDirectory) f.write('num_thrds %d\n'%DMRGCI.num_thrds) for line in extraline: f.write('%s\n'%line) f.write('occ %d\n'%(10000)) if (perturber == "AAAC") : f.write("reorder reorder_aaac.txt\n") f.write("responseaaac\n") f.write("baseStates %d\n"%(root)) f.write("projectorStates %d\n"%(root)) f.write("targetState 12\n") f.write("partialsweep %d\n"%(ncas)) f.write("open \n") f.write("closed ") for i in range(1,ncore+1): f.write("%d "%(i)) f.write("\n") else: f.write("reorder reorder_aaav%d.txt\n"%(aaavIter)) f.write("responseaaav\n") f.write("baseStates %d\n"%(root)) f.write("projectorStates %d\n"%(root)) f.write("targetState 12\n") f.write("partialsweep %d\n"%(ncas)) f.write("open ") for i in range( len(virtRange[aaavIter]) ): f.write("%d "%(i+1+ncas)) f.write("\nclosed \n") f.close()
def writeDMRGConfFile(neleca, nelecb, ncore, ncas, norbs, DMRGCI, maxM, perturber, memory, numthrds, reorder, extraline, root=0, approx=False, aaavsplit=1, aaavIter=0, name="MRLCC"): virtOrbs = range(norbs - ncore - ncas) chunks = len(virtOrbs) / aaavsplit virtRange = [ virtOrbs[i:i + chunks] for i in xrange(0, len(virtOrbs), chunks) ] configFile = "response%s_aaav%d.conf" % (name, aaavIter) if (perturber == "AAAC"): configFile = "response%s_aaac.conf" % (name) r = open("reorder_aaac.txt", 'w') for i in range(ncas): r.write("%d " % (reorder[i] + 1 + ncore)) for i in range(ncore): r.write("%d " % (i + 1)) r.close() else: r = open("reorder_aaav%d.txt" % (aaavIter), 'w') for i in range(ncas): r.write("%d " % (reorder[i] + 1)) for i in range(len(virtRange[aaavIter])): r.write("%d " % (i + 1 + ncas)) r.close() f = open(configFile, 'w') if (memory is not None): f.write('memory, %i, g\n' % (memory)) ncoreE = 0 if (perturber == "AAAC"): ncoreE = 2 * ncore f.write('nelec %i\n' % (neleca + nelecb + ncoreE)) f.write('spin %i\n' % (neleca - nelecb)) if isinstance(DMRGCI.wfnsym, str): wfnsym = dmrg_sym.irrep_name2id(DMRGCI.mol.groupname, DMRGCI.wfnsym) else: wfnsym = DMRGCI.wfnsym f.write('irrep %i\n' % wfnsym) f.write('schedule\n') if (maxM <= DMRGCI.maxM): maxM = DMRGCI.maxM + 1 iter = 0 for M in range(DMRGCI.maxM, maxM, 1000): f.write('%6i %6i %8.4e %8.4e \n' % (iter * 4, M, 1e-6, 1.0e-5)) iter += 1 f.write('%6i %6i %8.4e %8.4e \n' % (iter * 4, maxM, 1e-6, 1.0e-5)) f.write('end\n') f.write('twodot \n') if DMRGCI.mol.symmetry: if DMRGCI.groupname.lower() == 'dooh': f.write('sym d2h\n') elif DMRGCI.groupname.lower() == 'coov': f.write('sym c2v\n') else: f.write('sym %s\n' % DMRGCI.groupname.lower()) integralFile = "FCIDUMP_aaav%d" % (aaavIter) if (perturber == "AAAC"): integralFile = "FCIDUMP_aaac" f.write('orbitals %s\n' % integralFile) f.write('maxiter %i\n' % (4 * iter + 4)) f.write('sweep_tol %8.4e\n' % DMRGCI.tol) f.write('outputlevel %s\n' % DMRGCI.outputlevel) f.write('hf_occ integral\n') if (DMRGCI.scratchDirectory): f.write('prefix %s\n' % DMRGCI.scratchDirectory) f.write('num_thrds %d\n' % DMRGCI.num_thrds) for line in extraline: f.write('%s\n' % line) f.write('occ %d\n' % (10000)) if (perturber == "AAAC"): f.write("reorder reorder_aaac.txt\n") f.write("responseaaac\n") f.write("baseStates %d\n" % (root)) f.write("projectorStates %d\n" % (root)) f.write("targetState 12\n") f.write("partialsweep %d\n" % (ncas)) f.write("open \n") f.write("closed ") for i in range(1, ncore + 1): f.write("%d " % (i)) f.write("\n") else: f.write("reorder reorder_aaav%d.txt\n" % (aaavIter)) f.write("responseaaav\n") f.write("baseStates %d\n" % (root)) f.write("projectorStates %d\n" % (root)) f.write("targetState 12\n") f.write("partialsweep %d\n" % (ncas)) f.write("open ") for i in range(len(virtRange[aaavIter])): f.write("%d " % (i + 1 + ncas)) f.write("\nclosed \n") f.close()
def writeSHCIConfFile(SHCI, nelec, Restart): confFile = os.path.join(SHCI.runtimeDir, SHCI.configFile) f = open(confFile, 'w') # Reference determinant section f.write('nocc %i\n' % (nelec[0] + nelec[1])) if SHCI.__class__.__name__ == 'FakeCISolver': for i in range(nelec[0]): f.write('%i ' % (2 * i)) for i in range(nelec[1]): f.write('%i ' % (2 * i + 1)) else: if SHCI.initialStates is not None: for i in range(len(SHCI.initialStates)): for j in SHCI.initialStates[i]: f.write('%i ' % (j)) if (i != len(SHCI.initialStates) - 1): f.write('\n') elif SHCI.irrep_nelec is None: for i in range(int(nelec[0])): f.write('%i ' % (2 * i)) for i in range(int(nelec[1])): f.write('%i ' % (2 * i + 1)) else: from pyscf import symm from pyscf.dmrgscf import dmrg_sym from pyscf.symm.basis import DOOH_IRREP_ID_TABLE if SHCI.groupname is not None and SHCI.orbsym is not []: orbsym = dmrg_sym.convert_orbsym(SHCI.groupname, SHCI.orbsym) else: orbsym = [1] * norb done = [] for k, v in SHCI.irrep_nelec.items(): irrep, nalpha, nbeta = [dmrg_sym.irrep_name2id(SHCI.groupname, k)],\ v[0], v[1] for i in range(len(orbsym)): #loop over alpha electrons if (orbsym[i] == irrep[0] and nalpha != 0 and i * 2 not in done): done.append(i * 2) f.write('%i ' % (i * 2)) nalpha -= 1 if (orbsym[i] == irrep[0] and nbeta != 0 and i * 2 + 1 not in done): done.append(i * 2 + 1) f.write('%i ' % (i * 2 + 1)) nbeta -= 1 if (nalpha != 0): print("number of irreps %s in active space = %d" % (k, v[0] - nalpha)) print("number of irreps %s alpha electrons = %d" % (k, v[0])) exit(1) if (nbeta != 0): print("number of irreps %s in active space = %d" % (k, v[1] - nbeta)) print("number of irreps %s beta electrons = %d" % (k, v[1])) exit(1) f.write('\nend\n') f.write('nroots %r\n' % SHCI.nroots) # Variational Keyword Section if (not Restart): schedStr = make_sched(SHCI) f.write(schedStr) else: f.write('schedule\n') f.write('%d %g\n' % (0, SHCI.sweep_epsilon[-1])) f.write('end\n') f.write('davidsonTol %g\n' % SHCI.davidsonTol) f.write('dE %g\n' % SHCI.dE) if (SHCI.DoRDM): f.write('DoRDM\n') # Perturbative Keyword Section if (SHCI.stochastic == False): f.write('deterministic \n') else: f.write('nPTiter %d\n' % SHCI.nPTiter) f.write('epsilon2 %g\n' % SHCI.epsilon2) f.write('epsilon2Large %g\n' % SHCI.epsilon2Large) f.write('targetError %g\n' % SHCI.targetError) f.write('sampleN %i\n' % SHCI.sampleN) # Miscellaneous Keywords f.write('noio \n') if (SHCI.prefix != ""): if not os.path.exists(SHCI.prefix): os.makedirs(SHCI.prefix) f.write('prefix %s\n' % (SHCI.prefix)) # Sets maxiter to 6 more than the last iter in sweep_iter[] if restarted. if (not Restart): f.write('maxiter %i\n' % (SHCI.sweep_iter[-1] + 6)) else: f.write('maxiter 6\n') f.write('fullrestart\n') f.write('\n') # SHCI requires that there is an extra line. f.write('%s\n' % (SHCI.extraline)) f.close()
def writeDMRGConfFile(DMRGCI, nelec, Restart, maxIter=None, with_2pdm=True, extraline=[]): confFile = os.path.join(DMRGCI.runtimeDir, DMRGCI.configFile) f = open(confFile, 'w') if isinstance(nelec, (int, numpy.integer)): neleca = nelec//2 + nelec%2 nelecb = nelec - neleca else : neleca, nelecb = nelec f.write('nelec %i\n'%(neleca+nelecb)) f.write('spin %i\n' %(neleca-nelecb)) if DMRGCI.groupname is not None: if isinstance(DMRGCI.wfnsym, str): wfnsym = dmrg_sym.irrep_name2id(DMRGCI.groupname, DMRGCI.wfnsym) else: import pyscf.symm if DMRGCI.groupname.lower() == 'dooh': gpname = 'D2h' elif DMRGCI.groupname.lower() == 'coov': gpname = 'C2v' else: gpname = pyscf.symm.std_symb(DMRGCI.groupname) assert(DMRGCI.wfnsym in dmrg_sym.IRREP_MAP[gpname]) wfnsym = DMRGCI.wfnsym f.write('irrep %i\n' % wfnsym) if (not Restart): #f.write('schedule\n') #f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-5, 10.0)) #f.write('1 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-5, 1e-4)) #f.write('10 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-6, 1e-5)) #f.write('16 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol/10.0, 0e-6)) #f.write('end\n') schedule = make_schedule(DMRGCI.scheduleSweeps, DMRGCI.scheduleMaxMs, DMRGCI.scheduleTols, DMRGCI.scheduleNoises, DMRGCI.twodot_to_onedot) f.write('%s\n' % schedule) else : f.write('schedule\n') #if approx == True : # f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol*10.0, 0e-6)) #else : # f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol, 0e-6)) f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol/10, 0e-6)) f.write('end\n') f.write('fullrestart\n') f.write('onedot \n') if DMRGCI.groupname is not None: if DMRGCI.groupname.lower() == 'dooh': f.write('sym d2h\n' ) elif DMRGCI.groupname.lower() == 'coov': f.write('sym c2v\n' ) else: f.write('sym %s\n' % DMRGCI.groupname.lower()) f.write('orbitals %s\n' % os.path.join(DMRGCI.runtimeDir, DMRGCI.integralFile)) if maxIter is None: maxIter = DMRGCI.maxIter f.write('maxiter %i\n'%maxIter) f.write('sweep_tol %8.4e\n'%DMRGCI.tol) f.write('outputlevel %s\n'%DMRGCI.outputlevel) f.write('hf_occ integral\n') if(with_2pdm and DMRGCI.twopdm): f.write('twopdm\n') if(DMRGCI.nonspinAdapted): f.write('nonspinAdapted\n') if(DMRGCI.scratchDirectory): f.write('prefix %s\n'%DMRGCI.scratchDirectory) if (DMRGCI.nroots !=1): f.write('nroots %d\n'%DMRGCI.nroots) if (DMRGCI.weights==[]): DMRGCI.weights= [1.0/DMRGCI.nroots]* DMRGCI.nroots f.write('weights ') for weight in DMRGCI.weights: f.write('%f '%weight) f.write('\n') for line in DMRGCI.block_extra_keyword: f.write('%s\n'%line) for line in extraline: f.write('%s\n'%line) f.close()
def writeDMRGConfFile(DMRGCI, nelec, Restart, maxIter=None, with_2pdm=True, extraline=[]): version = block_version(DMRGCI.executable) confFile = os.path.join(DMRGCI.runtimeDir, DMRGCI.configFile) f = open(confFile, 'w') if 'Block 1.1' not in version and DMRGCI.memory is not None: f.write('memory, %i, g\n'%(DMRGCI.memory)) if isinstance(nelec, (int, numpy.integer)): nelecb = (nelec-DMRGCI.spin) // 2 neleca = nelec - nelecb else : neleca, nelecb = nelec f.write('nelec %i\n'%(neleca+nelecb)) f.write('spin %i\n' %(neleca-nelecb)) if DMRGCI.groupname is not None: if isinstance(DMRGCI.wfnsym, str): wfnsym = dmrg_sym.irrep_name2id(DMRGCI.groupname, DMRGCI.wfnsym) else: gpname = dmrg_sym.d2h_subgroup(DMRGCI.groupname) assert(DMRGCI.wfnsym in dmrg_sym.IRREP_MAP[gpname]) wfnsym = DMRGCI.wfnsym f.write('irrep %i\n' % wfnsym) if (not Restart): #f.write('schedule\n') #f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-5, 10.0)) #f.write('1 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-5, 1e-4)) #f.write('10 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-6, 1e-5)) #f.write('16 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol/10.0, 0e-6)) #f.write('end\n') schedule = make_schedule(DMRGCI.scheduleSweeps, DMRGCI.scheduleMaxMs, DMRGCI.scheduleTols, DMRGCI.scheduleNoises, DMRGCI.twodot_to_onedot) f.write('%s\n' % schedule) else : f.write('schedule\n') #if approx == True : # f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol*10.0, 0e-6)) #else : # f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol, 0e-6)) f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol/10, 0e-6)) f.write('end\n') f.write('fullrestart\n') f.write('onedot \n') if DMRGCI.groupname is not None: f.write('sym %s\n' % dmrg_sym.d2h_subgroup(DMRGCI.groupname).lower()) f.write('orbitals %s\n' % os.path.join(DMRGCI.runtimeDir, DMRGCI.integralFile)) if maxIter is None: maxIter = DMRGCI.maxIter f.write('maxiter %i\n'%maxIter) f.write('sweep_tol %8.4e\n'%DMRGCI.tol) f.write('outputlevel %s\n'%DMRGCI.outputlevel) f.write('hf_occ integral\n') if(with_2pdm and DMRGCI.twopdm): f.write('twopdm\n') if(DMRGCI.nonspinAdapted): f.write('nonspinAdapted\n') if(DMRGCI.scratchDirectory): f.write('prefix %s\n'%DMRGCI.scratchDirectory) if (DMRGCI.nroots !=1): f.write('nroots %d\n'%DMRGCI.nroots) if (DMRGCI.weights==[]): DMRGCI.weights= [1.0/DMRGCI.nroots]* DMRGCI.nroots f.write('weights ') for weight in DMRGCI.weights: f.write('%f '%weight) f.write('\n') if 'Block 1.1' not in version: f.write('num_thrds %d\n'%DMRGCI.num_thrds) for line in DMRGCI.extraline: if not ('Block 1.1' in version and ('num_thrds' in line or 'memory' in line)): f.write('%s\n'%line) for line in DMRGCI.block_extra_keyword: if not ('Block 1.1' in version and ('num_thrds' in line or 'memory' in line)): f.write('%s\n'%line) for line in extraline: if not ('Block 1.1' in version and ('num_thrds' in line or 'memory' in line)): f.write('%s\n'%line) f.close()
def writeDMRGConfFile(DMRGCI, nelec, Restart, maxIter=None, with_2pdm=True, extraline=[]): confFile = os.path.join(DMRGCI.runtimeDir, DMRGCI.configFile) f = open(confFile, 'w') if isinstance(nelec, (int, numpy.integer)): neleca = nelec // 2 + nelec % 2 nelecb = nelec - neleca else: neleca, nelecb = nelec f.write('nelec %i\n' % (neleca + nelecb)) f.write('spin %i\n' % (neleca - nelecb)) if DMRGCI.groupname is not None: if isinstance(DMRGCI.wfnsym, str): wfnsym = dmrg_sym.irrep_name2id(DMRGCI.groupname, DMRGCI.wfnsym) else: import pyscf.symm if DMRGCI.groupname.lower() == 'dooh': gpname = 'D2h' elif DMRGCI.groupname.lower() == 'coov': gpname = 'C2v' else: gpname = pyscf.symm.std_symb(DMRGCI.groupname) assert (DMRGCI.wfnsym in dmrg_sym.IRREP_MAP[gpname]) wfnsym = DMRGCI.wfnsym f.write('irrep %i\n' % wfnsym) if (not Restart): #f.write('schedule\n') #f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-5, 10.0)) #f.write('1 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-5, 1e-4)) #f.write('10 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, 1e-6, 1e-5)) #f.write('16 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol/10.0, 0e-6)) #f.write('end\n') schedule = make_schedule(DMRGCI.scheduleSweeps, DMRGCI.scheduleMaxMs, DMRGCI.scheduleTols, DMRGCI.scheduleNoises, DMRGCI.twodot_to_onedot) f.write('%s\n' % schedule) else: f.write('schedule\n') #if approx == True : # f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol*10.0, 0e-6)) #else : # f.write('0 %6i %8.4e %8.4e \n' %(DMRGCI.maxM, DMRGCI.tol, 0e-6)) f.write('0 %6i %8.4e %8.4e \n' % (DMRGCI.maxM, DMRGCI.tol / 10, 0e-6)) f.write('end\n') f.write('fullrestart\n') f.write('onedot \n') if DMRGCI.groupname is not None: if DMRGCI.groupname.lower() == 'dooh': f.write('sym d2h\n') elif DMRGCI.groupname.lower() == 'coov': f.write('sym c2v\n') else: f.write('sym %s\n' % DMRGCI.groupname.lower()) f.write('orbitals %s\n' % os.path.join(DMRGCI.runtimeDir, DMRGCI.integralFile)) if maxIter is None: maxIter = DMRGCI.maxIter f.write('maxiter %i\n' % maxIter) f.write('sweep_tol %8.4e\n' % DMRGCI.tol) f.write('outputlevel %s\n' % DMRGCI.outputlevel) f.write('hf_occ integral\n') if (with_2pdm and DMRGCI.twopdm): f.write('twopdm\n') if (DMRGCI.nonspinAdapted): f.write('nonspinAdapted\n') if (DMRGCI.scratchDirectory): f.write('prefix %s\n' % DMRGCI.scratchDirectory) if (DMRGCI.nroots != 1): f.write('nroots %d\n' % DMRGCI.nroots) if (DMRGCI.weights == []): DMRGCI.weights = [1.0 / DMRGCI.nroots] * DMRGCI.nroots f.write('weights ') for weight in DMRGCI.weights: f.write('%f ' % weight) f.write('\n') for line in DMRGCI.block_extra_keyword: f.write('%s\n' % line) for line in extraline: f.write('%s\n' % line) f.close()