Exemple #1
0
def highlevel_mep(ctc, itc, keyHL_sp, software, dtesHL, dhighlvl, points):
    # key for dhighlvl
    keyHL_path = "%s.%s.path" % (ctc, itc)
    # initialize dictE
    dictE = {}
    # folder for calculation and file name
    TMP = PN.TMPHLi % PN.struckey(ctc, itc)
    # template and function for calculation
    tes = dtesHL.get(software, {}).get(ctc, None)
    spc_fnc = get_spc_fnc(software)
    # extra-arguments for spc_fnc
    clean = False  # do not delete files
    bhess = False  # do not calculate hessian (no needed actually)
    eargs = (tes, TMP, clean)
    # rst file
    rstfile = PN.get_rst(ctc, itc)
    tpath2, tcommon2, drst = ff.read_rst(rstfile)
    if drst == {}:
        yield None, keyHL_path, (None, None), None, "emptyrst"
        return
    ch, mtp, atonums, masses, mu = tcommon2
    symbols = fncs.atonums2symbols(atonums)
    # define points
    allpoints = sorted_points(drst, hess=False)
    for point in points:
        if point.startswith("auto"):
            auto, nbw, nfw = point.split("_")
            points = auto_points(drst, allpoints, int(nbw), int(nfw))
            break
    # loop in points
    for point_i in points:
        # name for files
        mname = "%s.%s.%s" % (ctc, itc, point_i)
        # get label
        label_i, s_i = find_label_in_rst(point_i, drst)
        # tuple for identify
        tuple_ID = (s_i, label_i)
        # not in drst?
        if label_i is None:
            yield point_i, keyHL_path, tuple_ID, None, "noinrst"
        # already calculated
        elif label_i in dhighlvl.get(keyHL_path, {}).keys():
            yield point_i, keyHL_path, tuple_ID, dhighlvl[keyHL_path][
                label_i], "already"
        # HL-calculation
        else:
            if s_i == 0.0:
                Ehl_sp = dhighlvl.get(keyHL_sp, None)
                if Ehl_sp is not None:
                    yield point_i, keyHL_path, tuple_ID, Ehl_sp, "saddlefromsp"
                    continue
            # get xcc from rst
            xms = drst[label_i][2]
            xcc = fncs.ms2cc_x(xms, masses, mu)
            # calculation
            try:
                out_spc = spc_fnc(xcc, symbols, bhess, mname, eargs)
                yield point_i, keyHL_path, tuple_ID, out_spc[4], "calculated"
            except:
                yield point_i, keyHL_path, tuple_ID, None, "fail"
Exemple #2
0
def rst2xyz(rst, xyz, onlyhess=True, Eref=None):
    tpath, tcommon, drst = read_rst(rst)
    thelist = [(data[0], label) for (label, data) in drst.items()]
    thelist.sort()
    (ch, mtp, atonums, masses, mu) = tcommon
    symbols = fncs.atonums2symbols(atonums)
    natoms = len(symbols)
    string = ""
    for s_i, label in thelist:
        s_i, E_i, xms_i, gms_i, Fms_i, v0_i, v1_i, t_i = drst[label]
        if onlyhess and Fms_i is None: continue
        if Eref is not None:
            E_i = (E_i - Eref) * KCALMOL
            energy = "%+.4f kcal/mol" % E_i
        else:
            energy = "%+.6f hartree" % E_i
        string += " %i\n" % natoms
        string += " * E = %s ; s = %7.4f (%s)\n" % (energy, s_i, label)
        xcc_i = fncs.ms2cc_x(xms_i, masses, mu)
        for idx, symbol in enumerate(symbols):
            x, y, z = fncs.xyz(xcc_i, idx)
            x *= ANGSTROM
            y *= ANGSTROM
            z *= ANGSTROM
            string += " %2s   %+12.8f  %+12.8f  %+12.8f\n" % (symbol, x, y, z)
    with open(xyz, 'w') as asdf:
        asdf.write(string)
Exemple #3
0
 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)