Пример #1
0
def animate():
    ##FROM DCD
    M=MD.ReadCord()
    Lx = M.box_length
    Ly = M.box_length_y
    Lz = M.box_length_z
    L = np.array([Lx, Ly, Lz])
    L_cont = M.box_volume()
    Z = util.pickle_load('Zbound.pkl')
    VW = util.pickle_load('VW.pkl')
    animate_script = open('animate/animate.tcl','w')
    for i in range(VW.shape[1]):
        if i < VW.shape[1]/2:
            A.append(0)
        else:
            A.append(1)

    #for k in range(len(VW.shape[0])):
    for k in range(50,100):
        fid = open('animate/square%i.tcl'%k,'w')
        #A = read_color_index(frame=k)
        for i in range(VW.shape[1]):
            c = VW[k][i]
            v1 = Z[k][i*6] - c
            v2 = Z[k][i*6+2] - c
            v3 = Z[k][i*6+4] - c
            #v1 = Z[k][i*6] - c
            #v2 = Z[k][i*6+1] - c
            #v3 = Z[k][i*6+5] - c
            #v1,v2,v3 = allign(v1,v2,v3)
            color = ['blue','red','green','orange','purple']
            dw.draw_cube(fid,c,v1,v2,v3,color[int(A[i])])
        animate_script.write('\nsource square%i.tcl\n display update ui\n'%k)
        animate_script.write('\nafter 1000\ndraw delete all\n display update ui\n')
        fid.close()
Пример #2
0
def vac_near():
    import MD
    CV = util.pickle_load('CV.pkl')
    CW = util.pickle_load('CW.pkl')
    DV = util.pickle_load('DV.pkl')
    DW = util.pickle_load('DW.pkl')
    vac_surround(DV,DW,CV,CW,MD.L)
Пример #3
0
def msd_index(VW,L):
    k=100
    time = 500

    surface =  util.pickle_load('surface.pkl')
    DV =  util.pickle_load('DV_s.pkl')
    DW =  util.pickle_load('DW_s.pkl')
    CV =  util.pickle_load('CV.pkl')
    CW =  util.pickle_load('CW.pkl')

    defects = []
    print DV.shape
    print DW.shape
    for i in range(DV[k].shape[0]):
        if DV[k][i] == -1:
            index, d = close_neighbors_point(VW[k],CV[i],L)
            defects.append(index)
    for i in range(DW[k].shape[0]):
        if DW[k][i] == -1:
            index, d = close_neighbors_point(VW[k],CW[i],L)
            defects.append(index)
    print len(defects)


    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))
    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
    s = []
    for i in range(len(bcc[k])):
            if surface[k][i]:
                s.append(i)
    gel = []
    for i in range(len(bcc[k])):
            if bcc[k][i] ==0 and surface[k][i] == 0:
                gel.append(i)
    crystal = []
    for i in range(len(bcc[k])):
            if bcc[k][i] == 1:
                crystal.append(i)

    #diffuse.index_msd(VW,s,L,time,save='msd_index_%i_surface_%i'%(k,len(s)))
    x,msd=diffuse.index_msd(VW,gel,L,time,save='msd_index_%i_gel_%i'%(k,len(gel)))
    x2,msd2=diffuse.index_msd(VW,crystal,L,time,save='msd_index_%i_solid_%i'%(k,len(crystal)))
    util.pickle_dump([x,msd,x2,msd2],'msd_index.pkl')
    #diffuse.index_msd(VW,defects,L,time,save='msd_index_%i_defects_%i'%(k,len(defects)))
    #r = list(set(s)-set(defects))
    #diffuse.index_msd(VW,r,L,time,save='msd_index_%i_nodefect%i'%(k,len(r)))
    #print len(defects)
    #print len(s)
    import MD.plot.pyplot_eps as pyplot_eps
    pyplot_eps.plot2(x,msd,x2,msd2,xlabel='t',ylabel='msd',label1='gel',label2='solid',save='msdgelsolid')
Пример #4
0
def run_test():
    #print out directory dirname = os.getcwd().partition('/')[-1]
    dirname = os.getcwd().partition('/')[-1]
    print "Starting:",dirname.split('/')[-1]
    M=MD.ReadCord()
    Lx = M.box_length
    Ly = M.box_length_y
    Lz = M.box_length_z
    L = np.array([Lx, Ly, Lz])
    print L
    last = M.frames
    delta = 25
    try:
        V = util.pickle_load('V.pkl')
        W = util.pickle_load('W.pkl')
        VW = util.pickle_load('VW.pkl')
    except:
        #V=M.cord_range(['V'],delta=delta)
        #W=M.cord_range(['W'],delta=delta)
        #VW=M.cord_range(['V','W'],delta=delta)
        V=M.cord_auto(['V'])
        W=M.cord_auto(['W'])
        VW=M.cord_auto(['V','W'])
        VW_index=M.get_names(['V','W'])
        VW,V,W = drift_remove_all(VW,V,W,L,VW_index)
        util.pickle_dump(V,'V.pkl')
        util.pickle_dump(W,'W.pkl')
        util.pickle_dump(VW,'VW.pkl')
    if V.shape[0]>5:
        x = range(0,V.shape[0],V.shape[0]/3)
    else:
        x = range(V.shape[0])
    delta = 1
    #step,temp = mylog(row = 2)
    #plt.close()
    mylog_average(row = 1,delta=20)
    msd(VW,L,time_scale=delta)
    print V
    #msd_phases(VW,L)
    #msd_jump(VW,L)
    #sd_index(VW,L)
    #jump_lattice(VW,L)
    #solid_particles_vmd(VW,V,W,L,M,skip=25)
    #solid_particles_vmd(VW[1000:],V[1000:],W[1000:],L,var,skip=10)
    #plt.close()
    #species_mixing(V,W,L,n_finish=last)
    #plt.close()
    #end_end(V,W,M,L)
    ##plt.close()
    for i in x:
        print "finding s(q)"
        structure_factor(VW, L, n_start=i,save='sf'+str(i))
        #structure_factor(V, L, n_start=i,save='sfV'+str(i))
        #structure_factor(W, L, n_start=i,save='sfW'+str(i))
        print "finding g(s)"
        distance_distribution(V,W,L,n_start=i)
        plt.close()
