def check_db(db, params): if debug: print "%10s %10s %10s ( %10s )" \ % ( "bond", "value", "reference", "error" ) for mol, values in db.iteritems(): #if mol == 'H2O': if 1: if debug: print mol a = molecule(mol) a.center(vacuum=10.0) a.set_pbc(False) #print a.get_chemical_symbols() calc = Hotbit( charge_density = 'Slater', SCC = True, width = 1e-6, txt = 'mio.out', **params) a.set_calculator(calc) #calc.ia.plot_table('H', 'H') #calc.rep.get_repulsion('H', 'H').plot() OPT(a, logfile='opt.log').run(fmax=FMAX) #print a.get_charges() for name, ( ( i1, i2 ), refvalue ) in values.iteritems(): value = a.get_distance(i1, i2) if debug: print '%10s %10.3f %10.3f ( %10.3f )' % \ ( name, value, refvalue, abs(value-refvalue) ) assert abs(value-refvalue) < 0.01
import numpy as np import ase from ase.units import Hartree from hotbit import Hotbit ### dir1 = '/Users/pas/Sourcen/hotbit/param/' #dir2 = '/Users/pas/Sourcen/hotbit/param/' dir2 = '/Users/pas/Sourcen/mdcore/data/slater_koster_tables/Frauenheim/download-2009-10-23/mio-0-1/' ### a = ase.molecule('C6H6') a.center(vacuum=6.0) c = Hotbit(elements={ 'H': dir2 + 'H-H.skf', 'C': dir2 + 'C-C.skf' }, tables={ 'HH': dir2 + 'H-H.skf', 'CH': dir2 + 'C-H.skf', 'CC': dir2 + 'C-C.skf' }, SCC=False) a.set_calculator(c) ase.FIRE(a).run(fmax=0.01)
import numpy as np import ase from ase.units import Hartree from hotbit import Hotbit ### dir1 = '/Users/pas/Sourcen/hotbit/param/' #dir2 = '/Users/pas/Sourcen/hotbit/param/' dir2 = '/Users/pas/Sourcen/mdcore/data/slater_koster_tables/Frauenheim/download-2009-10-23/mio-0-1/' ### a = ase.molecule('C6H6') a.center(vacuum=6.0) c = Hotbit( elements = { 'H': dir2 + 'H-H.skf', 'C': dir2 + 'C-C.skf' }, tables = { 'HH': dir2 + 'H-H.skf', 'CH': dir2 + 'C-H.skf', 'CC': dir2 + 'C-C.skf' }, SCC = False ) a.set_calculator(c)
import os import numpy as np from time import time from ase import molecule from gpaw import GPAW from gpaw.lcao.projected_wannier import ProjectedWannierFunctions, get_phs if not os.path.isfile('C6H6.gpw'): atoms = molecule('C6H6') atoms.center(vacuum=2.5) calc = GPAW(h=0.2, basis='szp', width=0.05, convergence={'bands': 17}) atoms.set_calculator(calc) atoms.get_potential_energy() calc.write('C6H6.gpw', 'all') calc = GPAW('C6H6.gpw', txt=None, basis='sz') ibzk_kc = calc.wfs.ibzk_kc nk = len(ibzk_kc) Ef = calc.get_fermi_level() eps_kn = np.asarray([calc.get_eigenvalues(k) for k in range(nk)]) eps_kn -= Ef V_knM, H_kMM, S_kMM, P_aqMi = get_phs(calc, s=0) H_kMM -= Ef * S_kMM pwf = ProjectedWannierFunctions(V_knM, h_lcao=H_kMM, s_lcao=S_kMM, eigenvalues=eps_kn,
import os import numpy as np from time import time from ase import molecule from gpaw import GPAW from gpaw.lcao.projected_wannier import ProjectedWannierFunctions, get_phs if not os.path.isfile('C6H6.gpw'): atoms = molecule('C6H6') atoms.center(vacuum=2.5) calc = GPAW(h=0.2, basis='szp', width=0.05, convergence={'bands':17}) atoms.set_calculator(calc) atoms.get_potential_energy() calc.write('C6H6.gpw', 'all') calc = GPAW('C6H6.gpw', txt=None, basis='sz') ibzk_kc = calc.wfs.ibzk_kc nk = len(ibzk_kc) Ef = calc.get_fermi_level() eps_kn = np.asarray([calc.get_eigenvalues(k) for k in range(nk)]) eps_kn -= Ef V_knM, H_kMM, S_kMM, P_aqMi = get_phs(calc, s=0) H_kMM -= Ef * S_kMM pwf = ProjectedWannierFunctions(V_knM, h_lcao=H_kMM, s_lcao=S_kMM, eigenvalues=eps_kn,
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