Example #1
0
def plot_atoms(atoms,types,basis=[],dup=0):

	Ntypes=len(set(types))
	N=len(atoms)
	cs=["yellow","green","blue","red","purple","orange","black"]
	
        #Periodic Atoms (duplicated)
	if dup==1:
		atoms,types=duplicate26(atoms,types,zip(v1,v2,v3))

        #Type sorted atoms lists
        tatoms=[list() for i in range(Ntypes)]
	for i,j in enumerate(types):
		tatoms[j-1].append(atoms[i])

	fig=pl.figure()
        aa = fig.add_subplot(111,projection='3d')
        for i in range(Ntypes):
		ax,ay,az=zip(*tatoms[i])
		aa.scatter(ax,ay,az,c=cs.pop(0),marker="o")


	if len(basis)>0:
		v1,v2,v3=zip(*basis)
		aa.plot([0,v1[0]],[0,v1[1]],[0,v1[2]],c="red")
		aa.plot([0,v2[0]],[0,v2[1]],[0,v2[2]],c="blue")
		aa.plot([0,v3[0]],[0,v3[1]],[0,v3[2]],c="green")
Example #2
0
def plot_atoms(atoms, types, basis=[], dup=0):

    Ntypes = len(set(types))
    N = len(atoms)
    cs = ["yellow", "green", "blue", "red", "purple", "orange", "black"]

    #Periodic Atoms (duplicated)
    if dup == 1:
        atoms, types = duplicate26(atoms, types, zip(v1, v2, v3))

#Type sorted atoms lists
    tatoms = [list() for i in range(Ntypes)]
    for i, j in enumerate(types):
        tatoms[j - 1].append(atoms[i])

    fig = pl.figure()
    aa = fig.add_subplot(111, projection='3d')
    for i in range(Ntypes):
        ax, ay, az = zip(*tatoms[i])
        aa.scatter(ax, ay, az, c=cs.pop(0), marker="o")

    if len(basis) > 0:
        v1, v2, v3 = zip(*basis)
        aa.plot([0, v1[0]], [0, v1[1]], [0, v1[2]], c="red")
        aa.plot([0, v2[0]], [0, v2[1]], [0, v2[2]], c="blue")
        aa.plot([0, v3[0]], [0, v3[1]], [0, v3[2]], c="green")
Example #3
0
def plot_pos_rad_ang(atoms, types, basis, dup=0):

    Ntypes = len(set(types))
    N = len(atoms)
    cs = ["yellow", "green", "blue", "red", "purple", "orange", "black"]

    #Periodic Atoms (duplicated, needed for distributions)
    datoms, dtypes = duplicate26(atoms, types, basis)

    #Neighbors needed for angular distribution
    dneighbs = neighbors(datoms, 5.0, style="full")

    #Radial Distribution
    [rbins, rdist] = rdf(datoms, inloop=N, cutoff=12.0)

    #Correlation of Angles
    [abins, adist] = adf(datoms, dneighbs, inloop=N)

    #Type sorted atoms lists
    tatoms = [list() for i in range(Ntypes)]
    if (dup == 1):
        for i, j in enumerate(dtypes):
            tatoms[j].append(datoms[i])
    else:
        for i, j in enumerate(types):
            tatoms[j].append(atoms[i])

    v1, v2, v3 = zip(*basis)

    #findsymmetry([v1,v2,v3],types,zip(xs,ys,zs))

    fig = pl.figure(figsize=(12, 6))
    aa = fig.add_subplot(311, projection='3d')
    aa.set_position([0, 0, 0.5, 1.0])
    for i in range(Ntypes):
        ax, ay, az = zip(*tatoms[i])
        aa.scatter(ax, ay, az, c=cs.pop(0), marker="o")

    aa.plot([0, v1[0]], [0, v1[1]], [0, v1[2]])
    aa.plot([0, v2[0]], [0, v2[1]], [0, v2[2]])
    aa.plot([0, v3[0]], [0, v3[1]], [0, v3[2]])

    bb = fig.add_subplot(312)
    bb.set_position([0.56, 0.55, 0.4, 0.4])
    bb.plot(rbins, rdist)
    pl.xlabel("Radius (A)")
    pl.ylabel("Count")

    cc = fig.add_subplot(313)
    cc.set_position([0.56, 0.08, 0.4, 0.36])
    cc.plot(abins, adist)
    pl.xlabel("Angle (deg)")
    pl.ylabel("Count")

    pl.show()
