Ejemplo n.º 1
0
def dia(magobj, gauge_orig=None):
    '''Part of rotational g-tensors. It is the direct second derivatives of
    the Lagrangian (corresponding to the zeroth order wavefunction).  Unit
    hbar/mu_N is not included.  This part may be different to the conventional
    dia-magnetic contributions of rotational g-tensors.
    '''
    mol = magobj.mol
    im, mass_center = rhf_g.inertia_tensor(mol)
    if gauge_orig is None:
        # Eq. (35) of JCP, 105, 2804
        e2 = uhf_mag.dia(magobj, gauge_orig)
        e2 -= uhf_mag.dia(magobj, mass_center)
        e2 = rhf_g._safe_solve(im, e2)
        return -4 * nist.PROTON_MASS_AU * e2
    else:
        dm0a, dm0b = magobj._scf.make_rdm1()
        dm0 = dm0a + dm0b
        with mol.with_common_origin(gauge_orig):
            int_r = mol.intor('int1e_r', comp=3)
        cm = mass_center - gauge_orig
        e2 = numpy.einsum('xpq,qp,y->xy', int_r, dm0, cm)

        e2 = numpy.eye(3) * e2.trace() - e2
        e2 *= .5
        e2 = rhf_g._safe_solve(im, e2)
        return -2 * nist.PROTON_MASS_AU * e2
Ejemplo n.º 2
0
Archivo: uhf.py Proyecto: MSwenne/BEP
def dia(magobj, gauge_orig=None):
    '''Part of rotational g-tensors. It is the direct second derivatives of
    the Lagrangian (corresponding to the zeroth order wavefunction).  Unit
    hbar/mu_N is not included.  This part may be different to the conventional
    dia-magnetic contributions of rotational g-tensors.
    '''
    mol = magobj.mol
    im, mass_center = rhf_g.inertia_tensor(mol)
    if gauge_orig is None:
        # Eq. (35) of JCP, 105, 2804
        e2 = uhf_mag.dia(magobj, gauge_orig)
        e2 -= uhf_mag.dia(magobj, mass_center)
        e2 = rhf_g._safe_solve(im, e2)
        return -4 * nist.PROTON_MASS_AU * e2
    else:
        dm0a, dm0b = magobj._scf.make_rdm1()
        dm0 = dm0a + dm0b
        with mol.with_common_origin(gauge_orig):
            int_r = mol.intor('int1e_r', comp=3)
        cm = mass_center - gauge_orig
        e2 = numpy.einsum('xpq,qp,y->xy', int_r, dm0, cm)

        e2 = numpy.eye(3) * e2.trace() - e2
        e2 *= .5
        e2 = rhf_g._safe_solve(im, e2)
        return -2 * nist.PROTON_MASS_AU * e2
Ejemplo n.º 3
0
Archivo: rhf.py Proyecto: MSwenne/BEP
def para(nsrobj, mo10=None, mo_coeff=None, mo_occ=None, shielding_nuc=None):
    '''Paramagnetic part of NSR shielding tensors.
    '''
    if shielding_nuc is None: shielding_nuc = nsrobj.shielding_nuc

    # The first order Hamiltonian for rotation part is the same to the
    # first order Hamiltonian for magnetic field except a factor of 2.
    nsr_para = rhf_nmr.para(nsrobj, mo10, mo_coeff, mo_occ,
                            shielding_nuc)[0] * 2

    mol = nsrobj.mol
    im, mass_center = inertia_tensor(mol)
    nsr_para = _safe_solve(im, nsr_para)
    unit = _atom_gyro_list(mol)[shielding_nuc] * nist.ALPHA**2
    return numpy.einsum('ixy,i->ixy', nsr_para, unit)
Ejemplo n.º 4
0
Archivo: rks.py Proyecto: MSwenne/BEP
def dia(magobj, gauge_orig=None):
    '''Part of rotational g-tensors. It is the direct second derivatives of
    the Lagrangian (corresponding to the zeroth order wavefunction).  Unit
    hbar/mu_N is not included.  This part may be different to the conventional
    dia-magnetic contributions of rotational g-tensors.
    '''
    if gauge_orig is None:
        mol = magobj.mol
        im, mass_center = rhf_g.inertia_tensor(mol)
        # Eq. (35) of JCP, 105, 2804
        e2 = rks_mag.dia(magobj, gauge_orig)
        e2 -= rks_mag.dia(magobj, mass_center)
        e2 = rhf_g._safe_solve(im, e2)
        return -4 * nist.PROTON_MASS_AU * e2
    else:
        return rhf_g.dia(magobj, gauge_orig)
Ejemplo n.º 5
0
def dia(magobj, gauge_orig=None):
    '''Part of rotational g-tensors. It is the direct second derivatives of
    the Lagrangian (corresponding to the zeroth order wavefunction).  Unit
    hbar/mu_N is not included.  This part may be different to the conventional
    dia-magnetic contributions of rotational g-tensors.
    '''
    if gauge_orig is None:
        mol = magobj.mol
        im, mass_center = rhf_g.inertia_tensor(mol)
        # Eq. (35) of JCP, 105, 2804
        e2 = uks_mag.dia(magobj, gauge_orig)
        e2 -= uks_mag.dia(magobj, mass_center)
        e2 = rhf_g._safe_solve(im, e2)
        return -4 * nist.PROTON_MASS_AU * e2
    else:
        return uhf_g.dia(magobj, gauge_orig)