Пример #5
0
def animate_binary(frames=[0,1]):
    #print out directory
    M=MD.ReadCord()
    Lx = M.box_length
    Ly = M.box_length_y
    Lz = M.box_length_z
    L = M.box_volume()
    last = M.frames
    try:
        Z = util.pickle_load('Z.pkl')
        VW = util.pickle_load('VW.pkl')
        npType = M.get_type(['V','W'])
    except:
        Z=M.cord_auto(['Z'])
        VW=M.cord_auto(['V','W'])
        npType = M.get_type(['V','W'])
        util.pickle_dump(Z,'Z.pkl')
        util.pickle_dump(VW,'VW.pkl')
    for k in frames:
    #apply boundary conditions to move particle
        for i in range(VW.shape[1]):
            for j in range(i*6,i*6+6):
                Z[k][j] = boundary(Z[k][j],VW[k][i],L[k])
    util.pickle_dump(Z,'Zbound.pkl')
    animate_script = open('animate/animate.tcl','w')
    #for binary systems use this A
    #fid = open('sc_num.txt','r')
    #crystal = []
    #for line in fid.readlines():
    #    crystal.append(float(line.split()[0]))
    #fid.close()
    A = []
    for i in range(VW.shape[1]):
        if npType[i] == 'V':
            A.append(0)
        else:
            A.append(1)
    for k in frames:
        fid = open('animate/square%i.tcl'%k,'w')
        for i in range(VW.shape[1]):
            c = VW[k][i]
            #v1 = Z[k][i*6] - c
            #v2 = Z[k][i*6+2] - c
            #v3 = Z[k][i*6+4] - c
            v1 = Z[k][i*6] - c
            v2 = Z[k][i*6+1] - c
            v3 = Z[k][i*6+5] - c
            #v1,v2,v3 = allign(v1,v2,v3)
            color = ['blue','red','green','orange','purple']
            dw.draw_cube(fid,c,v1,v2,v3,color[int(A[i])])
        cub.gaussmap_color(VW,Z,L,k,A)
        animate_script.write('\nsource square%i.tcl\n display update ui\n'%k)
        animate_script.write('\nafter 1000\ndraw delete all\n display update ui\n')
        fid.close()
Пример #6
0
def animate(frames=[0,1]):
    #print out directory
    M=MD.ReadCord()
    Lx = M.box_length
    Ly = M.box_length_y
    Lz = M.box_length_z
    L = M.box_volume()
    last = M.frames
    try:
        Z = util.pickle_load('Z.pkl')
        VW = util.pickle_load('VW.pkl')
    except:
        Z=M.cord_auto(['Z'])
        VW=M.cord_auto(['V','W'])
        util.pickle_dump(Z,'Z.pkl')
        util.pickle_dump(VW,'VW.pkl')
    cubic_order_animate(VW,Z,L,frames)
    for k in frames:
    #apply boundary conditions to move particle
        for i in range(VW.shape[1]):
            for j in range(i*6,i*6+6):
                Z[k][j] = boundary(Z[k][j],VW[k][i],L[k])
    util.pickle_dump(Z,'Zbound.pkl')
    animate_script = open('animate/animate.tcl','w')
    #for binary systems use this A
    #A = []
    #for i in range(VW.shape[1]):
    #    if i < VW.shape[1]/2:
    #        A.append(0)
    #    else:
    #        A.append(1)
    #for k in range(len(VW.shape[0])):
    for k in frames:
        fid = open('animate/square%i.tcl'%k,'w')
        fid2= open('animate/square%i.txt'%k,'w')
        A = read_color_index(frame=k)
        for i in range(VW.shape[1]):
            c = VW[k][i]
            v1 = Z[k][i*6] - c
            v2 = Z[k][i*6+2] - c
            v3 = Z[k][i*6+4] - c
            #v1 = Z[k][i*6] - c
            #v2 = Z[k][i*6+1] - c
            #v3 = Z[k][i*6+5] - c
            #v1,v2,v3 = allign(v1,v2,v3)
            color = ['blue','red','green','orange','purple']
            dw.draw_cube(fid,fid2,c,v1,v2,v3,color[int(A[i])])
        cub.gaussmap_color(VW,Z,L,k,A)
        animate_script.write('\nsource square%i.tcl\n display update ui\n'%k)
        animate_script.write('\nafter 1000\ndraw delete all\n display update ui\n')
        fid.close()
Пример #7
0
Файл: dna.py Проект: cdknorow/MD
def end_end_connected(M,L): #find the length of the polymer
    ## \brief end to end distance of hybridized vs nonhybridized polymers
    #
    # \returns average distance from start to end of polymer 
    #           for hybridizations and free polymer
    #
    # \param M - ReadCord Class  
    # \param L 
    #
    # V ----- A C k
    # W ----- F G T
    import MD.analysis.connections as con
    try:
        K=util.pickle_load('K.pkl')
        T=util.pickle_load('T.pkl')
        S=util.pickle_load('S.pkl')
    except:
        K=M.cord_auto(['K'])
        T=M.cord_auto(['T'])
        S=M.cord_auto(['M'])
        util.pickle_dump(K,'K.pkl')
        util.pickle_dump(T,'T.pkl')
        util.pickle_dump(S,'S.pkl')
    #get connections
    con = _connections(M)
    h_sum = []
    f_sum = []
    for k in range(len(con)):
        print k
        hybrid = []
        free = []
        #get the points that are not connected
        for i in range(K.shape[1]):
            if i in con[k][0]:
                hybrid.append(points.dist(K[k][i],S[k][i],L[k])[0]+0.5)
            else:
                free.append(points.dist(K[k][i],S[k][i],L[k])[0]+0.5)
        for i in range(T.shape[1]):
            if i in con[k][1]:
                hybrid.append(points.dist(T[k][i],S[k][i+K.shape[1]],L[k])[0]+0.5)
            else:
                free.append(points.dist(T[k][i],S[k][i+K.shape[1]],L[k])[0]+0.5)
        print hybrid
        h_sum.append(sum(hybrid)/len(hybrid))
        f_sum.append(sum(free)/len(free))
    f_sum[-1]= f_sum[-2]
    h_sum[-1]= h_sum[-2]
    x = range(S.shape[0])
    pyplot.plot2(x,h_sum,x,f_sum,xlabel='timestep',ylabel='sigma',label1='hybridizations',
        label2='free',save='free_hybrid_end_end_connections',showleg='true')
