print >> f, molecule, ss = Cluster(Atoms(data[molecule]['symbols'], data[molecule]['positions'])) # split the structures s1 = ss.find_connected(0) s2 = ss.find_connected(-1) assert(len(ss) == len(s1) + len(s2)) if xc == 'TS09' or xc == 'TPSS' or xc == 'M06L': c = GPAW(xc='PBE', h=h, nbands=-6, occupations=FermiDirac(width=0.1)) else: c = GPAW(xc=xc, h=h, nbands=-6, occupations=FermiDirac(width=0.1)) E = [] for s in [s1, s2, ss]: s.set_calculator(c) s.minimal_box(box, h=h) if xc == 'TS09': s.get_potential_energy() cc = vdWTkatchenko09prl(HirshfeldPartitioning(c), vdWradii(s.get_chemical_symbols(), 'PBE')) s.set_calculator(cc) if xc == 'TPSS' or xc == 'M06L': ene = s.get_potential_energy() ene += c.get_xc_difference(xc) E.append(ene) else: E.append(s.get_potential_energy()) print >> f, E[0], E[1], E[2], print >> f, E[0] + E[1] - E[2] f.flush() f.close()
from gpaw.analyse.vdwradii import vdWradii # data from A. Bondi, J. Phys. Chem. 68 (1964) 441 data_Bondi = { # units Anstrom 'He': 1.40, 'Ne': 1.54, 'Ar': 1.88, 'Kr': 2.02, 'Xe': 2.16 } # data from Felix Hanke (FHI-AIMS ?) data_Hanke = { # units Anstrom 'H' : 1.640449351, 'C' : 1.8997461838999998, 'N' : 1.7674518813999998, 'O' : 1.6880752998999997, 'Cu': 1.9897063095999996, } for symbol in ['He', 'Ne', 'Ar', 'Kr', 'H', 'C', 'N', 'O', 'Cu']: R = vdWradii([symbol], 'PBE')[0] if symbol in data_Bondi: Rref = data_Bondi[symbol] else: Rref = data_Hanke[symbol] error = abs(R - Rref) print("symbol, R, Rref, error:", symbol, R, Rref, error) assert (error < 0.05)
from ase.units import Bohr from gpaw.analyse.vdwradii import vdWradii # data from A. Bondi, J. Phys. Chem. 68 (1964) 441 data_Bondi = {"He": 1.40, "Ne": 1.54, "Ar": 1.88, "Kr": 2.02, "Xe": 2.16} # units Anstrom # data from Felix Hanke (FHI-AIMS ?) data_Hanke = { # units Anstrom "H": 1.640449351, "C": 1.8997461838999998, "N": 1.7674518813999998, "O": 1.6880752998999997, "Cu": 1.9897063095999996, } for symbol in ["He", "Ne", "Ar", "Kr", "H", "C", "N", "O", "Cu"]: R = vdWradii([symbol], "PBE")[0] if symbol in data_Bondi: Rref = data_Bondi[symbol] else: Rref = data_Hanke[symbol] error = abs(R - Rref) print "symbol, R, Rref, error:", symbol, R, Rref, error assert error < 0.05
# split the structures s1 = ss.find_connected(0) s2 = ss.find_connected(-1) assert len(ss) == len(s1) + len(s2) c = GPAW(xc='PBE', h=h, nbands=-6, occupations=FermiDirac(width=0.1), txt=None) cdf = GPAW(xc='vdW-DF', h=h, nbands=-6, occupations=FermiDirac(width=0.1), txt=None) for s in [s1, s2, ss]: s.set_calculator(c) s.minimal_box(box, h=h) Energy['PBE'].append(s.get_potential_energy()) cc = vdWTkatchenko09prl(HirshfeldPartitioning(c), vdWradii(s.get_chemical_symbols(), 'PBE')) s.set_calculator(cc) Energy['TS09'].append(s.get_potential_energy()) s.set_calculator(cdf) Energy['vdW-DF'].append(s.get_potential_energy()) parprint('Coupled cluster binding energy', -data[molecule]['interaction energy CC'] * 1000, 'meV') for xc in ['PBE', 'vdW-DF', 'TS09']: ene = Energy[xc] # print xc, 'energies', ene parprint(xc, 'binding energy', (ene[0] + ene[1] - ene[2]) * 1000, 'meV')
return q_a # spin unpolarized if 1: out_traj = 'LiH.traj' out_txt = 'LiH.txt' cc = GPAW(h=h, xc='PBE', txt=out_txt) # this is needed to initialize txt output cc.initialize(s) hp = HirshfeldPartitioning(cc) c = vdWTkatchenko09prl(hp, vdWradii(s.get_chemical_symbols(), 'PBE')) s.set_calculator(c) E = s.get_potential_energy() F_ac = s.get_forces() s.write(out_traj) q_a = print_charge_and_check(hp) barrier() # test I/O, accuracy due to text output accuracy = 1.e-5 for fname in [out_traj, out_txt]: print(fname) s_out = ase.io.read(fname) print(s_out.calc) equal(s_out.get_potential_energy(), E, accuracy)