예제 #1
0
파일: animate.py 프로젝트: cdknorow/MD
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()
예제 #2
0
파일: animate.py 프로젝트: cdknorow/MD
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()