Exemple #1
0
def average_position_simple(M):
    A = np.zeros((M.shape[1],3))
    for i in range(M.shape[1]):
        count = 1
        p = np.array([0.0,0.0,0.0])
        p += M[0][i]
        for j in range(1,M.shape[0]):
            if points.dist_np(M[0][i],M[j][i])[0] <  5:
                p += M[j][i]
                count += 1
        p = p/count
        A[i] = p
    return A
Exemple #2
0
def msd(A,L,step=1):
    #find the drift
    print A.shape
    Drift = drift_position(A,L)[0]
    #find msd
    num = A[0].shape[0]
    print num
    frames=A.shape[0]
    print "Calculating MSD"
    MSD=np.zeros((frames-1))
    B = np.zeros((num,3))
    for k in range(frames-1):
        r_sum=0
        for i in range(num):
            B[i] = boundary_cross(A[k][i], A[k+1][i], L, B[i])
            d = points.dist_np(A[0][i][0:3] + Drift[k], A[k+1][i][0:3] - B[i] * L)
            r_sum = d[0]**2 / num + r_sum
        MSD[k] = r_sum
    x = np.arange(0, A.shape[0] * step - step, step)
    return x,MSD
Exemple #3
0
def write_qmap_xyz(VW,Q6,Q4,frame,rcut):
    # counter bcc, hcp, fcc, mrco, liqid
    counter = [0,0,0,0,0]
    fid = open('%s.q6q4.xyz'%frame,'w')
    bcc_cut = .055
    bcc = np.array([.475,.03 ])
    hcp_cut = .035
    hcp = np.array([.475,.1 ])
    fcc_cut = .075
    fcc = np.array([.5,.17 ])
    Liq_cut = .1
    Liq = np.array([.2,.04])
    C = np.array([200,200,200])
    fid.write('%i\n\n'%(5*len(VW)))
    Qx = [[]  for n in range(5)]
    Qy = [[]  for n in range(5)]
    for j in range(len(VW)):
        w = [False for n in range(5)]
        #bcc
        if points.dist_np(bcc,np.array([Q6[j],Q4[j]]))[0] < bcc_cut:
            w[0] = True
            counter[0] = counter[0] + 1
        #hcp
        elif points.dist_np(hcp,np.array([Q6[j],Q4[j]]))[0] < hcp_cut:
            w[1] = True
            counter[1] = counter[1] + 1
        #fcc
        elif points.dist_np(fcc,np.array([Q6[j],Q4[j]]))[0] < fcc_cut:
            w[2] = True
            counter[2] = counter[2] + 1
        #liq
        elif points.dist_np(Liq,np.array([Q6[j],Q4[j]]))[0] < Liq_cut:
            w[3] = True
            counter[3] = counter[3] + 1
        #Interface
        else:
            w[4] = True
            counter[4] = counter[4] + 1
        if w[0] == True:
            fid.write(('B %.4f %.4f %.4f\n'%(VW[j][0],
                VW[j][1],VW[j][2])))
            Qx[0].append(Q4[j])
            Qy[0].append(Q6[j])
        else:
            fid.write(('B %.4f %.4f %.4f\n'%(C[0],C[1],C[2])))
        if w[1] == True:
            fid.write(('H %.4f %.4f %.4f\n'%(VW[j][0],
                VW[j][1],VW[j][2])))
            Qx[1].append(Q4[j])
            Qy[1].append(Q6[j])
        else:
            fid.write(('H %.4f %.4f %.4f\n'%(C[0],C[1],C[2])))
        if w[2] == True:
            fid.write(('F %.4f %.4f %.4f\n'%(VW[j][0],
                VW[j][1],VW[j][2])))
            Qx[2].append(Q4[j])
            Qy[2].append(Q6[j])
        else:
            fid.write(('F %.4f %.4f %.4f\n'%(C[0],C[1],C[2])))
        if w[3] == True:
            fid.write(('L %.4f %.4f %.4f\n'%(VW[j][0],
                VW[j][1],VW[j][2])))
            Qx[3].append(Q4[j])
            Qy[3].append(Q6[j])
        else:
            fid.write(('L %.4f %.4f %.4f\n'%(C[0],C[1],C[2])))
        if w[4] == True:
            fid.write(('I %.4f %.4f %.4f\n'%(VW[j][0],
                VW[j][1],VW[j][2])))
            Qx[4].append(Q4[j])
            Qy[4].append(Q6[j])
        else:
            fid.write(('I %.4f %.4f %.4f\n'%(C[0],C[1],C[2])))
    xlabel = 'q4_avg'
    ylabel = 'q6_avg'
    Label = ['bcc','hcp','fcc','liq','int']
    #pyplot.plot_multi(Qx,Qy,Label,
    #        xlabel=xlabel,ylabel=ylabel,save=('Qmap_frame%i_rcut%.2f'%(frame,rcut)),
    #        limx=(0,.2),limy=(0,.6),make_marker=True)
    fid.close()
    return counter, [Qx,Qy]