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)
def test_dimer_method(testdir): # 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.calc = EMT() atoms.get_potential_energy() # Set up the dimer with DimerControl(initial_eigenmode_method='displacement', displacement_method='vector', logfile=None, mask=[0, 0, 0, 0, 1]) as d_control: 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 with MinModeTranslate(d_atoms, trajectory='dimer_method.traj', logfile="dimer_method.log") as dim_rlx: dim_rlx.run(fmax=0.001)
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))
# Freeze the "slab" mask = [atom.tag > 0 for atom in atoms] atoms.set_constraint(FixAtoms(mask = mask)) # Calculate using EMT atoms.set_calculator(EMT()) relaxed_energy = 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) # Dispalce 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.889396) < tolerance) assert(d_atoms.get_eigenmode()[-1][1] < -0.99) assert(abs(d_atoms.get_positions()[-1][1]) < tolerance)
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)
maximum_translation=0.2, trial_trans_step=5.0e-3, dimer_separation=dimer_dist, mask=d_mask, f_rot_min=0.01, f_rot_max=0.2, 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 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)
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))