def get_dsoft(): ''' This functions is in charge of reading the file mesc.txt where the available softwares are listed ''' # defined here: if False: dsoft = {'clhbrpot': 'mpilgrim.itf_asurf', \ 'gaussian': 'mpilgrim.itf_gau' ,\ 'orca' : 'mpilgrim.itf_orca' \ } # read from file if True: TXTFILE = os.path.dirname(os.path.realpath(__file__)) + "/mesc.txt" # read file lines = read_file(TXTFILE) lines = clean_lines(lines, "#", True) # get info from lines dsoft = {} for line in lines: if line == "\n": continue software, module = line.split() dsoft[software] = module # return dictionary return dsoft
def file2lines(filename): if not os.path.exists(filename): lines = [] status = -1 else: lines = read_file(filename) lines = clean_lines(lines,"#",True) lines = [line for line in lines if line != "\n"] if lines == []: status = 0 else : status = 1 return lines, status
def read_ispe(filename): ''' read input file for ispe ''' # read lines lines = ff.read_file(filename) lines = fncs.clean_lines(lines, strip=True) # initialize data ispe_xy = [] VR, VP = None, None tension = 0.0 # find data in lines for line in lines: if line == "\n": continue label, val = line.split() val = float(val) if label.lower() == "tension": tension = val elif label.lower() == "reac": VR = val elif label.lower() == "prod": VP = val else: ispe_xy.append((label, val)) return ispe_xy, tension, VR, VP
def set_EXE(): global EXE txt = os.path.dirname(os.path.realpath(__file__))+"/paths.txt" # Defined in this file if 'EXE' in globals(): return # Try to export it from bashrc elif "OrcaExe" in os.environ: # in .bashrc: export OrcaExe="$MYHOME/Software/orca_4_0_1_2/orca" EXE = os.environ["OrcaExe"] return # Export it from file elif os.path.exists(txt): lines = read_file(txt) lines = clean_lines(lines,"#",True) for line in lines: if line == "\n": continue name, path = line.split() if name == "orca": EXE = path return # Not found else: raise Exc.ExeNotDef(Exception)
def read_rst(rstfile): if not os.path.exists(rstfile): return None, None, {} lines = read_file(rstfile) lines = fncs.clean_lines(lines, "#", True) if len(lines) == 0: return None, None, {} # pathinfo lines lines_path = fncs.extract_lines(lines, "start_pathinfo", "end_pathinfo") for line in lines_path: if line.startswith("path "): path = line.split()[1].lower() if line.startswith("mtype "): path = line.split()[1].lower() if line.startswith("mu "): mu = float(line.split()[1]) / AMU if line.startswith("ds "): ds = float(line.split()[1]) if line.startswith("hsteps "): hsteps = int(line.split()[1]) if line.startswith("cubic "): cubic = line.split()[1].lower() if cubic != "no": cubic = float(cubic) else: cubic = None # structinfo lines lines_struct = fncs.extract_lines(lines, "start_structinfo", "end_structinfo") bool1 = False bool2 = False atonums = [] masses = [] for line in lines_struct: if line.startswith("atonums"): bool1, bool2 = True, False continue elif line.startswith("masslist") or line.startswith("masses"): bool1, bool2 = False, True continue elif line.startswith("ch "): bool1, bool2 = False, False ch = int(line.split()[1]) elif line.startswith("mtp "): bool1, bool2 = False, False mtp = int(line.split()[1]) if bool1: atonums += [int(atonum) for atonum in line.split()] if bool2: masses += [float(mass) / AMU for mass in line.split()] # tuples of common data and of path tcommon = (ch, mtp, atonums, masses, mu) tpath = (path, mu, ds, hsteps, cubic) # initialize structures drst = {} mins = +float("inf") maxs = -float("inf") record = False lines = iter(lines) # Read structures for line in lines: if "==>" in line: record = True t_value = None data_line = line.split()[1:] meplabel = data_line[0] if meplabel.endswith("bw"): meplabel = "bw" + meplabel.split("bw")[0] if meplabel.endswith("fw"): meplabel = "fw" + meplabel.split("fw")[0] variables = data_line[1].split("-") mepsvalue = float(data_line[2]) Vmep = float(data_line[3]) if len(data_line) == 5: t_value = float(data_line[4]) xms, gms, Fms, v0, v1 = None, None, None, None, None # Read geometry if "x" in variables: xms = [] while True: line = next(lines) if "---" in line: break xms += line.split() xms = [float(xx) for xx in xms] #xcc = ms2cc_x(xms,masses,mu) # Read gradient if "g" in variables: gms = [] while True: line = next(lines) if "---" in line: break gms += line.split() gms = [float(gg) for gg in gms] #gcc = ms2cc_g(gms,masses,mu) # Read hessian if "F" in variables: Fms = [] while True: line = next(lines) if "---" in line: break Fms += line.split() Fms = [float(FF) for FF in Fms] Fms = fncs.lowt2matrix(Fms) #Fcc = ms2cc_F(Fms,masses,mu) # Read v0 if "v0" in variables: v0 = [] while True: line = next(lines) if "---" in line: break v0 += line.split() v0 = [float(xx) for xx in v0] # Read v1 if "v1" in variables: v1 = [] while True: line = next(lines) if "---" in line: break v1 += line.split() v1 = [float(xx) for xx in v1] # Generate Structure drst[meplabel] = (mepsvalue, Vmep, xms, gms, Fms, v0, v1, t_value) # limit values if mepsvalue < mins: mins = mepsvalue if mepsvalue > maxs: maxs = mepsvalue return tpath, tcommon, drst