Пример #8
0
def run_defect():
    #setup
    #print out directory
    dirname = os.getcwd().partition('/')[-1]
    print "Starting:",dirname.split('/')[-1]
    try:
        var = MD.util.get_path_variables()
    except:
        var = {'ndna':60}
    print var
    M=MD.ReadCord()
    L = M.box_length
    last = M.frames
    try:
        V = util.pickle_load('V.pkl')
        W = util.pickle_load('W.pkl')
        R = util.pickle_load('R.pkl')
        VW = util.pickle_load('VW.pkl')
    except:
        V=M.cord_auto(['V'])
        W=M.cord_auto(['W'])
        R=M.cord_auto(['R'])
        VW=M.cord_auto(['V','W'])
        VW,V,W = drift_remove_all(VW,V,W,L)
        R = drift_remove(R,L)
        util.pickle_dump(V,'V.pkl')
        util.pickle_dump(W,'W.pkl')
        util.pickle_dump(VW,'VW.pkl')
        util.pickle_dump(R,'R.pkl')
    x = range(0,last,last/5)
    #mylog()
    #plt.close()
    solid_particles_vmd(VW,V,W,L,var,skip=100)
    plt.close()
    #species_mixing(V,W,L,n_finish=last)
    #plt.close()
    #species_mixing_fcc(VW,L,n_finish=last)
    #plt.close()
    for i in x:
        #print "finding s(q)"
        structure_factor(VW, L, var, n_start=i,save='sf'+str(i))
        print "finding g(s)"
        distance_distribution(V,W,L,n_start=i)
        plt.close()
    msd(VW,L)
    plt.close()
    msd(R,L,save='msd_R')
    plt.close()
Пример #9
0
def animate_beads(frames=[0,1]):
    #print out directory
    M=MD.ReadCord()
    Lx = M.box_length
    Ly = M.box_length_y
    Lz = M.box_length_z
    L = M.box_volume()
    last = M.frames
    try:
        VW = util.pickle_load('VW.pkl')
        npType = M.get_type(['V','W'])
    except:
        VW=M.cord_auto(['V','W'])
        npType = M.get_type(['V','W'])
        util.pickle_dump(VW,'VW.pkl')
    #for binary systems use this A
    for k in frames:
        fid = open('animate/Color%i.tcl'%k,'w')
        fid.write('%i\n\n'%VW.shape[1])
        V = Average(VW,L,k-5,5)
        A = read_color_index(frame=k)
        for i in range(VW.shape[1]):
            x = V[i][0]
            y = V[i][1]
            z = V[i][2]
            color = ['B','R','G','O','P']
            fid.write('%c %.2f %.2f %.2f\n'%(color[int(A[i])],x,y,z))
        fid.close()
Пример #10
0
Файл: dna.py Проект: cdknorow/MD
def ipy_single():
    dirname = os.getcwd().partition('/')[-1]
    print "Starting:",dirname.split('/')[-1]
    #initial file
    dirname = os.getcwd().partition('/')[-1]
    print "Starting:",dirname.split('/')[-1]
    delta = 10
    M=MD.ReadCord()
    Lx = M.box_length
    Ly = M.box_length_y
    Lz = M.box_length_z
    L = np.array([Lx, Ly, Lz])
    L_cont = M.box_volume()
    L_cont[-1] = L_cont[-2]
    util.print_box_volume(L_cont,delta=delta)
    last = M.frames
    #V_index = M.get_index(['V'])
    #W_index = M.get_index(['W'])
    try:
        VW = util.pickle_load('VW.pkl')
    except:
         VW=M.cord_auto(['V','W'])
         #VW,Z,W = drift_remove_all(VW,Z,VW,L)
         util.pickle_dump(VW,'VW.pkl')
    #L_last = L_cont[0][0]
    #for i,j in enumerate(L_cont):
    #    if j[0] != L_last:
    #        L_last = j[0]
    #        if i - 5 > 0:
    #            x.append(i-5)
    x = range(0,last)
    index = M.get_index(['C','G'])
    ndna = len(index)/VW.shape[1]
    return [M,VW,L_cont,x,ndna]
Пример #11
0
Файл: dna.py Проект: cdknorow/MD
def _connections(M):
    try:
        con = util.pickle_load('conn.pkl')
    except:
        fid = open('conn_who.dat','r')
        c_index = M.get_index(['C'])
        g_index = M.get_index(['G'])
        con = []
        count = 0
        for line in fid.readlines():
            print count
            con_K = []
            con_T = []
            #linker alternates between c g and cc gg
            line = line.replace('}','')
            for i in line.split('{')[1].split():
                #translate connections
                try:
                    con_K.append(c_index.index(int(i)))
                except:
                    print 'error connection was not in list'
            for i in line.split('{')[2].split():
                #translate connections
                try:
                    con_T.append(g_index.index(int(i)))
                except:
                    print 'error connection was not in list'
            con.append([con_K,con_T])
            count += 1
        del con[-1]
        util.pickle_dump(con,'conn.pkl')
    return con
Пример #12
0
def find_networks(M, VW, L, n_finish=1, n_start=0, delta=30, rcut=1.0, ndna=25):
    #The total number of frames we are going to look at
    x=np.arange(n_start,n_finish,delta)
    print len(x)
    #Find the number of connections at specific points x
    import MD.canalysis.connections as con
    import MD.analysis.connections as conn
    import MD.analysis.graph as graph
    try:
        connections = util.pickle_load('con.pkl')
    except:
        try:
            C = util.pickle_load('C.pkl')
            G = util.pickle_load('G.pkl')
        except:
            G=M.cord_auto(['G'])
            C=M.cord_auto(['C'])
            util.pickle_dump(C,'C.pkl')
            util.pickle_dump(G,'G.pkl')
        connections = con.connections(C[x],G[x],L,rcut=rcut)
        util.pickle_dump(connections,'con.pkl')
    #plot total number of connections
    num_connections=conn.num_connections(connections,VW.shape[1])
    con_all = []
    for i in range(len(connections)):
        con_all.append(len(connections[i])/2.)
    pyplot.plot(x,num_connections,xlabel='Time',
            ylabel='hyrbid. density', save='connections')
    pyplot.plot(x,con_all,xlabel='Time',
            ylabel='hyrbid', save='connections_all')
    plt.close()
    #get the info
    networks, num_networks, deg, neighbors, num_n, gr = graph.grapher(connections,VW.shape[1],ndna)
    util.pickle_dump(networks,'net.pkl')
    #plot the number of neighbors at each timesteps
    pyplot_eps.plot(x,num_n,xlabel='Time',
            ylabel='num neighbors', save='neighbors')
    plt.close()
    print 'making plot'
    net = []
    for i in networks:
        net.append(len(i))
    pyplot_eps.plot(x,net,xlabel='t',ylabel='networks',save='net')
    label = ['networks','1','2','3','4','5','6','7','8','9']
    pyplot_eps.plot(x,networks,xlabel='t',ylabel='Networks',save='net')
    pyplot.plot_multi(x,deg,label,xlabel='time',ylabel='number',save='con_net')
    return x, networks, connections
