Exemple #1
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')
Exemple #2
0
def end_end(V,W,M,L):
    T=M.cord_auto(['T'])
    K=M.cord_auto(['K'])
    V=M.cord_auto(['V'])
    W=M.cord_auto(['W'])
    ndna = T.shape[1]/V.shape[1]
    #K-V
    #W-T
    VK=[]
    WT=[]
    last = V.shape[0]
    #find center-ssdna particle distance
    for k in range(last-5,last):
        for i in range(V.shape[1]):
            for j in range(ndna):
                VK.append(points.dist(V[k][i],K[k][j+i*ndna],L)[0]-3)
                WT.append(points.dist(W[k][i],T[k][j+i*ndna],L)[0]-3)
    hist_K,xK,max_k=histogram(VK,10)
    hist_T,xT,max_T=histogram(WT,10)

    plt.close()
    pyplot.plot_bar(xK,hist_K,save='VK_distance')
    plt.close()
    pyplot.plot_bar(xT,hist_T,save='WT_distance')
    plt.close()

    #find the length of the polymer

    KT=M.cord_auto(['K','T'])
    S=M.cord_auto(['M'])
    edge=[]
    for k in range(last-5,last):
        for i in range(S.shape[1]):
            edge.append(points.dist(KT[k][i],S[k][i],L)[0])
    hist_edge,xedge,max_edge=histogram(edge,50)

    pyplot.plot_bar(xedge,hist_edge,save='polymer_length')
    plt.close()
Exemple #3
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()