示例#1
0
文件: neb.py 项目: rosswhitfield/ase
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
示例#2
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')
示例#3
0
文件: diffusion.py 项目: uu1477/MyAse
# -*- 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
示例#4
0
文件: autoneb.py 项目: thonmaker/gpaw
    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)
示例#5
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
示例#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")
示例#7
0
文件: neb.py 项目: 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
示例#8
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