Пример #13
0
def run_blah2():
    dirname = os.getcwd().partition('/')[-1]
    print "Starting:",dirname.split('/')[-1]
    M=MD.ReadCord()
    Lx = M.box_length
    Ly = M.box_length_y
    Lz = M.box_length_z
    L = np.array([Lx, Ly, Lz])
    surface =  util.pickle_load('surface.pkl')
    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))
    for k in range(bcc.shape[0]):
        for i in range(bcc.shape[1]):
            if crystal[k][i][0] > L[0]:
                bcc[k][i]=0
            else:
                bcc[k][i]=1
    crystal = []
    for k in range(len(bcc)):
        c=[]
        for i in range(len(bcc[k])):
            if bcc[k][i] == 1:
                c.append(i)
        crystal.append(len(c))
    s = []
    for k in range(len(surface)):
        surf = []
        for i in range(len(surface[k])):
            if surface[k][i]:
                surf.append(i)
        s.append(surf)
    util.pickle_dump(s,'surface_diffusion.pkl')
    util.pickle_dump(crystal,'crystal_diffusion.pkl')
    lamda=4
    D=0.05
    ns = []
    dt = 10
    dmdt = []
    C = lamda**2/(D*24)
    start = 100
    finish = 350 
    for k in range(start,finish,dt):
        n = 0
        for i in range(dt):
            n += len(s[i+k]) 
        ns.append(n/dt)

    count = 0
    for i in range(start,finish,dt):
        dm = crystal[i]-crystal[i-dt]
        dmdt.append(C*dm/ns[count])
        count += 1
    x = np.arange(start,finish,dt)
    pyplot.plot(x,dmdt,save='diffusion')
Пример #14
0
def self_intermediate_scattering(VW, L, x, n_start=1, 
        filters=0.05, dh=0.05,save='sf',l=5,delta=5,calc=True):
    import MD.analysis.sfactor as sf
    #Find Structure Factor
    if calc:
        import time
        from MD.canalysis.int_scattering import int_scatter
        F = []
        for i in range(delta):
            print i
            print "caculating Average" 
            print VW.shape
            print "Structure Factor" 
            A = VW[n_start+i]
            stmp,qx = sf.sfactor(np.array([A]),L=L[n_start],l=l)
            S,Q,primitive_vectors = sf.sort_sfpeaks(stmp,qx)
            S,Q,primitive_vectors = sf.sf_filter_max(S,Q,primitive_vectors,filters=0.5)
            index = S.index(max(S))
            k = primitive_vectors[S.index(max(S))]
            #take the average over different starting configurations
            print "Calculating Int Scattering" 
            start = time.clock()
            scat_c = int_scatter(VW[n_start+i:],np.array(L[0]),np.array(k),
                    np.array(x[:-(n_start+i)]))
            end = time.clock()
            print 'cython runtime'
            print end-start
            F.append(scat_c)
        F_avg = np.zeros((len(F[-1])))
        for i in F:
            for j in range(len(F[-1])):
                F_avg[j] += i[j]
        F_avg /= delta
        #reset the zero of x so that the plot starts at the correct time
        x = range(len(F[-1]))
        util.pickle_dump([x,F_avg],'si_scat.pkl')
    xlabel = 't'
    ylabel = 'F(q,t)'
    save = 'int_scatter'
    A = util.pickle_load('si_scat.pkl')
    x = A[0]
    F_avg = A[1]
    #Kohlraush-Williams-Watts function
    # A exp[-(t/tau_b)^beta]
    beta = 1.4
    tau_a = 6
    K = []
    K_x = []
    fid = open('self_scat.dat','w')
    for i in range(len(A[0])):
        fid.write('%i %.4f\n'%(A[0][i],A[1][i]))
    fid.close()
    for i in np.arange(1,len(x),0.1):
        K.append(F_avg[1] * math.exp(-(i/tau_a)**beta))
        K_x.append(i)
Пример #15
0
def solid_particles(VW, L, VW_names, x, avg=1, step=5e4, bcc = True, sc = False, GenLattice = False):
    solid_particles = []
    solid_crystals = []
    try:
        solid_crystals = util.pickle_load('spcrystal.pkl')
        solid_particles = util.pickle_load('solidp.pkl')
    except:
        for k in x:
            print 'step', k
            A = av.average_position(VW,k,avg,L)
            if bcc:
                num, crystals = (bond_order.solid_particles(A,
                                L[k],c_cut=0.15, count=8,l=6,crystal=7))
            if sc:
                num, crystals = (bond_order.solid_particles(VW[k],
                                L[k],c_cut=0.175, count=6,l=4,crystal=5))
            solid_crystals.append(crystals)
            solid_particles.append(num)
        util.pickle_dump(solid_crystals,'spcrystal.pkl')
        util.pickle_dump(solid_particles,'solidp.pkl')

    fid = open('solidpart.txt','w')
    for i in range(len(x)):
        fid.write('%i %i %.2f\n'%(x[i], solid_particles[i], L[x[i]][0]))
    fid.close()

    if GenLattice:
        # make an xyz file of the crystals and there locations
        f = open('solidpcrystals.xyz','w')
        count=0
        for k in x:
            f.write(('%i \n\n')%(VW.shape[1]))
            for i in range((len(solid_crystals[count]))):
                if solid_crystals[count][i] == 1:
                        f.write(('%c %.2f %.2f %.2f \n')%('V',VW[k][i][0],VW[k][i][1],VW[k][i][2]))
                else:
                        f.write(('%c %.2f %.2f %.2f\n')%('W',4*L[k][0],4*L[k][0],4*L[k][0]))
            count += 1
        f.close()
    return x, solid_particles
Пример #16
0
def msd_jump_average(VW,L):
    reload(diffuse)
    try:
        jump_d = util.pickle_load('jump_d.pkl')
        jump_t = util.pickle_load('jump_t.pkl')
    except:
        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))
        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
        jump_d, jump_t = diffuse.crystal_jump(VW,bcc,L)
        util.pickle_dump(jump_d,'jump_d.pkl')
        util.pickle_dump(jump_t,'jump_t.pkl')
    pyplot.plot(jump_t,jump_d,'','s',xlabel='time',ylabel='jump distance',save='msd_jump')
    hist_s,xs,max_hist=histogram(jump_d,bins=20)
    pyplot.plot(xs,hist_s,xlabel='distance',ylabel='count',save='jump_hist')
