コード例 #1
0
def calculate_variation(Input, resolution):
    """Calculates the variation in the activation Energy"""
    filelist = bf.lookupfiles(path=Input['folder_snapshot_data'], 
                              filechr='Wigner')
    filenumbers = np.zeros((len(filelist)))
    i = 0
    for filename in filelist:
        filepath = '%s%s' % (Input['folder_snapshot_data'], filename)
        f = open(filepath, 'r')
        xml.ReadHeader(f)
        positions = xml.ReadCoordinates(f, Input['BASEparticles'])
        f.close()
        coordinates, potential = potential_slice(Input, positions, resolution)
        if i == 0:
            all_potential = potential.reshape((1,len(potential),len(potential)))
        else:
            all_potential = np.append(all_potential,
                                      potential.reshape((1,len(potential),len(potential))),
                                      axis=0)
        
        filenumber = int(filename.strip('Wigner.').strip('.xml'))
        filenumbers[i] = filenumber
        if i == 0:
             save_potential_field(Input, coordinates, potential, 'testje')
        i += 1
    sorted_filenumbers = np.argsort(filenumbers,axis=0)
    sorted_potentials = all_potential[sorted_filenumbers]
    average_potential = np.average(sorted_potentials,axis=0)
    variance_potential = np.var(sorted_potentials,axis=0)
    coordx, coordy = np.nonzero(np.less(variance_potential,100)) 
    print len(coordx)
    if len(coordx) > 0:
        time = np.sort(sorted_filenumbers)*Input['dt']*Input['BASEtau']
    #eplt.plotsliceheatmap(Input, coordinates, potential, positions, resolution, plotpart=False)
        eplt.plot_energy_track(time, sorted_potentials[:,coordx[0],coordy[0]] - np.min(sorted_potentials[:,coordx[0],coordy[0]]))
コード例 #2
0
ファイル: voronoi.py プロジェクト: sprakellab/dopantdynamics
def find_cell_volumes_folder(Input):
    """find cell volumes of a whole folder"""
    positions_folder = '%spositions_voronoi/' % Input['systempath']
    cell_volume_folder = '%svolumes_voronoi/' % Input['systempath']
    os.mkdir(cell_volume_folder) 
    filelist = bf.lookupfiles(path=positions_folder, filechr='Wigner')
    for file_ in filelist:
        filename = positions_folder + file_
        new_name = positions_folder + file_ + '.vol'
        savename = cell_volume_folder + file_ + '.vol'
        find_cell_volume(Input, filename)     
        os.rename(new_name, savename)
コード例 #3
0
def find_cell_volumes_folder(Input):
    """find cell volumes of a whole folder"""
    positions_folder = '%spositions_voronoi/' % Input['systempath']
    cell_volume_folder = '%svolumes_voronoi/' % Input['systempath']
    os.mkdir(cell_volume_folder)
    filelist = bf.lookupfiles(path=positions_folder, filechr='Wigner')
    for file_ in filelist:
        filename = positions_folder + file_
        new_name = positions_folder + file_ + '.vol'
        savename = cell_volume_folder + file_ + '.vol'
        find_cell_volume(Input, filename)
        os.rename(new_name, savename)
コード例 #4
0
ファイル: voronoi.py プロジェクト: sprakellab/dopantdynamics
def prepareforvoro(Input):
    voronoi_folder = '%spositions_voronoi/' % Input['systempath']
    os.mkdir(voronoi_folder)
    filelist = bf.lookupfiles(path=Input['folder_snapshot_data'], filechr='Wigner')
    for file_ in filelist:
        filename = '%s%s' % (Input['folder_snapshot_data'], file_)
        f = open(filename, 'r')
        xml.ReadHeader(f)
        Positions = xml.ReadCoordinates(f, Input['ALLparticles'])
        f.close()
        voronoiformat = np.concatenate((np.reshape(np.arange(1,Input['ALLparticles']+1),(-1,1)), Positions),axis=1)
        savename = '%s%s' % (voronoi_folder, file_.strip('.xml'))
        format_ = ['%6d','%.18e', '%.18e', '%.18e']
        np.savetxt(savename, voronoiformat, fmt=format_, delimiter='\t')
