Exemple #1
0
def _call_giao_vhf1(mol, dm):
    c1 = .5 / mol.light_speed
    n2c = dm.shape[0] // 2
    dmll = dm[:n2c, :n2c].copy()
    dmls = dm[:n2c, n2c:].copy()
    dmsl = dm[n2c:, :n2c].copy()
    dmss = dm[n2c:, n2c:].copy()
    vj = numpy.zeros((3, n2c * 2, n2c * 2), dtype=numpy.complex)
    vk = numpy.zeros((3, n2c * 2, n2c * 2), dtype=numpy.complex)
    vx = _vhf.rdirect_mapdm('cint2e_g1', 'a4ij', ('lk->s2ij', 'jk->s1il'),
                            dmll, 3, mol._atm, mol._bas, mol._env)
    vj[:, :n2c, :n2c] = vx[0]
    vk[:, :n2c, :n2c] = vx[1]
    vx = _vhf.rdirect_mapdm('cint2e_spgsp1spsp2', 'a4ij',
                            ('lk->s2ij', 'jk->s1il'), dmss, 3, mol._atm,
                            mol._bas, mol._env) * c1**4
    vj[:, n2c:, n2c:] = vx[0]
    vk[:, n2c:, n2c:] = vx[1]
    vx = _vhf.rdirect_bindm('cint2e_g1spsp2', 'a4ij', ('lk->s2ij', 'jk->s1il'),
                            (dmss, dmls), 3, mol._atm, mol._bas,
                            mol._env) * c1**2
    vj[:, :n2c, :n2c] += vx[0]
    vk[:, :n2c, n2c:] += vx[1]
    vx = _vhf.rdirect_bindm('cint2e_spgsp1', 'a4ij', ('lk->s2ij', 'jk->s1il'),
                            (dmll, dmsl), 3, mol._atm, mol._bas,
                            mol._env) * c1**2
    vj[:, n2c:, n2c:] += vx[0]
    vk[:, n2c:, :n2c] += vx[1]
    for i in range(3):
        vj[i] = pyscf.lib.hermi_triu(vj[i], 1)
        vk[i] = vk[i] + vk[i].T.conj()
    return vj, vk
Exemple #2
0
def _call_vhf1(mol, dm):
    c1 = .5/mol.light_speed
    n2c = dm.shape[0] // 2
    dmll = dm[:n2c,:n2c].copy()
    dmls = dm[:n2c,n2c:].copy()
    dmsl = dm[n2c:,:n2c].copy()
    dmss = dm[n2c:,n2c:].copy()
    vj = numpy.zeros((3,n2c*2,n2c*2), dtype=numpy.complex)
    vk = numpy.zeros((3,n2c*2,n2c*2), dtype=numpy.complex)
    vj[:,:n2c,:n2c], vk[:,:n2c,:n2c] = \
            _vhf.rdirect_mapdm('cint2e_ip1', 's2kl',
                               ('lk->s1ij', 'jk->s1il'), dmll, 3,
                               mol._atm, mol._bas, mol._env)
    vj[:,n2c:,n2c:], vk[:,n2c:,n2c:] = \
            _vhf.rdirect_mapdm('cint2e_ipspsp1spsp2', 's2kl',
                               ('lk->s1ij', 'jk->s1il'), dmss, 3,
                               mol._atm, mol._bas, mol._env) * c1**4
    vx = _vhf.rdirect_bindm('cint2e_ipspsp1', 's2kl',
                            ('lk->s1ij', 'jk->s1il'), (dmll, dmsl), 3,
                            mol._atm, mol._bas, mol._env) * c1**2
    vj[:,n2c:,n2c:] += vx[0]
    vk[:,n2c:,:n2c] += vx[1]
    vx = _vhf.rdirect_bindm('cint2e_ip1spsp2', 's2kl',
                            ('lk->s1ij', 'jk->s1il'), (dmss, dmls), 3,
                            mol._atm, mol._bas, mol._env) * c1**2
    vj[:,:n2c,:n2c] += vx[0]
    vk[:,:n2c,n2c:] += vx[1]
    return vj, vk