Пример #17
0
def run_binary():
    #print out directory dirname = os.getcwd().partition('/')[-1]
    dirname = os.getcwd().partition('/')[-1]
    print "Starting:",dirname.split('/')[-1]
    M=MD.ReadCord()
    Lx = M.box_length
    Ly = M.box_length_y
    Lz = M.box_length_z
    L = np.array([Lx, Ly, Lz])
    print L
    last = M.frames
    L_cont = M.box_volume()
    try:
        V = util.pickle_load('V.pkl')
        W = util.pickle_load('W.pkl')
        VW = util.pickle_load('VW.pkl')
    except:
        #delta = 25
        #V=M.cord_range(['V'],delta=delta)
        #W=M.cord_range(['W'],delta=delta)
        #VW=M.cord_range(['V','W'],delta=delta)
        V=M.cord_auto(['V'])
        W=M.cord_auto(['W'])
        VW=M.cord_auto(['V','W'])
        VW_index=M.get_names(['V','W'])
        #VW,V,W = drift_remove_all(VW,V,W,L,VW_index)
        util.pickle_dump(V,'V.pkl')
        util.pickle_dump(W,'W.pkl')
        util.pickle_dump(VW,'VW.pkl')
    delta = 30
    x = range(0,V.shape[0],delta)
    print V.shape[0]
    print x
    #plt.close()
    msd(VW,L,time_scale=delta)
    type_ordering(VW,L_cont)
Пример #18
0
def find_lifetime(M,L,steps,temp,step_range=30,delta=4,rcut=1.0,step=5e4):
    import MD.analysis.lifetime as life
    try:
        C = util.pickle_load('C.pkl')
        G = util.pickle_load('G.pkl')
    except:
        C=M.cord_auto(['C'])
        G=M.cord_auto(['G'])
        util.pickle_dump(C,'C.pkl')
        util.pickle_dump(G,'G.pkl')
    #The total number of frames we are going to look at
    for i in steps:
        try:
            print 'Frame',i,'Temp',temp[i]
        except:
            print i
        x=np.arange(i,step_range+i,delta)
        #Find he number of connections at specific points x
        remain = life.lifetime(C[x],G[x],L)
        x=np.arange(i,step_range+i,delta)*50000
        print remain
        pyplot_eps.plot(x,remain,xlabel='time', ylabel='remaining connections',
                save='lifetime%i'%i)
        plt.close()
Пример #19
0
def run_simple():
    import MD
    from MD.dna_scripts.square import drift_remove
    M=MD.ReadCord()
    L = M.box_length
    print 'MD.L is '
    print L
    last = M.frames
    L_cont = M.box_volume()
    MD.L = [L,L,L]
    MD.last = last
    try:
        MD.V = util.pickle_load('V.pkl')
    except:
        MD.V = M.cord_auto(['V'])
        MD.util.pickle_dump(MD.V,'V.pkl')
    crystal, C =  find_lattice(MD,MD.V,L_cont[MD.last-2],n_finish=MD.last-1,n_start=MD.last-2,delta=1)
Пример #20
0
def msd(VW,L,step=1,save='MSD_time',time_scale=1):
    from MD.analysis.msd import msd_no_drift #Find the msd of the system x,msd=msd_no_drift(VW,L,step=step)
    D=0.1
    D2=0.03
    tau=10
    try:
        M = util.pickle_load('msd.pkl')
        x = M[0][0]
        msd = M[1][0]
    except:
        x, msd = msd_no_drift(VW,L)
        x = x*time_scale
        util.pickle_dump([[x],[msd]],'msd.pkl')
    #msd_fit
    fit = []
    for i in x:
        fit.append((2*3*D2*(i) - tau*(1-math.e**(-i/tau)))**0.5)
    msd2 = (6*D*x)**0.5
    pyplot.plot(x,msd,xlabel='Time',ylabel='msd',save=save)
Пример #21
0
def get_crystals():
    dirname = os.getcwd().partition('/')[-1]
    print "Starting:",dirname.split('/')[-1]
    #initial file
    dirname = os.getcwd().partition('/')[-1]
    print "Starting:",dirname.split('/')[-1]
    delta = 10
    M=MD.ReadCord()
    Lx = M.box_length
    Ly = M.box_length_y
    Lz = M.box_length_z
    L = np.array([Lx, Ly, Lz])
    L_cont = M.box_volume()
    L_cont[-1] = L_cont[-2]
    last = M.frames
    try:
        VW = util.pickle_load('VW.pkl')
    except:
         VW=M.cord_auto(['V','W','A0','A1'])
         util.pickle_dump(VW,'VW.pkl')
    #######################################
    delta = 1
    x = range(0,last-2*delta,delta)
    C = np.zeros((len(x),VW.shape[1]),dtype=int)
    os.mkdir('imd_trajectory')
    os.chdir('imd_trajectory')
    for i,k in enumerate(x):
        A = Average(VW,L_cont,k,delta)
        util.print_imd(np.array([A]),L_cont,k)
        ovitojs(k)
        os.system('ovito --script ovito.js --nogui')
        name = 'data'+'%i'%(k)+'.dump'
        fid = open(name,'r')
        for j in range(9):
            fid.readline()
        for j, line in enumerate(fid.readlines()):
            C[i][j] = int(line.split()[0])
        fid.close()
    os.chdir('../')
    crystal_count(C,delta)
Пример #22
0
    #fid.write('\n')
    #for i in range(len(x[0])):
    #    fid.write('%i '%x[0][i])
    #    for j in range(len(y)):
    #        fid.write('%.7f '%y[j][i])
    #    fid.write('\n')

if __name__ == '__main__':
    M = []
    Label = []
    delta = int(sys.argv[1])
    for f in sorted(os.listdir("./")):
        if os.path.isdir(f) and f[0]=='p':
            print f
            os.chdir(f)
            p = util.pickle_load('si_scat.pkl')
            if len(p[0]) > delta:
                M.append(p)
                Label.append('%s'%(f.split('_')[1:]))
            os.chdir('../')
        if os.path.isdir(f) and f[0]=='F':
            print f
            os.chdir(f)
            try:
                p = util.pickle_load('si_scat.pkl')
                print len(p[0])
                if len(p[0]) > delta:
                    M.append(p)
                    Label.append('%s'%(f.split('_')[9]))
            except:
                print 'no pickle'
