Exemple #1
0
def calc_timedependent_D_fromdir(dirname,dtc,figname,zoom=100,shift=1):
    x = np.array(read_coor(dirname+"/smoothcrd-x/out"))
    y = np.array(read_coor(dirname+"/smoothcrd-y/out"))
    z = np.array(read_coor(dirname+"/smoothcrd-z/out")) 
    ddr,weight = calc_timedependent_D(x,y,z,dtc,shift=shift)
    meanddr = np.mean(ddr,axis=1)  # average over atoms
    plot_vs_time(meanddr,dtc,figname+".png")
    plot_vs_time(meanddr[:zoom],dtc,figname+".zoom.png")
    return ddr,weight
Exemple #2
0
def analyze_dist_multi_1D(list_x,nstep,outdir,dtc):
    "Take the average over the D estimates in each of these files"""
    assert len(list_x) > 0
    nfiles = len(list_x)
    t = np.arange(0,nstep*dtc,dtc)

    alldist = np.zeros((nstep,nfiles),float)
    allD = np.zeros((nfiles),float)

    print("="*5)
    print("Results")
    print("making %i fits" %nfiles)
    print("fit from %i steps, i.e. time %f ps, actually time %f ps" %(nstep,nstep*dtc,(nstep-1)*dtc))
    for i in range(nfiles):
        dist = calc_dist_1D(np.array(read_coor(list_x[i])))
        d = dist[:nstep,:]   # only fit the first nstep time steps (use all atoms)
        average = np.mean(d,1)
        alldist[:,i] = average

        p = np.polyfit(t,average**2,1)
        allD[i] = p[0]   # a_1 this is in angstrom**2/ps = 1e-20/1e-12 meter**2/second
                                # = 1e-8 meter**2/second = 1e-4 cm**2/s
        # if I want many figures:
        #fit_sqrt_vs_time(np.mean(dist_xy,1),dtc,outdir+"/fig_dist.xy.%i.png"%i,title=str(i))
        #fit_sqrt_vs_time(np.mean(dist_z,1), dtc,outdir+"/fig_dist.z.%i.png"%i,title=str(i))
        #fit_sqrt_vs_time(np.mean(dist_r,1), dtc,outdir+"/fig_dist.r.%i.png"%i,title=str(i))

    m = np.mean(alldist,axis=1)
    #s = np.std(alldist,axis=1)

    fit_sqrt_vs_time(m,dtc,outdir+"/fig_dist.average.png",title="average of %i"%nfiles)
    print_output_D_ave_1D(allD)
def analyze_dist_conditionalz(list_x,list_y,list_z,dtc,zpbc,lt,figname):
    "Collect distances in all these files"""
    assert len(list_x) > 0
    assert len(list_x) == len(list_y)
    assert len(list_x) == len(list_z)
    nfiles = len(list_x)

    nstep = 1000
    print("="*5)
    print("Results")

    edges = np.arange(-26.,26.1,1)
    nbins = len(edges)-1
    redges = np.arange(0,50,0.2)

    alldxy = []
    alldz = []
    alldr = []
    allz = []
    for i in range(nfiles):
        d_xy,d_z,d_r = calc_dist_lt_from3files(list_x[i],list_y[i],list_z[i],lt)
        z = np.array(read_coor(list_z[i]))
        z = z[:-lt]    # initz
        z -= zpbc*np.floor(z/zpbc+0.5)

        alldxy.append(d_xy)
        alldz.append(d_z)
        alldr.append(d_r)        
        allz.append(z)
    #alldxy = np.array(alldxy)

    print("XXXXXX lt*dtc",lt*dtc)
    if lt*dtc < 0.6:
        distmax = 2.
    elif lt*dtc < 6.:  #ps
        distmax = 5.
    elif lt*dtc < 60.:
        distmax = 10.
    else:
        distmax = 25.

    for i,alld in enumerate([alldxy,alldz,alldr]):
        label = ["xy","z","r"][i]
        factor = [np.sqrt(2),1.,np.sqrt(3)][i]
        k,xedges,yedges = np.histogram2d(np.array(alld).ravel(),np.array(allz).ravel(),[150,50])
        print(d_r.shape,z.shape)
        print(k.shape, xedges.shape, yedges.shape)
        # norm
        xedges /= factor
        k = k / np.sum(k,axis=0)
        import matplotlib.pyplot as plt
        plt.figure()
        plt.contourf(xedges[:-1],yedges[:-1],k.transpose()) #locator=ticker.LogLocator()
        plt.xlabel("distance [A]")
        plt.xlim(xmax=distmax)
        plt.ylabel("z [A]")
        plt.title("root mean square distance: "+label)
        plt.colorbar()
        plt.savefig(figname+"_hist2d.%s.lt%i.png"%(label,lt))