Exemple #3
0
def _call_giao_vhf1(mol, dm):
    c1 = .5/mol.light_speed
    n2c = dm.shape[0] // 2
    dmll = dm[:n2c,:n2c].copy()
    dmls = dm[:n2c,n2c:].copy()
    dmsl = dm[n2c:,:n2c].copy()
    dmss = dm[n2c:,n2c:].copy()
    vj = numpy.zeros((3,n2c*2,n2c*2), dtype=numpy.complex)
    vk = numpy.zeros((3,n2c*2,n2c*2), dtype=numpy.complex)
    vx = _vhf.rdirect_mapdm('cint2e_g1', 'a4ij',
                            ('lk->s2ij', 'jk->s1il'), dmll, 3,
                            mol._atm, mol._bas, mol._env)
    vj[:,:n2c,:n2c] = vx[0]
    vk[:,:n2c,:n2c] = vx[1]
    vx = _vhf.rdirect_mapdm('cint2e_spgsp1spsp2', 'a4ij',
                            ('lk->s2ij', 'jk->s1il'), dmss, 3,
                            mol._atm, mol._bas, mol._env) * c1**4
    vj[:,n2c:,n2c:] = vx[0]
    vk[:,n2c:,n2c:] = vx[1]
    vx = _vhf.rdirect_bindm('cint2e_g1spsp2', 'a4ij',
                            ('lk->s2ij', 'jk->s1il'), (dmss,dmls), 3,
                            mol._atm, mol._bas, mol._env) * c1**2
    vj[:,:n2c,:n2c] += vx[0]
    vk[:,:n2c,n2c:] += vx[1]
    vx = _vhf.rdirect_bindm('cint2e_spgsp1', 'a4ij',
                            ('lk->s2ij', 'jk->s1il'), (dmll,dmsl), 3,
                            mol._atm, mol._bas, mol._env) * c1**2
    vj[:,n2c:,n2c:] += vx[0]
    vk[:,n2c:,:n2c] += vx[1]
    for i in range(3):
        vj[i] = pyscf.lib.hermi_triu(vj[i], 1)
        vk[i] = vk[i] + vk[i].T.conj()
    return vj, vk
Exemple #4
0
def _call_vhf1(mol, dm):
    c1 = .5 / lib.param.LIGHT_SPEED
    n2c = dm.shape[0] // 2
    dmll = dm[:n2c,:n2c].copy()
    dmls = dm[:n2c,n2c:].copy()
    dmsl = dm[n2c:,:n2c].copy()
    dmss = dm[n2c:,n2c:].copy()
    vj = numpy.zeros((3,n2c*2,n2c*2), dtype=numpy.complex)
    vk = numpy.zeros((3,n2c*2,n2c*2), dtype=numpy.complex)
    vj[:,:n2c,:n2c], vk[:,:n2c,:n2c] = \
            _vhf.rdirect_mapdm('int2e_ip1_spinor', 's2kl',
                               ('lk->s1ij', 'jk->s1il'), dmll, 3,
                               mol._atm, mol._bas, mol._env)
    vj[:,n2c:,n2c:], vk[:,n2c:,n2c:] = \
            _vhf.rdirect_mapdm('int2e_ipspsp1spsp2_spinor', 's2kl',
                               ('lk->s1ij', 'jk->s1il'), dmss, 3,
                               mol._atm, mol._bas, mol._env) * c1**4
    vx = _vhf.rdirect_bindm('int2e_ipspsp1_spinor', 's2kl',
                            ('lk->s1ij', 'jk->s1il'), (dmll, dmsl), 3,
                            mol._atm, mol._bas, mol._env) * c1**2
    vj[:,n2c:,n2c:] += vx[0]
    vk[:,n2c:,:n2c] += vx[1]
    vx = _vhf.rdirect_bindm('int2e_ip1spsp2_spinor', 's2kl',
                            ('lk->s1ij', 'jk->s1il'), (dmss, dmls), 3,
                            mol._atm, mol._bas, mol._env) * c1**2
    vj[:,:n2c,:n2c] += vx[0]
    vk[:,:n2c,n2c:] += vx[1]
    return vj, vk
