Exemple #1
0
def kernel(method, efg_nuc=None):
    log = lib.logger.Logger(method.stdout, method.verbose)
    log.info(
        '\n******** EFG for 4-component SCF methods (In testing) ********')
    mol = method.mol
    if efg_nuc is None:
        efg_nuc = range(mol.natm)

    c = lib.param.LIGHT_SPEED
    dm = method.make_rdm1()

    log.info('\nElectric Field Gradient Tensor Results')
    n2c = mol.nao_2c()
    coords = mol.atom_coords()
    aoLa, aoLb = mol.eval_gto('GTOval_spinor', coords)
    aoSa, aoSb = mol.eval_gto('GTOval_sp_spinor', coords)
    efg = []
    for i, atm_id in enumerate(efg_nuc):
        # The electronic quadrupole operator (3 \vec{r} \vec{r} - r^2) / r^5
        with mol.with_rinv_origin(coords[atm_id]):
            ipipv = mol.intor('int1e_ipiprinv_spinor',
                              9).reshape(3, 3, n2c, n2c)
            ipvip = mol.intor('int1e_iprinvip_spinor',
                              9).reshape(3, 3, n2c, n2c)
            h1LL = ipipv + ipvip  # (nabla i | r/r^3 | j)
            h1LL = h1LL + h1LL.conj().transpose(0, 1, 3, 2)
            trace = h1LL[0, 0] + h1LL[1, 1] + h1LL[2, 2]
            h1LL[0, 0] -= trace
            h1LL[1, 1] -= trace
            h1LL[2, 2] -= trace

            ipipv = mol.intor('int1e_ipipsprinvsp_spinor',
                              9).reshape(3, 3, n2c, n2c)
            ipvip = mol.intor('int1e_ipsprinvspip_spinor',
                              9).reshape(3, 3, n2c, n2c)
            h1SS = ipipv + ipvip  # (nabla i | r/r^3 | j)
            h1SS = h1SS + h1SS.conj().transpose(0, 1, 3, 2)
            trace = h1SS[0, 0] + h1SS[1, 1] + h1SS[2, 2]
            h1SS[0, 0] -= trace
            h1SS[1, 1] -= trace
            h1SS[2, 2] -= trace

        fcLL = numpy.einsum('p,q->pq', aoLa[atm_id].conj(), aoLa[atm_id])
        fcLL += numpy.einsum('p,q->pq', aoLb[atm_id].conj(), aoLb[atm_id])
        fcSS = numpy.einsum('p,q->pq', aoSa[atm_id].conj(), aoSa[atm_id])
        fcSS += numpy.einsum('p,q->pq', aoSb[atm_id].conj(), aoSb[atm_id])

        fcsd = numpy.einsum('xyij,ji->xy', h1LL, dm[:n2c, :n2c])
        fcsd += numpy.einsum('xyij,ji->xy', h1SS, dm[n2c:, n2c:]) * (.5 / c)**2
        fc = numpy.einsum('ij,ji->', fcLL, dm[:n2c, :n2c])
        fc += numpy.einsum('ij,ji->', fcSS, dm[n2c:, n2c:]) * (.5 / c)**2
        efg_e = fcsd - 8 * numpy.pi / 3 * numpy.eye(3) * fc

        efg_nuc = rhf_efg._get_quad_nuc(mol, atm_id)
        v = efg_nuc - efg_e
        efg.append(v)

        rhf_efg._analyze(mol, atm_id, v.real, log)

    return numpy.asarray(efg).real
Exemple #2
0
def kernel(method, efg_nuc=None):
    log = lib.logger.Logger(method.stdout, method.verbose)
    cell = method.cell
    if efg_nuc is None:
        efg_nuc = range(cell.natm)

    dm = method.make_rdm1()
    if isinstance(method, scf.khf.KSCF):
        if isinstance(dm[0][0], numpy.ndarray) and dm[0][0].ndim == 2:
            dm = dm[0] + dm[1]  # KUHF density matrix
    elif isinstance(method, scf.hf.SCF):
        if isinstance(dm[0], numpy.ndarray) and dm[0].ndim == 2:
            dm = dm[0] + dm[1]  # UHF density matrix
    else:
        mo = method.mo_coeff
        if isinstance(dm[0][0], numpy.ndarray) and dm[0][0].ndim == 2:
            dm_a = [
                lib.einsum('pi,ij,qj->pq', c, dm[0][k], c.conj())
                for k, c in enumerate(mo)
            ]
            dm_b = [
                lib.einsum('pi,ij,qj->pq', c, dm[1][k], c.conj())
                for k, c in enumerate(mo)
            ]
            dm = lib.asarray(dm_a) + lib.asarray(dm_b)
        else:
            dm = lib.asarray([
                lib.einsum('pi,ij,qj->pq', c, dm[k], c.conj())
                for k, c in enumerate(mo)
            ])

    if isinstance(method, scf.hf.SCF):
        with_df = getattr(method, 'with_df', None)
        with_x2c = getattr(method, 'with_x2c', None)
    else:
        with_df = getattr(method._scf, 'with_df', None)
        with_x2c = getattr(method._scf, 'with_x2c', None)
    if with_x2c:
        raise NotImplementedError

    log.info('\nElectric Field Gradient Tensor Results')
    if isinstance(with_df, df.fft.FFTDF):
        efg_e = _fft_quad_integrals(with_df, dm, efg_nuc)
    else:
        efg_e = _aft_quad_integrals(with_df, dm, efg_nuc)
    efg = []
    for i, atm_id in enumerate(efg_nuc):
        efg_nuc = _get_quad_nuc(cell, atm_id)
        v = efg_nuc - efg_e[i]
        efg.append(v)

        rhf_efg._analyze(cell, atm_id, v, log)

    return numpy.asarray(efg)