コード例 #5
0
ファイル: msd.py プロジェクト: sprakellab/dopantdynamics
def meanmsd_wholefolder(Input):
    filelist = bf.lookupfiles(path=Input['folder_msd_data'], filechr='INTER')
    path = '%s%s' % (Input['folder_msd_data'], filelist[0])
    data = np.genfromtxt(path, delimiter='\t')        
    total_msd = np.zeros(len(data))
    mean_msd = np.zeros((len(data),2))
    mean_msd[:,0] = data[:,0]
    for filename in filelist:
        path = '%s%s' % (Input['folder_msd_data'], filename)
        data = np.genfromtxt(path, delimiter='\t')
        total_msd += data[:,1]
    mean_msd[:,1] = total_msd / len(filelist)
    savepath = '%s%smean.msd' % (Input['folder_processed_data'], Input['system'])
    np.savetxt(savepath, mean_msd, delimiter='\t')
コード例 #6
0
ファイル: msd.py プロジェクト: sprakellab/dopantdynamics
def get_msd_particles(Input, tau_inf=179):
    filelist = bf.lookupfiles(path=Input['folder_msd_data'], filechr='INTER')
    msd_particle = np.zeros([len(filelist), 2])
    counter = 0
    for particle in filelist:
        filename = '%s%s' % (Input['folder_msd_data'], particle)
        data = np.genfromtxt(filename, delimiter='\t')
        msd_particle[counter,0] = int(particle.strip('.msd').strip('INTER'))
        msd_particle[counter,1] = data[tau_inf,1]
        counter += 1
    msd_particle = msd_particle[msd_particle[:,0].argsort()]
    savename = '%s%smsdparticles.val' % (Input['folder_processed_data'], Input['system'])
    format_ = ['%6d','%.12e']
    np.savetxt(savename, msd_particle, delimiter='\t', fmt=format_)    
コード例 #7
0
ファイル: voronoi.py プロジェクト: sprakellab/dopantdynamics
def average_values(Input):
    """get the average of the cell volume over the simulation"""
    cell_volume_folder = '%svolumes_voronoi/' % Input['systempath']
    filelist = bf.lookupfiles(path=cell_volume_folder, filechr='Wigner')
    data = np.genfromtxt(cell_volume_folder + filelist[0], delimiter=' ')
    average = np.zeros([len(data),2])
    for file_ in filelist:
        filename = '%s%s' % (cell_volume_folder,file_)
        data = np.genfromtxt(filename, delimiter=' ')
        data = data[data[:,0].argsort()]
        average[:,1] += data[:,4]*(1.0/len(filelist))
    average[:,0] = data[:,0]
    savename = '%s%saveragevoronoi.vol' % (Input['folder_processed_data'], Input['system'])
    format_ = ['%6d','%.12e']
    np.savetxt(savename, average, delimiter='\t', fmt=format_)        
コード例 #8
0
def get_msd_particles(Input, tau_inf=179):
    filelist = bf.lookupfiles(path=Input['folder_msd_data'], filechr='INTER')
    msd_particle = np.zeros([len(filelist), 2])
    counter = 0
    for particle in filelist:
        filename = '%s%s' % (Input['folder_msd_data'], particle)
        data = np.genfromtxt(filename, delimiter='\t')
        msd_particle[counter, 0] = int(particle.strip('.msd').strip('INTER'))
        msd_particle[counter, 1] = data[tau_inf, 1]
        counter += 1
    msd_particle = msd_particle[msd_particle[:, 0].argsort()]
    savename = '%s%smsdparticles.val' % (Input['folder_processed_data'],
                                         Input['system'])
    format_ = ['%6d', '%.12e']
    np.savetxt(savename, msd_particle, delimiter='\t', fmt=format_)
