Пример #1
0
def type_ordering(VW,L):
    N = VW.shape[1]*8
    order = []
    count = 0
    for k in range(VW.shape[0]):
        print k
        print count
        count = 0
        for i in range(VW.shape[1]):
            NN=count_neighbors_index(VW[k],i,L[k],count=8)[0]
            NN.sort()
            if i < VW.shape[1]/2:
                for j in NN:
                    if j >= VW.shape[1]/2:
                        count+=1
            if i >= VW.shape[1]/2:
                for j in NN:
                    if j < VW.shape[1]/2:
                        count+=1
        order.append(count/float(N))
    x = range(VW.shape[0])
    fid = open('typeorder.txt','w')
    for i in range(len(order)):
        fid.write(('%i %.2f\n'%(i,order[i])))
    fid.close()
    pyplot.plot(x,order,
            xlabel='time',ylabel='ordering',save='typeorder')
Пример #2
0
def steinhardt_order(M,L,l=6,rcut=17.5,count=14,verbose=False):
    print 'l',l
    #Find nearest neighbors for all particles and convert to spherical
    #######
    #neighbors[i][0]=index of neighbors
    #neighbors[i][1]=array[i][x,y,z] of distance between neighbors
    ########
    neighbors=[]
    for i in range(M.shape[0]):
        N = nn.count_neighbors_index(M,i,L,count=count,rcut=rcut,vectors=True)
        if i == 0:
            print i, N[1]
        neighbors.append([N[0],xyz_to_spherical(N[1])])
        if verbose:
            print 'neighbors',len(N[0])
    #find qlm of each particle 
    #######
    #store as values m=-l-l in nparray
    #Qlm[i]=np.array(ql-m:ql+m) for particle i
    #Qlm[i]=qlm(i)
    ######
    Qlm=np.zeros((M.shape[0],2*l+1),dtype=complex)
    qi=np.zeros((1,2*l+1),dtype=complex)
    for i in range(M.shape[0]):
        for m in range(-l,l+1):
            qi[0][m+l]=qlm(neighbors[i][1],l,m)
        Qlm[i][:]=qi
    Ql=[]
    for i in range(M.shape[0]):
        Ql.append(ql(Qlm[i],l))
    print sum(Ql)/len(Ql)
    return Ql
Пример #3
0
def Qmapq6q4(M,L,count=14,crystal=6,verbose=False,rcut=30):
    #Find nearest neighbors for all particles and convert to spherical
    #######
    #neighbors[i][0]=index of neighbors
    #neighbors[i][1]=array[i][x,y,z] of distance between neighbors
    ########
    neighbors=[]
    print 'getting neighbors'
    for i in range(M.shape[0]):
        N = nn.count_neighbors_index(M,i,L,count=count, rcut=rcut,vectors=True)
        if len(N[0]) != count:
            print 'lenght of N', len(N[0])
        neighbors.append([N[0],xyz_to_spherical(N[1])])
        #include itself
        neighbors[-1][0].append(i)
        if verbose:
            print 'neighbors',len(N[0])
    #find qlm of each particle 
    #######
    #store as values m=-l-l in nparray
    #Qlm[i]=np.array(ql-m:ql+m) for particle i
    #Qlm[i]=qlm(i)
    ######
    print 'generating qlm matrix'
    l=4
    qlm_matrix=np.zeros((M.shape[0],2*l+1),dtype=complex)
    for i in range(M.shape[0]):
        for m in range(-l,l+1):
            qlm_matrix[i][m+l]=qlm(neighbors[i][1],l,m)
    Ql4=np.zeros((M.shape[0]),dtype=complex)
    print 'generating Ql_avg'
    for i in range(M.shape[0]):
        qlm_avg=np.zeros((2*l+1),dtype=complex)
        for m in range(-l,l+1):
            for k in neighbors[i][0]:
                qlm_avg[m+l] += qlm_matrix[k,m+l]
            qlm_avg[m+l]/=len(neighbors[i][0])
        Ql4[i]=ql(qlm_avg,l)
    print 'Ql4_avg=',l,Ql4.sum()/Ql4.shape[0]
    Ql6=np.zeros((M.shape[0]),dtype=complex)
    l=6
    qlm_matrix=np.zeros((M.shape[0],2*l+1),dtype=complex)
    for i in range(M.shape[0]):
        for m in range(-l,l+1):
            qlm_matrix[i][m+l]=qlm(neighbors[i][1],l,m)
    for i in range(M.shape[0]):
        qlm_avg=np.zeros((2*l+1),dtype=complex)
        for m in range(-l,l+1):
            for k in neighbors[i][0]:
                qlm_avg[m+l]+=qlm_matrix[k,m+l]
            qlm_avg[m+l]/=len(neighbors[i][0])
        Ql6[i]=ql(qlm_avg,l)
    print 'Ql6_avg=',l,Ql6.sum()/Ql6.shape[0]
    return Ql4,Ql6
