Beispiel #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()
Beispiel #2
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()
Beispiel #3
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()
Beispiel #4
0
def run_colored(frame=1):
    ##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()
    L_cont[-1] = L_cont[-2]
    #last = M.frames
    #V_index = M.get_index(['V'])
    #W_index = M.get_index(['W'])
    ## 
    #Z = util.pickle_load('Z.pkl')
    #VW = util.pickle_load('VW.pkl')
    ##
    #k = last
    #FROM XYZ
    VW,Z,VW_name = read_xyz()
    fid = open('square%i.tcl'%frame,'w')
    #set x to be the particles you wish to choose
    #x = np.array([47190, 77220, 72215, 80795, 42185, 17875, 72930, 52910,
    #    67925])
    #index 47190 77220 72215 80795 42185 17875 72930 52910 67925
    #x = x/715
    #print x
    #x = [1,2,3,4,5]
    #for i in x:
    A = read_color_index()
    for i in range(len(VW)):
        c = VW[i]
        v1 = Z[i*6] - c
        v2 = Z[i*6+2] - c
        v3 = Z[i*6+4] - c
        #v1 = Z[i*6] - c
        #v2 = Z[i*6+1] - c
        #v3 = Z[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[A[i]])
    fid.close()