Пример #1
0
def gen_enantio_and_correlate(xcc,
                              symbols,
                              masses=None,
                              fconnect=1.3,
                              pp=False):
    # generate list of masses
    if masses is None: masses = fncs.symbols2masses(symbols)
    # xcc1: center and reorient
    xcc1 = center_and_orient(xcc, None, None, masses)[0]
    # xcc2: xcc for enantiomer
    xcc2 = generate_enantio(xcc1)
    xcc2 = center_and_orient(xcc2, None, None, masses)[0]
    # correlate enantiomer
    dcorr = correlate_enantio(xcc1, xcc2, symbols, fconnect=fconnect, pp=pp)
    # non-assigned?
    if get_not_assigned(dcorr) != 0: return None
    # Generate xcc for enantiomer
    try:
        xcc_enantio = [0.0 for ii in range(len(xcc))]
        for node2, node1 in dcorr.items():
            xcc_enantio[3 * node1:3 * node1 + 3] = xcc2[3 * node2:3 * node2 +
                                                        3]
        return xcc_enantio
    except:
        return None
Пример #2
0
def correlate(symbols_t,xcc_t,symbols_0,xcc_0,fconnect=1.3):
    '''
    reference geometry: symbols_0,xcc_0
    target    geometry: symbols_t,xcc_t
    '''
    # prepare reference geometry
    masses_0 = fncs.symbols2masses(symbols_0)
    xcc_0    = center_and_orient(xcc_0,None,None,masses_0)[0]
    # prepare target geometry
    masses_t = fncs.symbols2masses(symbols_t)
    xcc_t    = center_and_orient(xcc_t,None,None,masses_t)[0]
    # correlate enantiomer
    dcorr = correlate_xccs(xcc_t,symbols_t,xcc_0,symbols_0,fconnect=fconnect,pp=False)
    # non-assigned?
    if get_num_of_not_assigned(dcorr) != 0: return None
    # Re-order xcc_t
    symbols,xcc = reorder_xcc(symbols_t,xcc_t,dcorr)
    return symbols,xcc
Пример #3
0
    def info_string(self, ib=0):
        root_mass = sum(fncs.symbols2masses(self._symbols))
        string = "Molecular formula     : %s\n" % self._mform
        string += "Number of atoms       : %i\n" % self._natoms
        string += "Number of electrons   : %i\n" % self._nel
        string += "Vibrational DOFs      : %i\n" % self._nvdof
        string += "Charge                : %i\n" % self._ch
        string += "Multiplicity          : %i\n" % self._mtp
        string += "Electronic energy (V0): %.8f hartree\n" % self._V0
        string += "Total mass [root]     : %.4f amu\n" % (root_mass * AMU)
        string += "Total mass            : %.4f amu\n" % (self._mass * AMU)
        if self._pgroup is not None:
            string += "Point group symmetry  : %s\n" % (self._pgroup)
        if self._rotsigma is not None:
            string += "Rotational sym num    : %i\n" % (self._rotsigma)
        string += "Cartesian coordinates (Angstrom):\n"
        for at, symbol in enumerate(self._symbols):
            mass = self._masses[at] * AMU
            x, y, z = fncs.xyz(self._xcc, at)
            x *= ANGSTROM
            y *= ANGSTROM
            z *= ANGSTROM
            string += "  %2s   %+12.8f  %+12.8f  %+12.8f  [%7.3f amu]\n" % (
                symbol, x, y, z, mass)

        try:
            str2 = "Moments and product of inertia (au):\n"
            if len(self._imoms) == 1:
                str2 += "        %+10.3E\n" % self._imoms[0]
            if len(self._imoms) == 3:
                prodinert = self._imoms[0] * self._imoms[1] * self._imoms[2]
                dataline = (self._imoms[0], self._imoms[1], self._imoms[2],
                            prodinert)
                str2 += "        %+10.3E  %+10.3E  %+10.3E  [%10.3E]\n" % dataline
            string += str2
        except:
            pass

        try:
            str2 = "Vibrational frequencies [1/cm] (scaled by %.3f):\n" % self._fscal
            for idx in range(0, len(self._ccfreqs), 6):
                str2 += "  %s\n"%("  ".join("%8.2f"%fncs.afreq2cm(freq) \
                                    for freq in self._ccfreqs[idx:idx+6]))
            if len(self._ccfreqs) != 0: string += str2
        except:
            pass

        try:
            str2 = "Vibrational zero-point energies [kcal/mol]:\n"
            for idx in range(0, len(self._cczpes), 6):
                str2 += "  %s\n"%("  ".join("%8.2f"%(zpe*KCALMOL) \
                                    for zpe in self._cczpes[idx:idx+6]))
            zpe_au = self._cczpe
            zpe_kcal = self._cczpe * KCALMOL
            zpe_eV = self._cczpe * EV
            zpe_cm = self._cczpe * H2CM
            str2 += "Vibrational zero-point energy: %+14.8f hartree  = \n" % zpe_au
            str2 += "                               %+14.2f kcal/mol = \n" % zpe_kcal
            str2 += "                               %+14.2f eV       = \n" % zpe_eV
            str2 += "                               %+14.2f cm^-1 \n" % zpe_cm
            str2 += "V0 + zero-point energy (V1)  : %+14.8f hartree\n" % self._ccV1
            if self._cczpe != 0.0: string += str2
        except:
            pass

        # add blank spaces
        string = "\n".join([" " * ib + line for line in string.split("\n")])
        return string
Пример #4
0
        (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()

    #----------------------------#
    # calculate M_{j,tau} values #
Пример #5
0
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)