Exemple #5
0
def _call_veff_gaunt_breit(mol, dm, hermi=1, mf_opt=None, with_breit=False):
    if with_breit:
        # integral function int2e_breit_ssp1ssp2_spinor evaluates
        # -1/2[alpha1*alpha2/r12 + (alpha1*r12)(alpha2*r12)/r12^3]
        intor_prefix = 'int2e_breit_'
    else:
        # integral function int2e_ssp1ssp2_spinor evaluates only
        # alpha1*alpha2/r12. Minus sign was not included.
        intor_prefix = 'int2e_'
    if isinstance(dm, numpy.ndarray) and dm.ndim == 2:
        n_dm = 1
        n2c = dm.shape[0] // 2
        dmls = dm[:n2c,n2c:].copy()
        dmsl = dm[n2c:,:n2c].copy()
        dmll = dm[:n2c,:n2c].copy()
        dmss = dm[n2c:,n2c:].copy()
        dms = [dmsl, dmsl, dmls, dmll, dmss]
    else:
        n_dm = len(dm)
        n2c = dm[0].shape[0] // 2
        dmll = [dmi[:n2c,:n2c].copy() for dmi in dm]
        dmls = [dmi[:n2c,n2c:].copy() for dmi in dm]
        dmsl = [dmi[n2c:,:n2c].copy() for dmi in dm]
        dmss = [dmi[n2c:,n2c:].copy() for dmi in dm]
        dms = dmsl + dmsl + dmls + dmll + dmss
    vj = numpy.zeros((n_dm,n2c*2,n2c*2), dtype=numpy.complex128)
    vk = numpy.zeros((n_dm,n2c*2,n2c*2), dtype=numpy.complex128)

    jks = ('lk->s1ij',) * n_dm \
        + ('jk->s1il',) * n_dm
    vx = _vhf.rdirect_bindm(intor_prefix+'ssp1ssp2_spinor', 's1', jks, dms[:n_dm*2], 1,
                            mol._atm, mol._bas, mol._env, mf_opt)
    vj[:,:n2c,n2c:] = vx[:n_dm,:,:]
    vk[:,:n2c,n2c:] = vx[n_dm:,:,:]

    jks = ('lk->s1ij',) * n_dm \
        + ('li->s1kj',) * n_dm \
        + ('jk->s1il',) * n_dm
    vx = _vhf.rdirect_bindm(intor_prefix+'ssp1sps2_spinor', 's1', jks, dms[n_dm*2:], 1,
                            mol._atm, mol._bas, mol._env, mf_opt)
    vj[:,:n2c,n2c:]+= vx[      :n_dm  ,:,:]
    vk[:,n2c:,n2c:] = vx[n_dm  :n_dm*2,:,:]
    vk[:,:n2c,:n2c] = vx[n_dm*2:      ,:,:]

    if hermi == 1:
        vj[:,n2c:,:n2c] = vj[:,:n2c,n2c:].transpose(0,2,1).conj()
        vk[:,n2c:,:n2c] = vk[:,:n2c,n2c:].transpose(0,2,1).conj()
    elif hermi == 2:
        vj[:,n2c:,:n2c] = -vj[:,:n2c,n2c:].transpose(0,2,1).conj()
        vk[:,n2c:,:n2c] = -vk[:,:n2c,n2c:].transpose(0,2,1).conj()
    else:
        raise NotImplementedError
    if n_dm == 1:
        vj = vj.reshape(n2c*2,n2c*2)
        vk = vk.reshape(n2c*2,n2c*2)
    c1 = .5 / lib.param.LIGHT_SPEED
    if with_breit:
        return vj*c1**2, vk*c1**2
    else:
        return -vj*c1**2, -vk*c1**2
