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(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()