コード例 #9
0
def meanmsd_wholefolder(Input):
    filelist = bf.lookupfiles(path=Input['folder_msd_data'], filechr='INTER')
    path = '%s%s' % (Input['folder_msd_data'], filelist[0])
    data = np.genfromtxt(path, delimiter='\t')
    total_msd = np.zeros(len(data))
    mean_msd = np.zeros((len(data), 2))
    mean_msd[:, 0] = data[:, 0]
    for filename in filelist:
        path = '%s%s' % (Input['folder_msd_data'], filename)
        data = np.genfromtxt(path, delimiter='\t')
        total_msd += data[:, 1]
    mean_msd[:, 1] = total_msd / len(filelist)
    savepath = '%s%smean.msd' % (Input['folder_processed_data'],
                                 Input['system'])
    np.savetxt(savepath, mean_msd, delimiter='\t')
コード例 #10
0
def prepareposfiles(Input, base):
    bp_folder = '%spositions_bp/' % Input['systempath']
    os.mkdir(bp_folder)
    filelist = bf.lookupfiles(path=Input['folder_snapshot_data'], filechr='Wigner')
    for file_ in filelist:
        filename = '%s%s' % (Input['folder_snapshot_data'], file_)
        f = open(filename, 'r')
        xml.ReadHeader(f) 
        if base is True:
            positions = xml.ReadCoordinates(f, Input['BASEparticles'])
        else:
            positions = xml.ReadCoordinates(f, Input['ALLparticles'])
        f.close()
        bp_positions = positions + 0.5*Input['BOXsize']
        savename = '%s%s.dat' % (bp_folder, file_.strip('.xml'))
        saveasdatfile(Input, bp_positions, savename, base)
コード例 #11
0
def average_values(Input):
    """get the average of the cell volume over the simulation"""
    cell_volume_folder = '%svolumes_voronoi/' % Input['systempath']
    filelist = bf.lookupfiles(path=cell_volume_folder, filechr='Wigner')
    data = np.genfromtxt(cell_volume_folder + filelist[0], delimiter=' ')
    average = np.zeros([len(data), 2])
    for file_ in filelist:
        filename = '%s%s' % (cell_volume_folder, file_)
        data = np.genfromtxt(filename, delimiter=' ')
        data = data[data[:, 0].argsort()]
        average[:, 1] += data[:, 4] * (1.0 / len(filelist))
    average[:, 0] = data[:, 0]
    savename = '%s%saveragevoronoi.vol' % (Input['folder_processed_data'],
                                           Input['system'])
    format_ = ['%6d', '%.12e']
    np.savetxt(savename, average, delimiter='\t', fmt=format_)
コード例 #12
0
def prepareposfiles(Input, base):
    bp_folder = '%spositions_bp/' % Input['systempath']
    os.mkdir(bp_folder)
    filelist = bf.lookupfiles(path=Input['folder_snapshot_data'],
                              filechr='Wigner')
    for file_ in filelist:
        filename = '%s%s' % (Input['folder_snapshot_data'], file_)
        f = open(filename, 'r')
        xml.ReadHeader(f)
        if base is True:
            positions = xml.ReadCoordinates(f, Input['BASEparticles'])
        else:
            positions = xml.ReadCoordinates(f, Input['ALLparticles'])
        f.close()
        bp_positions = positions + 0.5 * Input['BOXsize']
        savename = '%s%s.dat' % (bp_folder, file_.strip('.xml'))
        saveasdatfile(Input, bp_positions, savename, base)
コード例 #13
0
def prepareforvoro(Input):
    voronoi_folder = '%spositions_voronoi/' % Input['systempath']
    os.mkdir(voronoi_folder)
    filelist = bf.lookupfiles(path=Input['folder_snapshot_data'],
                              filechr='Wigner')
    for file_ in filelist:
        filename = '%s%s' % (Input['folder_snapshot_data'], file_)
        f = open(filename, 'r')
        xml.ReadHeader(f)
        Positions = xml.ReadCoordinates(f, Input['ALLparticles'])
        f.close()
        voronoiformat = np.concatenate(
            (np.reshape(np.arange(1, Input['ALLparticles'] + 1),
                        (-1, 1)), Positions),
            axis=1)
        savename = '%s%s' % (voronoi_folder, file_.strip('.xml'))
        format_ = ['%6d', '%.18e', '%.18e', '%.18e']
        np.savetxt(savename, voronoiformat, fmt=format_, delimiter='\t')
