Ejemplo n.º 1
0
def IP_EA(symb, remove_orb, add_orb, remove, add, add_args={}):
    """ Return ionization potential and electron affinity for given atom,
        and the valence energies of neutral atom.
    
    parameters: 
    -----------
    symb: element symbol
    remove_orb: orbital from where to remove atoms (e.g. '2p')
    add_orb: orbital from where to add atoms (e.g. '2p')
    remove: how many electrons to remove
    add: how many electrons to add
         (remove and add can be different from 1.0 if DFT should not
         be stable to e.g. adding one full electron)
         
    Fit second order curve for 3 points and return IP and EA for full
    electron adding and removal.             
    """
    #from box.data import atom_occupations
    atom = KSAllElectron(symb, txt='-', **add_args)

    # add electrons -> negative ion
    #occu=atom_occupations[symb].copy()
    w = 'negative.atom'
    occu_add = atom.occu.copy()
    occu_add[add_orb] += add
    ea = KSAllElectron(symb,
                       configuration=occu_add,
                       restart=w,
                       write=w,
                       **add_args)
    ea.run()

    # neutral atom
    w = 'neutral.atom'
    neutral = KSAllElectron(symb, restart=w, write=w, **add_args)
    neutral.run()
    valence_energies = neutral.get_valence_energies()

    # remove electrons -> positive ion
    #occu=atom_occupations[symb].copy()
    w = 'positive.atom'
    occu_remove = atom.occu.copy()
    occu_remove[remove_orb] -= remove
    ip = KSAllElectron(symb,
                       configuration=occu_remove,
                       restart=w,
                       write=w,
                       **add_args)
    ip.run()

    e0 = neutral.get_energy()
    en = ea.get_energy() - e0
    ep = ip.get_energy() - e0
    # e(x)=e0+c1*x+c2*x**2 =energy as a function of additional electrons
    c2 = (en + ep * add / remove) / (add * (remove + add))
    c1 = (c2 * remove**2 - ep) / remove
    IP = -c1 + c2
    EA = -(c1 + c2)
    return IP, EA, neutral
Ejemplo n.º 2
0
def electron_affinity(symb, add, electrons=1.0):
    """ Return electron affinity of given atom. 
    
    parameters: 
    -----------
    symb: element symbol
    add: orbital where electron is added (e.g. '2p')
    electrons: how many electrons are added. Can be fractional number
               if DFT should not be stable. EA is scaled by
               electrons^-1 in the end to extrapolate to electrons=1.
    """
    from box.data import atom_occupations
    occu = atom_occupations[symb].copy()
    # neutral atom
    atom = KSAllElectron(symb)
    atom.run()
    e0 = atom.get_energy()
    # positive ion
    occu[add] += electrons
    ion = KSAllElectron(symb, occu=occu)
    ion.run()
    e1 = ion.get_energy()
    return (e0 - e1) / electrons
Ejemplo n.º 3
0
def ionization_potential(symb, remove, electrons=1.0):
    """ Return ionization potential of given atom. 
    
    parameters: 
    -----------
    symb: element symbol
    remove: orbital from where electron is removed (e.g. '2p')
    electrons: how many electrons to remove. Can be fractional number
               if DFT should not be stable. IP is scaled by
               electrons^-1 in the end to extrapolate to electrons=1.
    
    """
    from box.data import atom_occupations
    occu = atom_occupations[symb].copy()
    # neutral atom
    atom = KSAllElectron(symb)
    atom.run()
    e0 = atom.get_energy()
    # negative ion
    occu[remove] -= electrons
    ion = KSAllElectron(symb, occu=occu)
    ion.run()
    e1 = ion.get_energy()
    return (e1 - e0) / electrons
Ejemplo n.º 4
0
from hotbit.parametrization.util import IP_EA
from box.mix import Timer
#import cgitb; cgitb.enable()
import pylab as pl

#IP=ionization_potential('C',remove='2p')
IP, EA = IP_EA('O', remove_orb='2p', add_orb='2p', remove=1.0, add=0.5)
print(IP, IP * 27.2114, IP * 27.2114 / 0.01036)
print(EA, EA * 27.2114, EA * 27.2114 / 0.01036)
raise SystemExit

for i, element in enumerate(['H', 'C', 'Ti', 'Au']):
    e = {}
    per = [100, 150, 200, 250, 300, 400, 500, 1000]
    for pernode in per:
        atom = KSAllElectron(element, pernode=pernode)
        v = atom.get_valence()
        if e == {}:
            for val in v:
                e[val] = []
        atom.run()
        for val in v:
            e[val].append(atom.get_eigenvalue(val))

    pl.subplot(2, 2, i + 1)
    for val in v:
        #pl.plot(per,e[val]-e[val][-1],label=val)
        pl.semilogy(per, e[val] - e[val][-1] + 1E-6, label=val)
    pl.legend()
    pl.xlabel('points/node')
from hotbit.parametrization import KSAllElectron, SlaterKosterTable

atom = KSAllElectron(
    'C',
    xc='PBE',
    confinement={
        'mode': 'Woods-Saxon',
        'r0': 8.,
        'a': 4.,
        'W': 0.75
    },
)
atom.run()
atom.plot_Rnl()

table = SlaterKosterTable(atom, atom)
table.run(R1=1, R2=10, N=3, ntheta=50, nr=10)
table.plot()
Ejemplo n.º 6
0
#sk.run(1,15,50)
#sk.write()
#compare_tables('Au_Au.par','Au_Au_NR.par',s1='Au',s2='Au',screen=False)
              
lst=[('C','C',1.85*1.46,1.85*1.46),\
     ('C','H',1.85*1.46,1.85*0.705),\
     ('Na','C',1.85*2.9,1.85*1.46),\
     ('O','H',1.85*1.38,1.85*0.705),\
     ('Mg','O',1.85*1.41/0.529177,1.85*1.38),\
     ('Na','O',1.85*2.9,1.85*1.38),\
     ('H','H',1.85*0.705,1.85*0.705)]
     
     
     
for s1,s2,r01,r02 in lst:     
    e1=KSAllElectron(s1,nodegpts=500,confinement={'mode':'quadratic','r0':r01})
    e1.run()
    if s1==s2:  
        e2=e1
    else:   
        e2=KSAllElectron(s2,confinement={'mode':'quadratic','r0':r02})
        e2.run()    
        
    sk=SlaterKosterTable(e1,e2)
    sk.run(1E-3,12,10) #,ntheta=20,nr=20)
    sk.write()
    file='%s_%s.par' %(s1,s2)
    #compare_tables( param+'/'+file,file,s1,s2,screen=False)
    plot_table(file,s1=s1,s2=s2,screen=True,der=0)
    plot_table(file,s1=s1,s2=s2,screen=True,der=1)
        
Ejemplo n.º 7
0
from hotbit.parametrization import KSAllElectron, SlaterKosterTable

atom = KSAllElectron('C',
                     convergence={
                         'density': 1E-1,
                         'energies': 1E-1
                     },
                     txt='/dev/null')
atom.run()

table = SlaterKosterTable(atom, atom, txt='/dev/null')
table.run(R1=1, R2=10, N=3, ntheta=50, nr=10, wflimit=1E-7)