Esempio n. 1
0
def test_crop():
    S = SMatrix(expansion_cutoff=30,
                interpolation=3,
                energy=300e3,
                extent=10,
                sampling=.02).build()
    gridscan = GridScan(start=[0, 0], end=S.extent, gpts=64)

    scans = gridscan.partition_scan((2, 2))
    cropped = S.crop_to_scan(scans[0])

    assert cropped.gpts != S.gpts

    position = (4.9, 0.)
    assert np.allclose(
        S.collapse(position).array - cropped.collapse(position).array, 0.)
Esempio n. 2
0
def test_cropped_scan():
    atoms = read(
        os.path.join(os.path.dirname(os.path.abspath(__file__)),
                     'data/amorphous_carbon.cif'))
    potential = Potential(atoms,
                          gpts=512,
                          slice_thickness=1,
                          device='gpu',
                          projection='infinite',
                          parametrization='kirkland',
                          storage='gpu').build(pbar=True)
    detector = AnnularDetector(inner=40, outer=60)
    gridscan = GridScan(start=[0, 0], end=potential.extent, gpts=16)

    S = SMatrix(expansion_cutoff=20,
                interpolation=4,
                energy=300e3,
                device='gpu',
                storage='cpu')  # .build()

    S = S.multislice(potential, pbar=True)
    S = S.downsample('limit')

    measurements = S.scan(gridscan, [detector], max_batch_probes=64)

    scans = gridscan.partition_scan((2, 2))
    cropped_measurements = {
        detector: detector.allocate_measurement(S.collapse((0, 0)), gridscan)
    }

    for scan in scans:
        cropped = S.crop_to_scan(scan)
        cropped = cropped.transfer('gpu')
        cropped_measurements = cropped.scan(scan,
                                            cropped_measurements,
                                            pbar=False)

    assert np.allclose(cropped_measurements[detector].array,
                       measurements[detector].array)