Example #1
0
            timings.append(calc.timer.get_timings())
            norbs.append(calc.el.get_nr_orbitals())
            calc.__del__()

    order = argsort(norbs)
    norbs = sort(norbs)
    timings2 = []
    for i in order:
        timings2.append(timings[i])

    times = {}
    maxtime = 0.0
    for key in timings2[0]:
        times[key] = array([ts[key] for ts in timings2])
        maxtime = max(maxtime, times[key].max())

    s = 0.1
    for key in timings[0]:
        s += 0.1
        if times[key].max() < 0.05 * maxtime: continue
        pl.plot(norbs, times[key], label=key, lw=s)

    atoms = Atoms(atoms)
    pl.title('Timings up to %s with %s' % (atoms.get_name(), sccs))
    pl.xlabel('Number of orbitals')
    pl.ylabel('Time (s)')
    pl.legend(loc='upper left')
    pl.savefig('size_timing_%s.png' % sccs)
    #pl.plot()
    #pl.show()
    pl.clf()
Example #2
0
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)
Example #3
0
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',
Example #4
0
from ase import *
from box import Atoms
plot = True
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()
Example #5
0
from hotbit.test.misc import default_param
from ase import *
from box import Atoms
plot=True
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()
       
Example #6
0
            n1 = n2

    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)
Example #7
0
        
    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)
    
Example #8
0
    atoms.set_cell(bx.get_cell(), fix=True)
    atoms.set_pbc(bx.get_pbc())

    # add atoms from atoms2 if not close
    for a2, r2 in zip(atoms2, atoms2.get_positions()):
        close = False
        for r1 in atoms1.get_positions():
            if atoms.distance(r1, r2) < R:
                close = True
        if not close:
            atoms = atoms + a2
    return atoms


if __name__ == '__main__':
    from box import Atoms
    atoms1 = Atoms(symbols='C4H',
                   positions=[(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3),
                              (0, 0, 4)],
                   cell=(7, 8, 9),
                   pbc=True)
    atoms2 = Atoms(symbols='C4H',
                   positions=[(0, 0, 0.29), (0, 0, 1), (0, 0, 7), (0, 0, 8),
                              (0, 0, 9)],
                   cell=(170, 18, 19),
                   pbc=True)
    atoms = merge_atoms(atoms1, atoms2, box_from=atoms2)
    print(atoms.get_positions())
    print(atoms.get_cell())
    print(atoms.get_pbc())