def pilgrim_spc(xcc,symbols,bhessian,mname,eargs): atonums = fncs.symbols2atonums(symbols) ch, mtp = None, None masses = None # expand extra-args if len(eargs) == 1: asurf = eargs[0] folder, clean = None, False elif len(eargs) == 2: asurf, folder = eargs clean = False elif len(eargs) == 3: asurf, folder, clean = eargs # create folder if folder is not None: if not os.path.exists(folder): os.mkdir(folder) # names of files wname, ifile, ofile, err = ITF.iofiles(mname,folder) # write ifile ITF.write_input(ifile,xcc) # calculate gradient/hessian if bhessian: E, gcc, Fcc = ITF.calculate_hessian(ifile,ofile,err,asurf) else : E, gcc, Fcc = ITF.calculate_gcc(ifile,ofile,err,asurf)+[None] # Remove files if clean: files = os.listdir(folder) for fff in files: os.remove(folder+fff) return xcc, atonums, ch, mtp, E, gcc, Fcc, masses
def read_gauout(filename): # read gaussian file data_gaulog = read_gaussian_log(filename) # split data ch = data_gaulog[2] mtp = data_gaulog[3] symbols = data_gaulog[4] xcc = data_gaulog[5] gcc = data_gaulog[6] Fcc = data_gaulog[7] V0 = data_gaulog[8] level = data_gaulog[11] # symbols to atomic numbers atonums = symbols2atonums(symbols) # atomic mass atomasses = atonums2masses(atonums) # return data return xcc, atonums, ch, mtp, V0, gcc, Fcc, atomasses, level
def prepare(self): # check atnums if self._atnums is not None and type(self._atnums[0]) == str: self._symbols = list(self._atnums) # check symbols if self._symbols is not None and type(self._symbols[0]) == int: self._atnums = list(self._symbols) # Get both atnums and symbols if None if self._atnums is None: self._atnums = fncs.symbols2atonums(self._symbols) if self._symbols is None: self._symbols = fncs.atonums2symbols(self._atnums) # check masses if self._masses is None: self._masses = fncs.atonums2masses(self._atnums) # derivated magnitudes self.genderivates() # check Fcc if self._Fcc not in (None,[]) and len(self._Fcc) != 3*self._natoms: self._Fcc = fncs.lowt2matrix(self._Fcc)
zmat = gau.zmat_from_loginp(folder + log) (lzmat, zmatvals, zmatatoms), symbols = gau.convert_zmat(zmat) # same current point strconfs.append(str(point)) allconfs.append(point) # correct symbols (just in case) symbols, atonums = fncs.symbols_and_atonums(symbols) # Data without dummies symbols_wo, xcc_wo = fncs.clean_dummies(symbols, xcc=list(xcc)) symbols_wo, gcc_wo = fncs.clean_dummies(symbols, gcc=list(gcc)) symbols_wo, Fcc_wo = fncs.clean_dummies(symbols, Fcc=list(Fcc)) # calculate weight atonums_wo = fncs.symbols2atonums(symbols_wo) masses_wo = fncs.symbols2masses(symbols_wo) pgroup, rotsigma = get_pgs(atonums_wo, masses_wo, xcc_wo) if inpvars._enantio and pgroup.lower() == "c1": weight = 2 enantio = tfh.enantiovec(lzmat, zmatvals, dcorr, inpvars) allconfs.append(enantio) denantio[str(enantio)] = str(point) else: weight = 1 # save data geoms.append((V0, xcc_wo, gcc_wo, Fcc_wo, str(point))) weights[str(point)] = weight geoms.sort() #----------------------------#
def write_mstorinp(geoms,symbols,mtp,freqscal,inpvars,dMj,nrics,folder,lCH3=[]): str_inp = "" str_inp += "#--------------------------------------------#\n" str_inp += "# Ms-Tor input file generated with TorsiFlex #\n" str_inp += "#--------------------------------------------#\n" str_inp += "\n" torsions = inpvars._tatoms ntorsions = inpvars._ntorsions Lenantio = inpvars._enantio natoms = len(symbols) atonums = fncs.symbols2atonums(symbols) masses = fncs.symbols2masses(symbols) Eref = geoms[0][0] #-----------------# # general section # #-----------------# str_inp += "$general\n" str_inp += " natoms %i\n"%natoms str_inp += " nstr %i\n"%len(geoms) str_inp += " ntor %i\n"%(ntorsions+len(lCH3)) str_inp += " freqscale %.4f\n"%freqscal str_inp += " deltat 0.5\n" str_inp += " elec\n" str_inp += " %i 0.0\n"%mtp str_inp += " end\n" str_inp += "end\n" str_inp += "\n" #---------------------# # temperature section # #---------------------# str_inp += "$temp\n" for idx in range(0,len(inpvars._temps),6): str_inp += " ".join("%7.2f"%T for T in inpvars._temps[idx:idx+6])+"\n" str_inp += "end\n" str_inp += "\n" #----------------------# # internal coordinates # #----------------------# str_inp += "$intdef\n" if nrics is not None: for ic in nrics: ictype,icatoms = ic # which torsion? dtorX = "" if ictype == "pt": for X,tatoms in inpvars._tatoms.items(): if icatoms in (tuple(tatoms),tuple(tatoms[::-1])): dtorX = "# torsion%s"%X break for CH3 in lCH3: if icatoms in (tuple(CH3),tuple(CH3[::-1])): dtorX = "# CH3" break # add to string str_inp += " %s %s\n"%(intl.ic2string(ic).replace("_","-"),dtorX) str_inp += "end\n" str_inp += "\n" #---------------------# # coordinates&hessian # #---------------------# count = 0 str_hess = "" for E,xcc,gcc,Fcc,point in geoms: count += 1 # relative energy erel = (E-Eref)*pc.KCALMOL # rotational symmetry number pgroup, rotsigma = get_pgs(atonums,masses,xcc) if Lenantio and pgroup.lower() == "c1": weight = 2 else : weight = 1 # The string str_inp += "$structure %i\n"%count str_inp += "geom\n" for idx,at in enumerate(atonums): x,y,z = [coord*pc.ANGSTROM for coord in xcc[3*idx:3*idx+3]] str_inp += "%-2s %15.8E %15.8E %15.8E\n"%(at,x,y,z) str_inp += "end\n" # M_j,tau values str_inp += "mtor\n" part_ttorsions = " ".join(["%.4f"%dMj[str(point)] for torsion in inpvars._ttorsions]) part_ch3 = " ".join("3.0000" for CH3 in lCH3) str_inp += " %s %s \n"%(part_ttorsions,part_ch3) str_inp += "end\n" # weight, rel energy and rotsigma str_inp += "weight %i\n"%weight str_inp += "energy %.5f\n"%erel str_inp += "rotsigma %i # point group: %s\n"%(rotsigma,pgroup) str_inp += "end\n" str_inp += "\n" # hessian str_hess += "$hess %2i\n"%count for idx in range(0,len(Fcc),6): values = "".join([" %+11.8f"%value for value in Fcc[idx:idx+6]]) str_hess += values + "\n" str_hess += "end\n\n" # write files print(tvars.IBS2+" - %s"%(folder+tvars.MSTORIF1)) with open(folder+tvars.MSTORIF1,"w") as asdf: asdf.write(str_inp) print(tvars.IBS2+" - %s"%(folder+tvars.MSTORIF2)) with open(folder+tvars.MSTORIF2,"w") as asdf: asdf.write(str_hess)