def prepare_variables(self): self._ttorsions = list(self._tic.keys()) # Sort them considering int(X) self._ttorsions.sort(key=int) # prepare temperatures for partition functions if self._temps == []: self._temps = list(range(100,2501,100)) self._temps.sort() # number of torsions self._ntorsions = len(self._ttorsions) for X in self._ttorsions: # (a) torsions symmetry number if X not in self._tsigma.keys() : self._tsigma[X] = 1 # (b) domain for each torsion if X not in self._tdomain.keys(): self._tdomain[X] = "(0,%i)"%(360/self._tsigma[X]) self._tdomain[X] = tfh.str2interval(self._tdomain[X],bint=True) # (c) default angles default = self._precond.get(X,[60,180,300]) self._precond[X] = [val for val in default if float_in_domain(val,self._tdomain[X])] # Convert to lists! self._tic = [self._tic[X] for X in self._ttorsions] self._tsigma = [self._tsigma[X] for X in self._ttorsions] self._tlimit = [int(round(360/s)) for s in self._tsigma ] self._precond = [self._precond[X] for X in self._ttorsions] self._tdomain = [self._tdomain[X] for X in self._ttorsions] # fix according to limit self._precond = [ [angle for angle in precond if angle <= tlimit] \ for precond,tlimit in zip(self._precond,self._tlimit)] self._tdomain = [[(min(phi1,tlimit),min(phi2,tlimit)) for phi1,phi2 in tdomain] \ for tdomain,tlimit in zip(self._tdomain,self._tlimit)] self._tdomain = [[(phi1,phi2) for phi1,phi2 in tdomain if phi1 != phi2] \ for tdomain,tlimit in zip(self._tdomain,self._tlimit)] # convert domains in constraints self._hconstr = [(ic,tfh.str2interval(icdomain)) for ic,icdomain in self._hconstr] self._sconstr = [(ic,tfh.str2interval(icdomain)) for ic,icdomain in self._sconstr]
def test_hsconstraints(lzmat, zmatvals, constr, which="hard"): if constr is None or len(constr) == 0: return True # the xcc xcc = None # check constraints for ic, icdomain in constr: if ic in zmatvals: icvalue = zmatvals[ic] if icvalue < 0.0: icvalue = icvalue % 360 else: # Get atoms icatoms = [int(at) - 1 for at in ic.split("-")] nicatoms = len(icatoms) # Get xcc for each atom if xcc is None: xcc = intl.zmat2xcc(lzmat, zmatvals) xyzs = [fncs.xyz(xcc, at) for at in icatoms] # calculate value in xcc if nicatoms == 2: icvalue = fncs.distance(*xyzs) * ANGSTROM elif nicatoms == 3: icvalue = np.rad2deg(fncs.angle(*xyzs)) % 360 elif nicatoms == 4: icvalue = np.rad2deg(fncs.dihedral(*xyzs)) % 360 else: raise Exception # in domain? boolean = fncs.float_in_domain(icvalue, icdomain) if which == "hard" and boolean is False: return False if which == "soft" and boolean is True: return True # (hard) all of them are fulfilled if which == "hard": return True # (soft) all of them failed if which == "soft": return False
def random_angle(tdomain=[(0, 360)]): for ii in range(10**6): # random angle as integer angle = int(round(random.random() * 360)) # assert in range if fncs.float_in_domain(angle, tdomain): return angle # unable to generate angle exception = exc.UnableGenRandAng(Exception) exception._domain = tdomain raise exception
def is_in_domain(self, tdomain): for angle, domain in zip(self._fvec, tdomain): if not fncs.float_in_domain(angle, domain): return False return True
def highlevel_reopt(inpvars,cmatrix,\ lowerconformer=0,\ upperconformer=float("inf"),\ calculate=False,\ lNH2=[]): dirll, dirhl = inpvars._dirll , inpvars._dirhl if not os.path.exists(dirll): print(" Folder NOT FOUND: %s\n"%dirll) return # Create folders if not os.path.exists(dirhl): try : mkdir_recursive(dirhl) except: pp.print_createdir(dirhl,tvars.NIBS2); exit() # Check Gaussian software if calculate: end_program = itf.check_executable() if end_program: return # print status of tests pp.print_tests(inpvars._tests,1) pp.print_ifreqconstr(inpvars._ifqrangeHL) #------------------------# # Templates for Gaussian # #------------------------# # HL opt & HL freq templates for MIN if not inpvars._ts: file1,file2 = tvars.TEMPLMINOPTHL,tvars.TEMPLMINFRQHL # HL opt & HL freq templates for TS else : file1,file2 = tvars.TEMPLTSOPTHL,tvars.TEMPLTSFRQHL # (a) do templates exist?? if not os.path.exists(file1): pp.print_filenotfound(file1,tvars.NIBS2,1); raise exc.END if not os.path.exists(file2): pp.print_filenotfound(file2,tvars.NIBS2,1); raise exc.END # (b) read templates with open(file1,'r') as asdf: loptHL = asdf.readlines() pp.print_template(loptHL,file1,"HL optimization",tvars.NIBS2) with open(file2,'r') as asdf: lfrqHL = asdf.readlines() pp.print_template(lfrqHL,file2,"HL frequency calculation",tvars.NIBS2) # (c) temporal folder if not os.path.exists(inpvars._tmphl): try : mkdir_recursive(inpvars._tmphl) except: pp.print_createdir(inpvars._tmphl,tvars.NIBS2); exit() # read LL energies if not os.path.exists(tvars.ENERGYSUMLL): sprint("- file NOT found: %s"%tvars.ENERGYSUMLL,tvars.NIBS2) sprint(" execute %s using --msho ll"%tvars.PROGNAMEnopy,tvars.NIBS2) sprint("") return sprint("- reading file: %s"%tvars.ENERGYSUMLL,tvars.NIBS2) sprint("") llenergies, lltemp = rw.read_llenergies() # check temperature if abs(lltemp-inpvars._temp) > 1e-3: sprint(" something went wrong!",tvars.NIBS2) sprint("") sprint(" temperature in file : %.3f K"%(lltemp),tvars.NIBS2) sprint(" temperature in %s: %.3f K"%(tvars.IFILE,inpvars._temp),tvars.NIBS2) sprint("") return sprint(" temperature for Gibbs free energy: %.3f K"%lltemp,tvars.NIBS2) # check number of conformers logs = [fname for fname in os.listdir(inpvars._dirll) if fname.endswith(".log")] if len(logs) != len(llenergies): sprint(" something went wrong!",tvars.NIBS2) sprint(" number of conformer differs!",tvars.NIBS2) sprint("") sprint(" # of conformers in file : %i"%len(llenergies),tvars.NIBS2) sprint(" # of conformers in LL folder: %i"%len(logs),tvars.NIBS2) sprint("") return sprint(" number of low-level conformers : %i"%len(llenergies),tvars.NIBS2) sprint("") # check conformers svecs_llenergies = [svec for count,V0,G,svec in llenergies] for log in logs: svec_i = log.split(".")[1] if svec_i not in svecs_llenergies: sprint(" something went wrong!",tvars.NIBS2) sprint("") sprint(" conformer NOT included: %s"%log,tvars.NIBS2) sprint("") return #---------------------# # Create HL gjf files # #---------------------# nopt = 0 nfrq = 0 nsp = 0 minV0 = llenergies[0][0] for count,relV0_kcalmol,relG_kcalmol,svec in llenergies: if not (lowerconformer <= count <= upperconformer): continue # read LL/HL-correlation file correlations = rw.read_llhlcorr() # LL log file log_prec = "prec.%s.log"%svec log_stoc = "stoc.%s.log"%svec if os.path.exists(inpvars._dirll+log_prec): log = log_prec prefix1 = "optprec." prefix2 = "frqprec." prefix3 = "prec." elif os.path.exists(inpvars._dirll+log_stoc): log = log_stoc prefix1 = "optstoc." prefix2 = "frqstoc." prefix3 = "stoc." else: raise Exception # read log file conftuple,symbols,string_fccards = itf.log_data(log,inpvars,inpvars._freqscalLL,dirll) # unpack conftuple vecA,V0,V1,G,weight,Qrv,ifreq,lzmat,zmatvals,log = conftuple sprint("(%i) %s [%s]"%(count,str(vecA),prefix3[:-1]),tvars.NIBS2) sprint("") # ONLY CONFORMERS IN ENERGY WINDOWS sprint("LL electronic energy: %.4f kcal/mol"%relV0_kcalmol,tvars.NIBS2+4) # ONLY CONFORMERS BELOW HLCUTOFF IN GIBBS if inpvars._hlcutoff is not None: relG = (G-minG)*KCALMOL sprint("Gibbs energy: %.3f kcal/mol"%relG,tvars.NIBS2+4) if relG > inpvars._hlcutoff: sprint("hlcutoff : %.3f kcal/mol"%inpvars._hlcutoff,tvars.NIBS2+4) sprint("HL optimization will not be carried out!",tvars.NIBS2+4) sprint() continue sprint() # SKIP IF ALREADY CALCULATED if str(vecA) in correlations.keys(): vecB = correlations[str(vecA)] # possible names for log files saved_log1 = inpvars._dirhl+"prec.%s.log"%str(vecB) saved_log2 = inpvars._dirhl+"stoc.%s.log"%str(vecB) # check existence bool1 = os.path.exists(saved_log1) bool2 = os.path.exists(saved_log2) # exists? then skip if bool1 or bool2: sprint("already in %s"%inpvars._dirhl,tvars.NIBS2+4) sprint("optimized conformer: %s"%str(vecB),tvars.NIBS2+4) sprint() continue sprint() #-----------------# # OPT CALCULATION # #-----------------# # Perform HL optimization data = (loptHL,prefix1+str(vecA),inpvars,lzmat,zmatvals,"HL",string_fccards) if calculate: sprint("optimization...",tvars.NIBS2+4) # execute Gaussian ofileOPT,statusOPT,dummy,vecB,zmatvals,zmatatoms = itf.execute(*data) sprint() # opt ends ok? if statusOPT == -1: continue else: sprint("optimization file:",tvars.NIBS2+4) generated, ifile, ofile, err = itf.generate_gjf(*data) sprint("- %s"%ifile,tvars.NIBS2+8) if generated: sprint("- generated!",tvars.NIBS2+8,1) nopt += 1 continue sprint("- not generated!",tvars.NIBS2+8,1) logdata = gau.read_gaussian_log(ofile) commands,comment,ch,mtp,symbols,xcc,gcc,Fcc,energy,statusFRQ,ozmat,level = logdata lzmat,zmatvals,zmatatoms = gau.convert_zmat(ozmat)[0] for ic in inpvars._tic: zmatvals[ic] %= 360 vecB = TorPESpoint(tfh.zmat2vec(zmatvals,inpvars._tic),inpvars._tlimit) # The optimization succedeed! sprint("analysing geometry...",tvars.NIBS2+4) sprint("- optimized point: %s"%str(vecB),tvars.NIBS+8,1) # NH2 inversion zmatvals,inversion = tfh.correct_NH2_inversion(lzmat,zmatvals,zmatatoms,lNH2) if inversion: svecB1 = str(vecB) vecB = TorPESpoint(tfh.zmat2vec(zmatvals,inpvars._tic),inpvars._tlimit) svecB2 = str(vecB) if svecB1 != svecB2: sprint("- NH2 inversion detected! Exchanging H atoms...",tvars.NIBS+8) sprint("- final vector: %s"%svecB2,tvars.NIBS+8,1) bools = tfh.precheck_geom(lzmat,zmatvals,cmatrix,inpvars) if (inpvars._tests[1][0] == 1) and not bools[0]: sprint("- connectivity test is negative!",tvars.NIBS+8,1) continue if (inpvars._tests[1][1] == 1) and not bools[1]: sprint("- torsion angle out of domain!",tvars.NIBS+8,1) continue if (inpvars._tests[1][2] == 1) and not bools[2]: sprint("- hard constraint test is negative!",tvars.NIBS+8,1) continue if (inpvars._tests[1][3] == 1) and not bools[3]: sprint("- soft constraint test is negative!",tvars.NIBS+8,1) continue # Already saved? pointsHL = tfh.folder_points(inpvars._dirhl) inlist, equalto = vecB.is_in_list(pointsHL,inpvars._epsdeg) if inlist: # exists? sprint("already in %s (%s)"%(inpvars._dirhl,str(equalto)),tvars.NIBS2+4) sprint() # rename stoc --> prec if required! for ext in "log,zmat".split(","): # possible names for log files saved_log1 = inpvars._dirhl+"prec.%s.%s"%(str(equalto),ext) saved_log2 = inpvars._dirhl+"stoc.%s.%s"%(str(equalto),ext) # check existence bool1 = os.path.exists(saved_log1) bool2 = os.path.exists(saved_log2) # if this is prec and the one obtained is stoc, replace name!! if bool2 and "prec" in prefix3: move(saved_log2,saved_log1) # save LL-->HL correlation correlations[str(vecA)] = str(vecB) rw.add_llhlcorr(str(vecA),str(vecB)) continue sprint() #-----------------# # FRQ CALCULATION # #-----------------# data = (lfrqHL,prefix2+str(vecA),inpvars,lzmat,zmatvals,"HL") if not calculate: sprint("frequency file:",tvars.NIBS2+4) generated, ifile, ofile, err = itf.generate_gjf(*data) sprint("- %s"%ifile,tvars.NIBS2+8) if generated: sprint("- generated!\n",tvars.NIBS2+8,1) nfrq += 1 continue # log with normal termination! else: sprint("- not generated!\n",tvars.NIBS2+8,1) statusFRQ,vecB_frq,dummy1,dummy2 = itf.read_normal_log(ofile,inpvars,"HL") ofileFRQ = ofile # Perform HL frequency else: sprint("frequency calculation...",tvars.NIBS2+4) ofileFRQ,dummy,statusFRQ,vecB_frq,dummy,dummy = itf.execute(*data) #============# # Save files # #============# bool1 = (statusFRQ == 0 and not inpvars._ts) bool2 = (statusFRQ == 1 and inpvars._ts) # check imag freq if bool2 and inpvars._ifqrangeHL != []: ifreq = abs( fncs.afreq2cm(itf.get_imag_freq(ofileFRQ,inpvars._freqscalHL)) ) isok = fncs.float_in_domain(ifreq,inpvars._ifqrangeHL) if not isok: sprint("imaginary frequency is: %.2fi cm^-1"%ifreq,tvars.NIBS2+4) bool2 = False if bool1 or bool2: nsp += 1 # create z-matrix file dst = inpvars._dirhl+prefix3+"%s.zmat"%str(vecB) write_zmat(dst,lzmat, zmatvals) # copy frq file src = ofileFRQ dst = inpvars._dirhl+prefix3+"%s.log"%str(vecB) if not os.path.exists(dst): copyfile(src, dst) # save LL-->HL correlation correlations[str(vecA)] = str(vecB) rw.add_llhlcorr(str(vecA),str(vecB)) sprint() # Print number of calculations pp.print_numcalcs(count,nopt,nfrq,nsp) if not calculate: sprint("Number of opt gjf files generated: %i"%nopt,tvars.NIBS2) sprint("Number of frq gjf files generated: %i"%nfrq,tvars.NIBS2) sprint() else: # rewrite correlations to remove repetitions correlations = rw.read_llhlcorr() rw.write_llhlcorr(correlations)
add_to_qmsho = weight1*Qrv1*np.exp(-(V1_1-minV1)/pc.KB/inpvars._temps) QMSHO += add_to_qmsho # preconditioned or stochastic? if log1.startswith("stoc"): table_line += " " QMSHO_sto += add_to_qmsho count_sto += weight1 sumxj_sto += xj else: table_line += " * " QMSHO_pre += add_to_qmsho count_pre += weight1 sumxj_pre += xj # check imag freq if ifreqconstr != []: bool_imag = fncs.float_in_domain(fncs.afreq2cm(abs(ifreq1)),ifreqconstr) else: bool_imag = True # check geom bools = tfh.precheck_geom(lzmat1,zmatvals1,cmatrix,inpvars) if (inpvars._tests[1][0] == 1) and (bools[0] is False): table_line += " <-- wrong connectivity" wrongconn.append(log1) elif (inpvars._tests[1][1] == 1) and (bools[1] is False): table_line += " <-- invalid domain" outofdomain.append(log1) elif (inpvars._tests[1][2] == 1) and (bools[2] is False): table_line += " <-- constraint not fulfilled" norestr.append(log1) elif (inpvars._tests[1][3] == 1) and (bools[3] is False): table_line += " <-- constraint not fulfilled"
def search_conformers(inpvars, zmat, symbols, cmatrix, dcorr, lNH2): ntorsions = len(inpvars._ttorsions) lzmat, zmatvals, zmatatoms = zmat # reference torsional vector vecR = TorPESpoint(tfh.zmat2vec(zmatvals, inpvars._tic), inpvars._tlimit) inpvars._vecR = vecR # Create folders try: tfh.create_dir(inpvars._tmpll) except: raise exc.END try: tfh.create_dir(inpvars._dirll) except: raise exc.END #====================================# # Print information before searching # #====================================# if inpvars._ts: file1, file2 = tvars.TEMPLTSOPTLL, tvars.TEMPLTSFRQLL else: file1, file2 = tvars.TEMPLMINOPTLL, tvars.TEMPLMINFRQLL # do templates exist?? if not os.path.exists(file1): pp.print_filenotfound(file1, tvars.NIBS2, 1) raise exc.END if not os.path.exists(file2): pp.print_filenotfound(file2, tvars.NIBS2, 1) raise exc.END # read templates with open(file1, 'r') as asdf: loptLL = asdf.readlines() with open(file2, 'r') as asdf: lfrqLL = asdf.readlines() pp.print_infoLLsearch(inpvars, file1, file2, loptLL, lfrqLL) # Check gaussian software end_program = itf.check_executable() if end_program: return pp.print_tests(inpvars._tests) pp.print_ifreqconstr(inpvars._ifqrangeLL) #=======================# # Deal with domain file # #=======================# ddomains = rw.read_domains() if os.path.exists(tvars.FDOMAINS): sprint("Domain file exists (%s)!" % tvars.FDOMAINS, tvars.NIBS2, 1) pp.print_domains(ddomains, tvars.DOMAINS) else: rw.initialize_domains(ntorsions) #=========================# # Search in torsional PES # #=========================# if inpvars._prec is not False: sprint("Preconditioned algorithm will be used!", tvars.NIBS2) prefix1, prefix2, prefix3 = "optprec.", "frqprec.", "prec." if inpvars._prec != (1, 1): sprint(" - Number of blocks: %i" % inpvars._prec[0], tvars.NIBS2) sprint(" - Selected block : %i" % inpvars._prec[1], tvars.NIBS2) sprint() else: sprint("Stochastic algorithm will be used!", tvars.NIBS2, 1) prefix1, prefix2, prefix3 = "optstoc.", "frqstoc.", "stoc." # save initial zmat i_lzmat = list(lzmat) i_zmatvals = {k: v for (k, v) in zmatvals.items()} # Calculate for each random angle count = 0 nopt = 0 nfrq = 0 nsp = 0 svec2log = tfh.get_logs_vecs(inpvars, dcorr, svec2log={}) for vecA in tfh.yield_angles(inpvars): count += 1 # read domains ddomains = rw.read_domains() # print target point sprint("(%i) %s" % (count, str(vecA)), tvars.NIBS2) sprint() #------------------# # analyze geometry # #------------------# sprint("preparing Z-matrix...", tvars.NIBS2 + 4) args = (vecA, inpvars, ddomains, svec2log, dcorr) bool_guess, closest, svec2log, distance = tfh.test_similarity_redundancy( *args) if bool_guess == -1: sprint("already listed in %s" % tvars.FDOMAINS, tvars.NIBS2 + 4) sprint() continue if bool_guess == 0 and (inpvars._tests[0][1] == 1): sprint( "similarity test is negative: in the domain of %s" % str(closest), tvars.NIBS2 + 4) sprint() continue closest_log = svec2log.get(str(closest), None) args = (vecA, i_zmatvals, inpvars, closest_log, distance) zmatvals = gen_guess_zmatrix(*args) if inpvars._enantio: vecA_enantio = tfh.enantiovec(lzmat, zmatvals, dcorr, inpvars) sprint("enantiomer: %s" % str(vecA_enantio), tvars.NIBS2 + 4) #- - - - - - - - - # # 1st set of TESTS # #- - - - - - - - - # bools = tfh.precheck_geom(lzmat, zmatvals, cmatrix, inpvars) if (inpvars._tests[0][0] == 1) and (bools[0] is False): sprint("connectivity test is negative: different connectivity!", tvars.NIBS + 7, 1) continue if (bools[1] is False): sprint("torsion angle out of domain...", tvars.NIBS + 7, 1) continue if (inpvars._tests[0][2] == 1) and (bools[2] is False): sprint("hard constraint test is negative!", tvars.NIBS + 7, 1) continue if (inpvars._tests[0][3] == 1) and (bools[3] is False): sprint("soft constraint test is negative!", tvars.NIBS + 7, 1) continue sprint() #------------------# # optimization # #------------------# sprint("optimization...", tvars.NIBS2 + 4) data = (loptLL, prefix1 + str(vecA), inpvars, lzmat, zmatvals, "LL") ofileOPT, statusOPT, dummy, vecB, zmatvals, zmatatoms = itf.execute( *data) nopt += 1 # optimization was carried out --> save guess if statusOPT != 0: rw.add_domain("fail", vecA, None, -1) #if inpvars._enantio: rw.add_domain("fail",vecA_enantio,None,-1) sprint() continue #===========================# # check NH2 inversion # #===========================# zmatvals, inversion = tfh.correct_NH2_inversion( lzmat, zmatvals, zmatatoms, lNH2) if inversion: # recalculate vector svecB1 = str(vecB) vecB = TorPESpoint(tfh.zmat2vec(zmatvals, inpvars._tic), inpvars._tlimit) svecB2 = str(vecB) if svecB1 != svecB2: sprint("NH2 inversion detected! Exchanging H atoms...", tvars.NIBS2 + 4) sprint("final vector: %s" % svecB2, tvars.NIBS2 + 4) #===========================# if inpvars._enantio: vecB_enantio = tfh.enantiovec(lzmat, zmatvals, dcorr, inpvars) sprint("enantiomer : %s" % str(vecB_enantio), tvars.NIBS2 + 4) change = int(round(vecA.distance(vecB))) sprint("distance from guess point: %i degrees" % change, tvars.NIBS2 + 4) sprint() #------------------# # analyze geometry # #------------------# sprint("analysing geometry...", tvars.NIBS2 + 4) #- - - - - - - - - # # 2nd set of TESTS # #- - - - - - - - - # bools = tfh.precheck_geom(lzmat, zmatvals, cmatrix, inpvars) if (inpvars._tests[1][0] == 1) and not bools[0]: sprint("connectivity test is negative: different connectivity!", tvars.NIBS + 7, 1) rw.add_domain("excl", vecA, vecB, -1) if inpvars._enantio: rw.add_domain("excl", vecA_enantio, vecB_enantio, -1) continue if not bools[1]: sprint("torsion angle out of domain...", tvars.NIBS + 7, 1) rw.add_domain("excl", vecA, vecB, -1) if inpvars._enantio: rw.add_domain("excl", vecA_enantio, vecB_enantio, -1) continue if (inpvars._tests[1][2] == 1) and not bools[2]: sprint("hard constraint test is negative!", tvars.NIBS + 7, 1) rw.add_domain("excl", vecA, vecB, -1) if inpvars._enantio: rw.add_domain("excl", vecA_enantio, vecB_enantio, -1) continue if (inpvars._tests[1][3] == 1) and not bools[3]: sprint("soft constraint test is negative!", tvars.NIBS + 7, 1) rw.add_domain("excl", vecA, vecB, -1) if inpvars._enantio: rw.add_domain("excl", vecA_enantio, vecB_enantio, -1) continue # current conformations #confs = tfh.folder_points(inpvars._dirll) confs = [fvec for ivec, fvec, frqstatus in ddomains["conf"]] confs += [fvec for ivec, fvec, frqstatus in ddomains["enan"]] # already stored? inlist, equalto = vecB.is_in_list(confs, inpvars._epsdeg) if inlist and (inpvars._tests[1][1] == 1): sprint( "redundancy test is negative: same as stored point (%s)" % equalto, tvars.NIBS2 + 4, 1) rw.add_domain("repe", vecA, vecB, -1) if inpvars._enantio: rw.add_domain("repe", vecA_enantio, vecB_enantio, -1) continue sprint("new geometry found!", tvars.NIBS2 + 4) sprint() #------------------# # freq calculation # #------------------# sprint("frequency calculation...", tvars.NIBS2 + 4) data = (lfrqLL, prefix2 + str(vecA), inpvars, lzmat, zmatvals, "LL") ofileFRQ, dummy, statusFRQ, vecB_frq, dummy, dummy = itf.execute(*data) nfrq += 1 #------------------------------# # Save points into domain file # #------------------------------# bool1 = (statusFRQ == 0 and not inpvars._ts) bool2 = (statusFRQ == 1 and inpvars._ts) bool_conf = bool1 or bool2 # Save optimized point if bool_conf: seldomain = "conf" else: seldomain = "wimag" # check imag freq if seldomain == "conf" and inpvars._ifqrangeLL != []: ifreq = abs( fncs.afreq2cm(itf.get_imag_freq(ofileFRQ, inpvars._freqscalLL))) isok = fncs.float_in_domain(ifreq, inpvars._ifqrangeLL) if not isok: seldomain, bool_conf = "wimag", False pp.print_excluded_ifreq(ifreq) else: pp.print_accepted_ifreq(ifreq) rw.add_domain(seldomain, vecA, vecB, statusFRQ) if inpvars._enantio and seldomain == "conf": rw.add_domain("enan", vecA_enantio, vecB_enantio, statusFRQ) elif inpvars._enantio and seldomain == "wimag": rw.add_domain("wimag", vecA_enantio, vecB_enantio, statusFRQ) #============# # Save files # #============# if bool_conf: # create z-matrix file dst = inpvars._dirll + prefix3 + "%s.zmat" % str(vecB) write_zmat(dst, lzmat, zmatvals) # copy frq file src = ofileFRQ dst = inpvars._dirll + prefix3 + "%s.log" % str(vecB) if not os.path.exists(dst): copyfile(src, dst) # update counter nsp += 1 sprint() # Print number of calculations pp.print_numcalcs(count, nopt, nfrq, nsp)