Esempio n. 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)
Esempio n. 2
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
Esempio n. 3
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
Esempio n. 4
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)
Esempio n. 5
0
from ase.neb import NEBtools
from ase.io import read

images = read('neb.traj@-5:')

nebtools = NEBtools(images)

# Get the calculated barrier and the energy change of the reaction.
Ef, dE = nebtools.get_barrier()

# Get the barrier without any interpolation between highest images.
Ef, dE = nebtools.get_barrier(fit=False)

# Get the actual maximum force at this point in the simulation.
max_force = nebtools.get_fmax()

# Create a figure like that coming from ase-gui.
fig = nebtools.plot_band()
fig.savefig('diffusion-barrier.png')

# Create a figure with custom parameters.
from matplotlib import pyplot, rcParams
rcParams.update({'font.size': 10})
fig = pyplot.figure(figsize=(4.5, 3))
ax = fig.add_axes((0.15, 0.15, 0.8, 0.75))
nebtools.plot_band(ax)
fig.savefig('diffusion-barrier.png')
Esempio n. 6
0
from ase.neb import NEBtools
from ase.io import read

images = read("neb.traj@-5:")

nebtools = NEBtools(images)

# Get the calculated barrier and the energy change of the reaction.
Ef, dE = nebtools.get_barrier()

# Get the barrier without any interpolation between highest images.
Ef, dE = nebtools.get_barrier(fit=False)

# Get the actual maximum force at this point in the simulation.
max_force = nebtools.get_fmax()

# Create a figure like that coming from ase-gui.
fig = nebtools.plot_band()
fig.savefig("diffusion-barrier.png")

# Create a figure with custom parameters.
from matplotlib import pyplot, rcParams

rcParams.update({"font.size": 10})
fig = pyplot.figure(figsize=(4.5, 3))
ax = fig.add_axes((0.15, 0.15, 0.8, 0.75))
nebtools.plot_band(ax)
fig.savefig("diffusion-barrier.png")
Esempio n. 7
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
Esempio n. 8
0
File: neb.py Progetto: uu1477/MyAse
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
Esempio n. 9
0
def NudgedElasticBand(images):
    nebtools = NEBtools(images)
    fig = nebtools.plot_band()
    fig.show()
Esempio n. 10
0
 def get_NEB_plot(images):
     return NEBtools(images).plot_band()
Esempio n. 11
0
File: neb.py Progetto: jboes/ase
images[0].get_potential_energy()
images[-1].get_potential_energy()


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())

results = [images[2].get_potential_energy()]

# Check NEB tools.
nt_images = [read('mep.traj', index=_) for _ in range(-4, 0)]
nebtools = NEBtools(nt_images)
nt_fmax = nebtools.get_fmax()
Ef, dE = nebtools.get_barrier()
assert nt_fmax < fmax


def run_neb_calculation(cpu):
    images = [Trajectory('H.traj')[-1]]
    for i in range(nimages):
        images.append(images[0].copy())
    images[-1].positions[6, 1] = 2 - images[0].positions[6, 1]
    neb = NEB(images, parallel=True, world=cpu)
    neb.interpolate()

    images[cpu.rank + 1].set_calculator(MorsePotential())
Esempio n. 12
0
    # Define the NEB and make a linear interpolation
    # with removing translational
    # and rotational degrees of freedom
    neb = NEB(images,
              remove_rotation_and_translation=remove_rotation_and_translation)
    neb.interpolate(method='idpp')

    qn = FIRE(neb, dt=0.005, maxmove=0.05, dtmax=0.1)
    qn.run(steps=20)

    # Switch to CI-NEB, still removing the external degrees of freedom
    # Also spesify the linearly varying spring constants
    neb = NEB(images,
              climb=True,
              remove_rotation_and_translation=remove_rotation_and_translation)
    qn = FIRE(neb, dt=0.005, maxmove=0.05, dtmax=0.1)
    qn.run(fmax=fmax)

    images = neb.images

    nebtools = NEBtools(images)
    Ef_neb, dE_neb = nebtools.get_barrier(fit=False)
    nsteps_neb = qn.nsteps
    if remove_rotation_and_translation:
        Ef_neb_0 = Ef_neb
        nsteps_neb_0 = nsteps_neb

assert abs(Ef_neb - Ef_neb_0) < 1e-2
assert nsteps_neb_0 < nsteps_neb * 0.7