Exemple #6
0
def _call_veff_gaunt_breit(mol, dm, hermi=1, mf_opt=None, with_breit=False):
    if with_breit:
        intor_prefix = 'cint2e_breit_'
    else:
        intor_prefix = 'cint2e_'
    if isinstance(dm, numpy.ndarray) and dm.ndim == 2:
        n_dm = 1
        n2c = dm.shape[0] // 2
        dmls = dm[:n2c, n2c:].copy()
        dmsl = dm[n2c:, :n2c].copy()
        dmll = dm[:n2c, :n2c].copy()
        dmss = dm[n2c:, n2c:].copy()
        dms = [dmsl, dmsl, dmls, dmll, dmss]
    else:
        n_dm = len(dm)
        n2c = dm[0].shape[0] // 2
        dmll = [dmi[:n2c, :n2c].copy() for dmi in dm]
        dmls = [dmi[:n2c, n2c:].copy() for dmi in dm]
        dmsl = [dmi[n2c:, :n2c].copy() for dmi in dm]
        dmss = [dmi[n2c:, n2c:].copy() for dmi in dm]
        dms = dmsl + dmsl + dmls + dmll + dmss
    vj = numpy.zeros((n_dm, n2c * 2, n2c * 2), dtype=numpy.complex)
    vk = numpy.zeros((n_dm, n2c * 2, n2c * 2), dtype=numpy.complex)

    jks = ('lk->s1ij',) * n_dm \
        + ('jk->s1il',) * n_dm
    vx = _vhf.rdirect_bindm(intor_prefix + 'ssp1ssp2', 's1', jks,
                            dms[:n_dm * 2], 1, mol._atm, mol._bas, mol._env,
                            mf_opt)
    vj[:, :n2c, n2c:] = vx[:n_dm, :, :]
    vk[:, :n2c, n2c:] = vx[n_dm:, :, :]

    jks = ('lk->s1ij',) * n_dm \
        + ('li->s1kj',) * n_dm \
        + ('jk->s1il',) * n_dm
    vx = _vhf.rdirect_bindm(intor_prefix + 'ssp1sps2', 's1', jks,
                            dms[n_dm * 2:], 1, mol._atm, mol._bas, mol._env,
                            mf_opt)
    vj[:, :n2c, n2c:] += vx[:n_dm, :, :]
    vk[:, n2c:, n2c:] = vx[n_dm:n_dm * 2, :, :]
    vk[:, :n2c, :n2c] = vx[n_dm * 2:, :, :]

    if hermi == 1:
        vj[:, n2c:, :n2c] = vj[:, :n2c, n2c:].transpose(0, 2, 1).conj()
        vk[:, n2c:, :n2c] = vk[:, :n2c, n2c:].transpose(0, 2, 1).conj()
    elif hermi == 2:
        vj[:, n2c:, :n2c] = -vj[:, :n2c, n2c:].transpose(0, 2, 1).conj()
        vk[:, n2c:, :n2c] = -vk[:, :n2c, n2c:].transpose(0, 2, 1).conj()
    else:
        raise NotImplementedError
    if n_dm == 1:
        vj = vj.reshape(n2c * 2, n2c * 2)
        vk = vk.reshape(n2c * 2, n2c * 2)
    c1 = .5 / mol.light_speed
    if with_breit:
        return vj * c1**2, vk * c1**2
    else:
        return -vj * c1**2, -vk * c1**2
Exemple #7
0
def _call_veff_gaunt_breit(mol, dm, hermi=1, mf_opt=None, with_breit=False):
    if with_breit:
        intor_prefix = 'cint2e_breit_'
    else:
        intor_prefix = 'cint2e_'
    if isinstance(dm, numpy.ndarray) and dm.ndim == 2:
        n_dm = 1
        n2c = dm.shape[0] // 2
        dmls = dm[:n2c,n2c:].copy()
        dmsl = dm[n2c:,:n2c].copy()
        dmll = dm[:n2c,:n2c].copy()
        dmss = dm[n2c:,n2c:].copy()
        dms = [dmsl, dmsl, dmls, dmll, dmss]
    else:
        n_dm = len(dm)
        n2c = dm[0].shape[0] // 2
        dmll = [dmi[:n2c,:n2c].copy() for dmi in dm]
        dmls = [dmi[:n2c,n2c:].copy() for dmi in dm]
        dmsl = [dmi[n2c:,:n2c].copy() for dmi in dm]
        dmss = [dmi[n2c:,n2c:].copy() for dmi in dm]
        dms = dmsl + dmsl + dmls + dmll + dmss
    vj = numpy.zeros((n_dm,n2c*2,n2c*2), dtype=numpy.complex)
    vk = numpy.zeros((n_dm,n2c*2,n2c*2), dtype=numpy.complex)

    jks = ('lk->s1ij',) * n_dm \
        + ('jk->s1il',) * n_dm
    vx = _vhf.rdirect_bindm(intor_prefix+'ssp1ssp2', 's1', jks, dms[:n_dm*2], 1,
                            mol._atm, mol._bas, mol._env, mf_opt)
    vj[:,:n2c,n2c:] = vx[:n_dm,:,:]
    vk[:,:n2c,n2c:] = vx[n_dm:,:,:]

    jks = ('lk->s1ij',) * n_dm \
        + ('li->s1kj',) * n_dm \
        + ('jk->s1il',) * n_dm
    vx = _vhf.rdirect_bindm(intor_prefix+'ssp1sps2', 's1', jks, dms[n_dm*2:], 1,
                            mol._atm, mol._bas, mol._env, mf_opt)
    vj[:,:n2c,n2c:]+= vx[      :n_dm  ,:,:]
    vk[:,n2c:,n2c:] = vx[n_dm  :n_dm*2,:,:]
    vk[:,:n2c,:n2c] = vx[n_dm*2:      ,:,:]

    if hermi == 1:
        vj[:,n2c:,:n2c] = vj[:,:n2c,n2c:].transpose(0,2,1).conj()
        vk[:,n2c:,:n2c] = vk[:,:n2c,n2c:].transpose(0,2,1).conj()
    elif hermi == 2:
        vj[:,n2c:,:n2c] = -vj[:,:n2c,n2c:].transpose(0,2,1).conj()
        vk[:,n2c:,:n2c] = -vk[:,:n2c,n2c:].transpose(0,2,1).conj()
    else:
        raise NotImplementedError
    if n_dm == 1:
        vj = vj.reshape(n2c*2,n2c*2)
        vk = vk.reshape(n2c*2,n2c*2)
    c1 = .5/mol.light_speed
    if with_breit:
        return vj*c1**2, vk*c1**2
    else:
        return -vj*c1**2, -vk*c1**2