Example #4
0
def plot_pos_rad_ang(atoms,types,basis,dup=0):

	Ntypes=len(set(types))
	N=len(atoms)
	cs=["yellow","green","blue","red","purple","orange","black"]

        #Periodic Atoms (duplicated, needed for distributions)
        datoms,dtypes=duplicate26(atoms,types,basis)

        #Neighbors needed for angular distribution
        dneighbs=neighbors(datoms,5.0,style="full")

        #Radial Distribution
        [rbins,rdist]=rdf(datoms,inloop=N,cutoff=12.0)

        #Correlation of Angles
        [abins,adist]=adf(datoms,dneighbs,inloop=N)

        #Type sorted atoms lists
        tatoms=[list() for i in range(Ntypes)]
        if(dup==1):
            for i,j in enumerate(dtypes):
                tatoms[j].append(datoms[i])
        else:
            for i,j in enumerate(types):
                tatoms[j].append(atoms[i])

	v1,v2,v3=zip(*basis)

        #findsymmetry([v1,v2,v3],types,zip(xs,ys,zs))

        fig=pl.figure(figsize=(12,6))
        aa = fig.add_subplot(311,projection='3d')
        aa.set_position([0,0,0.5,1.0])
        for i in range(Ntypes):
            ax,ay,az=zip(*tatoms[i])
            aa.scatter(ax,ay,az,c=cs.pop(0),marker="o")

        aa.plot([0,v1[0]],[0,v1[1]],[0,v1[2]])
        aa.plot([0,v2[0]],[0,v2[1]],[0,v2[2]])
        aa.plot([0,v3[0]],[0,v3[1]],[0,v3[2]])
        
        bb = fig.add_subplot(312)
        bb.set_position([0.56,0.55,0.4,0.4])
        bb.plot(rbins,rdist)
        pl.xlabel("Radius (A)")
        pl.ylabel("Count")

        cc = fig.add_subplot(313)
        cc.set_position([0.56,0.08,0.4,0.36])
        cc.plot(abins,adist)
        pl.xlabel("Angle (deg)")
        pl.ylabel("Count")

        pl.show()
Example #5
0
def poscar2qvoronoi(atoms,basis,atypes,qvfile="QV_input"):

    qvfp=open(qvfile,"w")

    NRealAtoms=len(atoms)

    #Ensure simulation bx is sufficiently orthorhombic
    if sum(map(fabs,basis[0]))-fabs(basis[0][0]) > 1e-10 or \
            sum(map(fabs,basis[1]))-fabs(basis[1][1]) > 1e-10 or \
            sum(map(fabs,basis[2]))-fabs(basis[2][2]) > 1e-10:
        print "Error: simulation axes are not sufficiently orthogonal.  Use script poscarRectify.py and regenerate doscar"
        exit(0)

    types=list()
    j=1
    for i in atypes:
        types+=[j]*i
        j+=1

    datoms,dtypes,dbasis=duplicate26(atoms,types,basis)

    bounds=[[-i/2.0,i*3.0/2] for i in [basis[0][0],basis[1][1],basis[2][2]]]
    def inBounds(point,bounds):
        for a,[b,c] in zip(point,bounds):
            if a>=c or a<b:
                return False
        return True

    datoms=[atom for atom in datoms if inBounds(atom,bounds)]
    Natoms=len(datoms)

    qvfp.write("3\n")
    qvfp.write("%d\n"%Natoms)
    for atom in datoms:
        qvfp.write("% 6.6f % 6.6f % 6.6f\n"%(atom[0],atom[1],atom[2]))
    qvfp.flush()
    qvfp.close()
    return qvfile,basis,datoms,NRealAtoms
Example #6
0
        print "If duplicate==1, copies the structure (translated by lattice vecs) and then plots."
        exit(0)


    poscar = open(sys.argv[1],"r").readlines()

    dupl=0
    if len(sys.argv)==3:
        dupl=int(sys.argv[2])

    while True:
        if len(poscar)<=1:
            break
        [basis,atypes,atoms,head,poscar] = poscarIO.read(poscar)
        types=list()
        #cs=list()
        j=1
        for i in atypes:
            types+=[j]*i
            #cs.append(colors[j-1])
            j+=1
        Ntypes=len(types)

        if dupl==1:
            atoms,types,basis = duplicate26(atoms,types,basis)
            atoms,types = zip(*sorted(zip(atoms,types),key=lambda x:x[1])) #sort based on type
            atypes = [i*26 for i in atypes]           

        plotsimulation(basis,atoms,atypes)
        pl.show()