コード例 #14
0
def calculate_deviations(Input):
    """Calculates the deviations from the average particle site"""
    filelist = bf.lookupfiles(path=Input['folder_snapshot_data'],
                              filechr='Wigner')
    i = 0
    for filename in filelist:
        if int(filename.strip('Wigner').strip('.xml')) > 10000000:
            filepath = '%s%s' % (Input['folder_snapshot_data'], filename)
            f = open(filepath, 'r')
            xml.ReadHeader(f)
            positions = xml.ReadCoordinates(f, Input['ALLparticles'])
            f.close()
            if i == 0:
                all_positions = np.reshape(positions, (1, len(positions), 3))
            else:
                positions = unfold_boundary_crossings(Input, all_positions,
                                                      positions, i)
                positions = np.reshape(positions, (1, len(positions), 3))
                all_positions = np.append(all_positions, positions, axis=0)
            i += 1
    average_positions = np.average(all_positions, axis=0)
    deviations = np.std(np.sqrt(
        np.sum(np.square(all_positions - average_positions), axis=2)),
                        axis=0)
    filepath = '%sWigner.0099000000.xml' % (Input['folder_snapshot_data'])
    f = open(filepath, 'r')
    xml.ReadHeader(f)
    positions = xml.ReadCoordinates(f, Input['ALLparticles'])
    f.close()
    positions = unfold_boundary_crossings(Input, all_positions, positions, i)
    snapdeviations = np.sqrt(
        np.sum(np.square(average_positions - positions), axis=1))
    posanddev = np.zeros((Input['ALLparticles'], 8))
    posanddev[:, :3] = average_positions
    posanddev[:, 3] = deviations / Input['a']
    posanddev[:, 4:7] = positions
    posanddev[:, 7] = snapdeviations / Input['a']
    head = '%-18s\t%-18s\t%-18s\t%-18s\t%-18s\t%-18s\t%-18s\t%-18s' % (
        'x[sigma]', 'y[sigma]', 'z[sigma]', 'lindemann', 'snapx[sigma]',
        'snapy[sigma]', 'snapz[sigma]', 'snapdev[sigma]')
    savename = '%s%s.deviations' % (Input['folder_processed_data'],
                                    Input['system'])
    np.savetxt(savename, posanddev, fmt='%18.11e', header=head, delimiter='\t')
    return positions, deviations
コード例 #15
0
def averagebondparameter(Input, base=False):
    dir_bp = '%sbondparameters/' % Input['systempath']
    filelist = bf.lookupfiles(path=dir_bp, filechr='Wigner')
    if base is True:
        average_data = np.zeros((Input['BASEparticles'], 6))
    else:
        average_data = np.zeros((Input['ALLparticles'], 6))
    columns = np.array([0,4,5,6,7,8])
    count = 0
    for file_ in filelist:
        number = int(file_.strip('Wigner.').strip('.dat'))

        if number > Input['analysisstart']:
            filename = '%s%s' % (dir_bp, file_)
            data = np.genfromtxt(filename, delimiter=' ')
            average_data += data[:,columns]
            count +=1
    average_data = average_data/count
    savename = '%s%saveragebp.txt' % (Input['folder_processed_data'], Input['system']) 
    np.savetxt(savename, average_data, delimiter='\t')
コード例 #16
0
ファイル: unfold.py プロジェクト: sprakellab/dopantdynamics
def folder_unfolder(Input, nprocs=15):
    """Unfoldes tracks in folder if barrier is crossed"""

    def worker(Input, filelist, out_q):
        outdict = {}		
        for filename in filelist:
            outdict[i] = track_unfolder(Input, filename)	
        out_q.put(outdict)

    os.mkdir(Input['folder_backup'])
    filelist = bf.lookupfiles(path=Input['folder_interstitial_track'], filechr='INTER')
    out_q = multiprocessing.Queue()
    chunksize = int(np.ceil(len(filelist) / float(nprocs)))
    procs = []
    for i in range(nprocs):
        p = multiprocessing.Process(target=worker, args=(Input, filelist[chunksize*i:chunksize*(i + 1)], out_q))
        procs.append(p)
        p.start()
    for p in procs:
        p.join()
    logging.info('finished calculating all harrays.')
