コード例 #1
0
ファイル: rks.py プロジェクト: MSwenne/BEP
def _add_giao_phase(mol, vmat):
    '''Add the factor i/2*(Ri-Rj) of the GIAO phase e^{i/2 (Ri-Rj) times r}'''
    ao_coords = rhf_mag._get_ao_coords(mol)
    Rx = .5 * (ao_coords[:, 0:1] - ao_coords[:, 0])
    Ry = .5 * (ao_coords[:, 1:2] - ao_coords[:, 1])
    Rz = .5 * (ao_coords[:, 2:3] - ao_coords[:, 2])
    vxc20 = numpy.empty_like(vmat)
    vxc20[0] = Ry * vmat[2] - Rz * vmat[1]
    vxc20[1] = Rz * vmat[0] - Rx * vmat[2]
    vxc20[2] = Rx * vmat[1] - Ry * vmat[0]
    vxc20, vmat = vmat, vxc20
    vxc20[:, 0] = Ry * vmat[:, 2] - Rz * vmat[:, 1]
    vxc20[:, 1] = Rz * vmat[:, 0] - Rx * vmat[:, 2]
    vxc20[:, 2] = Rx * vmat[:, 1] - Ry * vmat[:, 0]
    vxc20 *= -1
    return vxc20
コード例 #2
0
ファイル: rhf.py プロジェクト: MSwenne/BEP
def dia(nsrobj, gauge_orig=None, shielding_nuc=None, dm0=None):
    '''Diamagnetic part of NSR tensors.
    '''
    if shielding_nuc is None: shielding_nuc = nsrobj.shielding_nuc
    if dm0 is None: dm0 = nsrobj._scf.make_rdm1()

    mol = nsrobj.mol
    im, mass_center = inertia_tensor(mol)
    if gauge_orig is None:
        ao_coords = rhf_mag._get_ao_coords(mol)
        # Eq. (34) of JCP, 105, 2804
        nsr_dia = rhf_nmr.dia(nsrobj, gauge_orig, shielding_nuc, dm0)
        for n, atm_id in enumerate(shielding_nuc):
            coord = mol.atom_coord(atm_id)
            with mol.with_common_origin(coord):
                with mol.with_rinv_origin(coord):
                    # a11part = (B dot) -1/2 frac{\vec{r}_N}{r_N^3} r_N (dot mu)
                    h11 = mol.intor('int1e_cg_a11part', comp=9)
            e11 = numpy.einsum('xpq,qp->x', h11, dm0).reshape(3, 3)
            nsr_dia[n] -= e11 - numpy.eye(3) * e11.trace()
            nsr_dia[n] *= 2
    else:
        nsr_dia = []
        for n, atm_id in enumerate(shielding_nuc):
            coord = mol.atom_coord(atm_id)
            with mol.with_rinv_origin(coord):
                with mol.with_common_origin(gauge_orig):
                    # a11part = (B dot) -1/2 frac{\vec{r}_N}{r_N^3} (r-R_c) (dot mu)
                    h11 = mol.intor('int1e_cg_a11part', comp=9)
                e11 = numpy.einsum('xpq,qp->x', h11, dm0).reshape(3, 3)
                with mol.with_common_origin(coord):
                    # a11part = (B dot) -1/2 frac{\vec{r}_N}{r_N^3} r_N (dot mu)
                    h11 = mol.intor('int1e_cg_a11part', comp=9)
                # e11 ~ (B dot) -1/2 frac{\vec{r}_N}{r_N^3} (R_N-R_c) (dot mu)
                e11 -= numpy.einsum('xpq,qp->x', h11, dm0).reshape(3, 3)
            e11 = e11 - numpy.eye(3) * e11.trace()
            nsr_dia.append(e11)

    nsr_dia = _safe_solve(im, numpy.asarray(nsr_dia))
    unit = _atom_gyro_list(mol)[shielding_nuc] * nist.ALPHA**2
    return numpy.einsum('ixy,i->ixy', nsr_dia, unit)