Exemple #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
Exemple #2
0
    def kernel(self, mo1=None):
        cput0 = (time.clock(), time.time())
        self.check_sanity()
        #self.dump_flags()

        dm0 = self._scf.make_rdm1()
        #print('dm0 from kernel', dm0.shape)
        #dm0 = dm0[0] - dm0[1]
        tt_dia = self.dia(dm0)
        tt_para = self.para(mo1, self._scf.mo_coeff, self._scf.mo_occ)

        im, mass_center = rhf_rotg.inertia_tensor(self.mol)
        im_inv = numpy.linalg.inv(im)
        #print('im', im)
        #print('im_inv', im_inv)
        To_MHz = 1804742.77343363
        esr_para = -1.0 * numpy.einsum('ij,jk->ik', im_inv,
                                       tt_para) * To_MHz * 2
        esr_dia = -1.0 * numpy.einsum('ij,jk->ik', im_inv, tt_dia) * To_MHz * 2
        print('esr_dia', esr_dia)
        esr_tensor = esr_para + esr_dia

        #print('esr_para', esr_para) for debug
        #print('esr_dia', esr_dia)
        #print('esr_tot', esr_tot)

        esr_tot, v = self.align(esr_tensor)
        esr_dia = reduce(numpy.dot, (v.T, esr_dia, v))
        esr_para = reduce(numpy.dot, (v.T, esr_para, v))
        _write(self, esr_dia, 'esr-tensor diamagnetic terms (in MHz)')
        _write(self, esr_para, 'esr-tensor paramagnetic terms (in MHz)')
        _write(self, esr_tot, 'esr-tensor total (in MHz)')
        return esr_tot
Exemple #3
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
Exemple #4
0
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)
Exemple #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 = 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)
Exemple #6
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)
Exemple #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
Exemple #8
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
Exemple #9
0
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)
Exemple #10
0
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)
Exemple #11
0
def dia(gobj, dm0, gauge_orig=None):
    '''Note the side effects of set_common_origin'''

    if isinstance(dm0, numpy.ndarray) and dm0.ndim == 2:  # RHF DM
        return numpy.zeros((3, 3))
    mol = gobj.mol
    effspin = mol.spin * .5
    muB = .5  # Bohr magneton

    dma, dmb = dm0
    totdm = dma + dmb
    spindm = dma - dmb
    alpha2 = nist.ALPHA**2
    #Many choices of qed_fac, see JPC, 101, 3388
    #qed_fac = (nist.G_ELECTRON - 1)
    #qed_fac = nist.G_ELECTRON / 2
    qed_fac = 1

    assert (not mol.has_ecp())
    if gauge_orig is not None:
        mol.set_common_origin(gauge_orig)

    e11 = numpy.zeros((3, 3))
    im, mass_center = rhf_rotg.inertia_tensor(mol)
    for ia in range(mol.natm):
        Z = koseki_charge(mol.atom_charge(ia))
        R = mol.atom_coord(ia) - mass_center
        with mol.with_rinv_origin(R):
            h11 = mol.intor('int1e_drinv', comp=3) * Z  # * mol.atom_charge(ia)
            t1 = numpy.einsum('xij,ij->x', h11, spindm)
            e11 += numpy.dot(R, t1) * numpy.eye(3) - numpy.kron(R, t1).reshape(
                3, 3)

        #GIAO part of dia-magnetic constribution
        #print('kron', numpy.kron(R, t1).reshape(3,3))
        #h22 =  mol.intor('int1e_a01gp', comp=9)
        #e11 -=  Z * numpy.einsum('xij,ij->x', h22, spindm).reshape(3,3)
    gdia = e11 * alpha2 / effspin / 4.
    return gdia