Example #7
0
     mlab.points3d(ax,
                   ay,
                   az,
                   types,
                   colormap="gist_heat",
                   scale_factor=0.7)
     mlab.quiver3d(ax,
                   ay,
                   az,
                   afx,
                   afy,
                   afz,
                   line_width=3,
                   scale_factor=1)
 else:
     datoms, dtypes = duplicate26(zip(ax, ay, az), types,
                                  zip(v1, v2, v3))
     axd, ayd, azd = zip(*datoms)
     mlab.points3d(axd,
                   ayd,
                   azd,
                   dtypes,
                   colormap="gist_heat",
                   scale_factor=0.7)
     mlab.plot3d([0, v1[0]], [0, v1[1]], [0, v1[2]],
                 color=(0, 1, 0))
     mlab.plot3d([v1[0], v1[0] + v2[0]], [v1[1], v1[1] + v2[1]],
                 [v1[2], v1[2] + v2[2]],
                 color=(0, 1, 0))
     mlab.plot3d([v1[0], v1[0] + v3[0]], [v1[1], v1[1] + v3[1]],
                 [v1[2], v1[2] + v3[2]],
                 color=(0, 1, 0))
Example #8
0
 print count
 print "Stress (in kB) XX YY ZZ XY YZ XZ:"
 print stresskb
 if md==True:
     print "T=%g,   PE=%g,   TE=%g" % (T,PE,KE)
 else:
     print "PE=%g" % (PE)
 print "="*50
 print ""
 if not(disabled):
     mlab.clf()
     if md==True:
         mlab.points3d(ax,ay,az,types,colormap="gist_heat",scale_factor=0.7)
         mlab.quiver3d(ax,ay,az,afx,afy,afz,line_width=3,scale_factor=1)
     else:
         datoms,dtypes=duplicate26(zip(ax,ay,az),types,zip(v1,v2,v3))
         axd,ayd,azd=zip(*datoms)
         mlab.points3d(axd,ayd,azd,dtypes,colormap="gist_heat",scale_factor=0.7)
         mlab.plot3d([0,v1[0]],[0,v1[1]],[0,v1[2]],color=(0,1,0))
         mlab.plot3d([v1[0],v1[0]+v2[0]],[v1[1],v1[1]+v2[1]],[v1[2],v1[2]+v2[2]],color=(0,1,0))
         mlab.plot3d([v1[0],v1[0]+v3[0]],[v1[1],v1[1]+v3[1]],[v1[2],v1[2]+v3[2]],color=(0,1,0))
         mlab.plot3d([v1[0]+v2[0],v1[0]+v2[0]+v3[0]],[v1[1]+v2[1],v1[1]+v2[1]+v3[1]],[v1[2]+v2[2],v1[2]+v2[2]+v3[2]],color=(0,1,0))
     
         mlab.plot3d([0,v2[0]],[0,v2[1]],[0,v2[2]],color=(0,1,0))
         mlab.plot3d([v2[0],v2[0]+v1[0]],[v2[1],v2[1]+v1[1]],[v2[2],v2[2]+v1[2]],color=(0,1,0))
         mlab.plot3d([v2[0],v2[0]+v3[0]],[v2[1],v2[1]+v3[1]],[v2[2],v2[2]+v3[2]],color=(0,1,0))
         mlab.plot3d([v2[0]+v3[0],v1[0]+v2[0]+v3[0]],[v2[1]+v3[1],v1[1]+v2[1]+v3[1]],[v2[2]+v3[2],v1[2]+v2[2]+v3[2]],color=(0,1,0))
         
         mlab.plot3d([0,v3[0]],[0,v3[1]],[0,v3[2]],color=(0,1,0))
         mlab.plot3d([v3[0],v3[0]+v1[0]],[v3[1],v3[1]+v1[1]],[v3[2],v3[2]+v1[2]],color=(0,1,0))
         mlab.plot3d([v3[0],v3[0]+v2[0]],[v3[1],v3[1]+v2[1]],[v3[2],v3[2]+v2[2]],color=(0,1,0))