Пример #23
0
def run_defect():
    #run_debug()
    #run_all()
    import MD
    from MD.dna_scripts.square import drift_remove_all
    M=MD.ReadCord()
    L = M.box_length
    print 'MD.L is '
    print L
    last = M.frames
    MD.L = [L,L,L]
    MD.last = last
    try:
        MD.V = util.pickle_load('V.pkl')
        MD.W = util.pickle_load('W.pkl')
        MD.VW = util.pickle_load('VW.pkl')
    except:
        MD.V = MD.M.cord_auto(['V'])
        MD.W = MD.M.cord_auto(['W'])
        MD.VW = MD.M.cord_auto(['V','W'])
        MD.VW, MD.V, MD.W = drift_remove_all(MD.VW[1:],MD.V[1:],MD.W[1:],MD.L)
        util.pickle_dump(MD.V,'V.pkl')
        util.pickle_dump(MD.W,'W.pkl')
        util.pickle_dump(MD.VW,'VW.pkl')
    try:
        print 'attempting to load lattice'
        crystal = util.pickle_load('ccrystal.pkl')
        cword = util.pickle_load('cword.pkl')
        C = util.pickle_load('Ccry.pkl')
    except:
        print 'finding lattice'
        crystal, C =  find_lattice(MD.VW,MD.L,n_finish=MD.last-1,n_start=MD.last-2,delta=1)
        util.pickle_dump(C,'Ccry.pkl')
        util.pickle_dump(crystal,'ccrystal.pkl')
    try:
        print 'attempting to load CV and CW'
        CV = util.pickle_load('CV.pkl')
        CW = util.pickle_load('CW.pkl')
    except:
        print 'filtering the lattice'
        CV, CW = filter_lattice(C, MD.V.shape[1], MD.W.shape[1], MD.L)
        util.pickle_dump(CV,'CW.pkl')
        util.pickle_dump(CW,'CV.pkl')
    #try:
    #    print 'attempting to load DW, DV'
    #    DV = util.pickle_load('DV.pkl')
    #    DW = util.pickle_load('DW.pkl')
    #    plot_def = util.pickle_load('plot_def.pkl')
    #except:
    #    print 'finding the defects'
    #    try:
    #        DV, DW, plot_def = find_defects(CV,CW,MD.VW,MD.V,MD.W,MD.L,n_finish=MD.last-1,n_start=0,delta=1)
    #    except:
    #        pass
    #        print 'using mod'
    #        print 'using mod'
    #        DV, DW, plot_def = find_defects_mod(CV,CW,MD.VW,MD.V,MD.W,MD.L,n_finish=MD.last-1,n_start=0,delta=1)
    ##############################################
    ########################################
    #vac_msd(DV,DW,CV,CW,MD.L)
    #int_msd(DV,DW,MD.V,MD.W,CV,CW,MD.L)
    #plt.close()
    #vac_move_to(DV,DW)
    #plt.close()
    #x = plot_def[3]*50000
    #pyplot.plot3(x, plot_def[0], plot_def[1], plot_def[2], xlabel='Time',ylabel='defects', label1='Substitutional',label2='Vacancies',label3='Intersticials',
    #        showleg=True)
    #int_type(MD.V, MD.W, DV, DW, CV, CW, MD.L)
    #write_vac_new(DV,DW,CV,CW,delta=1)
    #write_sub(DV,DW,CV,CW,delta=1)
    #write_int(DV,DW,CV,CW,delta=1)
    vac_near()
Пример #24
0
def run_blah():
    dirname = os.getcwd().partition('/')[-1]
    print "Starting:",dirname.split('/')[-1]
    M=MD.ReadCord()
    Lx = M.box_length
    Ly = M.box_length_y
    Lz = M.box_length_z
    L = np.array([Lx, Ly, Lz])
    print L
    last = M.frames
    f=150
    def distance_distribution(V,W,L,n_start=1,save=''):
        #finds end to end distances and plots a histogram with that data
        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
        ########################################
        #Plot Data for AA,AB,BB distances
        save_name=save+'_time_'+'%i'%(n_start)
        max_hist=0
        AB=hist(V,W,save_name,'A-B')
        AA=hist(W,W,save_name,'A-A')
        BB=hist(V,V,save_name,'B-B')
        pyplot_eps.plot3(AA[0],AA[1],AB[0],AB[1],BB[0],BB[1],'s','g(s)',
                'A-A','A-B','B-B',save='nnplot_'+save_name,showleg=True)
    V = util.pickle_load('V.pkl')
    W = util.pickle_load('W.pkl')
    VW = util.pickle_load('VW.pkl')
    surface =  util.pickle_load('surface.pkl')
    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))
    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
    s = []
    for i in range(len(surface[f])):
            if surface[f][i]:
                s.append(i)
    ###############################
    gel = []
    for i in range(len(bcc[f])):
            if bcc[f][i] ==0 and surface[f][i] == 0:
                gel.append(i)
    g = np.zeros((15,len(gel),3))
    gV = np.zeros((15,len(gel),3))
    gW = np.zeros((15,len(gel),3))
    for k in range(g.shape[0]):
        for i in range(g.shape[1]):
            if gel[i] < V.shape[1]:
                gV[k][i] = V[k+f][gel[i]]
            else:
                gW[k][i] = W[k+f][gel[i]-V.shape[1]]
    distance_distribution(gV,gW,L,f,'gel')
    print 'gel finished'
    ###########################
    crystal = []
    for i in range(len(bcc[f])):
        if bcc[f][i] == 1:
            crystal.append(i)
    g = np.zeros((15,len(crystal),3))
    gV = np.zeros((15,len(crystal),3))
    gW = np.zeros((15,len(crystal),3))
    for k in range(g.shape[0]):
        for i in range(g.shape[1]):
            if crystal[i] < V.shape[1]:
                gV[k][i] = V[k+f][crystal[i]]
            else:
                gW[k][i] = W[k+f][crystal[i]-V.shape[1]]
    distance_distribution(gV,gW,L,f,'crystal')
    print 'crystal finished'
Пример #25
0
Файл: dna.py Проект: cdknorow/MD
def center_end_connected(M,L):
    ## \brief center to end distance of hybridized vs nonhybridized polymers
    #
    # \returns average distance from center of particle to end of polymer 
    #           for hybridizations and free polymer
    #
    # \param M - ReadCord Class  
    # \param L 
    #
    # V ----- A C k
    # W ----- F G T
    #find the length of the polymer
    import MD.analysis.connections as con
    try:
        K=util.pickle_load('K.pkl')
        T=util.pickle_load('T.pkl')
        V=util.pickle_load('V.pkl')
        W=util.pickle_load('W.pkl')
    except:
        V=M.cord_auto(['V'])
        W=M.cord_auto(['W'])
        K=M.cord_auto(['K'])
        T=M.cord_auto(['T'])
        util.pickle_dump(K,'K.pkl')
        util.pickle_dump(T,'T.pkl')
        util.pickle_dump(V,'V.pkl')
        util.pickle_dump(W,'W.pkl')
    #get connections
    con = _connections(M)
    h_sum = []
    f_sum = []
    if len(con) != K.shape[0]:
        print len(con)
        print K.shape
        print 'connections and K have different lenghts'
        asdf
    for k in range(len(con)):
        print k
        hybrid = []
        free = []
        #get the points that are not connected
        for i in range(K.shape[1]):
            if i in con[k][0]:
                hybrid.append(points.dist(K[k][i],V[k][i/(K.shape[1]/V.shape[1])],L[k])[0]+0.5)
            else:
                free.append(points.dist(K[k][i],V[k][i/(K.shape[1]/V.shape[1])],L[k])[0]+0.5)
        for i in range(T.shape[1]):
            if i in con[k][1]:
                hybrid.append(points.dist(T[k][i],W[k][i/(T.shape[1]/W.shape[1])],L[k])[0]+0.5)
            else:
                free.append(points.dist(T[k][i],W[k][i/(T.shape[1]/W.shape[1])],L[k])[0]+0.5)
        h_sum.append(sum(hybrid)/len(hybrid))
        f_sum.append(sum(free)/len(free))
    f_sum[-1]= f_sum[-2]
    h_sum[-1]= h_sum[-2]
    x = range(V.shape[0])
    print 'number of DNA per NP'
    print K.shape[1]/V.shape[1]
    print T.shape[1]/W.shape[1]
    pyplot.plot2(x,h_sum,x,f_sum,xlabel='timestep',ylabel='sigma',label1='hybridizations',
        label2='free',save='free_hybrid_connections',showleg='true')
