Exemplo n.º 1
0
 def hist(M1,M2,save_name,label):
     distance=particle_distance(M1,M2,L)
     dist = []
     for d in distance:
         if d>1 and d<25:
             dist.append(d)
     hist_s,xs=histogram_reg(dist,bins=25)
     return xs,hist_s
Exemplo n.º 2
0
def mixing_frame(V,W,L,frame,rcut=False):
    #The total number of frames we are going to look at
    #rcut = 19
    rcut = 22
    k = frame
    Same = []
    Other = []
    print k
    for k in range(frame,frame+10):
        for i in range(V[k].shape[0]):
            Same.append(len(nearest_neighbors_point(V[k],V[k][i],L,rcut)[0]))
            Same.append(len(nearest_neighbors_point(W[k],W[k][i],L,rcut)[0]))
            Other.append(len(nearest_neighbors_point(W[k],V[k][i],L,rcut)[0]))
            Other.append(len(nearest_neighbors_point(V[k],W[k][i],L,rcut)[0]))
    hist_same, x_s = histogram_reg(Same,8)
    hist_other, x_o = histogram_reg(Other,8)
    pyplot.plot_bar(x_o, hist_other, label='other', save=('mix_other%i'%k), showleg=True)
    pyplot.plot_bar(x_s, hist_same, label='Same',
            save=(('mix_same_frame%i_rcut%.1f')%(k,rcut)), showleg=True,color='r')
Exemplo n.º 3
0
def projection_jump(VW,surface,proj,L,k,save='proj_hist'):
    #skip = VW.shape[0]/len(surface)
    skip = 1
    jump_d = []
    print len(surface)
    print VW.shape
    print proj.shape
    try:
        for i in surface:
            n, dist = close_neighbors_point(proj,VW[i],L)
            jump_d.append(dist)
    except:
        for i in surface:
            n, dist = close_neighbors_point(proj,VW[i-VW.shape[0]],L)
            jump_d.append(dist)
    print jump_d
    hist_s,xs=histogram_reg(jump_d,bins=10)
    pyplot.plot(xs,hist_s,xlabel='distance',ylabel='count',save=save)
    return jump_d
Exemplo n.º 4
0
def msd_jump(VW,L):
    reload(diffuse)
    fid = open('large.xyz','r')
    M = readxyz.ReadCord(trajectory = 'large.xyz',frames = 777)
    crystal = M.cord_auto(['V','W'])
    bcc = np.zeros((777,432,1))
    x = range(50,500,50)
    delta = 50
    for frame in range(bcc.shape[0]):
        for i in range(bcc.shape[1]):
            if crystal[frame][i][0] > L[0]:
                bcc[frame][i]=0
            else:
                bcc[frame][i]=1
    jumps = []
    for i in x:
        jumps.extend(diffuse.crystal_jump(VW,bcc,L,i,delta))
    print len(jumps)
    import MD.plot.pyplot_eps as pyplot_eps
    util.pickle_dump(jumps,'jump.pkl')
    hist_s,xs=histogram_reg(jumps,bins=20)
    pyplot_eps.plot_bar(xs,hist_s,xlabel=r'$\sigma$',ylabel='count',save='jump_hist')
Exemplo n.º 5
0
def vac_surround(DV,DW,CV,CW,L):
    vacancies = np.zeros((DV.shape[0],1))
    #find the vacancies in the simulations
    for k in range(len(DW)):
        #find the points that are nearest neighbor that are different
        index = np.where(DW[k] == 0)[0]
        if len(index) > 0:
            if len(index) > 1:
                print index
                index = index[0]
            vacancies[k]  = index
        else:
            index = np.where(DV[k] == 0)[0]
            if len(index) > 1:
                index = index[0]
            vacancies[k] = index + DW.shape[1]
    #now that we have the indexes lets go back through and pick out where they
    #came from
    def check(vac, DW, DV):
        if vac > DW.shape[0]:
            return DV[vac-DW.shape[0]]
        else:
            return DW[vac]
    # find lattice point
    def find_lattice(vac, CW, CV):
        vac = int(vac[0])
        if vac > CW.shape[0]:
            return CV[vac-CW.shape[0]]
        else:
            return CW[vac]
    #find the index of the neighbors of the vacancey
    def find_neighbors(index, CW, CV, L, cut = 17):
        point = find_lattice(index,CW,CV)
        V_neighbors = []
        W_neighbors = []
        for i,j in enumerate(CV):
            if points.dist(j,point,L)[0] < cut:
                if points.dist(j,point,L)[0] > 1:
                    V_neighbors.append(i)
        for i,j in enumerate(CW):
            if points.dist(j,point,L)[0] < cut:
                if points.dist(j,point,L)[0] > 1:
                    W_neighbors.append(i)
        return V_neighbors, W_neighbors

    #Find out if the neighbors are substitutions or correctly placed
    def find_subs(V, W, DW, DV):
        subs = []
        for i in V:
            subs.append(DV[i])
        for i in W:
            subs.append(DW[i])
        return subs

    #find the number of substitutions at each step surrounding the vacancy
    subs = []
    for k in range(len(vacancies)):
        V_neigh, W_neigh = find_neighbors(vacancies[k], CW, CV, L)
        sub  = find_subs(V_neigh, W_neigh, DW[k], DV[k])
        count = 0
        for i in sub:
            if i < 0:
                count+=1
        subs.append(count)


    #find the number of substitutions surrounding a point
    #find the time that the vacancy remains there
    time = 1
    vac = []
    for k in range(2,vacancies.shape[0]):
        if vacancies[k] == vacancies[k-1]:
            time += 1
        else:
            vac.append([subs[k-1],time,k-1])
            time = 1
    out = open('vacancy_sub_time_frame','w')
    out.write('num subs, time, frame\n')
    for i in vac:
        out.write(('%i    %i    %i\n')%(i[0],i[1],i[2]))
    out.close()
    print vac
    #lets make the data accessable. How about trying a histogram
    #first sort by numer of substittuioins
    d0 = []
    d1 = []
    d2 = []
    d3 = []
    d4 = []
    for i in vac:
        if i[1] > 1:
            if i[0] == 3:
                d3.append(i[1])
            if i[0] == 2:
                d2.append(i[1])
            if i[0] == 1:
                d1.append(i[1])
            if i[0] == 0:
                d0.append(i[1])
            if i[0] == 4:
                d4.append(i[1])
    print d0
    print d1
    print d2
    print d3
    print d4

    hist0,x0=histogram_reg(d0,20)
    hist1,x1=histogram_reg(d1,20)
    hist2,x2=histogram_reg(d2,20)
    hist3,x3=histogram_reg(d3,20)
    s0 = sum(d0)/float(len(d0))
    s1 = sum(d1)/float(len(d1))
    s2 = sum(d2)/float(len(d2))
    s3 = sum(d3)/float(len(d3))

    pyplot.plot_bar([0,1,2,3],[s0,s1,s2,s3],save='vaclife')
    plt.close()

    pyplot.plot_bar(x0,hist0,save='substitutions0')
    plt.close()
    
    util.pickle_dump([d0,d1,d2,d3],'subs_lifetime.pkl')

    pyplot.plot_bar(x0,hist0,save='substitutions0')
    plt.close()
    pyplot.plot_bar(x1,hist1,save='substitutions1')
    plt.close()
    pyplot.plot_bar(x2,hist2,save='substitutions2')
    plt.close()
    pyplot.plot_bar(x3,hist3,save='substitutions3')
    plt.close()