Exemplo n.º 1
0
 def test_aux_e2_becke(self):
     cell = pgto.Cell()
     cell.unit = 'B'
     cell.h = np.eye(3) * 3.
     cell.gs = np.array([20,20,20])
     cell.atom = 'He 0 1 1; He 1 1 0'
     cell.basis = { 'He': [[0, (10.8, 1.0)],
                           [0, (300.2, 1.0)]] }
     cell.verbose = 0
     cell.build(0, 0)
     auxcell = df.format_aux_basis(cell)
     auxcell.nimgs = [3,3,3]
     a1 = df.aux_e2(cell, auxcell, 'cint3c1e_sph')
     grids = pdft.gen_grid.BeckeGrids(cell)
     grids.level = 3
     #grids = pdft.gen_grid.UniformGrids(cell)
     grids.build_()
     a2 = df.aux_e2_grid(cell, auxcell, grids)
     self.assertAlmostEqual(np.linalg.norm(a1-a2), 0, 4)
Exemplo n.º 2
0
def get_j_gaussian_mod(cell, dm, auxcell, modcell, kpt=None, grids=None):
    ovlp = pscf.scfint.get_ovlp(cell)
    nao = ovlp.shape[0]
    if grids is None:
        c3 = df.aux_e2(cell, auxcell, 'cint3c1e_sph').reshape(nao,nao,-1)
    else:
        c3 = df.aux_e2_grid(cell, auxcell, grids).reshape(nao,nao,-1)
    rho = np.einsum('ijk,ij->k', c3, dm)
    modchg = np.asarray([cell.atom_charge(ia) for ia in range(cell.natm)])
    modchg = modchg / auxnorm(modcell)
    s1 = pscf.scfint.get_int1e_cross('cint1e_ovlp_sph', auxcell, modcell)
    rho -= np.einsum('ij,j->i', s1, modchg)

    v1 = np.linalg.solve(pscf.scfint.get_t(auxcell), 2*np.pi*rho)
    vj = np.einsum('ijk,k->ij', c3, v1)

# remove the constant in potential
    intdf = auxnorm(auxcell)
    vj -= np.dot(v1, intdf) / cell.vol * ovlp
    return vj
Exemplo n.º 3
0
def get_j_uniform_mod(cell, dm, auxcell, kpt=None, grids=None):
    ovlp = pscf.scfint.get_ovlp(cell)
    nao = ovlp.shape[0]
    if grids is None:
        c3 = df.aux_e2(cell, auxcell, 'cint3c1e_sph').reshape(nao,nao,-1)
    else:
        c3 = df.aux_e2_grid(cell, auxcell, grids).reshape(nao,nao,-1)
    rho = np.einsum('ijk,ij->k', c3, dm)

    nelec = np.einsum('ij,ij', ovlp, dm)
    intdf = auxnorm(auxcell)
    rho -= nelec / cell.vol * intdf

    v1 = np.linalg.solve(pscf.scfint.get_t(auxcell), 2*np.pi*rho)
    vj = np.einsum('ijk,k->ij', c3, v1)

# remove the constant in potential
#    vj += (np.dot(v1, rho) - (vj*dm).sum())/nelec * ovlp
#    v1[idx].sum()/cell.vol == (np.dot(v1, rho) - (vj*dm).sum())/nelec
    vj -= np.dot(v1, intdf) / cell.vol * ovlp
    return vj
Exemplo n.º 4
0
def get_nuc_gaussian_mod(cell, auxcell, modcell, kpt=None, grids=None):
    coords = np.asarray([cell.atom_coord(ia) for ia in range(cell.natm)])
    chargs = np.asarray([cell.atom_charge(ia) for ia in range(cell.natm)])
    rho = np.dot(-chargs, pdft.numint.eval_ao(auxcell, coords))

    modchg = chargs / auxnorm(modcell)
    s1 = pscf.scfint.get_int1e_cross('cint1e_ovlp_sph', auxcell, modcell)
    rho += np.einsum('ij,j->i', s1, modchg)

    ovlp = pscf.scfint.get_ovlp(cell)
    nao = ovlp.shape[0]
    if grids is None:
        c3 = df.aux_e2(cell, auxcell, 'cint3c1e_sph').reshape(nao,nao,-1)
    else:
        c3 = df.aux_e2_grid(cell, auxcell, grids).reshape(nao,nao,-1)
    v1 = np.linalg.solve(pscf.scfint.get_t(auxcell), 2*np.pi*rho)
    vnuc = np.einsum('ijk,k->ij', c3, v1)

# remove constant from potential. The constant contributes to V(G=0)
    intdf = auxnorm(auxcell)
    vnuc -= np.dot(v1, intdf) / cell.vol * ovlp
    return vnuc
Exemplo n.º 5
0
def get_nuc_uniform_mod(cell, auxcell, kpt=None, grids=None):
    r'''Solving Poisson equation for Nuclear attraction

    \nabla^2|g>V_g = rho_nuc - C
    V_pq = \sum_g <pq|g> V_g
    '''
    intdf = auxnorm(auxcell)
    coords = np.asarray([cell.atom_coord(ia) for ia in range(cell.natm)])
    chargs =-np.asarray([cell.atom_charge(ia) for ia in range(cell.natm)])
    rho = np.dot(chargs, pdft.numint.eval_ao(auxcell, coords))
    rho += cell.nelectron / cell.vol * intdf

    ovlp = pscf.scfint.get_ovlp(cell)
    nao = ovlp.shape[0]
    if grids is None:
        c3 = df.aux_e2(cell, auxcell, 'cint3c1e_sph').reshape(nao,nao,-1)
    else:
        c3 = df.aux_e2_grid(cell, auxcell, grids).reshape(nao,nao,-1)
    v1 = np.linalg.solve(pscf.scfint.get_t(auxcell), 2*np.pi*rho)
    vnuc = np.einsum('ijk,k->ij', c3, v1)

# remove constant from potential. The constant contributes to V(G=0)
    vnuc -= np.dot(v1, intdf) / cell.vol * ovlp
    return vnuc