Exemple #3
0
def kernel(method, efg_nuc=None):
    log = lib.logger.Logger(method.stdout, method.verbose)
    log.info('\n******** EFG for 4-component SCF methods (In testing) ********')
    mol = method.mol
    if efg_nuc is None:
        efg_nuc = range(mol.natm)

    dm = method.make_rdm1()

    log.info('\nElectric Field Gradient Tensor Results')
    n2c = mol.nao_2c()
    coords = mol.atom_coords()
    aoLa, aoLb = mol.eval_gto('GTOval_spinor', coords)
    aoSa, aoSb = mol.eval_gto('GTOval_sp_spinor', coords)
    efg = []
    for i, atm_id in enumerate(efg_nuc):
        # The electronic quadrupole operator (3 \vec{r} \vec{r} - r^2) / r^5
        with mol.with_rinv_origin(coords[atm_id]):
            ipipv = mol.intor('int1e_ipiprinv_spinor', 9).reshape(3,3,n2c,n2c)
            ipvip = mol.intor('int1e_iprinvip_spinor', 9).reshape(3,3,n2c,n2c)
            h1LL = ipipv + ipvip  # (nabla i | r/r^3 | j)
            h1LL = h1LL + h1LL.conj().transpose(0,1,3,2)
            trace = h1LL[0,0] + h1LL[1,1] + h1LL[2,2]
            h1LL[0,0] -= trace
            h1LL[1,1] -= trace
            h1LL[2,2] -= trace

            ipipv = mol.intor('int1e_ipipsprinvsp_spinor', 9).reshape(3,3,n2c,n2c)
            ipvip = mol.intor('int1e_ipsprinvspip_spinor', 9).reshape(3,3,n2c,n2c)
            h1SS = ipipv + ipvip  # (nabla i | r/r^3 | j)
            h1SS = h1SS + h1SS.conj().transpose(0,1,3,2)
            trace = h1SS[0,0] + h1SS[1,1] + h1SS[2,2]
            h1SS[0,0] -= trace
            h1SS[1,1] -= trace
            h1SS[2,2] -= trace

        fcLL = numpy.einsum('p,q->pq', aoLa[atm_id].conj(), aoLa[atm_id])
        fcLL+= numpy.einsum('p,q->pq', aoLb[atm_id].conj(), aoLb[atm_id])
        fcSS = numpy.einsum('p,q->pq', aoSa[atm_id].conj(), aoSa[atm_id])
        fcSS+= numpy.einsum('p,q->pq', aoSb[atm_id].conj(), aoSb[atm_id])

        fcsd = numpy.einsum('xyij,ji->xy', h1LL, dm[:n2c,:n2c])
        fcsd+= numpy.einsum('xyij,ji->xy', h1SS, dm[n2c:,n2c:])
        fc = numpy.einsum('ij,ji->', fcLL, dm[:n2c,:n2c])
        fc+= numpy.einsum('ij,ji->', fcSS, dm[n2c:,n2c:])
        efg_e = fcsd - 8*numpy.pi/3 * numpy.eye(3) * fc

        efg_nuc = rhf_efg._get_quad_nuc(mol, atm_id)
        v = efg_nuc - efg_e
        efg.append(v)

        rhf_efg._analyze(mol, atm_id, v, log)

    return numpy.asarray(efg)
Exemple #4
0
def kernel(method, efg_nuc=None):
    log = lib.logger.Logger(method.stdout, method.verbose)
    cell = method.cell
    if efg_nuc is None:
        efg_nuc = range(cell.natm)

    dm = method.make_rdm1()
    if isinstance(method, scf.khf.KSCF):
        if isinstance(dm[0][0], numpy.ndarray) and dm[0][0].ndim == 2:
            dm = dm[0] + dm[1]  # KUHF density matrix
    elif isinstance(method, scf.hf.SCF):
        if isinstance(dm[0], numpy.ndarray) and dm[0].ndim == 2:
            dm = dm[0] + dm[1]  # UHF density matrix
    else:
        mo = method.mo_coeff
        if isinstance(dm[0][0], numpy.ndarray) and dm[0][0].ndim == 2:
            dm_a = [lib.einsum('pi,ij,qj->pq', c, dm[0][k], c.conj())
                    for k, c in enumerate(mo)]
            dm_b = [lib.einsum('pi,ij,qj->pq', c, dm[1][k], c.conj())
                    for k, c in enumerate(mo)]
            dm = lib.asarray(dm_a) + lib.asarray(dm_b)
        else:
            dm = lib.asarray([lib.einsum('pi,ij,qj->pq', c, dm[k], c.conj())
                              for k, c in enumerate(mo)])

    if isinstance(method, scf.hf.SCF):
        with_df = getattr(method, 'with_df', None)
        with_x2c = getattr(method, 'with_x2c', None)
    else:
        with_df = getattr(method._scf, 'with_df', None)
        with_x2c = getattr(method._scf, 'with_x2c', None)
    if with_x2c:
        raise NotImplementedError

    log.info('\nElectric Field Gradient Tensor Results')
    if isinstance(with_df, df.fft.FFTDF):
        efg_e = _fft_quad_integrals(with_df, dm, efg_nuc)
    else:
        efg_e = _aft_quad_integrals(with_df, dm, efg_nuc)
    efg = []
    for i, atm_id in enumerate(efg_nuc):
        efg_nuc = _get_quad_nuc(cell, atm_id)
        v = efg_nuc - efg_e[i]
        efg.append(v)

        rhf_efg._analyze(cell, atm_id, v, log)

    return numpy.asarray(efg)