Пример #26
0
Файл: dna.py Проект: cdknorow/MD
def polymer_gauss(M,VW, Z,L, frames, rcut=1.0, step=5e4):
    #\brief find the gauss map of polymers surrounding NC
    try:
        #V = util.pickle_load('V.pkl')
        P = util.pickle_load('M.pkl')
    except:
         P = M.cord_auto(['M'])
         util.pickle_dump(P,'M.pkl')
    A = VW.shape[1]/2
    gauss_map = []
    w = np.array([[1,0,0],[0,1,0],[0,0,1]])
    ndna = P.shape[1]/VW.shape[1]
    print P.shape
    for k in frames:
        location = []
        print k
        try:
            for i in range(VW.shape[1]):
                #we must rotate about a specific cube reference frame
                if i in range(1):
                    V = VW[k][i]
                    x_r = points.unit(points.vector1d(V,Z[k][i*6+1],L[k]))
                    y_r = points.unit(points.vector1d(V,Z[k][i*6+2],L[k]))
                    z_r = points.unit(points.vector1d(V,Z[k][i*6+5],L[k]))
                    v = np.array([x_r,y_r,z_r])
                    R = points.reference_rotation(v,w)
                    for j in range(1,ndna,2):
                        d = points.dist(V,P[k][j+i*ndna],L[k])[0]
                        c_r = points.unit(points.vector1d(V,P[k][j+i*ndna],L[k]))
                        location.append(points.unit(np.dot(R,np.transpose(c_r)))*d)
        except:
            print 'something went wrong here'
        gauss_map.append(location)
    #########
    #fid = open('gaussmap_polymer.xyz','w')
    #max_gauss = 0
    #for k in gauss_map:
    #    if len(k) > max_gauss:
    #        max_gauss = len(k)
    #for k in range(len(gauss_map)):
    #    fid.write('%i\n%i\n'%(max_gauss+4,frames[k]))
    #    fid.write('E  1 0 0\n')
    #    fid.write('E  0 1 0\n')
    #    fid.write('E  0 0 1\n')
    #    fid.write('V  0 0 0\n')
    #    for i in gauss_map[k]:
    #        fid.write('N  %.3f %.3f %.3f\n'%(i[0],i[1],i[2]))
    #    for i in range(max_gauss - len(gauss_map[k])):
    #       fid.write('N  0 0 0\n')
    #fid.close()
    ###########
    fid = open('gaussmap_polymers_total.xyz','w')
    max_gauss = 0
    for k in gauss_map:
        if len(k) > max_gauss:
            max_gauss = len(k)
    max_gauss = max_gauss*len(gauss_map)
    fid.write('%i\n\n'%(max_gauss+4))
    fid.write('E  1 0 0\n')
    fid.write('E  0 1 0\n')
    fid.write('E  0 0 1\n')
    fid.write('V  0 0 0\n')
    count = 4
    for k in range(len(gauss_map)):
        for i in gauss_map[k]:
            fid.write('N  %.3f %.3f %.3f\n'%(i[0],i[1],i[2]))
            count+=1
    fid.close()
Пример #27
0
Файл: dna.py Проект: cdknorow/MD
def ssDNA_gauss(M,VW, Z,L, frames, rcut=1.0, step=5e4):
    try:
        #V = util.pickle_load('V.pkl')
        P = util.pickle_load('SSDNA.pkl')
    except:
         P = M.cord_auto(['K','T'])
         util.pickle_dump(P,'SSDNA.pkl')
    gauss_map = []
    w = np.array([[1,0,0],[0,1,0],[0,0,1]])
    ndna = P.shape[1]/VW.shape[1]
    print P.shape
    for k in frames:
        location = []
        print k
        try:
            for i in range(VW.shape[1]):
                #we must rotate about a specific cube reference frame
                if i in range(20):
                    V = VW[k][i]
                    x_r = points.unit(points.vector1d(V,Z[k][i*6+1],L[k]))
                    y_r = points.unit(points.vector1d(V,Z[k][i*6+2],L[k]))
                    z_r = points.unit(points.vector1d(V,Z[k][i*6+5],L[k]))
                    dd = points.dist(V,Z[k][i*6+5],L[k])[0]
                    v = np.array([x_r,y_r,z_r])
                    R = points.reference_rotation(v,w)
                    for j in range(ndna):
                        d = points.dist(V,P[k][j+i*ndna],L[k])[0]
                        c_r = points.unit(points.vector1d(V,P[k][j+i*ndna],L[k]))
                        location.append(points.unit(np.dot(R,np.transpose(c_r)))*d)
        except:
            print 'something went wrong here'
        gauss_map.append(location)
    #########
    fid = open('gaussmap_dna.xyz','w')
    max_gauss = 0
    for k in gauss_map:
        if len(k) > max_gauss:
            max_gauss = len(k)
    for k in range(len(gauss_map)):
        fid.write('%i\n%i\n'%(max_gauss+4,frames[k]))
        fid.write('E  %.2f 0 0\n'%dd)
        fid.write('E  0 %.2f 0\n'%dd)
        fid.write('E  0 0 %.2f\n'%dd)
        fid.write('V  0 0 0\n')
        for i in gauss_map[k]:
            fid.write('N  %.3f %.3f %.3f\n'%(i[0],i[1],i[2]))
        for i in range(max_gauss - len(gauss_map[k])):
           fid.write('N  0 0 0\n')
    fid.close()
    ###########
    fid = open('gaussmap_dna_step.xyz','w')
    max_gauss = 0
    step = 10
    for k in gauss_map:
        if len(k) > max_gauss:
            max_gauss = len(k)
    max_gauss = max_gauss*step
    for s in range(0,len(gauss_map)-step,step):
        fid.write('%i\n\n'%(max_gauss+4))
        fid.write('E  1 0 0\n')
        fid.write('E  0 1 0\n')
        fid.write('E  0 0 1\n')
        fid.write('V  0 0 0\n')
        count = 4
        for k in range(s,s+step): 
            for i in gauss_map[k]:
                fid.write('N  %.3f %.3f %.3f\n'%(i[0],i[1],i[2]))
                count+=1
        for i in range(max_gauss+4 - count):
            fid.write('N  0 0 0\n')
    fid.close()