Exemple #8
0
def _call_veff_ssll(mol, dm, hermi=1, mf_opt=None):
    if isinstance(dm, numpy.ndarray) and dm.ndim == 2:
        n_dm = 1
        n2c = dm.shape[0] // 2
        dmll = dm[:n2c,:n2c].copy()
        dmsl = dm[n2c:,:n2c].copy()
        dmss = dm[n2c:,n2c:].copy()
        dms = (dmll, dmss, dmsl)
    else:
        n_dm = len(dm)
        n2c = dm[0].shape[0] // 2
        dms = [dmi[:n2c,:n2c].copy() for dmi in dm] \
            + [dmi[n2c:,n2c:].copy() for dmi in dm] \
            + [dmi[n2c:,:n2c].copy() for dmi in dm]
    jks = ('lk->s2ij',) * n_dm \
        + ('ji->s2kl',) * n_dm \
        + ('jk->s1il',) * n_dm
    c1 = .5/mol.light_speed
    vx = _vhf.rdirect_bindm('cint2e_spsp1', 's4', jks, dms, 1,
                            mol._atm, mol._bas, mol._env, mf_opt) * c1**2
    vj = numpy.zeros((n_dm,n2c*2,n2c*2), dtype=numpy.complex)
    vk = numpy.zeros((n_dm,n2c*2,n2c*2), dtype=numpy.complex)
    vj[:,n2c:,n2c:] = vx[      :n_dm  ,:,:]
    vj[:,:n2c,:n2c] = vx[n_dm  :n_dm*2,:,:]
    vk[:,n2c:,:n2c] = vx[n_dm*2:      ,:,:]
    if n_dm == 1:
        vj = vj.reshape(vj.shape[1:])
        vk = vk.reshape(vk.shape[1:])
    return _jk_triu_(vj, vk, hermi)
Exemple #9
0
def _call_veff_ssll(mol, dm, hermi=1, mf_opt=None):
    if isinstance(dm, numpy.ndarray) and dm.ndim == 2:
        n_dm = 1
        n2c = dm.shape[0] // 2
        dmll = dm[:n2c, :n2c].copy()
        dmsl = dm[n2c:, :n2c].copy()
        dmss = dm[n2c:, n2c:].copy()
        dms = (dmll, dmss, dmsl)
    else:
        n_dm = len(dm)
        n2c = dm[0].shape[0] // 2
        dms = [dmi[:n2c,:n2c].copy() for dmi in dm] \
            + [dmi[n2c:,n2c:].copy() for dmi in dm] \
            + [dmi[n2c:,:n2c].copy() for dmi in dm]
    jks = ('lk->s2ij',) * n_dm \
        + ('ji->s2kl',) * n_dm \
        + ('jk->s1il',) * n_dm
    c1 = .5 / lib.param.LIGHT_SPEED
    vx = _vhf.rdirect_bindm('int2e_spsp1_spinor', 's4', jks, dms, 1, mol._atm,
                            mol._bas, mol._env, mf_opt) * c1**2
    vj = numpy.zeros((n_dm, n2c * 2, n2c * 2), dtype=numpy.complex)
    vk = numpy.zeros((n_dm, n2c * 2, n2c * 2), dtype=numpy.complex)
    vj[:, n2c:, n2c:] = vx[:n_dm, :, :]
    vj[:, :n2c, :n2c] = vx[n_dm:n_dm * 2, :, :]
    vk[:, n2c:, :n2c] = vx[n_dm * 2:, :, :]
    if n_dm == 1:
        vj = vj.reshape(vj.shape[1:])
        vk = vk.reshape(vk.shape[1:])
    return _jk_triu_(vj, vk, hermi)