コード例 #17
0
ファイル: msd.py プロジェクト: sprakellab/dopantdynamics
def msd_wholefolder(Input, nprocs=25):
    """Calculates the msd profiles of a folder with tracks"""

    def worker(Input, filelist, out_q):
        outdict = {}
        for filename in filelist:
            outdict[i] = calculate_msd(Input, filename)			
        out_q.put(outdict)

    os.mkdir(Input['folder_msd_data'])
    filelist = bf.lookupfiles(path=Input['folder_interstitial_track'], filechr='INTER')
    out_q = multiprocessing.Queue()
    chunksize = int(np.ceil(len(filelist) / float(nprocs)))
    procs = []
    for i in range(nprocs):
        p = multiprocessing.Process(target=worker, args=(Input,filelist[chunksize*i:chunksize*(i + 1)], out_q))
        procs.append(p)
        p.start()
    for p in procs:
        p.join()
    logging.info('finished calculating all independent msd profiles.')
コード例 #18
0
def averagebondparameter(Input, base=False):
    dir_bp = '%sbondparameters/' % Input['systempath']
    filelist = bf.lookupfiles(path=dir_bp, filechr='Wigner')
    if base is True:
        average_data = np.zeros((Input['BASEparticles'], 6))
    else:
        average_data = np.zeros((Input['ALLparticles'], 6))
    columns = np.array([0, 4, 5, 6, 7, 8])
    count = 0
    for file_ in filelist:
        number = int(file_.strip('Wigner.').strip('.dat'))

        if number > Input['analysisstart']:
            filename = '%s%s' % (dir_bp, file_)
            data = np.genfromtxt(filename, delimiter=' ')
            average_data += data[:, columns]
            count += 1
    average_data = average_data / count
    savename = '%s%saveragebp.txt' % (Input['folder_processed_data'],
                                      Input['system'])
    np.savetxt(savename, average_data, delimiter='\t')
コード例 #19
0
def calculate_variation(Input, resolution):
    """Calculates the variation in the activation Energy"""
    filelist = bf.lookupfiles(path=Input['folder_snapshot_data'],
                              filechr='Wigner')
    filenumbers = np.zeros((len(filelist)))
    i = 0
    for filename in filelist:
        filepath = '%s%s' % (Input['folder_snapshot_data'], filename)
        f = open(filepath, 'r')
        xml.ReadHeader(f)
        positions = xml.ReadCoordinates(f, Input['BASEparticles'])
        f.close()
        coordinates, potential = potential_slice(Input, positions, resolution)
        if i == 0:
            all_potential = potential.reshape(
                (1, len(potential), len(potential)))
        else:
            all_potential = np.append(all_potential,
                                      potential.reshape(
                                          (1, len(potential), len(potential))),
                                      axis=0)

        filenumber = int(filename.strip('Wigner.').strip('.xml'))
        filenumbers[i] = filenumber
        if i == 0:
            save_potential_field(Input, coordinates, potential, 'testje')
        i += 1
    sorted_filenumbers = np.argsort(filenumbers, axis=0)
    sorted_potentials = all_potential[sorted_filenumbers]
    average_potential = np.average(sorted_potentials, axis=0)
    variance_potential = np.var(sorted_potentials, axis=0)
    coordx, coordy = np.nonzero(np.less(variance_potential, 100))
    print len(coordx)
    if len(coordx) > 0:
        time = np.sort(sorted_filenumbers) * Input['dt'] * Input['BASEtau']
        #eplt.plotsliceheatmap(Input, coordinates, potential, positions, resolution, plotpart=False)
        eplt.plot_energy_track(
            time, sorted_potentials[:, coordx[0], coordy[0]] -
            np.min(sorted_potentials[:, coordx[0], coordy[0]]))