Пример #28
0
def jump_lattice(VW,L):
    reload(diffuse)
    k=100
    time = 500

    surface =  util.pickle_load('surface.pkl')
    CV =  util.pickle_load('CV.pkl')
    CW =  util.pickle_load('CW.pkl')
    DV =  util.pickle_load('DV_s.pkl')
    DW =  util.pickle_load('DW_s.pkl')
    defects = []
    for i in range(DV[k].shape[0]):
        if DV[k][i] == -1:
            index, d = close_neighbors_point(VW[k],CV[i],L)
            defects.append(index)
    for i in range(DW[k].shape[0]):
        if DW[k][i] == -1:
            index, d = close_neighbors_point(VW[k],CW[i],L)
            defects.append(index)

    proj = np.zeros((CV.shape[0]*2,CV.shape[1]))
    for i in range(CV.shape[0]):
        proj[i] = CV[i]
    for i in range(CW.shape[0]):
        proj[i+CV.shape[0]] = CW[i]


    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))
    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
    s = []
    for i in range(len(bcc[k])):
            if surface[k][i]:
                s.append(i)
    gel = []
    for i in range(len(bcc[k])):
            if bcc[k][i] ==0 and surface[k][i] == 0:
                gel.append(i)
    crystal = []
    for i in range(len(bcc[k])):
            if bcc[k][i] == 1:
                crystal.append(i)

    diffuse.projection_jump(VW[k],s,proj,L,time,save='msd_index_%i_surface_%i'%(k,len(s)))
    diffuse.projection_jump(VW[k][:216],gel[:216],CW,L,time,save='msd_index_%i_gelV_%i'%(k,len(gel)))
    diffuse.projection_jump(VW[k][216:],gel[216:],CV,L,time,save='msd_index_%i_gelW_%i'%(k,len(gel)))
    diffuse.projection_jump(VW[k],crystal,proj,L,time,save='msd_index_%i_solid_%i'%(k,len(crystal)))
    diffuse.projection_jump(VW[k][:216],crystal[:216],CW,L,time,save='msd_index_%i_solidW_%i'%(k,len(crystal)))
    for i in range(len(crystal)):
        crystal[i] = crystal[i] - CV.shape[0]
    diffuse.projection_jump(VW[k][216:],crystal[216:],CV,L,time,save='msd_index_%i_solidV_%i'%(k,len(crystal)))
    diffuse.projection_jump(VW[k],defects,proj,L,time,save='msd_index_%i_defects_%i'%(k,len(defects)))
    r = list(set(s)-set(defects))
    diffuse.projection_jump(VW,r,proj,L,time,save='msd_index_%i_nodefect%i'%(k,len(r)))
    print len(defects)
    print len(s)
Пример #29
0
    #pyplot.plot(x, int_count, save='defect_int_diffusion_count')
    return DV, DW, [substitutions, vacancies, intersticial, x]
    #find the vacancies
#if __name__ == '__main__':
#    vac_near()
if __name__ == '__main__':
    #run_debug() #run_all()
    import MD
    from MD.dna_scripts.square import drift_remove_all
    print 'MD.L is '
    M=readxyz.ReadCord(trajectory = 'surface.xyz',frames=777)
    last = 777
    MD.L = [103.85,103.85,103.84]
    MD.last = last
    try:
        MD.V = util.pickle_load('Vs.pkl')
        MD.W = util.pickle_load('Ws.pkl')
        MD.VW = util.pickle_load('VWs.pkl')
    except:
        MD.V = M.cord_auto(['V'])
        MD.W = M.cord_auto(['W'])
        MD.VW = M.cord_auto(['V','W'])
        util.pickle_dump(MD.V,'Vs.pkl')
        util.pickle_dump(MD.W,'Ws.pkl')
        util.pickle_dump(MD.VW,'VWs.pkl')
    CV = util.pickle_load('CV.pkl')
    CW = util.pickle_load('CW.pkl')
    try:
        print 'attempting to load DW, DV'
        DV = util.pickle_load('DV_s.pkl')
        DW = util.pickle_load('DW_s.pkl')
Пример #30
0
def run_():
    #setp
    dirname = os.getcwd().partition('/')[-1] 
    print "Starting:",dirname.split('/')[-1]
    M=MD.ReadCord()
    Lx = M.box_length
    Ly = M.box_length_y
    Lz = M.box_length_z
    L = np.array([Lx, Ly, Lz])
    L_cont = M.box_volume()
    L_cont[-1] =L_cont[-2]
    last = M.frames
    new = False
    try:
        V = util.pickle_load('V.pkl')
        if V.shape[0] != last:
            print 'generating new pickle'
            asdf
        #Z = util.pickle_load('Z.pkl')
    except:
        #V=M.cord_auto(['V','W'])
        new = True
        V=M.cord_auto(['V'])
        if V.shape[1] < 1:
            V=M.cord_auto(['A','A0','A1'])
        #Z=M.cord_auto(['Z'])
        #VW_index=M.get_names(['V','W'])
        #Z_index=M.get_names(['Z'])
        #V = drift_remove(V,L,VW_index)
        #Z = drift_remove(Z,L,Z_index)
        #dump_xyz(V)
        #dump_xyz(Z)
        util.pickle_dump(V,'V.pkl')
        #util.pickle_dump(Z,'Z.pkl')
    # if (os.path.isfile('msd.pkl') is False):
    #    msd(V,L)
    print V
    asdf
    x, xcount = util.get_box_size_steps(L_cont)
    print x
    x_set = []
    n_frames = []
    print xcount
    print x
    #F = filter(lambda x: x > 10, xcount)
    for i in range(len(xcount)):
        if xcount[i] > 10:
            x_set.append(x[i])
            n_frames.append(xcount[i]-10)
    print n_frames
    print x_set

    f = h5py.File('../pmf_dist.hdf5','w')
    for j,i in enumerate(x_set):
        if  i + n_frames[j] <= V.shape[0]:
            if L_cont[i] == L_cont[i+n_frames[j]]:
                print "L = ",L_cont[i][0]
                print "rho = ",V.shape[1]/L_cont[i][0]**3
                print "frame = ", i 
                print "n_frame", n_frames[j]
                PMF(f, V,L_cont[i],n_start=i,n_frames=n_frames[j])
            else:
                print "L is not the same reduce the n_frames"
    f.close()