Ejemplo n.º 6
0
Archivo: uhf.py Proyecto: MSwenne/BEP
def para(magobj, gauge_orig=None, h1=None, s1=None, with_cphf=None):
    '''Part of rotational g-tensors from the first order wavefunctions. Unit
    hbar/mu_N is not included.  This part may be different to the conventional
    para-magnetic contributions of rotational g-tensors.
    '''
    mol = magobj.mol
    im, mass_center = rhf_g.inertia_tensor(mol)

    if gauge_orig is None:
        # The first order Hamiltonian for rotation part is the same to the
        # first order Hamiltonian for magnetic field except a factor of 2. It can
        # be computed using the magnetizability code.
        mag_para = uhf_mag.para(magobj, gauge_orig, h1, s1, with_cphf) * 2

    else:
        mf = magobj._scf
        mo_energy = mf.mo_energy
        mo_coeff = mf.mo_coeff
        mo_occ = mf.mo_occ
        orboa = mo_coeff[0][:, mo_occ[0] > 0]
        orbob = mo_coeff[1][:, mo_occ[1] > 0]

        # for magnetic field
        with mol.with_common_origin(mass_center):
            h10 = .5 * mol.intor('int1e_cg_irxp', 3)
            h10a = lib.einsum('xpq,pi,qj->xij', h10, mo_coeff[0].conj(), orboa)
            h10b = lib.einsum('xpq,pi,qj->xij', h10, mo_coeff[1].conj(), orbob)

        # for rotation part
        with mol.with_common_origin(gauge_orig):
            h01 = -mol.intor('int1e_cg_irxp', 3)
            h01a = lib.einsum('xpq,pi,qj->xij', h01, mo_coeff[0].conj(), orboa)
            h01b = lib.einsum('xpq,pi,qj->xij', h01, mo_coeff[1].conj(), orbob)

        s10a = numpy.zeros_like(h10a)
        s10b = numpy.zeros_like(h10b)
        mo10 = uhf_nmr._solve_mo1_uncoupled(mo_energy, mo_occ, (h10a, h10b),
                                            (s10a, s10b))[0]

        mag_para = numpy.einsum('xji,yji->xy', mo10[0].conj(), h01a)
        mag_para += numpy.einsum('xji,yji->xy', mo10[1].conj(), h01b)
        mag_para = mag_para + mag_para.conj()

    mag_para = rhf_g._safe_solve(im, mag_para)
    # unit = hbar/mu_N, mu_N is nuclear magneton
    unit = -2 * nist.PROTON_MASS_AU
    return mag_para * unit
Ejemplo n.º 7
0
def para(magobj, gauge_orig=None, h1=None, s1=None, with_cphf=None):
    '''Part of rotational g-tensors from the first order wavefunctions. Unit
    hbar/mu_N is not included.  This part may be different to the conventional
    para-magnetic contributions of rotational g-tensors.
    '''
    mol = magobj.mol
    im, mass_center = rhf_g.inertia_tensor(mol)

    if gauge_orig is None:
        # The first order Hamiltonian for rotation part is the same to the
        # first order Hamiltonian for magnetic field except a factor of 2. It can
        # be computed using the magnetizability code.
        mag_para = uhf_mag.para(magobj, gauge_orig, h1, s1, with_cphf) * 2

    else:
        mf = magobj._scf
        mo_energy = mf.mo_energy
        mo_coeff = mf.mo_coeff
        mo_occ = mf.mo_occ
        orboa = mo_coeff[0][:,mo_occ[0]>0]
        orbob = mo_coeff[1][:,mo_occ[1]>0]

        # for magnetic field
        with mol.with_common_origin(mass_center):
            h10 = .5 * mol.intor('int1e_cg_irxp', 3)
            h10a = lib.einsum('xpq,pi,qj->xij', h10, mo_coeff[0].conj(), orboa)
            h10b = lib.einsum('xpq,pi,qj->xij', h10, mo_coeff[1].conj(), orbob)

        # for rotation part
        with mol.with_common_origin(gauge_orig):
            h01 = -mol.intor('int1e_cg_irxp', 3)
            h01a = lib.einsum('xpq,pi,qj->xij', h01, mo_coeff[0].conj(), orboa)
            h01b = lib.einsum('xpq,pi,qj->xij', h01, mo_coeff[1].conj(), orbob)

        s10a = numpy.zeros_like(h10a)
        s10b = numpy.zeros_like(h10b)
        mo10 = uhf_nmr._solve_mo1_uncoupled(mo_energy, mo_occ,
                                            (h10a,h10b), (s10a,s10b))[0]

        mag_para = numpy.einsum('xji,yji->xy', mo10[0].conj(), h01a)
        mag_para+= numpy.einsum('xji,yji->xy', mo10[1].conj(), h01b)
        mag_para = mag_para + mag_para.conj()

    mag_para = rhf_g._safe_solve(im, mag_para)
    # unit = hbar/mu_N, mu_N is nuclear magneton
    unit = -2 * nist.PROTON_MASS_AU
    return mag_para * unit
Ejemplo n.º 8
0
Archivo: rhf.py Proyecto: MSwenne/BEP
def nuc(mol, shielding_nuc):
    '''Nuclear contributions'''
    im, mass_center = inertia_tensor(mol)
    charges = mol.atom_charges()
    coords = mol.atom_coords()

    nsr_nuc = []
    for n, atm_id in enumerate(shielding_nuc):
        rkl = coords - coords[atm_id]
        d = numpy.linalg.norm(rkl, axis=1)
        d[atm_id] = 1e100
        e11 = numpy.einsum('z,zx,zy->xy', charges / d**3, rkl, rkl)
        e11 = numpy.eye(3) * e11.trace() - e11
        nsr_nuc.append(e11)

    nsr_nuc = _safe_solve(im, numpy.asarray(nsr_nuc))
    unit = _atom_gyro_list(mol)[shielding_nuc] * nist.ALPHA**2
    return numpy.einsum('ixy,i->ixy', nsr_nuc, unit)
Ejemplo n.º 9
0
Archivo: rhf.py Proyecto: 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)