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)
# Calculate using EMT: initial.calc = EMT() # Relax the initial state: 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)
trajname = fname + '.traj' print(trajname) traj = Trajectory(trajname, 'w', runner) traj.write() # Making dimer mask list: # d_mask = [atom.index == 69 for atom in initial] d_mask = [False] * (N - 1) + [True] # [0, 0, 0, 0, 1] # d_mask = initial.positions[:, 2] - min(initial.positions[:, 2]) < 1 * a # Set up the dimer (gaus is for ramdom rotation std sets up the level): d_control = DimerControl( initial_eigenmode_method='gauss', # initial_eigenmode_method='displacement', displacement_method='gauss', # 'vector', # displacement_method='vector', gauss_std=0.1, trial_angle=pi / 12.0, logfile=fname + '.log', mask=d_mask) """ All the avaiable parameters are: parameters = {'eigenmode_method': 'dimer', 'f_rot_min': 0.1, 'f_rot_max': 1.00, 'max_num_rot': 1, 'trial_angle': pi / 4.0, 'trial_trans_step': 0.001, 'maximum_translation': 0.1, 'cg_translation': True, 'use_central_forces': True, 'dimer_separation': 0.0001,
# 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()) 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
algo="N", ismear=0, sigma=0.1, npar=8, lreal="Auto", lcharg=False, 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()
dimer.set_constraint(constraint) d_mask = [False] * N_fix + [True] * (N_atom - N_fix) # set gp calculator gp_file = open('PdAg.gp', 'rb') gp_model = pickle.load(gp_file) gp_model.energy_force_kernel = mc_simple.two_plus_three_mc_force_en dimer.set_calculator(gp_calculator.GPCalculator(gp_model)) # dimer setup dimer_control = DimerControl(initial_eigenmode_method='displacement', displacement_method='vector', 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',