Exemple #1
0
def makeNnzDist():
    import parseXYZ

    matD = getAtomMatrix("/Volumes/s/matrices/matrixmarket/diamond-2r_P2_A.mm")
    matW = getAtomMatrix("/Volumes/s/matrices/matrixmarket/nanowire25-2r_P2_A.mm")
    nnzD = matD.nnz
    nnzW = matW.nnz
    distD = np.array([0.0] * nnzD)
    distW = np.array([0.0] * nnzW)
    xyzD = parseXYZ.getXYZ("diamond-2r_P2.xyz")
    xyzW = parseXYZ.getXYZ("nanowire25-2r_P2.xyz")

    for i in range(matW.nnz):
        if i < matD.nnz:
            atom1 = matD.row[i]
            atom2 = matD.col[i]
            distD[i] = parseXYZ.getdistance(
                xyzD[1][atom1], xyzD[2][atom1], xyzD[3][atom1], xyzD[1][atom2], xyzD[2][atom2], xyzD[3][atom2]
            )
        atom1 = matW.row[i]
        atom2 = matW.col[i]
        distW[i] = parseXYZ.getdistance(
            xyzW[1][atom1], xyzW[2][atom1], xyzW[3][atom1], xyzW[1][atom2], xyzW[2][atom2], xyzW[3][atom2]
        )
    print "done"
    plt.figure()
    plt.hist(distD, bins=1000, cumulative=False, normed=True, histtype=u"step", color="red", edgecolor="red", alpha=0.7)
    plt.hist(
        distW, bins=1000, cumulative=False, normed=True, histtype=u"step", color="green", edgecolor="green", alpha=0.7
    )
    plt.show()
    return
Exemple #2
0
def makeCouplingAtomPlot(n, tag):
    import parseXYZ
    from mpl_toolkits.mplot3d import Axes3D

    mmdir = "/Volumes/s/matrices/matrixmarket/"
    mmfile = mmdir + tag + "_A.mm"
    xyzdir = "/Volumes/s/keceli/Dropbox/work/SEMO/xyz/"
    xyzfile = xyzdir + tag + ".xyz"
    mat = getAtomMatrix(mmfile)
    nnz = mat.nnz
    distW = np.array([0.0] * nnz)
    xyz = parseXYZ.getXYZ(xyzfile)
    matD = getDistMat(xyz, 5.6)
    makeNnzHist(mat, xyz)
    xyzW = np.asarray(xyz[1:4])
    myrow = np.asarray(mat.row)
    mycol = np.asarray(mat.col)
    listofAtoms1 = myrow[mycol == n]
    listofAtoms2 = mycol[myrow == n]
    listofAtoms = np.unique(np.concatenate((listofAtoms1, listofAtoms2)))
    print "focused atom number and its coordinates:", n + 1, xyzW[:, n]
    print "number of atoms interacting with this atom:", len(listofAtoms)
    print "list of interacting atoms:", listofAtoms + 1
    print "jmol command:", str(["C" + str(listofAtoms[i] + 1) for i in range(len(listofAtoms))]).replace(
        "[", ""
    ).replace("]", "").replace("'", "")
    print "coordinates of interacting atoms", xyzW[:, listofAtoms]
    fig = plt.figure()
    plt.spy(mat, markersize=1)
    fig = plt.figure()
    plt.spy(matD, markersize=1)
    fig = plt.figure()
    plt.plot(listofAtoms, linestyle="None", marker="s")
    fig = plt.figure()
    ax = fig.add_subplot(111, projection="3d")
    plt.plot(xyzW[0, :], xyzW[1, :], xyzW[2, :], linestyle="None", marker=".", color="black", markersize=2)
    plt.plot(
        xyzW[0, listofAtoms],
        xyzW[1, listofAtoms],
        xyzW[2, listofAtoms],
        linestyle="None",
        marker="o",
        color="red",
        markersize=3,
    )
    plt.plot([xyzW[0, n]], [xyzW[1, n]], [xyzW[2, n]], linestyle="None", marker="s", color="blue", markersize=4)
    plt.grid(which="major", axis="all")
    plt.gca().set_aspect("equal", adjustable="box")
    #    ax.auto_scale_xyz()
    # plt.axis('equal')
    ax.set_xlim([-5, 25])
    ax.set_ylim([-5, 25])
    ax.set_zlim([0, 45])
    ax.set_xlabel("x")
    ax.set_ylabel("y")
    ax.set_zlabel("z")
    return