Exemple #1
0
 def neb(self):
     from ase.neb import NEBtools
     try:
         nebtools = NEBtools(self.images)
         fit = nebtools.get_fit()
     except Exception as err:
         self.bad_plot(err, _('Images must have energies and forces, '
                              'and atoms must not be stationary.'))
     else:
         self.pipe('neb', fit)
Exemple #2
0
# -*- coding: utf-8 -*-
# creates:  diffusion-I.png  diffusion-T.png  diffusion-F.png diffusion-barrier.png
from ase.io import read, write
from ase.neb import NEBtools
if 1:
    exec(compile(open('diffusion1.py').read(), 'diffusion1.py', 'exec'))
    exec(compile(open('diffusion2.py').read(), 'diffusion2.py', 'exec'))
    exec(compile(open('diffusion4.py').read(), 'diffusion4.py', 'exec'))
    exec(compile(open('diffusion5.py').read(), 'diffusion5.py', 'exec'))
images = read('neb.traj@-5:')
for name, a in zip('ITF', images[::2]):
    cell = a.get_cell()
    del a.constraints
    a = a * (2, 2, 1)
    a.set_cell(cell)
    write('diffusion-%s.pov' % name,
          a,
          show_unit_cell=True,
          transparent=False,
          display=False,
          run_povray=True)

nebtools = NEBtools(images)
assert abs(nebtools.get_barrier()[0] - 0.374) < 1e-3
Exemple #3
0
    nim = len(images)
    n = size // nim  # number of cpu's per image
    j = rank // n  # image number
    assert nim * n == size

    for i in range(nim):
        ranks = range(i * n, (i + 1) * n)
        if rank in ranks:
            calc = getcalc(txt='neb%d.txt' % j, communicator=ranks)
            images[i].set_calculator(calc)


autoneb = AutoNEB(attach_calculators,
                  prefix='neb',
                  n_simul=2,
                  parallel=True,
                  climb=True,
                  n_max=5,
                  optimizer='FIRE',
                  fmax=0.05,
                  k=0.5,
                  maxsteps=[25, 1000])
autoneb.run()

nebtools = NEBtools(autoneb.all_images)
barrier, delta_e = nebtools.get_barrier()
print('barrier', barrier)
ref = 0.74051020956857272  # 1.484 <- with better parameters
err = abs(barrier - ref)
assert err < 1e-3, 'barrier={}, expected={}, err={}'.format(barrier, ref, err)
Exemple #4
0
for i in range(nimages):
    images.append(images[0].copy())
images[-1].positions[6, 1] = 2 - images[0].positions[6, 1]
neb = NEB(images)
neb.interpolate()
if 0:  # verify that initial images make sense
    from ase.visualize import view
    view(neb.images)

for image in images:
    image.set_calculator(MorsePotential())

dyn = BFGS(neb, trajectory='mep.traj')  # , logfile='mep.log')

dyn.run(fmax=fmax)

for a in neb.images:
    print(a.positions[-1], a.get_potential_energy())

neb.climb = True
dyn.run(fmax=fmax)

# Check NEB tools.
nt_images = read('mep.traj@-4:')
nebtools = NEBtools(nt_images)
nt_fmax = nebtools.get_fmax(climb=True)
Ef, dE = nebtools.get_barrier()
print(Ef, dE, fmax, nt_fmax)
assert nt_fmax < fmax
assert abs(Ef - 1.389) < 0.001
Exemple #5
0
def NudgedElasticBand(images):
    nebtools = NEBtools(images)
    fig = nebtools.plot_band()
    fig.show()
Exemple #6
0
 def get_NEB_plot(images):
     return NEBtools(images).plot_band()