Ejemplo n.º 1
0
def test_dimer_method():
    # Set up a small "slab" with an adatoms
    atoms = fcc100('Pt', size=(2, 2, 1), vacuum=10.0)
    add_adsorbate(atoms, 'Pt', 1.611, 'hollow')

    # Freeze the "slab"
    mask = [atom.tag > 0 for atom in atoms]
    atoms.set_constraint(FixAtoms(mask=mask))

    # Calculate using EMT
    atoms.set_calculator(EMT())
    atoms.get_potential_energy()

    # Set up the dimer
    d_control = DimerControl(initial_eigenmode_method = 'displacement', \
                             displacement_method = 'vector', logfile = None, \
                             mask = [0, 0, 0, 0, 1])
    d_atoms = MinModeAtoms(atoms, d_control)

    # Displace the atoms
    displacement_vector = [[0.0] * 3] * 5
    displacement_vector[-1][1] = -0.1
    d_atoms.displace(displacement_vector=displacement_vector)

    # Converge to a saddle point
    dim_rlx = MinModeTranslate(d_atoms, trajectory = 'dimer_method.traj', \
                               logfile = None)
    dim_rlx.run(fmax=0.001)

    # Test the results
    tolerance = 1e-3
    assert (d_atoms.get_barrier_energy() - 1.03733136918 < tolerance)
    assert (abs(d_atoms.get_curvature() + 0.900467048707) < tolerance)
    assert (d_atoms.get_eigenmode()[-1][1] < -0.99)
    assert (abs(d_atoms.get_positions()[-1][1]) < tolerance)
Ejemplo n.º 2
0
QuasiNewton(initial).run(fmax=0.05)
e0 = initial.get_potential_energy()

traj = Trajectory('dimer_along.traj', 'w', initial)
traj.write()

# Making dimer mask list:
d_mask = [False] * (N - 1) + [True]

# Set up the dimer:
d_control = DimerControl(initial_eigenmode_method='displacement',
                         displacement_method='vector',
                         logfile=None,
                         mask=d_mask)
d_atoms = MinModeAtoms(initial, d_control)

# Displacement settings:
displacement_vector = np.zeros((N, 3))
# Strength of displacement along y axis = along row:
displacement_vector[-1, 1] = 0.001
# The direction of the displacement is set by the a in
# displacement_vector[-1, a], where a can be 0 for x, 1 for y and 2 for z.
d_atoms.displace(displacement_vector=displacement_vector)

# Converge to a saddle point:
dim_rlx = MinModeTranslate(d_atoms, trajectory=traj, logfile=None)
dim_rlx.run(fmax=0.001)

diff = initial.get_potential_energy() - e0
print(('The energy barrier is %f eV.' % diff))
Ejemplo n.º 3
0
             lwave=True,
             directory='calculator')

atoms.set_calculator(calc)

# Set up the dimer
d_control = DimerControl(initial_eigenmode_method='displacement',
                         displacement_method='vector',
                         logfile='dimer_control.log',
                         dimer_separation=0.008,
                         max_num_rot=2,
                         mask=mask,
                         eigenmode_logfile='dimer_eigenmodes.dat')

d_atoms = MinModeAtoms(atoms, d_control)
d_atoms.displace(displacement_vector=displacement_vector)

dim_rlx = MinModeTranslate(d_atoms,
                           trajectory="dimer_opt.traj",
                           logfile="dimer_opt.log")
dim_rlx.run(fmax=0.03)

# remember to add in the constraint
original_atoms = read("vasp_optimized.traj")
energy = atoms.get_potential_energy()
forces = atoms.get_forces()
a = atoms.copy()
a.set_constraint(original_atoms.constraints)
a.set_calculator(SinglePointCalculator(a, energy=energy, forces=forces))
write("dimer_optimized.traj", a)
                             trial_angle=pi / 4,
                             max_num_rot=2,
                             logfile='%s_control.log' % prefix,
                             eigenmode_logfile='%s_eigenmode.log' % prefix)

dimer_atoms = MinModeAtoms(dimer, dimer_control, eigenmodes=[mode])
dimer_atoms.displace(displacement_vector=mode)

dimer_relax = MinModeTranslate(dimer_atoms,
                               trajectory='%s.traj' % prefix,
                               logfile='%s_relax.log' % prefix)