Exemple #10
0
def _call_rmb_vhf1(mol, dm, key='giao'):
    c1 = .5 / mol.light_speed
    n2c = dm.shape[0] // 2
    dmll = dm[:n2c, :n2c].copy()
    dmls = dm[:n2c, n2c:].copy()
    dmsl = dm[n2c:, :n2c].copy()
    dmss = dm[n2c:, n2c:].copy()
    vj = numpy.zeros((3, n2c * 2, n2c * 2), dtype=numpy.complex)
    vk = numpy.zeros((3, n2c * 2, n2c * 2), dtype=numpy.complex)
    vx = _vhf.rdirect_mapdm('cint2e_' + key + '_sa10sp1spsp2', 's2kl',
                            ('ji->s2kl', 'lk->s1ij', 'jk->s1il', 'li->s1kj'),
                            dmss, 3, mol._atm, mol._bas, mol._env) * c1**4
    for i in range(3):
        vx[0, i] = pyscf.lib.hermi_triu(vx[0, i], 2)
    vj[:, n2c:, n2c:] = vx[0] + vx[1]
    vk[:, n2c:, n2c:] = vx[2] + vx[3]

    vx = _vhf.rdirect_bindm('cint2e_' + key + '_sa10sp1', 's2kl',
                            ('lk->s1ij', 'ji->s2kl', 'jk->s1il', 'li->s1kj'),
                            (dmll, dmss, dmsl, dmls), 3, mol._atm, mol._bas,
                            mol._env) * c1**2
    for i in range(3):
        vx[1, i] = pyscf.lib.hermi_triu(vx[1, i], 2)
    vj[:, n2c:, n2c:] += vx[0]
    vj[:, :n2c, :n2c] += vx[1]
    vk[:, n2c:, :n2c] += vx[2]
    vk[:, :n2c, n2c:] += vx[3]
    for i in range(3):
        vj[i] = vj[i] + vj[i].T.conj()
        vk[i] = vk[i] + vk[i].T.conj()
    return vj, vk
Exemple #11
0
def _call_rmb_vhf1(mol, dm, key='giao'):
    c1 = .5/mol.light_speed
    n2c = dm.shape[0] // 2
    dmll = dm[:n2c,:n2c].copy()
    dmls = dm[:n2c,n2c:].copy()
    dmsl = dm[n2c:,:n2c].copy()
    dmss = dm[n2c:,n2c:].copy()
    vj = numpy.zeros((3,n2c*2,n2c*2), dtype=numpy.complex)
    vk = numpy.zeros((3,n2c*2,n2c*2), dtype=numpy.complex)
    vx = _vhf.rdirect_mapdm('cint2e_'+key+'_sa10sp1spsp2', 's2kl',
                            ('ji->s2kl', 'lk->s1ij', 'jk->s1il', 'li->s1kj'),
                            dmss, 3, mol._atm, mol._bas, mol._env) * c1**4
    for i in range(3):
        vx[0,i] = pyscf.lib.hermi_triu(vx[0,i], 2)
    vj[:,n2c:,n2c:] = vx[0] + vx[1]
    vk[:,n2c:,n2c:] = vx[2] + vx[3]

    vx = _vhf.rdirect_bindm('cint2e_'+key+'_sa10sp1', 's2kl',
                            ('lk->s1ij', 'ji->s2kl', 'jk->s1il', 'li->s1kj'),
                            (dmll,dmss,dmsl,dmls), 3,
                            mol._atm, mol._bas, mol._env) * c1**2
    for i in range(3):
        vx[1,i] = pyscf.lib.hermi_triu(vx[1,i], 2)
    vj[:,n2c:,n2c:] += vx[0]
    vj[:,:n2c,:n2c] += vx[1]
    vk[:,n2c:,:n2c] += vx[2]
    vk[:,:n2c,n2c:] += vx[3]
    for i in range(3):
        vj[i] = vj[i] + vj[i].T.conj()
        vk[i] = vk[i] + vk[i].T.conj()
    return vj, vk
