from ase import * from numpy import random, pi from box import Atoms from box import mix from hotbit import Hotbit #from hotbit import Calculator0 from ase.units import Bohr, Hartree from hotbit.test.misc import default_param # C-non-SCC calc = Hotbit(SCC=False, txt='test.cal', **default_param) C = Atoms('C', positions=[(0, 0, 0)], cell=(10, 10, 10), pbc=False) C.center(vacuum=100) C.set_calculator(calc) e = C.get_potential_energy() if abs(e) > 1E-6: raise RuntimeError('energy %f, should be %f' % (e, 0.0)) # C, SCC calc = Hotbit(SCC=True, txt='test.cal', **default_param) C = Atoms('C', positions=[(0, 0, 0)], cell=(10, 10, 10), pbc=False) C.center(vacuum=100) C.set_calculator(calc) e = C.get_potential_energy() if abs(e) > 1E-6: raise RuntimeError('energy %f, should be %f' % (e, 0.0)) # rotate Au-dimer #calc0=Calculator0(SCC=True,txt='test.cal',**default_param) calc = Hotbit(SCC=True, txt='test.cal', **default_param) Au2 = Atoms('Au2',
from ase import * from numpy import random, pi from box import Atoms from box import mix from hotbit import Hotbit # from hotbit import Calculator0 from ase.units import Bohr, Hartree from hotbit.test.misc import default_param # C-non-SCC calc = Hotbit(SCC=False, txt="test.cal", **default_param) C = Atoms("C", positions=[(0, 0, 0)], cell=(10, 10, 10), pbc=False) C.center(vacuum=100) C.set_calculator(calc) e = C.get_potential_energy() if abs(e) > 1e-6: raise RuntimeError("energy %f, should be %f" % (e, 0.0)) # C, SCC calc = Hotbit(SCC=True, txt="test.cal", **default_param) C = Atoms("C", positions=[(0, 0, 0)], cell=(10, 10, 10), pbc=False) C.center(vacuum=100) C.set_calculator(calc) e = C.get_potential_energy() if abs(e) > 1e-6: raise RuntimeError("energy %f, should be %f" % (e, 0.0)) # rotate Au-dimer # calc0=Calculator0(SCC=True,txt='test.cal',**default_param)
plot = False import numpy as np from box import mix from ase.units import Hartree Na3 = Atoms('Na3', positions=[(1.69649997, 0, 0), (-1.69649997, 0, 0), (0, 2.9384241, 0)], cell=(50, 50, 50), pbc=False) tm = mix.Timer() calc = Hotbit(charge=1, SCC=True, txt='test_lr.cal', **default_param) Na3.set_calculator(calc) calc.solve_ground_state(Na3) lr = LinearResponse(calc) omega, F = lr.get_linear_response() e, f = mix.broaden(omega, F, width=0.1) if plot: pl.scatter(e2, f2) pl.plot(e, f, label='python') pl.legend() pl.show() calc = Hotbit(SCC=True, txt='test_lr.cal', **default_param) C60 = Atoms(read('C60.xyz')) C60.set_calculator(calc) calc.solve_ground_state(C60)
try: import pylab as pl except: plot=False import numpy as np from box import mix from ase.units import Hartree Na3=Atoms('Na3',positions=[(1.69649997,0,0),(-1.69649997,0,0),(0,2.9384241,0)],cell=(50,50,50),pbc=False) tm=mix.Timer() calc=Hotbit(charge=1,SCC=True,txt='test_lr.cal',**default_param) Na3.set_calculator(calc) calc.solve_ground_state(Na3) lr=LinearResponse(calc) omega,F=lr.get_linear_response() e,f=mix.broaden(omega,F,width=0.1) if plot: pl.scatter(e2,f2) pl.plot(e,f,label='python') pl.legend() pl.show() calc=Hotbit(SCC=True,txt='test_lr.cal',**default_param) C60=Atoms(read('C60.xyz')) C60.set_calculator(calc) calc.solve_ground_state(C60)
def get_positions(self): positions = np.empty((self.M * self.N, 3)) n1 = 0 for image in self.images: n2 = n1 + self.N positions[n1:n2] = image.get_positions() n1 = n2 return positions if __name__ == '__main__': fmax = 1E-4 calc = Hotbit(potential='neb_model_1') first = Atoms(symbols='H', positions=[(3.0, -1.3, 0.0)]) #,(0,0,0)]) first.set_calculator(calc) md.quench_atoms(first, fmax=fmax) print('first minimum:', first.get_positions()[0]) last = Atoms('H', [(0.77, 1.31, 0.0)]) #,(0,0,0)]) last.set_calculator(calc) md.quench_atoms(last, fmax=fmax) print('last minimum:', last.get_positions()[0]) images = [first.copy() for x in range(10)] images.append(last) bti = BTI(images, calc) bti.initial_interpolation() qn = ase.MDMin(bti, dt=0.05) writer = md.TrajectoryWriter(images, name='test')
def get_positions(self): positions = np.empty((self.M*self.N,3)) n1 = 0 for image in self.images: n2 = n1 + self.N positions[n1:n2] = image.get_positions() n1 = n2 return positions if __name__=='__main__': fmax=1E-4 calc=Hotbit(potential='neb_model_1') first=Atoms(symbols='H',positions=[(3.0,-1.3,0.0)]) #,(0,0,0)]) first.set_calculator(calc) md.quench_atoms(first,fmax=fmax) print 'first minimum:',first.get_positions()[0] last=Atoms('H',[(0.77,1.31,0.0)]) #,(0,0,0)]) last.set_calculator(calc) md.quench_atoms(last,fmax=fmax) print 'last minimum:',last.get_positions()[0] images=[first.copy() for x in range(10)] images.append(last)