def orc(path, File, template, sysData, jobTemp): import re from supercomp import host from templates import orc_rjnJob from write import write_inp from write import write_job name = File.replace('.xyz', '').split('_')[0] # MAKE NEW DIR AND NEW PATH npath = newDir(path, File, template) # UNPACK sysData fragList, atmList, totChrg, totMult = sysData # CREATE xyzData xyzData = [] for frag in fragList: for atm in atmList: if atm['id'] in frag['ids']: xyzData.append( [atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) # PUT XYZ IN TEMPLATE input = xyzTemp(path, template, xyzData) for i in range(len(input)): if type(input[i]) != list: # CHANGE CHRG AND MULT if re.search('^\*xyzfile\s*-?[0-9]\s*-?[0-9]\s*', input[i]): if totChrg == '?': print("Cannot determine chrg/mult, using template values") # IF CHRG = MULT COULD BE TRICKY else: line = input[i].split() if '.xyz' in line[-1]: input[i] = '*xyzfile ' + str(totChrg) + ' ' + str( totMult) + ' ' + line[-1] if re.search('.xyz', input[i]): line = input[i].strip() line = line.rsplit(' ', 1)[0] input[i] = line + ' ' + name + '.xyz\n' # WRITE INP write_inp(npath, name, input) # WRITE JOB lines = False if jobTemp: lines = job_replace(name, jobTemp) else: hw = host() if hw == 'rjn': lines = orc_rjnJob(name) if lines: write_job(npath, name, lines)
def psi(path, File, template, sysData, jobTemp): import re from general import xyzPull from general import hardware from system import systemData from templates import psi_rjnJob from templates import psi_gaiJob from write import write_inp from write import write_job name = File.replace('.xyz', '').split('_')[0] # MAKE NEW DIR AND NEW PATH npath = newDir(path, File, template) # UNPACK sysData fragList, atmList, totChrg, totMult = sysData # CREATE xyzData xyzData = [] for frag in fragList: for ID in frag['ids']: atm = atmList[ID] xyzData.append([atm['sym'], atm["x"], atm["y"], atm["z"]]) # PUT XYZ IN TEMPLATE input = xyzTemp(path, template, xyzData) for i in range(len(input)): if type(input[i]) != list: # CHANGE CHRG AND MULT if re.search('^\s*-?[0-9]\s*-?[0-9]\s*$', input[i]): if totChrg == '?': print("Cannot determine chrg/mult, using template values") # IF CHRG = MULT COULD BE TRICKY else: input[i] = ' ' + str(totChrg) + ' ' + str(totMult) + '\n' # WRITE INP write_inp(npath, name, input) # MEMORY for line in input: if 'memory' in line: line = line.split() memory = int(line[1]) # WRITE JOB if jobTemp: lines = job_replace(name, jobTemp) else: hw = hardware() if hw == 'rjn': lines = psi_rjnJob(name) if hw == 'gai': lines = psi_gaiJob(name) write_job(npath, name, lines)
def g09(path, File, template, sysData): # CREATES JOB FILE FROM TEMPLATE AND .xyz import re from write import write_job name = File.replace('.xyz', '').split('_')[0] # FOR MORE THAN ONE TEMPLATE IN DIR temp = numTemp(path) if temp > 1: name = name + '-' + template.replace('.template', '')\ .replace('template', '') # UNPACK LIST fragList, atmList, totChrg, totMult = sysData # CREATE xyzData xyzData = [] for frag in fragList: for atm in atmList: if atm['id'] in frag['ids']: xyzData.append( [atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) # PUT XYZ COORDS IN TEMPLATE input = xyzTemp(path, template, xyzData) # ADD COORDS IN TEMPLATE for i in range(len(input)): if type(input[i]) != list: # CHANGE NAMES BEFORE LOG ETC. input[i] = job_replace(name, input[i]) # CHANGE CHARGE AND MULT if re.search('^\s*-?[0-9]\s*-?[0-9]\s*$', input[i]): # DON'T CHANGE IF NOT KNOWN if totChrg == '?': print("Cannot determine chrg/mult, using template values") # IF CHRG = MULT COULD BE TRICKY else: input[i] = str(totChrg) + ' ' + str(totMult) + '\n' write_job(path, name, input)
def fmo(path, File, template, sysData, jobTemp): import os, re from supercomp import host from chemData import pTable from templates import fmo_rjnJob from templates import fmo_mgsJob from templates import fmo_stmJob from templates import fmo_gaiJob from templates import fmo_monJob from templates import fmo_masJob from templates import gms_rjnJob from templates import gms_mgsJob from templates import gms_masJob from templates import gms_monJob from templates import gms_gaiJob from templates import gms_stmJob from tempInp import fmo_ions from write import write_xyz from write import write_gmsInp from write import write_job # NAME FOR WRITING FILE, DIRS ions = False name = File.replace('.xyz', '').split('_')[0] # MAKE NEW DIR AND NEW PATH npath = newDir(path, File, template) # UNPACK sysData mp2 = False fragList, atmList, totChrg, totMult = sysData # NUMBER OF FRAGS nfrags = len(fragList) # CREATE xyzData xyzData = [] for frag in fragList: for atm in atmList: if atm['id'] in frag['ids']: xyzData.append( [atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) # TEMPLATE LINES input = xyzTemp(path, template, xyzData) fmo_input = [] # IF RUNTYP IS ENERGY MAKE ION JOBS for ind in range(len(input)): if 'NGROUP' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'NGROUP': in_grp = spl_line[val + 1] if in_grp != str(nfrags): #print('Changing NGROUP to', nfrags) input[ind] = input[ind].\ replace('NGROUP=' + in_grp, 'NGROUP=' + str(nfrags)) # CHECK NFRAG = NO. OF FOUND FRAGMENTS if 'NFRAG' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'NFRAG': in_nfrags = spl_line[val + 1] if in_nfrags != str(nfrags): #print('Changing NFRAG to', nfrags) input[ind] = input[ind].\ replace('NFRAG=' + in_nfrags, 'NFRAG=' + str(nfrags)) # LIST OF CHARGES FOR FRAGMENTS if 'ICHARG' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if 'ICHARG' in bit: in_chrg = spl_line[val + 1] chrgs = [] for frag in fragList: chrgs.append(frag['chrg']) input[ind] = input[ind].replace('ICHARG(1)=' + in_chrg, \ 'ICHARG(1)=' + ','.join(str(p) for p in chrgs) + '\n') # MULT if 'MULT' in input[ind]: spl_line = re.split('=', input[ind]) for val, bit in enumerate(spl_line): if 'MULT' in bit: mults = [] for frag in fragList: mults.append(frag['mult']) in_chrg = spl_line[val + 1] input[ind] = input[ind].replace('MULT(1)=' + in_chrg,\ 'MULT(1)=' + ','.join(str(p) for p in mults) + '\n') # CHECK IF SPEC FOR ION CALCS if 'RUNTYP' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if 'RUNTYP' in bit: if spl_line[val + 1] == 'ENERGY': ions = True # MEMORY USED IN INPUT USED FOR JOB MEMORY if 'MWORDS' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'MWORDS' in input[ind]: memory = spl_line[val + 1] # MEMORY USED IN INPUT FOR JOB MEMORY ddi = False if 'MEMDDI' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'MEMDDI' in input[ind]: ddi = spl_line[val + 1] # FOR FMO_IONS if '$MP2' in input[ind]: mp2 = input[ind] if "GBASIS" in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'GBASIS' in input[ind]: bset = spl_line[val + 1] # REMOVE LINES FROM INPUT WITH NEW LIST # FOR MANY LINE CHANGES - COORDS, INDAT, ATM LIST atmUniq = [] numUniq = [] seenA = False for line in input: if type(line) != list: # INDAT MAY BE DIFF NUMBER OF LINES TO NEW INDAT if 'INDAT' in line: fmo_input.append(' INDAT(1)=0,1,-' + str(len(fragList[0]['ids'])) + ',\n') # REMEMBER WHERE LAST FRAG FINISHED n = len(fragList[0]['ids']) + 1 for frag in fragList: if not frag is fragList[0]: fmo_input.append(' '*13 + '0,' + str(n) + \ ',-' + str(n + len(frag['ids']) - 1) + ',\n') n += len(frag['ids']) fmo_input.append(' ' * 13 + '0\n') # SO NOT PASSED TO ELSE // EXTRA LINES TO DETERMINE FRAGMENT elif re.search('^\s*0,[0-9]{1,3},-[0-9]{1,3},\s*$', line) or \ re.search('^\s*0\s*$', line): pass # ATOM LIST MAY BE DIFF NUMBER OF LINES TO NEW ATOM LIST elif re.search('^\s*[A-Za-z]*\s*[0-9]*\.0*$', line): if not seenA: for i in xyzData: atmUniq.append(i[0]) numUniq.append(i[1]) atmUniq = list(set(atmUniq)) for i in range(len(atmUniq)): for sym, data in pTable.items(): if sym == atmUniq[i]: fmo_input.append(' ' + str(atmUniq[i]) + ' ' + \ str(data[0]) + '\n') seenA = True # EVERY OTHER LINE AS IS else: fmo_input.append(line) else: fmo_input.append(line) # HARDWARE FOR WRITING hw = host() if ions: # FOR EACH FRAGMENT for frag in fragList: ifrag = [] for ID in frag['ids']: atm = atmList[ID] ifrag.append( [atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) # MAKE FOLDER AND XYZ if not os.path.isdir(npath + name + '-' + frag["name"]): os.mkdir(npath + name + '-' + frag["name"]) write_xyz(npath + name + '-' + frag["name"] + '/', name + '-' + frag["name"], ifrag) # INPUT AND OUTPUT FOR JOB input = fmo_ions(str(frag['chrg']), ifrag, bset, mp2) write_gmsInp(npath + name + '-' + frag["name"] + '/', name + '-' + frag["name"], input) # WRITE JOB lines = False if jobTemp: # lines = job_replace(name, jobTemp) lines = job_replace(name + '-' + frag["name"], jobTemp) else: if hw == 'rjn': lines = gms_rjnJob(name + '-' + frag["name"]) elif hw == 'mgs': lines = gms_mgsJob(name + '-' + frag["name"]) elif hw == 'gai': lines = gms_gaiJob(name + '-' + frag["name"]) elif hw == 'mas': lines = gms_masJob(name + '-' + frag["name"]) elif hw == 'mon': lines = gms_monJob(name + '-' + frag["name"]) elif hw == 'stm': lines = gms_stmJob(name + '-' + frag["name"]) if lines: write_job(npath + name + '-' + frag["name"] + '/', name + '-' + frag["name"], lines) # ------------------------------------------------- # WRITE INP write_gmsInp(npath, name, fmo_input) # WRITE JOB lines = False if jobTemp: lines = job_replace(name, jobTemp) else: if hw == 'rjn': lines = fmo_rjnJob(name, nfrags, memory, ddi) elif hw == 'mgs': lines = fmo_mgsJob(name, nfrags, memory, ddi) elif hw == 'stm': lines = fmo_stmJob(name, nfrags, memory, ddi) elif hw == 'gai': lines = fmo_gaiJob(name) #, nfrags, memory, ddi) elif hw == 'mon': lines = fmo_monJob(name, nfrags, memory, ddi) elif hw == 'mas': lines = fmo_masJob(name, nfrags, memory, ddi) if lines: write_job(npath, name, lines)
def gms(path, File, template, sysData, jobTemp): import re from supercomp import host from templates import gms_rjnJob from templates import gms_mgsJob from templates import gms_gaiJob from templates import gms_masJob from templates import gms_monJob from templates import gms_stmJob from write import write_gmsInp from write import write_job name = File.replace('.xyz', '').split('_')[0] # MAKE NEW DIR AND NEW PATH npath = newDir(path, File, template) # UNPACK sysData fragList, atmList, totChrg, totMult = sysData # CREATE xyzData xyzData = [] for frag in fragList: for atm in atmList: if atm['id'] in frag['ids']: xyzData.append( [atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) # GET TEMPLATE LINES WITH COORDS input = xyzTemp(path, template, xyzData) # CHARGE AND MULT for ind in range(len(input)): if 'ICHARG' in input[ind]: if totChrg == '?': print("Cannot determine chrg/mult, using template values") else: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'ICHARG': oldChrg = spl_line[val + 1] input[ind] = input[ind].replace('ICHARG=' + \ oldChrg, 'ICHARG=' + str(totChrg)) if totMult != 0: if 'CONTRL' in input[ind]: if totChrg == '?': print("Cannot determine chrg/mult, using template values") elif not 'MULT' in input[ind]: input[ind] = input[ind].\ replace(' RUN',' MULT=' + str(totMult) + ' RUN') # MEMORY USED IN INPUT if 'MWORDS' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'MWORDS' in input[ind]: memory = spl_line[val + 1] # MEMORY USED IN INPUT ddi = False if 'MEMDDI' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'MEMDDI' in input[ind]: ddi = spl_line[val + 1] # WRITE INP write_gmsInp(npath, name, input) # WRITE JOB lines = False if jobTemp: lines = job_replace(name, jobTemp) else: hw = host() if hw == 'rjn': lines = gms_rjnJob(name) elif hw == 'mgs': lines = gms_mgsJob(name) elif hw == 'gai': lines = gms_gaiJob(name) elif hw == 'mas': lines = gms_masJob(name) elif hw == 'mon': lines = gms_monJob(name) elif hw == 'stm': lines = gms_stmJob(name) if lines: write_job(npath, name, lines)
def g09(path, File, template, sysData): # CREATES JOB FILE FROM TEMPLATE AND .xyz import re from write import write_job name = File.replace('.xyz', '').split('_')[0] # FOR MORE THAN ONE TEMPLATE IN DIR temp = numTemp(path) if temp > 1: name = name + '-' + template.replace('.template', '')\ .replace('template', '') # UNPACK LIST fragList, atmList, totChrg, totMult = sysData # CREATE xyzData xyzData = [] for frag in fragList: for ID in frag['ids']: atm = atmList[ID] xyzData.append([atm['sym'], atm["x"], atm["y"], atm["z"]]) # PUT XYZ COORDS IN TEMPLATE input = xyzTemp(path, template, xyzData) # ADD COORDS IN TEMPLATE for i in range(len(input)): if type(input[i]) != list: # CHANGE NAMES BEFORE LOG Ect. input[i] = job_replace(name, input[i]) # CHANGE CHARGE AND MULT if re.search('^\s*-?[0-9]\s*-?[0-9]\s*$', input[i]): # DON'T CHANGE IF NOT KNOWN if totChrg == '?': print("Cannot determine chrg/mult, using template values") # IF CHRG = MULT COULD BE TRICKY else: input[i] = str(totChrg) + ' ' + str(totMult) + '\n' # CHANGE OUTPUT NAME # if re.search('\.log', input[i]) \ # or re.search('\.out', input[i]): # # KEEP LINE TO REPLACE # chng = input[i].split() # for val, bit in enumerate(chng): # print(chng) # if '.log' in bit: # print(bit) # n = val # # chng[n] = a1b3d2.log # input[i] = input[i].replace(chng[n], name + '.log') # # # CHANGE CHECKPOINT NAME # if re.search('%chk', input[i]): # %chk=reactant.chk # # KEEP LINE TO REPLACE # chng = input[i].split('=') # for val, bit in enumerate(chng): # if '%chk' in bit: # n = val + 1 # # chng[n] = a1b3d2.log # input[i] = input[i].replace(chng[n], name + '.chk\n') write_job(path, name, input)
def fmo(path, File, template, sysData, jobTemp): import os, re from general import hardware from chemData import pTable from templates import fmo_rjnJob from templates import fmo_mgsJob from templates import fmo_gaiJob from templates import gms_rjnJob from templates import gms_mgsJob from templates import gms_gaiJob from tempInp import fmo_ions from write import write_xyz from write import write_gmsInp from write import write_job # NAME FOR WRITING FILE, DIRS name = File.replace('.xyz', '').split('_')[0] # MAKE NEW DIR AND NEW PATH npath = newDir(path, File, template) # UNPACK sysData fmo = True mp2 = False fragList, atmList, totChrg, totMult = sysData # NUMBER OF FRAGS nfrags = len(fragList) # MAKE xyzData xyzData = [] # USE LIST OF IDS TO APPEND for frag in fragList: for ID in frag['ids']: atm = atmList[ID] xyzData.append( [atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) # TEMPLATE LINES input = xyzTemp(path, template, xyzData) #print(input) fmo_input = [] # ONE LINE REPLACEMENTS - NO MULT YET *** # IF RUNTYP IS ENERGY MAKE ION JOBS ions = False for ind in range(len(input)): if 'NGROUP' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'NGROUP': in_grp = spl_line[val + 1] if in_grp != str(nfrags): #print('Changing NGROUP to', nfrags) input[ind] = input[ind].\ replace('NGROUP=' + in_grp, 'NGROUP=' + str(nfrags)) # CHECK NFRAG = NO. OF FOUND FRAGMENTS if 'NFRAG' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'NFRAG': in_nfrags = spl_line[val + 1] if in_nfrags != str(nfrags): #print('Changing NFRAG to', nfrags) input[ind] = input[ind].\ replace('NFRAG=' + in_nfrags, 'NFRAG=' + str(nfrags)) # LIST OF CHARGES FOR FRAGMENTS if 'ICHARG' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if 'ICHARG' in bit: in_chrg = spl_line[val + 1] chrgs = [] for frag in fragList: chrgs.append(frag['chrg']) input[ind] = input[ind].replace('ICHARG(1)=' + in_chrg, \ 'ICHARG(1)=' + ','.join(str(p) for p in chrgs) + '\n') # MULT if 'MULT' in input[ind]: spl_line = re.split('=', input[ind]) for val, bit in enumerate(spl_line): if 'MULT' in bit: mults = [] for frag in fragList: mults.append(frag['mult']) in_chrg = spl_line[val + 1] input[ind] = input[ind].replace('MULT(1)=' + in_chrg,\ 'MULT(1)=' + ','.join(str(p) for p in mults) + '\n') # CHECK IF SPEC FOR ION CALCS if 'RUNTYP' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if 'RUNTYP' in bit: if spl_line[val + 1] == 'ENERGY': ions = True # MEMORY USED IN INPUT USED FOR JOB MEMORY if 'MWORDS' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'MWORDS' in input[ind]: memory = spl_line[val + 1] # MEMORY USED IN INPUT FOR JOB MEMORY ddi = False if 'MEMDDI' in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'MEMDDI' in input[ind]: ddi = spl_line[val + 1] # FOR FMO_IONS if '$MP2' in input[ind]: mp2 = input[ind] if "GBASIS" in input[ind]: spl_line = re.split('=| ', input[ind]) for val, bit in enumerate(spl_line): if bit == 'GBASIS' in input[ind]: bset = spl_line[val + 1] # REMOVE LINES FROM INPUT WITH NEW LIST # FOR MANY LINE CHANGES - COORDS, INDAT, ATM LIST atmUniq = [] numUniq = [] seenA = False for line in input: if type(line) != list: # INDAT MAY BE DIFF NUMBER OF LINES TO NEW INDAT if 'INDAT' in line: fmo_input.append(' INDAT(1)=0,1,-' + str(fragList[0]['ids'][-1] + 1) + ',\n') for frag in fragList: if not frag is fragList[0]: fmo_input.append(' '*13 + '0,' + str(frag['ids'][0] + 1) + \ ',-' + str(frag['ids'][-1] + 1) + ',\n') fmo_input.append(' ' * 13 + '0\n') # SO NOT PASSED TO ELSE // EXTRA LINES TO DETERMINE FRAGMENT elif re.search('^\s*0,[0-9]{1,3},-[0-9]{1,3},\s*$', line) or \ re.search('^\s*0\s*$', line): pass # ATOM LIST MAY BE DIFF NUMBER OF LINES TO NEW ATOM LIST elif re.search('^\s*[A-Za-z]*\s*[0-9]*\.0*$', line): if not seenA: for i in xyzData: atmUniq.append(i[0]) numUniq.append(i[1]) atmUniq = list(set(atmUniq)) for i in range(len(atmUniq)): for sym, data in pTable.items(): if sym == atmUniq[i]: fmo_input.append(' ' + str(atmUniq[i]) + ' ' + \ str(data[0]) + '\n') seenA = True # EVERY OTHER LINE AS IS else: fmo_input.append(line) else: fmo_input.append(line) # HARDWARE FOR WRITING hw = hardware() # XYZ OF IONS ------------------------------------ if ions: ncat = 0 nani = 0 nnrt = 0 nunk = 0 # FOR EACH FRAGMENT for i, frag in enumerate(fragList): ifrag = [] for val, atm in enumerate(xyzData): if val in frag['ids']: ifrag.append(atm) # IN CASE QUESTION MARK try: if frag['chrg'] < 0: ion = 'anion' + str(nani) nani += 1 elif frag['chrg'] > 0: ion = 'cation' + str(ncat) ncat += 1 else: ion = 'neutral' + str(nnrt) nnrt += 1 except: if frag['chrg'] == '?': ion = 'unknown' + str(nunk) nunk += 1 # MAKE FOLDER AND XYZ if not os.path.isdir(npath + ion): os.mkdir(npath + ion) write_xyz(npath + ion + '/', ion, ifrag) # INPUT AND OUTPUT FOR JOB input = fmo_ions(str(frag['chrg']), ifrag, bset, mp2) write_gmsInp(npath + ion + '/', ion, input) # WRITE JOB if hw == 'rjn': lines = gms_rjnJob(ion, memory, ddi) if hw == 'mgs': lines = gms_mgsJob(ion, memory, ddi) if hw == 'gai': lines = gms_gaiJob(ion, memory, ddi) write_job(npath + fol + '/', ion, lines) # ------------------------------------------------- # WRITE INP write_gmsInp(npath, name, fmo_input) # WRITE JOB if jobTemp: lines = job_replace(name, jobTemp) else: if hw == 'rjn': lines = fmo_rjnJob(name, nfrags, memory, ddi) if hw == 'mgs': lines = fmo_mgsJob(name, nfrags, memory, ddi) if hw == 'gai': lines = fmo_gaiJob(name) #, nfrags, memory, ddi) write_job(npath, name, lines)
def orc_cpoise(path, File, template, sysData, jobTemp, dist): import os, re from supercomp import host from genJob import xyzTemp from genJob import job_replace from templates import orc_rjnJob from write import write_inp from write import write_xyz from write import write_job name = File.replace('.xyz', '').split('_')[0] # MAKE NEW DIR AND NEW PATH npath = newDirCP(path, File, template) # UNPACK sysData fragList, atmList, totChrg, totMult = sysData # IF NOT RADIAL CUTOFF FOR MOLS INCLUDED DO ALL if not dist: # FOR EACH FRAGMENT for frag in fragList: ifrag = [] for atm in atmList: if atm['id'] in frag['ids']: ifrag.append([atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) else: # MAKE OTHER FRAGS GHOST ifrag.append([atm['sym'] + ':'] + [atm['nu'], atm["x"], atm["y"], atm["z"]]) # MAKE FOLDERS if not os.path.isdir(npath + frag["name"]): os.mkdir(npath + frag["name"]) # PUT XYZ IN TEMP FOR EACH FRAG input = xyzTemp(path, template, ifrag) # CHANGE CHARGE AND MULTIPLICITY/MEMORY for i in range(len(input)): if type(input[i]) != list: # CHANGE CHRG AND MULT if re.search('^\*xyzfile\s*-?[0-9]\s*-?[0-9]\s*', input[i]): if totChrg == '?': print("Cannot determine chrg/mult, using template values") # IF CHRG = MULT COULD BE TRICKY else: line = input[i].split() if '.xyz' in line[-1]: input[i] = '*xyz ' + str(frag["chrg"]) + ' ' + str(frag["mult"]) + '\n' # ADD XYZ AS GHOST ATOMS for atm in ifrag: i += 1 input.insert(i, atm) # END XYZ input.insert(i+1, '*') # WILL CHANGE NUMBER OF LINES - DO NOT CONTINUE THIS LOOP break # WRITE INPUT FILE FOR EACH FRAG write_inp(npath + frag["name"] + '/', name +'-'+ frag["name"], input) # WRITE JOB lines = False if jobTemp: lines = job_replace(name +'-'+ frag["name"], jobTemp) else: hw = host() if hw == 'rjn': lines = orc_rjnJob(name +'-'+ frag["name"]) if lines: write_job(npath + frag["name"] + '/', name +'-'+ frag["name"], lines) # IF RADIAL CUTOFF FOR MOLS INCLUDED IN EACH FILE else: from xyzGenerate import xyzShell # GET < DIST SEPARATED FRAGS # xyzList = [frag, mol, ghost atoms] xyzList = xyzShell(path, File, sysData, dist, returnList=True) # FOR EACH FRAGMENT CENTER for frag, firstMol, otherMol in xyzList: ifrag = [] for atm in firstMol: ifrag.append([atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) for atm in otherMol: ifrag.append([atm['sym'] + ":"] + [atm['nu'], atm["x"], atm["y"], atm["z"]]) # MAKE FOLDERS if not os.path.isdir(npath + frag["name"]): os.mkdir(npath + frag["name"]) # PUT XYZ IN TEMP FOR EACH FRAG input = xyzTemp(path, template, ifrag) # CHANGE CHARGE AND MULTIPLICITY/MEMORY # MEMORY OF INPUT NEEDS TO BE >>> MEM JOB for i in range(len(input)): if type(input[i]) != list: # CHANGE CHRG AND MULT if re.search('^\*xyzfile\s*-?[0-9]\s*-?[0-9]\s*', input[i]): if totChrg == '?': print("Cannot determine chrg/mult, using template values") # IF CHRG = MULT COULD BE TRICKY else: line = input[i].split() if '.xyz' in line[-1]: input[i] = '*xyzfile ' + str(totChrg) + ' ' + str(totMult) + ' ' +line[-1] if re.search('.xyz', input[i]): line = input[i].strip() line = line.rsplit(' ', 1)[0] input[i] = line+' '+name+'-ghost.xyz\n' # WRITE GHOST FILE XYZ write_xyz(npath + frag["name"] + '/', frag["name"] + "-ghost", ifrag) # WRITE INPUT FILE FOR EACH FRAG write_inp(npath + frag["name"] + '/', frag["name"], input) # WRITE JOB lines = False if jobTemp: lines = job_replace(frag["name"], jobTemp) else: hw = host() if hw == 'rjn': lines = orc_rjnJob(frag["name"]) if lines: write_job(npath + frag["name"] + '/', frag["name"], lines)
def psi_cpoise(path, File, template, sysData, jobTemp, dist): import os, re from supercomp import host from genJob import xyzTemp from genJob import job_replace from templates import psi_rjnJob from templates import psi_gaiJob from templates import psi_masJob from write import write_inp from write import write_job name = File.replace('.xyz', '').split('_')[0] # MAKE NEW DIR AND NEW PATH npath = newDirCP(path, File, template) # UNPACK sysData fragList, atmList, totChrg, totMult = sysData # CREATE xyzData xyzData = [] for frag in fragList: for atm in atmList: if atm['id'] in frag['ids']: xyzData.append([atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) # PUT XYZ IN TEMPLATE input = xyzTemp(path, template, xyzData) # IF bsse_type='cp' PSI4 ONLY ONE CALC cp_type = False for line in input: if "bsse_type=" in line and "'cp'" in line: cp_type = True # IF bsse_type='cp' PSI4 ONLY ONE CALC if cp_type: # REMOVE EXTRA '--' AND CHARGE MULTIPLICITY cp_input = [] for line in input: if type(line) != list: if '--' in line: pass elif re.search('\s*-?[0-9]\s*[0-9]\s*', line): pass else: cp_input.append(line) else: cp_input.append(line) # COUNT WHICH ATOM UP TO count = 0 input = [] for i in range(len(cp_input)): # IF ATOM LINE if type(cp_input[i]) is list: # FOR EACH FRAG put = False for frag in fragList: # IF ATOM NUMBER LAST ATOMS OF FRAG if count == frag['ids'][0]: # IF NOT FIRST FRAG if not count == fragList[0]['ids'][0]: input.append('--\n') input.append(str(frag['chrg'])+' '+str(frag['mult'])+'\n') input.append(cp_input[i]) put = True if not put: input.append(cp_input[i]) count += 1 else: input.append(cp_input[i]) # WRITE INP write_inp(npath, name, input) # WRITE JOB lines = False if jobTemp: lines = job_replace(name, jobTemp) else: hw = host() if hw == 'rjn': lines = psi_rjnJob(name) elif hw == 'gai': lines = psi_gaiJob(name) elif hw == 'mas': lines = psi_masJob(name) if lines: write_job(npath, name, lines) # NORMAL INPUT ------------------------- else: # IF NOT RADIAL CUTOFF FOR MOLS INCLUDED DO ALL if not dist: for i in range(len(input)): if type(input[i]) != list: # CHANGE MEMORY to 64 #if 'memory' in input[i]: # line = input[i].split() # memory = line[1] # input[i] = input[i].replace(memory, '64') # CHANGE CHRG AND MULT if re.search('^\s*-?[0-9]\s*-?[0-9]\s*$', input[i]): # IF CHRG = MULT COULD BE TRICKY input[i] = ' ' + str(totChrg) + ' ' + str(totMult) + '\n' # WRITE INP write_inp(npath, name, input) # WRITE JOB lines = False if jobTemp: lines = job_replace(name, jobTemp) else: hw = host() if hw == 'rjn': lines = psi_rjnJob(name) elif hw == 'gai': lines = psi_gaiJob(name) elif hw == 'mas': lines = psi_masJob(name) if lines: write_job(npath, name, lines) # FOR EACH FRAGMENT for frag in fragList: ifrag = [] for atm in atmList: if atm['id'] in frag['ids']: ifrag.append([atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) else: # MAKE OTHER FRAGS GHOST ifrag.append(['@' + atm['sym']] + [atm['nu'], atm["x"], atm["y"], atm["z"]]) # MAKE FOLDERS if not os.path.isdir(npath + frag["name"]): os.mkdir(npath + frag["name"]) # PUT XYZ IN TEMP FOR EACH FRAG input = xyzTemp(path, template, ifrag) # CHANGE CHARGE AND MULTIPLICITY/MEMORY # MEMORY OF INPUT NEEDS TO BE >>> MEM JOB for i in range(len(input)): if type(input[i]) != list: # CHANGE CHRG AND MULT if re.search('^\s*-?[0-9]\s*-?[0-9]\s*$', input[i]): # IF CHRG = MULT COULD BE TRICKY input[i] = ' ' + str(frag['chrg']) + ' ' + str(totMult) + '\n' # WRITE INPUT FILE FOR EACH FRAG write_inp(npath + frag["name"] + '/', frag["name"], input) # WRITE JOB lines = False if jobTemp: lines = job_replace(frag["name"], jobTemp) else: hw = host() if hw == 'rjn': lines = psi_rjnJob(frag["name"]) elif hw == 'gai': lines = psi_gaiJob(frag["name"]) elif hw == 'mas': lines = psi_masJob(frag["name"]) if lines: write_job(npath + frag["name"] + '/', frag["name"], lines) # IF RADIAL CUTOFF FOR MOLS INCLUDED IN EACH FILE else: from xyzGenerate import xyzShell # GET < DIST SEPARATED FRAGS # xyzList = [frag, mol, ghost atoms] xyzList = xyzShell(path, File, sysData, dist, returnList=True) # FOR EACH FRAGMENT CENTER for frag, firstMol, otherMol in xyzList: ifrag = [] for atm in firstMol: ifrag.append([atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) for atm in otherMol: ifrag.append(['@' + atm['sym']] + [atm['nu'], atm["x"], atm["y"], atm["z"]]) # MAKE FOLDERS if not os.path.isdir(npath + frag["name"]): os.mkdir(npath + frag["name"]) # PUT XYZ IN TEMP FOR EACH FRAG input = xyzTemp(path, template, ifrag) # CHANGE CHARGE AND MULTIPLICITY/MEMORY # MEMORY OF INPUT NEEDS TO BE >>> MEM JOB for i in range(len(input)): if type(input[i]) != list: # CHANGE CHRG AND MULT if re.search('^\s*-?[0-9]\s*-?[0-9]\s*$', input[i]): # IF CHRG = MULT COULD BE TRICKY input[i] = ' ' + str(frag['chrg']) + ' ' + str(totMult) + '\n' # CHANGE MEMORY if re.search('memory', input[i]): line = re.split(' |G|g', input[i]) for bit in line: if re.search('[0-9]', bit): input[i] = input[i].replace(bit, '64') break # WRITE INPUT FILE FOR EACH FRAG write_inp(npath + frag["name"] + '/', frag["name"], input) # WRITE JOB lines = False if jobTemp: lines = job_replace(frag["name"], jobTemp) else: hw = host() if hw == 'rjn': lines = psi_rjnJob(frag["name"]) elif hw == 'gai': lines = psi_gaiJob(frag["name"]) elif hw == 'mas': lines = psi_masJob(frag["name"]) if lines: write_job(npath + frag["name"] + '/', frag["name"], lines)
def g09_cpoise(path, File, template, sysData, dist): # CREATES JOB FILE FROM TEMPLATE AND .xyz import re from genJob import xyzTemp from write import write_job # NAME AFTER COUNTERPOISE name = File.replace('.xyz', '').split('_')[0] # MAKE NEW DIR AND NEW PATH npath = newDirCP(path, File, template) # UNPACK sysData fragList, atmList, totChrg, totMult = sysData nfrags = len(fragList) if not dist: # CREATE xyzData xyzData = [] for frag in fragList: for atm in atmList: if atm['id'] in frag['ids']: xyzData.append([atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) # PUT XYZ IN TEMPLATE input = xyzTemp(path, template, xyzData) input_cp = input[:] # CHANGE INPUT LINES for i in range(len(input)): if type(input[i]) != list: # CHANGE CHRG AND MULT if re.search('^\s*-?[0-9]\s*-?[0-9]\s*$', input[i]): # IF CHRG = MULT COULD BE TRICKY input[i] = ' ' + str(totChrg) + ' ' + str(totMult) + '\n' # CHANGE OUTPUT NAME if re.search('\.log', input[i]) \ or re.search('\.out', input[i]): # KEEP LINE TO REPLACE chng = input[i].split() for val, bit in enumerate(chng): if '.log' in bit: n = val # chng[n] = a1b3d2.log input[i] = input[i].replace(chng[n], name + '.log') # WRITE JOB FOR TOTAL CALC write_job(npath, name, input) # WRITE JOB FOR CPOISE CORRECTION # MAKE SURE INTO INPUT inInput = False # COUNT PLACE IN COORDS t = 0 for i in range(len(input_cp)): if "module load" in input_cp[i]: inInput = True if inInput and type(input_cp[i]) != list: if "#" in input_cp[i]: if 'counterpoise' in input_cp[i]: input_cp[i] = input_cp[i].replace("counterpoise=*",'') else: input_cp[i] = input_cp[i].\ replace('\n'," counterpoise=" + str(nfrags) + '\n') elif re.search('^\s*-?[0-9]\s*-?[0-9]\s*$', input_cp[i]): # IF CHRG = MULT COULD BE TRICKY input_cp[i] = str(totChrg) + ',' + str(totMult) for frag in fragList: input_cp[i] += ' ' + str(frag['chrg']) + ',' + str(frag['mult']) input_cp[i] = input_cp[i] + '\n' # CHANGE OUTPUT NAME if re.search('\.log', input_cp[i]) or re.search('\.out', input_cp[i]): # KEEP LINE TO REPLACE chng = input_cp[i].split() for val, bit in enumerate(chng): if '.log' in bit: n = val # chng[n] = blahblah.log input_cp[i] = input_cp[i].replace(chng[n], 'cp-' + name + '.log') # FIND WHICH FRAG ATOM PART OF elif inInput and type(input_cp[i]) == list: atm = atmList[t] input_cp[i] = [atm['sym'], atm["x"], atm["y"], atm["z"], str(int(atm["grp"]) + 1)] # NUMBER ATOM t += 1 # WRITE COUNTERPOISE JOB write_job(npath, 'CP-'+ name, input_cp, cp = True) # FOR EACH FRAGMENT for frag in fragList: ifrag = [] for atm in atmList: if atm['id'] in frag['ids']: ifrag.append([atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) else: # MAKE OTHER FRAGS GHOST ifrag.append([atm['sym']+ '-Bq'] + [atm['nu'], atm["x"], atm["y"], atm["z"]]) # PUT XYZ IN TEMP FOR EACH FRAG input = xyzTemp(path, template, ifrag) # CHANGE CHARGE AND MULTIPLICITY/MEMORY # MEMORY OF INPUT NEEDS TO BE >>> MEM JOB for i in range(len(input)): if type(input[i]) != list: # CHANGE CHRG AND MULT if re.search('^\s*-?[0-9]\s*-?[0-9]\s*$', input[i]): # IF CHRG = MULT COULD BE TRICKY input[i] = ' ' + str(frag['chrg']) + ' ' + str(totMult) + '\n' # CHANGE MEMORY elif re.search(' mem', input[i]): line = re.split('=|G|g', input[i]) for bit in line: if re.search('[0-9]', bit): input[i] = input[i].replace(bit, '16') break elif re.search('%mem', input[i]): line = re.split('=|G|g', input[i]) for bit in line: if re.search('[0-9]', bit): input[i] = input[i].replace(bit, '14') break elif re.search('ncpus', input[i]): line = re.split('=', input[i]) for bit in line: if re.search('[0-9]', bit): input[i] = input[i].replace(bit, '8\n') break elif re.search('nprocshared', input[i]): line = re.split('=', input[i]) for bit in line: if re.search('[0-9]', bit): input[i] = input[i].replace(bit, '8\n') break # WRITE INPUT FILE FOR EACH FRAG write_job(npath, frag["name"], input) # DIST RADIUS TO EXCLUDE MOLS FROM CP CORRECTION else: from xyzGenerate import xyzShell # GET < DIST SEPARATED FRAGS # xyzList = [frag, mol, ghost atoms] xyzList = xyzShell(path, File, sysData, dist) # FOR EACH FRAGMENT CENTER for frag, firstMol, otherMol in xyzList: ifrag = [] for atm in firstMol: ifrag.append([atm['sym'], atm['nu'], atm["x"], atm["y"], atm["z"]]) for atm in otherMol: ifrag.append([atm['sym'] + '-Bq'] + [atm['nu'], atm["x"], atm["y"], atm["z"]]) # PUT XYZ IN TEMP FOR EACH FRAG input = xyzTemp(path, template, ifrag) # CHANGE CHARGE AND MULTIPLICITY/MEMORY # MEMORY OF INPUT NEEDS TO BE >>> MEM JOB for i in range(len(input)): if type(input[i]) != list: # CHANGE CHRG AND MULT if re.search('^\s*-?[0-9]\s*-?[0-9]\s*$', input[i]): # IF CHRG = MULT COULD BE TRICKY input[i] = ' ' + str(frag['chrg']) + ' ' + str(totMult) + '\n' # CHANGE MEMORY elif re.search(' mem', input[i]): line = re.split('=|G|g', input[i]) for bit in line: if re.search('[0-9]', bit): input[i] = input[i].replace(bit, '16') break elif re.search('%mem', input[i]): line = re.split('=|G|g', input[i]) for bit in line: if re.search('[0-9]', bit): input[i] = input[i].replace(bit, '14') break elif re.search('ncpus', input[i]): line = re.split('=', input[i]) for bit in line: if re.search('[0-9]', bit): input[i] = input[i].replace(bit, '8\n') break elif re.search('nprocshared', input[i]): line = re.split('=', input[i]) for bit in line: if re.search('[0-9]', bit): input[i] = input[i].replace(bit, '8\n') break # WRITE INPUT FILE FOR EACH FRAG write_job(npath, frag["name"], input)