import os import sys from ase import Atoms, Atom, QuasiNewton, PickleTrajectory from gpaw import * from gpaw.cluster import Cluster from gpaw.utilities.viewmol import ViewmolTrajectory, write_viewmol s = Cluster([Atom('H'), Atom('H', (0, 0, 3))]) s.minimal_box(2) c = GPAW(h=0.3, nbands=2) s.set_calculator(c) vfname = 'traj.vmol' pfname = 'traj.pickle' vmt = ViewmolTrajectory(s, vfname) traj = PickleTrajectory(pfname, 'w', s) #c.attach(vmt.add, 100000) #sys.exit() # Find the theoretical bond length: dyn = QuasiNewton(s) dyn.attach(traj.write) dyn.attach(vmt.add) dyn.run(fmax=0.05) traj = PickleTrajectory(pfname, 'r') vfname2 = 'pickle.vmol' write_viewmol(traj, vfname2)
def run_slab(adsorbate, geometry, xc, code): parameters = initialize_parameters(code, 0.1, h) parameters['xc'] = xc tag = 'Ru001' if adsorbate != 'None': name = adsorbate + tag else: name = tag if geometry == 'fix': slab = read_trajectory(code + '_' + name + '.traj') else: adsorbate_heights = {'N': 1.108, 'O': 1.257} slab = hcp0001('Ru', size=(2, 2, 4), a=2.72, c=1.58 * 2.72, vacuum=5.0 + add_vacuum, orthogonal=True) slab.center(axis=2) if adsorbate != 'None': add_adsorbate(slab, adsorbate, adsorbate_heights[adsorbate], 'hcp') slab.set_constraint(FixAtoms(mask=slab.get_tags() >= 3)) if code != 'elk': parameters['nbands'] = 80 parameters['kpts'] = [4, 4, 1] # if code == 'gpaw': from gpaw import GPAW as Calculator from gpaw.mpi import rank parameters['txt'] = code + '_' + name + '.txt' from gpaw.mixer import Mixer, MixerSum parameters['mixer'] = Mixer(beta=0.2, nmaxold=5, weight=100.0) if code == 'dacapo': from ase.calculators.dacapo import Dacapo as Calculator rank = 0 parameters['txtout'] = code + '_' + name + '.txt' if code == 'abinit': from ase.calculators.abinit import Abinit as Calculator rank = 0 parameters['label'] = code + '_' + name if code == 'elk': from ase.calculators.elk import ELK as Calculator rank = 0 parameters['autokpt'] = True elk_dir = 'elk_' + str(parameters['rgkmax']) conv_param = 1.0 parameters['dir'] = elk_dir + '_' + name # calc = Calculator(**parameters) # slab.set_calculator(calc) try: if geometry == 'fix': slab.get_potential_energy() traj = PickleTrajectory(code + '_' + name + '.traj', mode='w') traj.write(slab) else: opt = QuasiNewton(slab, logfile=code + '_' + name + '.qn', trajectory=code + '_' + name + '.traj') opt.run(fmax=fmax) except: raise
import os import sys from ase import Atoms, Atom, QuasiNewton, PickleTrajectory from gpaw import * from gpaw.cluster import Cluster from gpaw.utilities.viewmol import ViewmolTrajectory, write_viewmol s = Cluster([Atom('H'), Atom('H',(0,0,3))]) s.minimal_box(2) c = GPAW(h=0.3, nbands=2) s.set_calculator(c) vfname='traj.vmol' pfname='traj.pickle' vmt = ViewmolTrajectory(s, vfname) traj = PickleTrajectory(pfname, 'w', s) #c.attach(vmt.add, 100000) #sys.exit() # Find the theoretical bond length: dyn = QuasiNewton(s) dyn.attach(traj.write) dyn.attach(vmt.add) dyn.run(fmax=0.05) traj = PickleTrajectory(pfname, 'r') vfname2='pickle.vmol' write_viewmol(traj, vfname2)
def run_molecule(adsorbate, geometry, xc, code): parameters = initialize_parameters(code, 0.01, h) parameters['xc'] = xc molecules = { 'None': ('NO', 8), 'N': ('N2', 8), 'O': ('O2', 8), } for name, nbands in [molecules[adsorbate]]: if code != 'elk': parameters['nbands'] = nbands if geometry == 'fix': mol = read_trajectory(code + '_' + name + '.traj') else: mol = molecule(name) mol.center(vacuum=3.0 + add_vacuum) if name == 'NO': mol.translate((0, 0.1, 0)) # if code == 'gpaw': from gpaw import GPAW as Calculator from gpaw.mpi import rank parameters['txt'] = code + '_' + name + '.txt' from gpaw.mixer import Mixer, MixerSum #if name == 'N2': # parameters['mixer'] = Mixer(beta=0.1, nmaxold=5, metric='new', weight=100.0) #else: # #parameters['eigensolver'] = 'cg' # parameters['mixer'] = MixerSum(beta=0.2, nmaxold=5, metric='new', weight=100.0) if code == 'dacapo': from ase.calculators.dacapo import Dacapo as Calculator rank = 0 parameters['txtout'] = code + '_' + name + '.txt' if code == 'abinit': from ase.calculators.abinit import Abinit as Calculator rank = 0 parameters['label'] = code + '_' + name if code == 'elk': from ase.calculators.elk import ELK as Calculator rank = 0 elk_dir = 'elk_' + str(parameters['rgkmax']) conv_param = 1.0 parameters['dir'] = elk_dir + '_' + name # calc = Calculator(**parameters) # mol.set_calculator(calc) try: if geometry == 'fix': mol.get_potential_energy() traj = PickleTrajectory(code + '_' + name + '.traj', mode='w') traj.write(mol) else: opt = QuasiNewton(mol, logfile=code + '_' + name + '.qn', trajectory=code + '_' + name + '.traj') opt.run(fmax=fmax) except: raise