# also possible to use these:
#dimer_relax = FIRE(dimer_atoms, trajectory='dimer.traj',
#                   restart='restart_file',
#                   dt=0.1, # default 0.1
#                   maxmove=0.2, # default 0.2
#                   dtmax=1.0, # default 1.0
#                   Nmin=3, # default 5
#                   finc=1.1, # default 3
#                   fdec=0.71, # default 0.5
#                   astart=0.2, # default 0.1
#                   fa=0.99) # default 0.99
#dimer_relax = BFGS(dimer_atoms, trajectory='dimer.traj', restart='restart_file')

# run dimer
dimer_relax.run(fmax=force_tol)

# clean up
np.savetxt('%s.MODE' % prefix, dimer_atoms.get_eigenmode())
write('POSCAR.vasp', dimer_atoms.get_atoms(), format='vasp')
Ejemplo n.º 5
0
# Dimer method using ASE.

atoms.set_calculator(Himmelblau())

# Set trajectory
traj = Trajectory('dimer_optimization.traj', 'w', atoms)
traj.write()

# Set up the dimer:
d_control = DimerControl(initial_eigenmode_method='displacement',
                         displacement_method='vector',
                         logfile=None,
                         mask=d_mask)
d_atoms = MinModeAtoms(atoms, d_control)

d_atoms.displace(displacement_vector=displacement_vector)

# Converge to a saddle point:
dim_rlx = MinModeTranslate(d_atoms, trajectory=traj, logfile='-')
dim_rlx.run(fmax=0.01, steps=1000)

get_plot('dimer_optimization.traj')

iter_catlearn = len(read('mldimer_opt.traj', ':'))
iter_ase = len(read('dimer_optimization.traj', ':'))

print('Number of iterations performed by ASE Dimer:', iter_ase)
print('Number of iterations performed by CatLearn ML-Dimer:',
      ml_dimer.iter + 1)
Ejemplo n.º 6
0
traj = Trajectory('dimer_along.traj', 'w', initial)
traj.write()

# Making dimer mask list:
d_mask = [False] * (N - 1) + [True]

# Set up the dimer:
d_control = DimerControl(initial_eigenmode_method='displacement',
                         displacement_method='vector',
                         logfile=None,
                         mask=d_mask)
d_atoms = MinModeAtoms(initial, d_control)

# Displacement settings:
displacement_vector = np.zeros((N, 3))
# Strength of displacement along y axis = along row:
displacement_vector[-1, 1] = 0.001
# The direction of the displacement is set by the a in
# displacement_vector[-1, a], where a can be 0 for x, 1 for y and 2 for z.
d_atoms.displace(displacement_vector=displacement_vector)

# Converge to a saddle point:
dim_rlx = MinModeTranslate(d_atoms,
                           trajectory=traj,
                           logfile=None)
dim_rlx.run(fmax=0.001)

diff = initial.get_potential_energy() - e0
print(('The energy barrier is %f eV.' % diff))
Ejemplo n.º 7
0
# displacement_vector[-2, 1] = 0.8

# Random vector:
step_displ = 1.
displacement_vector = np.random.uniform(low=-step_displ,
                                        high=step_displ,
                                        size=(N, 3))
displacement_vector[:, 2] = 0.0

# The direction of the displacement is set by the a in
# displacement_vector[-1, a], where a can be 0 for x, 1 for y and 2 for z.
d_atoms.displace(displacement_vector=displacement_vector)

# Converge to a saddle point:
dim_rlx = MinModeTranslate(d_atoms, trajectory=traj, logfile='-')
dim_rlx.run(fmax=0.02)

diff = atoms.get_potential_energy() - e0
print(('The energy barrier is %f eV.' % diff))

final_ase = read('dimer_along.traj', ':')
iter_ase = len(final_ase)

# CatLearn MLDimer:
atoms = read('initial.traj')
ml_dimer = MLDimer(x0=atoms, ase_calc=EMT(), trajectory='mldimer_opt.traj')
ml_dimer.run(fmax=0.02, dmask=d_mask, vector=displacement_vector)

# Summary:
final_catlearn = read('mldimer_opt.traj', ':')
iter_catlearn = len(final_catlearn)