Exemple #4
0
def analyze_dist_multi_1D(list_x, nstep, outdir, dtc):
    "Take the average over the D estimates in each of these files" ""
    assert len(list_x) > 0
    nfiles = len(list_x)
    t = np.arange(0, nstep * dtc, dtc)

    alldist = np.zeros((nstep, nfiles), float)
    allD = np.zeros((nfiles), float)

    print("=" * 5)
    print("Results")
    print("making %i fits" % nfiles)
    print("fit from %i steps, i.e. time %f ps, actually time %f ps" %
          (nstep, nstep * dtc, (nstep - 1) * dtc))
    for i in range(nfiles):
        dist = calc_dist_1D(np.array(read_coor(list_x[i])))
        d = dist[:
                 nstep, :]  # only fit the first nstep time steps (use all atoms)
        average = np.mean(d, 1)
        alldist[:, i] = average

        p = np.polyfit(t, average**2, 1)
        allD[i] = p[
            0]  # a_1 this is in angstrom**2/ps = 1e-20/1e-12 meter**2/second
        # = 1e-8 meter**2/second = 1e-4 cm**2/s
        # if I want many figures:
        #fit_sqrt_vs_time(np.mean(dist_xy,1),dtc,outdir+"/fig_dist.xy.%i.png"%i,title=str(i))
        #fit_sqrt_vs_time(np.mean(dist_z,1), dtc,outdir+"/fig_dist.z.%i.png"%i,title=str(i))
        #fit_sqrt_vs_time(np.mean(dist_r,1), dtc,outdir+"/fig_dist.r.%i.png"%i,title=str(i))

    m = np.mean(alldist, axis=1)
    #s = np.std(alldist,axis=1)

    fit_sqrt_vs_time(m,
                     dtc,
                     outdir + "/fig_dist.average.png",
                     title="average of %i" % nfiles)
    print_output_D_ave_1D(allD)
Exemple #5
0
def calc_dist_from3files(xfile, yfile, zfile):
    x = np.array(read_coor(xfile))
    y = np.array(read_coor(yfile))
    z = np.array(read_coor(zfile))
    dist_xy, dist_z, dist_r = calc_dist(x, y, z)  # use ALL data in the file!
    return dist_xy, dist_z, dist_r
Exemple #6
0
def calc_dist_fromdir(dirname):
    x = np.array(read_coor(dirname + "/smoothcrd-x/out"))
    y = np.array(read_coor(dirname + "/smoothcrd-y/out"))
    z = np.array(read_coor(dirname + "/smoothcrd-z/out"))
    dist_xy, dist_z, dist_r = calc_dist(x, y, z)
    return dist_xy, dist_z, dist_r
Exemple #7
0
def collect_dist_from3files(xfile,yfile,zfile,dtc):
    x = np.array(read_coor(xfile))
    y = np.array(read_coor(yfile))
    z = np.array(read_coor(zfile))
    lagtimes,dist2_xy,dist2_z,dist2_r = collect_dist(x,y,z,dtc)
    return lagtimes,dist2_xy,dist2_z,dist2_r
Exemple #8
0
def calc_dist_lt_from3files(xfile,yfile,zfile,dn,rv=False):
    x = np.array(read_coor(xfile,rv=rv,axis=0))
    y = np.array(read_coor(yfile,rv=rv,axis=1))
    z = np.array(read_coor(zfile,rv=rv,axis=2))
    d2_xy,d2_z,d2_r = calc_dist_lt(x,y,z,dn)
    return d2_xy,d2_z,d2_r
Exemple #9
0
def calc_dist_from3files(xfile,yfile,zfile,rv=False):
    x = np.array(read_coor(xfile,rv=rv,axis=0))
    y = np.array(read_coor(yfile,rv=rv,axis=1))
    z = np.array(read_coor(zfile,rv=rv,axis=2))
    dist2_xy,dist2_z,dist2_r,weight = calc_dist(x,y,z)
    return dist2_xy,dist2_z,dist2_r,weight
Exemple #10
0
def calc_dist_fromdir(dirname):
    x = np.array(read_coor(dirname+"/smoothcrd-x/out"))
    y = np.array(read_coor(dirname+"/smoothcrd-y/out"))
    z = np.array(read_coor(dirname+"/smoothcrd-z/out"))
    dist2_xy,dist2_z,dist2_r,weight = calc_dist(x,y,z)
    return dist2_xy,dist2_z,dist2_r,weight
Exemple #11
0
def calc_timedependent_D_from3files(xfile,yfile,zfile,dtc,shift=1):
    x = np.array(read_coor(xfile))
    y = np.array(read_coor(yfile))
    z = np.array(read_coor(zfile))
    ddr,weight = calc_timedependent_D(x,y,z,dtc,shift=shift)
    return ddr,weight
Exemple #12
0
def calc_dist_from3files(xfile,yfile,zfile):
    x = np.array(read_coor(xfile))
    y = np.array(read_coor(yfile))
    z = np.array(read_coor(zfile))
    dist_xy,dist_z,dist_r = calc_dist(x,y,z)   # use ALL data in the file!
    return dist_xy,dist_z,dist_r
def calc_dist_lt_from3files(xfile,yfile,zfile,lt):
    x = np.array(read_coor(xfile))
    y = np.array(read_coor(yfile))
    z = np.array(read_coor(zfile))
    d_xy,d_z,d_r = calc_dist_lt(x,y,z,lt)
    return d_xy,d_z,d_r