Ejemplo n.º 1
0
def test_plane_waves_raises():
    plane_waves = PlaneWave(energy=60e3)

    with pytest.raises(RuntimeError) as e:
        plane_waves.multislice(DummyPotential(extent=5), pbar=False)

    assert str(e.value) == 'Grid gpts cannot be inferred'
Ejemplo n.º 2
0
def test_propagator_cache():
    wave = PlaneWave(extent=10, gpts=100, energy=60e3).build()

    propagator = FresnelPropagator()
    propagator.propagate(wave, .5)
    propagator.propagate(wave, .5)

    assert propagator.cache._hits == 1
    assert propagator.cache._misses == 1
Ejemplo n.º 3
0
def test_fig_5_12():
    atoms = Atoms('CSiCuAuU',
                  positions=[(x, 25, 4) for x in np.linspace(5, 45, 5)],
                  cell=(50, 50, 8))

    potential = Potential(atoms=atoms,
                          gpts=512,
                          parametrization='kirkland',
                          cutoff_tolerance=1e-4)

    waves = PlaneWave(energy=200e3)

    waves = waves.multislice(potential, pbar=False)
    waves = waves.apply_ctf(defocus=700, Cs=1.3e7, semiangle_cutoff=.01037)

    intensity = np.abs(waves.array)**2

    assert np.round(intensity.min(), 2) == np.float32(.72)
    assert np.round(intensity.max(), 2) == np.float32(1.03)
Ejemplo n.º 4
0
def test_plane_waves_multislice():
    plane_waves = PlaneWave(gpts=50, energy=60e3)
    plane_waves.multislice(DummyPotential(extent=5))

    plane_waves = PlaneWave(sampling=.1, energy=60e3)
    plane_waves.multislice(DummyPotential(extent=5))
Ejemplo n.º 5
0
def test_create_plane_waves():
    plane_wave = PlaneWave(extent=2, gpts=10, energy=60e3)
    waves = plane_wave.build()
    assert np.all(waves.array == np.ones((10, 10), dtype=np.complex64))
Ejemplo n.º 6
0
                    orientation='vertical')
#plt.colorbar(sc, cax=cax, orientation='vertical',ticks=[-5,-2.5,0,2.5,5],label='$\epsilon_p$ [\%]')

#plt.tight_layout()
plt.show()

for i, model in enumerate(models_list):

    # # # Building the potential
    potential = Potential(model,
                          gpts=L,
                          slice_thickness=1,
                          parametrization='kirkland',
                          projection='infinite')

    wave = PlaneWave(energy=300e3  # acceleration voltage in eV
                     )

    exit_wave = wave.multislice(potential)

    np.savez('{0}/points/points_{1:04d}.npz'.format(dir_name,
                                                    first_number + i),
             sites=sites_list[i],
             classes=classes_list[i])
    exit_wave.write('{0}/wave/wave_{1:04d}.hdf5'.format(
        dir_name, first_number + i))
    write('{0}/model/model_{1:04d}.cfg'.format(dir_name, first_number + i),
          model)

    print('TEM images finnished: ' + str(100 * (i + 1) // num_examples) + '%')