Exemple #12
0
def _call_veff_ssll(mol, dm, hermi=1, mf_opt=None):
    if isinstance(dm, numpy.ndarray) and dm.ndim == 2:
        dm1 = dm[numpy.newaxis]
    else:
        dm1 = numpy.asarray(dm)
    n_dm = len(dm1)
    n2c = dm1.shape[1] // 2
    dms = numpy.vstack([
        dm1[:, :n2c, :n2c], dm1[:, n2c:, n2c:], dm1[:, n2c:, :n2c],
        dm1[:, :n2c, n2c:]
    ])
    if hermi:
        jks = (['lk->s2ij'] * n_dm + ['ji->s2kl'] * n_dm + ['jk->s1il'] * n_dm)
    else:
        jks = (['lk->s2ij'] * n_dm + ['ji->s2kl'] * n_dm +
               ['jk->s1il'] * n_dm + ['li->s1kj'] * n_dm)
    c1 = .5 / lib.param.LIGHT_SPEED
    vx = _vhf.rdirect_bindm('int2e_spsp1_spinor', 's4', jks, dms, 1, mol._atm,
                            mol._bas, mol._env, mf_opt)
    vx = vx.reshape(-1, n_dm, n2c, n2c) * c1**2
    vj = numpy.zeros((n_dm, n2c * 2, n2c * 2), dtype=numpy.complex128)
    vk = numpy.zeros((n_dm, n2c * 2, n2c * 2), dtype=numpy.complex128)
    if hermi == 0:
        vj[:, n2c:, n2c:] = _time_reversal_triu_(mol, vx[0])
        vj[:, :n2c, :n2c] = _time_reversal_triu_(mol, vx[1])
        vk[:, n2c:, :n2c] = vx[2]
        vk[:, :n2c, n2c:] = vx[3]
    else:
        vj[:, n2c:, n2c:] = _mat_hermi_(vx[0], hermi)
        vj[:, :n2c, :n2c] = _mat_hermi_(vx[1], hermi)
        vk[:, n2c:, :n2c] = vx[2]
        vk[:, :n2c, n2c:] = vx[2].conj().transpose(0, 2, 1)
    vj = vj.reshape(dm.shape)
    vk = vk.reshape(dm.shape)
    return vj, vk
Exemple #13
0
    def test_rdirect_bindm(self):
        n2c = nao * 2
        eri0 = numpy.zeros((n2c, n2c, n2c, n2c), dtype=numpy.complex)
        mfr = scf.DHF(mol)
        mfr.scf()
        dm = mfr.make_rdm1()[:n2c, :n2c].copy()
        c_atm = numpy.array(mol._atm, dtype=numpy.int32)
        c_bas = numpy.array(mol._bas, dtype=numpy.int32)
        c_env = numpy.array(mol._env)
        i0 = 0
        for i in range(mol.nbas):
            j0 = 0
            for j in range(mol.nbas):
                k0 = 0
                for k in range(mol.nbas):
                    l0 = 0
                    for l in range(mol.nbas):
                        buf = gto.getints_by_shell('int2e_spsp1_spinor',
                                                   (i, j, k, l), c_atm, c_bas,
                                                   c_env, 1)
                        di, dj, dk, dl = buf.shape
                        eri0[i0:i0 + di, j0:j0 + dj, k0:k0 + dk,
                             l0:l0 + dl] = buf
                        l0 += dl
                    k0 += dk
                j0 += dj
            i0 += di

        vk0 = numpy.einsum('ijkl,jk->il', eri0, dm)
        vk1 = _vhf.rdirect_bindm('int2e_spsp1_spinor', 's4', ('jk->s1il', ),
                                 (dm, ), 1, mol._atm, mol._bas, mol._env)
        self.assertTrue(numpy.allclose(vk0, vk1))
