예제 #1
0
파일: efcalc.py 프로젝트: ehermes/LJFS
def de_df(nsolatoms, optatoms, optlist, epsilon, sigma, charge, n, x, y, z, atomtype, conv):
    delist = np.zeros((n, 3 * len(optatoms)))
    dflist = np.zeros((n, 3 * len(optatoms), len(optlist), 3))
    for i in xrange(n):
        for j in xrange(len(optlist)):
            h = optlist[j]
            g = -1
            for u in xrange(len(optatoms)):
                if atomtype[i][h] == optatoms[u]:
                    g = u
                    break
            else:
                print "Something terrible has happened."
                sys.exit()
            for k in xrange(nsolatoms, len(x[i])):
                ep1 = epsilon[atomtype[i][h]]
                ep2 = epsilon[atomtype[i][k]]
                sig1 = sigma[atomtype[i][h]]
                sig2 = sigma[atomtype[i][k]]
                r = np.array([x[i][h] - x[i][k], y[i][h] - y[i][k], z[i][h] - z[i][k]])
                q1 = charge[atomtype[i][h]]
                q2 = charge[atomtype[i][k]]
                if ep1 != 0 and ep2 != 0:
                    (delist[i][3 * g], delist[i][3 * g + 1], dflist[i][3 * g][j], dflist[i][3 * g + 1][j]) = map(
                        operator.add,
                        (delist[i][3 * g], delist[i][3 * g + 1], dflist[i][3 * g][j], dflist[i][3 * g + 1][j]),
                        analyze.dedf_lj(ep1, ep2, sig1, sig2, r),
                    )
                if q1 != 0 and q2 != 0:
                    (delist[i][3 * g + 2], dflist[i][3 * g + 2][j]) = map(
                        operator.add,
                        (delist[i][3 * g + 2], dflist[i][3 * g + 2][j]),
                        analyze.dedf_coul(conv, q1, q2, r),
                    )
    return delist, dflist
예제 #2
0
파일: efcalc.py 프로젝트: ehermes/LJFS
def de_df_chcomp(nsolatoms, chcomptype, epsilon, sigma, charge, n, x, y, z, atomtype, conv):
    delist = []
    dflist = []
    for i in xrange(n):
        de = 0
        df = []
        for j in xrange(nsolatoms):
            if atomtype[i][j] == chcomptype:
                dfi = np.zeros(3)
                for k in xrange(nsolatoms, len(x[i])):
                    r = np.array([x[i][j] - x[i][k], y[i][j] - y[i][k], z[i][j] - z[i][k]])
                    q1 = charge[atomtype[i][j]]
                    q2 = charge[atomtype[i][k]]
                    if q1 != 0 and q2 != 0:
                        (de, dfi) = map(operator.add, (de, dfi), analyze.dedf_coul(conv, q1, q2, r))
                df.append(dfi)
            else:
                df.append(np.zeros(3))
        delist.append(de)
        dflist.append(df)
    return np.array(delist), np.array(dflist)