Skip to content

suggestion to change probe looping #92

@tpchuckles

Description

@tpchuckles

Currently we generate the entire potential, then loop_probes allows chunked/looped (vs fully vectorized) processing of many probe positions.

it may be possible to do probe looping at a higher level, with cropped trajectories.

e.g. what if i have a bonkers-huge system, hundreds of nanometers square: the potential alone won't fit in memory. but presumably, if i'm using a focused probe, then most of the potential doesn't matter for any individual probe. I could crop the trajectory, generate a potential for a portion of the system, calculate those probes, rinse and repeat.

below is a quick-and-dirty script i threw together to demo this concept:

ADF = np.zeros((len(probe_ys),len(probe_xs)))

chunksize = 10 # process squares of 10x10 probes
buffer = 10 # leave an additional 10A border around each square

# chunked processing: square grid of chunks
trimmed = None ; extent = np.zeros((2,2))
for i0 in range(0,len(probe_xs),chunksize):
    for j0 in range(0,len(probe_ys),chunksize):
        # chunk of probe positions, square grid selected from trajectory
        pxs = probe_xs[i0:i0+chunksize]
        pys = probe_ys[j0:j0+chunksize]
        # check if the previously-trimmed trajectory is within bounds
        if trimmed is None or extent[0,0]+5 > min(pxs) or extent[0,1]-5 < max(pxs) or\
            extent[1,0]+5 > min(pys) or extent[1,1]-5 < max(pys):
            xi=min(pxs)-10 ; xf=max(pxs)+10 ; yi=min(pys)-10 ; yf=max(pys)+10
            # trim trajectory if required
            trimmed = trajectory.slice_positions([xi,xf],[yi,yf])
            extent.flat=[xi,xf,yi,yf]
        # run multislice on chunked bit of trajectory
        calculator=MultisliceCalculator()
        calculator.setup(trimmed,aperture=7, voltage_eV=200e3, sampling=.1, slice_thickness=.5,probe_xs=pxs,probe_ys=pys,ADF=True,store_full=False)
        exitwaves,haadf = calculator.run()
        ADF[j0:j0+chunksize,i0:i0+chunksize]=np.absolute(haadf.array)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions