sh.write(tmp_row, tmp_col+7, 'SP Energy in energy') sh.write(tmp_row, tmp_col+8, 'SP Energy (0 K) in energy corrected with freq scaling factor') sh.write(tmp_row, tmp_col+9, 'SP Enthalpy (298.15 K) in energy corrected with freq scaling factor') sh.write(tmp_row, tmp_col+10, 'Multiplicity') sh.write(tmp_row, tmp_col+11, 'External Symmetry Number') sh.write(tmp_row, tmp_col+12, 'Geometry') sh.write(tmp_row, tmp_col+13, 'Frequencies') tmp_row = 1 tmp_col = 0 for i in xrange(speciesNum): sh.write(tmp_row, tmp_col, name[i]) sh.write(tmp_row, tmp_col+1, name[i]) sh.write(tmp_row, tmp_col+2, formula[i]) sh.write(tmp_row, tmp_col+3, atomsNum[i]) sh.write(tmp_row, tmp_col+4, optEnergy[i]) sh.write(tmp_row, tmp_col+5, optZPE[i]) sh.write(tmp_row, tmp_col+6, optEnthalpy[i]) sh.write(tmp_row, tmp_col+7, SPEnergy[i]) # ZPE scaling factor from Truhlar used here sh.write(tmp_row, tmp_col+8, SPEnergy[i] + (optZPE[i]-optEnergy[i])*0.977) sh.write(tmp_row, tmp_col+9, SPEnergy[i] + (optZPE[i]-optEnergy[i])*0.977 + optEnthalpy[i]-optZPE[i]) sh.write(tmp_row, tmp_col+10, multi[i]) sh.write(tmp_row, tmp_col+11, RSN[i]) sh.write(tmp_row, tmp_col+12, textExtractor.geometryExtractor(geom[i]).replace('\t',' ')) sh.write(tmp_row, tmp_col+13, ' '.join(freq[i])) tmp_row += 1 wb.close()
multi = int(tmp_m.group(1)) multi_done = 1 elif optimized_done != 1: tmp_m = pattern_optimized.match(tmp_line) if tmp_m: optimized_done = 1 elif standard_done != 1: tmp_m = pattern_standard.match(tmp_line) if tmp_m: tmp_num = lineNum + 5 standard_done = 1 elif coordinate_done != 1: tmp_m = pattern_endline.match(tmp_line) if tmp_m: if lineNum > tmp_num: tmp_geom = textExtractor.geometryExtractor(tmp_lines[tmp_num: lineNum]) coordinate_done = 1 fw = file(os.path.join('..', '_i_radicalSPEnergy', tmp_file[0]+'.gjf'), 'w') fw.write( '''%mem=28GB %nprocshared=12 %chk=''' + tmp_file[0] + '''.chk #p B3LYP/6-31G(d) opt freq using B3LYP/6-31G(d) to do opt and freq calc. 0 '''+str(multi) + '\n' + tmp_geom + '\n\n\n\n\n\n') fw.close() fr.close() else: print 'Error! There is no jobs about molecule ' + tmp_mole
multi = int(tmp_m.group(1)) multi_done = 1 elif optimized_done != 1: tmp_m = pattern_optimized.match(tmp_line) if tmp_m: optimized_done = 1 elif standard_done != 1: tmp_m = pattern_standard.match(tmp_line) if tmp_m: tmp_num = lineNum + 5 standard_done = 1 elif coordinate_done != 1: tmp_m = pattern_endline.match(tmp_line) if tmp_m: if lineNum > tmp_num: tmp_geom = textExtractor.geometryExtractor( tmp_lines[tmp_num:lineNum]) coordinate_done = 1 fw = file(os.path.join('..', '_g_SPEnergy', tmp_file[0] + '.gjf'), 'w') fw.write('''%mem=28GB %nprocshared=12 %chk=''' + tmp_file[0] + '''.chk #p B3LYP/6-31G(d) opt freq using B3LYP/6-31G(d) to do opt and freq calc. 0 ''' + str(multi) + '\n' + tmp_geom + '\n\n\n\n\n\n') fw.close() fr.close() else: print 'Error! There is no jobs about molecule ' + tmp_mole os.chdir('../')
def generateJobFromLog(self, fileName, path='', nosym=False, jobName=''): #variables multi = 1 #flags multi_done = -1 freqCom_done = -1 standard_done = -1 coordinate_done = -1 # temporary variables tmp_m = [] tmp_num = 0 if jobName == '': tmp_dir = fileName[0:-4] + '_2_cbs' else: tmp_dir = jobName if path == '': tmp_dir_path = tmp_dir fr = file(fileName, 'r') else: tmp_dir_path = os.path.join(path, tmp_dir) fr = file(os.path.join(path, fileName), 'r') tmp_lines = fr.readlines() for (lineNum, tmp_line) in enumerate(tmp_lines): if multi_done != 1: tmp_m = pattern_logMulti.match(tmp_line) if tmp_m: multi = int(tmp_m.group(1)) multi_done = 1 elif freqCom_done != 1: if lineNum < len(tmp_lines) - 1: tmp2_line = tmp_lines[lineNum].strip() + tmp_lines[lineNum+1].strip() tmp_m = pattern_logFreqCom.match(tmp2_line) if tmp_m: freqCom_done = 1 elif standard_done != 1: if nosym == False: tmp_m = pattern_logStandard.match(tmp_line) else: tmp_m = pattern_logInput.match(tmp_line) if tmp_m: tmp_num = lineNum + 5 standard_done = 1 elif coordinate_done != 1: tmp_m = pattern_logEndline.match(tmp_line) if tmp_m: if lineNum > tmp_num: tmp_geom = textExtractor.geometryExtractor(tmp_lines[tmp_num: lineNum]) coordinate_done = 1 if os.path.exists(tmp_dir): shutil.rmtree(tmp_dir) os.mkdir(tmp_dir) fw = file(os.path.join(tmp_dir_path, tmp_dir+'.gjf'), 'w') if self.name == 'Tianhe' or self.name == 'Tianhe2': fw.write( '''%mem=16GB %nprocshared=12 ''') else: fw.write( '''%mem=28GB %nprocshared=12 ''') if self._TS == False: fw.write('#p cbs-qb3') else: fw.write('#p cbs-qb3 opt=(TS, calcfc) freq') if self._dispersionD3 == False: fw.write('\n') else: print 'Warning! It should be verified whether D3 could be used in CBS-QB3 calculation!' fw.write(' EmpiricalDispersion=GD3\n') fw.write(''' using ub3lyp/6-31G(d) to scan 0 ''') fw.write(''.join([str(multi), '\n', tmp_geom]) + '\n\n\n\n\n') fw.close() os.system("..\\dos2unix-6.0.6-win64\\bin\\dos2unix.exe " + fw.name + ' > log_dos2unix.txt 2>&1') fw = file(os.path.join(tmp_dir_path, tmp_dir+'.job'), 'w') if self.name == 'cce': if self._g09D01 == False: fw.write( # cce cluster '''#!/bin/csh # #$ -cwd #$ -j y #$ -S /bin/csh # setenv GAUSS_SCRDIR /state/partition1 setenv g09root /share/apps source $g09root/g09/bsd/g09.login cd ''' + self.jobLocation + '/' + tmp_dir + ''' $g09root/g09/g09 ''' + tmp_dir + '''.gjf $g09root/g09/formchk ''' + tmp_dir + '''.chk ''') else: fw.write( # cce cluster '''#!/bin/csh # #$ -cwd #$ -j y #$ -S /bin/csh # setenv GAUSS_SCRDIR /state/partition1 setenv g09root /home/hetanjin/apps/g09D01 source $g09root/g09/bsd/g09.login cd ''' + self.jobLocation + '/' + tmp_dir + ''' $g09root/g09/g09 ''' + tmp_dir + '''.gjf $g09root/g09/formchk ''' + tmp_dir + '''.chk ''') elif self.name == 'Tsinghua100': fw.write( # Tsinghua100 cluster '''#BSUB -J ''' + tmp_dir + ''' #BSUB -q hpc_linux #BSUB -R "select[mem>30000]" #BSUB -n 12 #BSUB -R "span[hosts=1]" #BSUB -o ''' + self.jobLocation + '/' + tmp_dir + '''/output.%J #BSUB -e ''' + self.jobLocation + '/' + tmp_dir + '''/error.%J export g09root=/home/hexin/gaussian export GAUSS_SCRDIR=/scratch source $g09root/g09/bsd/g09.profile ''') if self._scratchStrategy == True: fw.write( '''rm /scratch/* cd ''' + self.jobLocation + '/' + tmp_dir + ''' $g09root/g09/g09 ''' + tmp_dir + '''.gjf ''' + tmp_dir + '''.log $g09root/g09/formchk /scratch/''' + tmp_dir + '''.chk cp /scratch/''' + tmp_dir + '''.chk ''' + tmp_dir + '''.chk cp /scratch/''' + tmp_dir + '''.fchk ''' + tmp_dir + '''.fchk rm /scratch/* ''') else: fw.write( '''cd ''' + self.jobLocation + '/' + tmp_dir + ''' $g09root/g09/g09 ''' + tmp_dir + '''.gjf ''' + tmp_dir + '''.log $g09root/g09/formchk ''' + tmp_dir + '''.chk ''') elif self.name == 'Tianhe': if self._g09D01 == False: fw.write( # Tianhe cluster '''#!/bin/bash cd ''' + self.jobLocation + '/' + tmp_dir + ''' /vol-th/home/you/g09/g09 ''' + tmp_dir + '''.gjf ''') else: fw.write( # Tianhe cluster '''#!/bin/bash export GAUSS_SCRDIR=/vol-th/home/you/scratch export g09root=/vol-th/home/you/softwares/gaussian/g09D01 source $g09root/g09/bsd/g09.profile cd ''' + self.jobLocation + '/' + tmp_dir + ''' $g09root/g09/g09 ''' + tmp_dir + '''.gjf ''') elif self.name == 'Tianhe2': if self._g09D01 == False: fw.write( # Tianhe cluster '''#!/bin/bash cd ''' + self.jobLocation + '/' + tmp_dir + ''' /vol-th/home/you1/g09/g09 ''' + tmp_dir + '''.gjf ''') else: fw.write( # Tianhe cluster '''#!/bin/bash export GAUSS_SCRDIR=/vol-th/home/you1/scratch export g09root=/vol-th/home/you1/softwares/gaussian/g09D01 source $g09root/g09/bsd/g09.profile cd ''' + self.jobLocation + '/' + tmp_dir + ''' $g09root/g09/g09 ''' + tmp_dir + '''.gjf ''') fw.close() os.system("..\\dos2unix-6.0.6-win64\\bin\\dos2unix.exe " + fw.name + ' > log_dos2unix.txt 2>&1')
sh.write(tmp_row, tmp_col + 10, 'Multiplicity') sh.write(tmp_row, tmp_col + 11, 'External Symmetry Number') sh.write(tmp_row, tmp_col + 12, 'Geometry') sh.write(tmp_row, tmp_col + 13, 'Frequencies') tmp_row = 1 tmp_col = 0 for i in xrange(speciesNum): sh.write(tmp_row, tmp_col, name[i]) sh.write(tmp_row, tmp_col + 1, name[i]) sh.write(tmp_row, tmp_col + 2, formula[i]) sh.write(tmp_row, tmp_col + 3, atomsNum[i]) sh.write(tmp_row, tmp_col + 4, optEnergy[i]) sh.write(tmp_row, tmp_col + 5, optZPE[i]) sh.write(tmp_row, tmp_col + 6, optEnthalpy[i]) sh.write(tmp_row, tmp_col + 7, SPEnergy[i]) # ZPE scaling factor from Truhlar used here sh.write(tmp_row, tmp_col + 8, SPEnergy[i] + (optZPE[i] - optEnergy[i]) * 0.977) sh.write( tmp_row, tmp_col + 9, SPEnergy[i] + (optZPE[i] - optEnergy[i]) * 0.977 + optEnthalpy[i] - optZPE[i]) sh.write(tmp_row, tmp_col + 10, multi[i]) sh.write(tmp_row, tmp_col + 11, RSN[i]) sh.write(tmp_row, tmp_col + 12, textExtractor.geometryExtractor(geom[i]).replace('\t', ' ')) sh.write(tmp_row, tmp_col + 13, ' '.join(freq[i])) tmp_row += 1 wb.close()
print 'Error! ' + tmp_species + ' not found in mole_dict!' break molecule1.getLogGeom(mole_dict[tmp_species]) molecule1.fulfillBonds() molecule1.calcFormula() tmp_groups = molecule1.get1stOrderGroup() tmp_groupDict = {} for tmp_atom in molecule1.atoms: if tmp_atom.symbol != 'H': tmp_groupDict[tmp_atom.label] = tmp_groups.pop(0) if len(tmp_groups) != 0: print 'Error! The number of groups is larger than the number of non-H atoms!' shw.write(tmp_row, tmp_col, tmp_species) shw.write(tmp_row, tmp_col+1, tmp_species) shw.write(tmp_row, tmp_col+2, molecule1.formula) shw.write(tmp_row, tmp_col+3, textExtractor.geometryExtractor(mole_dict[tmp_species]).replace('\t',' ')) for tmp_rot in HR_dict[tmp_species]: tmp_list = sorted([tmp_groupDict[tmp_rot[0]], tmp_groupDict[tmp_rot[1]]]) tmp_rotText = tmp_list[0] + '-' + tmp_list[1] shw.write(tmp_row, tmp_col+4, tmp_rotText) shw.write(tmp_row, tmp_col+5, tmp_rot[0]) shw.write(tmp_row, tmp_col+6, tmp_rot[1]) for (i, tmp_T) in enumerate(temperature): shw.write(tmp_row, tmp_col+7+i, tmp_rot[5][tmp_T]) tmp_row += 1 wbw.close()