Пример #4
0
def solid_particles(M,L,count=14,l=6,c_cut=0.15,crystal=6,verbose=False,rcut=30):
    #Find nearest neighbors for all particles and convert to spherical
    #######
    #neighbors[i][0]=index of neighbors
    #neighbors[i][1]=array[i][x,y,z] of distance between neighbors
    ########
    neighbors=[]
    for i in range(M.shape[0]):
        N = nn.count_neighbors_index(M,i,L,count=count,rcut=rcut, vectors=True)
        neighbors.append([N[0],xyz_to_spherical(N[1])])
        if verbose:
            print 'neighbors',len(N[0])
    #find qlm of each particle 
    #######
    #store as values m=-l-l in nparray
    #Qlm[i]=np.array(ql-m:ql+m) for particle i
    #Qlm[i]=qlm(i)
    ######
    Qlm=np.zeros((M.shape[0],2*l+1),dtype=complex)
    qi=np.zeros((1,2*l+1),dtype=complex)
    for i in range(M.shape[0]):
        for m in range(-l,l+1):
            qi[0][m+l]=qlm(neighbors[i][1],l,m)
        Qlm[i][:]=qi
    #for nearest neighbors find the Sij vector
    S=[]
    for i in range(M.shape[0]):
        S.append(Sij(Qlm[i],Qlm[neighbors[i][0]]))
    #for each particle lets counts its neighbors
    #if it has more than ccut we say it is a solid
    iscrystal=[0.0 for i in range(M.shape[0])]
    counter=0
    store_j = []
    for i in S:
        #if verbose:
        #    print i
        count=0
        for j in i:
            #this is the cutoff for declaring 2 particles connected
            if j.real>c_cut:
                store_j.append(j.real)
                count+=1
        if count >= crystal:
            iscrystal[counter]=1
        counter+=1
    try:
        print sum(store_j)/len(store_j)
    except:
        print 'no bonds'
    num=iscrystal.count(1)
    print 'crystals',num
    return num, iscrystal
Пример #5
0
def Qmap(M,L,count=14,l=6,crystal=6,verbose=False,rcut=30):
    #Find nearest neighbors for all particles and convert to spherical
    #######
    #neighbors[i][0]=index of neighbors
    #neighbors[i][1]=array[i][x,y,z] of distance between neighbors
    ########
    neighbors=[]
    #otree = node(L,delta=(M.shape[0]/2)**0.333)
    #otree.add_particles(M)
    print 'getting neighbors'
    for i in range(M.shape[0]):
        #N = cn_tree_index(M,i,otree,L,count=count,rcut=rcut)
        N = nn.count_neighbors_index(M,i,L,count=count,rcut=rcut,vectors=True)
        neighbors.append([N[0],xyz_to_spherical(N[1])])
        #include itself
        neighbors[-1][0].append(i)
        if verbose:
            print 'neighbors',len(N[0])
    #find qlm of each particle 
    #######
    #store as values m=-l-l in nparray
    #Qlm[i]=np.array(ql-m:ql+m) for particle i
    #Qlm[i]=qlm(i)
    ######
    print 'generating qlm matrix'
    qlm_matrix=np.zeros((M.shape[0],2*l+1),dtype=complex)
    for i in range(M.shape[0]):
        for m in range(-l,l+1):
            qlm_matrix[i][m+l]=qlm(neighbors[i][1],l,m)
    Ql=np.zeros((M.shape[0]),dtype=complex)
    print 'generating Ql_avg'
    for i in range(M.shape[0]):
        qlm_avg=np.zeros((2*l+1),dtype=complex)
        for m in range(-l,l+1):
            for k in neighbors[i][0]:
                qlm_avg[m+l]+=qlm_matrix[k,m+l]
            qlm_avg[m+l]/=len(neighbors[i][0])
        Ql[i]=ql(qlm_avg,l)
    print 'Ql=',l,Ql.sum()/Ql.shape[0]
    return Ql