예제 #1
0
def generate_basis_functions(ppdata):
    class SimpleBasis(Basis):
        def __init__(self, symbol, l_j):
            Basis.__init__(self, symbol, 'simple', readxml=False)
            self.generatordata = 'simple'
            self.d = 0.02
            self.ng = 160
            rgd = self.get_grid_descriptor()
            bf_j = self.bf_j
            rcgauss = rgd.r_g[-1] / 3.0
            gauss_g = np.exp(-(rgd.r_g / rcgauss)**2.0)
            for l in l_j:
                phit_g = rgd.r_g**l * gauss_g
                norm = (rgd.integrate(phit_g**2) / (4 * np.pi))**0.5
                phit_g /= norm
                bf = BasisFunction(l, rgd.r_g[-1], phit_g, 'gaussian')
                bf_j.append(bf)
    #l_orb_j = [state.l for state in self.data['states']]
    b1 = SimpleBasis(ppdata.symbol, ppdata.l_orb_j)
    apaw = AtomPAW(ppdata.symbol, [ppdata.f_ln], h=0.05, rcut=9.0,
                   basis={ppdata.symbol: b1},
                   setups={ppdata.symbol : ppdata},
                   lmax=0, txt=None)
    basis = apaw.extract_basis_functions()
    return basis
def generate_basis_functions(ppdata):
    class SimpleBasis(Basis):
        def __init__(self, symbol, l_j):
            Basis.__init__(self, symbol, 'simple', readxml=False)
            self.generatordata = 'simple'
            self.d = 0.02
            self.ng = 160
            rgd = self.get_grid_descriptor()
            bf_j = self.bf_j
            rcgauss = rgd.r_g[-1] / 3.0
            gauss_g = np.exp(-(rgd.r_g / rcgauss)**2.0)
            for l in l_j:
                phit_g = rgd.r_g**l * gauss_g
                norm = (rgd.integrate(phit_g**2) / (4 * np.pi))**0.5
                phit_g /= norm
                bf = BasisFunction(l, rgd.r_g[-1], phit_g, 'gaussian')
                bf_j.append(bf)
    #l_orb_j = [state.l for state in self.data['states']]
    b1 = SimpleBasis(ppdata.symbol, ppdata.l_orb_j)
    apaw = AtomPAW(ppdata.symbol, [ppdata.f_ln], h=0.05, rcut=9.0,
                   basis={ppdata.symbol: b1},
                   setups={ppdata.symbol: ppdata},
                   lmax=0, txt=None)
    basis = apaw.extract_basis_functions()
    return basis
예제 #3
0
파일: hgh.py 프로젝트: yihsuanliu/gpaw
 def create_basis_functions(self):
     class SimpleBasis(Basis):
         def __init__(self, symbol, l_j):
             Basis.__init__(self, symbol, 'simple', readxml=False)
             self.generatordata = 'simple'
             self.d = 0.02
             self.ng = 160
             rgd = self.get_grid_descriptor()
             bf_j = self.bf_j
             rcgauss = rgd.rcut / 3.0
             gauss_g = np.exp(-(rgd.r_g / rcgauss)**2.0)
             for l in l_j:
                 phit_g = rgd.r_g**l * gauss_g
                 norm = np.dot((rgd.r_g * phit_g)**2, rgd.dr_g)**.5
                 phit_g /= norm
                 bf = BasisFunction(l, rgd.rcut, phit_g, 'gaussian')
                 bf_j.append(bf)
     b1 = SimpleBasis(self.symbol, range(max(self.l_j) + 1))
     apaw = AtomPAW(self.symbol, [self.f_ln], h=0.05, rcut=9.0,
                    basis={self.symbol: b1},
                    setups={self.symbol : self},
                    lmax=0, txt=None)
     basis = apaw.extract_basis_functions()
     return basis
예제 #4
0
def upfplot(setup, show=True, calculate=False):
    # A version of this, perhaps nicer, is in pseudopotential.py.
    # Maybe it is not worth keeping this version
    if isinstance(setup, dict):
        setup = UPFSetupData(setup)

    pp = setup.data
    r0 = pp['r'].copy()
    r0[0] = 1e-8

    def rtrunc(array, rdividepower=0):
        r = r0[:len(array)]
        arr = divrl(array, rdividepower, r)
        return r, arr

    import pylab as pl
    fig = pl.figure()
    fig.canvas.set_window_title('%s - UPF setup for %s' %
                                (pp['fname'], setup.symbol))

    vax = fig.add_subplot(221)
    pax = fig.add_subplot(222)
    rhoax = fig.add_subplot(223)
    wfsax = fig.add_subplot(224)

    r, v = rtrunc(pp['vlocal'])

    vax.plot(r, v, label='vloc')

    vscreened, rhocomp = screen_potential(r, v, setup.Nv)
    icut = len(rhocomp)
    vcomp = v.copy()
    vcomp[:icut] -= vscreened
    vax.axvline(r[icut], ls=':', color='k')

    vax.plot(r, vcomp, label='vcomp')
    vax.plot(r[:icut], vscreened, label='vscr')
    vax.axis(xmin=0.0, xmax=6.0)
    rhoax.plot(r[:icut], rhocomp[:icut], label='rhocomp')

    for j, proj in enumerate(pp['projectors']):
        r, p = rtrunc(proj.values, 0)
        pax.plot(r, p, label='p%d [l=%d]' % (j + 1, proj.l))

    for j, st in enumerate(pp['states']):
        r, psi = rtrunc(st.values, 1)
        wfsax.plot(r, r * psi, label='wf%d %s' % (j, st.label))

    r, rho = rtrunc(pp['rhoatom'], 2)
    wfsax.plot(r, r * rho, label='rho')

    if calculate:
        calc = AtomPAW(
            setup.symbol,
            [setup.f_ln],
            # xc='PBE', # XXX does not support GGAs :( :( :(
            setups={setup.symbol: setup},
            h=0.08,
            rcut=10.0)
        r_g = calc.wfs.gd.r_g
        basis = calc.extract_basis_functions()
        wfsax.plot(r_g,
                   r_g * calc.density.nt_sg[0] * 4.0 * np.pi,
                   ls='--',
                   label='rho [calc]',
                   color='r')

        splines = basis.tosplines()
        for spline, bf in zip(splines, basis.bf_j):
            wfsax.plot(r_g, r_g * spline.map(r_g), label=bf.type)

    vax.legend(loc='best')
    rhoax.legend(loc='best')
    pax.legend(loc='best')
    wfsax.legend(loc='best')

    for ax in [vax, rhoax, pax, wfsax]:
        ax.set_xlabel('r [Bohr]')
        ax.axhline(0.0, ls=':', color='black')

    vax.set_ylabel('potential')
    pax.set_ylabel('projectors')
    wfsax.set_ylabel(r'$r \psi(r), r n(r)$')
    rhoax.set_ylabel('Comp charges')

    fig.subplots_adjust(wspace=0.3)

    if show:
        pl.show()