def shiftxc(calc, xc, energy_only=False):
     if isinstance(xc, str):
         xc = XCFunctional(xc, calc.wfs.nspins)
     elif isinstance(xc, dict):
         xc = XCFunctional(xc.copy(), calc.wfs.nspins)
     xc.set_non_local_things(calc.density, calc.hamiltonian, calc.wfs,
                             calc.atoms, energy_only=energy_only)
     calc.hamiltonian.xc.set_functional(xc)
     calc.hamiltonian.xc.set_positions(
         calc.atoms.get_scaled_positions() % 1.0)
     for setup in calc.wfs.setups:
         setup.xc_correction.xc.set_functional(xc)
         if xc.mgga:
             setup.xc_correction.initialize_kinetic(setup.data)
示例#2
0
 def gen(symbol, xcname):
     g = Generator(symbol, xcname, scalarrel=True, nofiles=True)
     g.run(exx=True, **parameters[symbol])
     files.append('%s.%s' % (symbol, XCFunctional(xcname).get_name()))
示例#3
0
    A[:, 1] = r[gc - 2:gc + 2]**2
    A[:, 2] = A[:, 1]**2
    A[:, 3] = A[:, 1] * A[:, 2]
    a = u[gc - 2:gc + 2] / r[gc - 2:gc + 2]**(l + 1)
    a = solve(A, a)
    r1 = r[:gc]
    r2 = r1**2
    rl1 = r1**(l + 1)
    y = a[0] + r2 * (a[1] + r2 * (a[2] + r2 * (a[3])))
    s[:gc] = rl1 * y


if __name__ == '__main__':
    import os
    from gpaw.xc_functional import XCFunctional
    from gpaw.atom.basis import BasisMaker
    from gpaw.atom.configurations import parameters

    for xcname in ['LDA', 'PBE', 'RPBE', 'revPBE']:
        for symbol, par in parameters.items():
            filename = symbol + '.' + XCFunctional(xcname).get_name()
            if os.path.isfile(filename):
                continue
            g = Generator(symbol, xcname, scalarrel=True, nofiles=True)
            g.run(exx=True, logderiv=False, use_restart_file=False, **par)

            if xcname == 'PBE':
                bm = BasisMaker(g, name='dzp', run=False)
                basis = bm.generate()
                basis.write_xml()
示例#4
0
        p1 = 0
        for a, setup in enumerate(wfs.setups):
            ni = setup.ni
            p2 = p1 + ni * (ni + 1) // 2
            # NOTE: Distrbibutes the matrices to more processors than necessary
            self.D_asp[a] = D_sp[:, p1:p2].copy()
            self.Dresp_asp[a] = Dresp_sp[:, p1:p2].copy()
            self.Dxc_D_asp[a] = Dxc_D_sp[:, p1:p2].copy()
            self.Dxc_Dresp_asp[a] = Dxc_Dresp_sp[:, p1:p2].copy()
            print "Proc", world.rank, " reading atom ", a
            p1 = p2


if __name__ == "__main__":
    from gpaw.xc_functional import XCFunctional
    xc = XCFunctional('LDA')
    dx = 1e-3
    Ntot = 100000
    x = np.array(range(1, Ntot + 1)) * dx
    kf = (2 * x)**(1. / 2)
    n_g = kf**3 / (3 * pi**2)
    v_g = np.zeros(Ntot)
    e_g = np.zeros(Ntot)
    xc.calculate_spinpaired(e_g, n_g, v_g)
    vresp = v_g - 2 * e_g / n_g

    f = open('response.dat', 'w')
    for xx, v in zip(x, vresp):
        print >> f, xx, v
    f.close()
            ni = setup.ni
            p2 = p1 + ni * (ni + 1) // 2
            self.D_asp[a] = D_sp[:, p1:p2].copy()
            self.Dresp_asp[a] = Dresp_sp[:, p1:p2].copy()
            self.Dxc_D_asp[a] = Dxc_D_sp[:, p1:p2].copy()
            self.Dxc_Dresp_asp[a] = Dxc_Dresp_sp[:, p1:p2].copy()
            print("Proc", world.rank, " reading atom ", a)
            p1 = p2


        # Dsp and Dresp need to be redistributed
        self.just_read = True

if __name__ == "__main__":
    from gpaw.xc_functional import XCFunctional
    xc = XCFunctional('LDA')
    dx = 1e-3
    Ntot = 100000
    x = np.array(range(1,Ntot+1))*dx
    kf = (2*x)**(1./2)
    n_g = kf**3 / (3*pi**2)
    v_g = np.zeros(Ntot)
    e_g = np.zeros(Ntot)
    xc.calculate_spinpaired(e_g, n_g, v_g)
    vresp = v_g - 2*e_g / n_g
    
    f = open('response.dat','w')
    for xx, v in zip(x, vresp):
        print(xx, v, file=f)
    f.close()