Exemple #14
0
    def test_rdirect_bindm(self):
        n2c = nao*2
        eri0 = numpy.zeros((n2c,n2c,n2c,n2c),dtype=numpy.complex)
        mfr = scf.DHF(mol)
        mfr.scf()
        dm = mfr.make_rdm1()[:n2c,:n2c].copy()
        c_atm = numpy.array(mol._atm, dtype=numpy.int32)
        c_bas = numpy.array(mol._bas, dtype=numpy.int32)
        c_env = numpy.array(mol._env)
        i0 = 0
        for i in range(mol.nbas):
            j0 = 0
            for j in range(mol.nbas):
                k0 = 0
                for k in range(mol.nbas):
                    l0 = 0
                    for l in range(mol.nbas):
                        buf = gto.getints_by_shell('cint2e_spsp1', (i,j,k,l),
                                                   c_atm, c_bas, c_env, 1)
                        di,dj,dk,dl = buf.shape
                        eri0[i0:i0+di,j0:j0+dj,k0:k0+dk,l0:l0+dl] = buf
                        l0 += dl
                    k0 += dk
                j0 += dj
            i0 += di

        vk0 = numpy.einsum('ijkl,jk->il', eri0, dm)
        vk1 = _vhf.rdirect_bindm('cint2e_spsp1', 's4', ('jk->s1il',),
                                 (dm,), 1, mol._atm, mol._bas, mol._env)
        self.assertTrue(numpy.allclose(vk0,vk1))
Exemple #15
0
    def test_rdirect_bindm(self):
        n2c = nao * 2
        numpy.random.seed(1)
        dm = (numpy.random.random((n2c, n2c)) + numpy.random.random(
            (n2c, n2c)) * 1j)
        dm = dm + dm.conj().T

        eri0 = mol.intor('int2e_spsp1_spinor').reshape(n2c, n2c, n2c, n2c)
        vk0 = numpy.einsum('ijkl,jk->il', eri0, dm)
        vk1 = _vhf.rdirect_bindm('int2e_spsp1_spinor', 's4', 'jk->s1il', dm, 1,
                                 mol._atm, mol._bas, mol._env)
        self.assertTrue(numpy.allclose(vk0, vk1))

        opt_llll = _vhf.VHFOpt(mol, 'int2e_spinor', 'CVHFrkbllll_prescreen',
                               'CVHFrkbllll_direct_scf',
                               'CVHFrkbllll_direct_scf_dm')
        opt_llll._this.contents.r_vkscreen = _vhf._fpointer(
            'CVHFrkbllll_vkscreen')
        eri0 = mol.intor('int2e_spinor').reshape(n2c, n2c, n2c, n2c)
        vk0 = numpy.einsum('ijkl,jk->il', eri0, dm)
        vk1 = _vhf.rdirect_bindm('int2e_spinor', 's1', 'jk->s1il', dm, 1,
                                 mol._atm, mol._bas, mol._env, opt_llll)
        self.assertTrue(numpy.allclose(vk0, vk1))
Exemple #16
0
    def test_rdirect_bindm(self):
        n2c = nao*2
        numpy.random.seed(1)
        dm = (numpy.random.random((n2c,n2c)) +
              numpy.random.random((n2c,n2c)) * 1j)
        dm = dm + dm.conj().T

        eri0 = mol.intor('int2e_spsp1_spinor').reshape(n2c,n2c,n2c,n2c)
        vk0 = numpy.einsum('ijkl,jk->il', eri0, dm)
        vk1 = _vhf.rdirect_bindm('int2e_spsp1_spinor', 's4', 'jk->s1il',
                                 dm, 1, mol._atm, mol._bas, mol._env)
        self.assertTrue(numpy.allclose(vk0,vk1))

        opt_llll = _vhf.VHFOpt(mol, 'int2e_spinor',
                               'CVHFrkbllll_prescreen',
                               'CVHFrkbllll_direct_scf',
                               'CVHFrkbllll_direct_scf_dm')
        opt_llll._this.contents.r_vkscreen = _vhf._fpointer('CVHFrkbllll_vkscreen')
        eri0 = mol.intor('int2e_spinor').reshape(n2c,n2c,n2c,n2c)
        vk0 = numpy.einsum('ijkl,jk->il', eri0, dm)
        vk1 = _vhf.rdirect_bindm('int2e_spinor', 's1', 'jk->s1il',
                                 dm, 1, mol._atm, mol._bas, mol._env, opt_llll)
        self.assertTrue(numpy.allclose(vk0,vk1))