コード例 #20
0
def msd_wholefolder(Input, nprocs=25):
    """Calculates the msd profiles of a folder with tracks"""
    def worker(Input, filelist, out_q):
        outdict = {}
        for filename in filelist:
            outdict[i] = calculate_msd(Input, filename)
        out_q.put(outdict)

    os.mkdir(Input['folder_msd_data'])
    filelist = bf.lookupfiles(path=Input['folder_interstitial_track'],
                              filechr='INTER')
    out_q = multiprocessing.Queue()
    chunksize = int(np.ceil(len(filelist) / float(nprocs)))
    procs = []
    for i in range(nprocs):
        p = multiprocessing.Process(
            target=worker,
            args=(Input, filelist[chunksize * i:chunksize * (i + 1)], out_q))
        procs.append(p)
        p.start()
    for p in procs:
        p.join()
    logging.info('finished calculating all independent msd profiles.')
コード例 #21
0
def folder_unfolder(Input, nprocs=15):
    """Unfoldes tracks in folder if barrier is crossed"""
    def worker(Input, filelist, out_q):
        outdict = {}
        for filename in filelist:
            outdict[i] = track_unfolder(Input, filename)
        out_q.put(outdict)

    os.mkdir(Input['folder_backup'])
    filelist = bf.lookupfiles(path=Input['folder_interstitial_track'],
                              filechr='INTER')
    out_q = multiprocessing.Queue()
    chunksize = int(np.ceil(len(filelist) / float(nprocs)))
    procs = []
    for i in range(nprocs):
        p = multiprocessing.Process(
            target=worker,
            args=(Input, filelist[chunksize * i:chunksize * (i + 1)], out_q))
        procs.append(p)
        p.start()
    for p in procs:
        p.join()
    logging.info('finished calculating all harrays.')
コード例 #22
0
def calculate_deviations(Input):
    """Calculates the deviations from the average particle site"""
    filelist = bf.lookupfiles(path=Input['folder_snapshot_data'], 
                              filechr='Wigner')
    i = 0
    for filename in filelist:
        if int(filename.strip('Wigner').strip('.xml')) > 10000000:
            filepath = '%s%s' % (Input['folder_snapshot_data'], filename)
            f = open(filepath, 'r')
            xml.ReadHeader(f)
            positions = xml.ReadCoordinates(f, Input['ALLparticles'])
            f.close()
            if i == 0:
                all_positions = np.reshape(positions, (1, len(positions), 3))
            else:
                positions = unfold_boundary_crossings(Input, all_positions, positions, i)
                positions = np.reshape(positions, (1, len(positions), 3))
                all_positions = np.append(all_positions, positions, axis=0)
            i += 1
    average_positions = np.average(all_positions, axis=0)
    deviations = np.std(np.sqrt(np.sum(np.square(all_positions - average_positions), axis=2)),axis=0)
    filepath = '%sWigner.0099000000.xml' % (Input['folder_snapshot_data'])
    f = open(filepath, 'r')
    xml.ReadHeader(f)
    positions = xml.ReadCoordinates(f, Input['ALLparticles'])
    f.close()
    positions = unfold_boundary_crossings(Input, all_positions, positions, i)
    snapdeviations = np.sqrt(np.sum(np.square(average_positions - positions), axis=1))
    posanddev = np.zeros((Input['ALLparticles'],8))
    posanddev[:,:3] = average_positions
    posanddev[:,3] = deviations / Input['a']
    posanddev[:,4:7] = positions
    posanddev[:,7] = snapdeviations / Input['a']
    head = '%-18s\t%-18s\t%-18s\t%-18s\t%-18s\t%-18s\t%-18s\t%-18s' % ('x[sigma]', 'y[sigma]', 'z[sigma]', 'lindemann','snapx[sigma]', 'snapy[sigma]', 'snapz[sigma]', 'snapdev[sigma]')
    savename = '%s%s.deviations' % (Input['folder_processed_data'], Input['system'])
    np.savetxt(savename, posanddev, fmt='%18.11e', header=head, delimiter='\t')
    return positions, deviations