Exemplo n.º 1
0
def solve_mo1(nmrobj, mo_energy=None, mo_coeff=None, mo_occ=None,
              h1=None, s1=None, with_cphf=None):
    if with_cphf is None:
        with_cphf = nmrobj.cphf
    libxc = nmrobj._scf._numint.libxc
    with_cphf = with_cphf and libxc.is_hybrid_xc(nmrobj._scf.xc)
    return uhf_nmr.solve_mo1(nmrobj, mo_energy, mo_coeff, mo_occ,
                             h1, s1, with_cphf)
Exemplo n.º 2
0
def solve_mo1(nmrobj, mo_energy=None, mo_coeff=None, mo_occ=None,
              h1=None, s1=None, with_cphf=None):
    if with_cphf is None:
        with_cphf = nmrobj.cphf
    libxc = nmrobj._scf._numint.libxc
    with_cphf = with_cphf and libxc.is_hybrid_xc(nmrobj._scf.xc)
    return uhf_nmr.solve_mo1(nmrobj, mo_energy, mo_coeff, mo_occ,
                             h1, s1, with_cphf)
Exemplo n.º 3
0
def para(magobj, gauge_orig=None, h1=None, s1=None, with_cphf=None):
    '''Paramagnetic susceptibility tensor

    Kwargs:
        h1: A list of arrays. Shapes are [(3,nmo_a,nocc_a), (3,nmo_b,nocc_b)]
            First order Fock matrices in MO basis.
        s1: A list of arrays. Shapes are [(3,nmo_a,nocc_a), (3,nmo_b,nocc_b)]
            First order overlap matrices in MO basis.
        with_cphf : boolean or  function(dm_mo) => v1_mo
            If a boolean value is given, the value determines whether CPHF
            equation will be solved or not. The induced potential will be
            generated by the function gen_vind.
            If a function is given, CPHF equation will be solved, and the
            given function is used to compute induced potential
    '''
    log = logger.Logger(magobj.stdout, magobj.verbose)
    cput1 = (time.clock(), time.time())

    mol = magobj.mol
    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]

    if h1 is None:
        # Imaginary part of F10
        dm0 = (numpy.dot(orboa, orboa.T), numpy.dot(orbob, orbob.T))
        h1 = magobj.get_fock(dm0, gauge_orig)
        h1 = (lib.einsum('xpq,pi,qj->xij', h1[0], mo_coeff[0].conj(), orboa),
              lib.einsum('xpq,pi,qj->xij', h1[1], mo_coeff[1].conj(), orbob))
        cput1 = log.timer('first order Fock matrix', *cput1)
    if s1 is None:
        # Imaginary part of S10
        s1 = magobj.get_ovlp(mol, gauge_orig)
        s1 = (lib.einsum('xpq,pi,qj->xij', s1, mo_coeff[0].conj(), orboa),
              lib.einsum('xpq,pi,qj->xij', s1, mo_coeff[1].conj(), orbob))

    with_cphf = magobj.cphf
    mo1, mo_e1 = uhf_nmr.solve_mo1(magobj, mo_energy, mo_coeff, mo_occ, h1, s1,
                                   with_cphf)
    cput1 = logger.timer(magobj, 'solving mo1 eqn', *cput1)

    occidxa = mo_occ[0] > 0
    occidxb = mo_occ[1] > 0
    mag_para = numpy.einsum('yji,xji->xy', mo1[0], h1[0])
    mag_para += numpy.einsum('yji,xji->xy', mo1[1], h1[1])
    mag_para -= numpy.einsum('yji,xji,i->xy', mo1[0], s1[0],
                             mo_energy[0][occidxa])
    mag_para -= numpy.einsum('yji,xji,i->xy', mo1[1], s1[1],
                             mo_energy[1][occidxb])
    # + c.c.
    mag_para = mag_para + mag_para.conj()

    mag_para -= numpy.einsum('xij,yij->xy', s1[0][:, occidxa], mo_e1[0])
    mag_para -= numpy.einsum('xij,yij->xy', s1[1][:, occidxb], mo_e1[1])
    return -mag_para
Exemplo n.º 4
0
def para(magobj, gauge_orig=None, h1=None, s1=None, with_cphf=None):
    '''Paramagnetic susceptibility tensor

    Kwargs:
        h1: A list of arrays. Shapes are [(3,nmo_a,nocc_a), (3,nmo_b,nocc_b)]
            First order Fock matrices in MO basis.
        s1: A list of arrays. Shapes are [(3,nmo_a,nocc_a), (3,nmo_b,nocc_b)]
            First order overlap matrices in MO basis.
        with_cphf : boolean or  function(dm_mo) => v1_mo
            If a boolean value is given, the value determines whether CPHF
            equation will be solved or not. The induced potential will be
            generated by the function gen_vind.
            If a function is given, CPHF equation will be solved, and the
            given function is used to compute induced potential
    '''
    log = logger.Logger(magobj.stdout, magobj.verbose)
    cput1 = (time.clock(), time.time())

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

    if h1 is None:
        # Imaginary part of F10
        dm0 = (numpy.dot(orboa, orboa.T), numpy.dot(orbob, orbob.T))
        h1 = magobj.get_fock(dm0, gauge_orig)
        h1 = (lib.einsum('xpq,pi,qj->xij', h1[0], mo_coeff[0].conj(), orboa),
              lib.einsum('xpq,pi,qj->xij', h1[1], mo_coeff[1].conj(), orbob))
        cput1 = log.timer('first order Fock matrix', *cput1)
    if s1 is None:
        # Imaginary part of S10
        s1 = magobj.get_ovlp(mol, gauge_orig)
        s1 = (lib.einsum('xpq,pi,qj->xij', s1, mo_coeff[0].conj(), orboa),
              lib.einsum('xpq,pi,qj->xij', s1, mo_coeff[1].conj(), orbob))

    with_cphf = magobj.cphf
    mo1, mo_e1 = uhf_nmr.solve_mo1(magobj, mo_energy, mo_coeff, mo_occ,
                                   h1, s1, with_cphf)
    cput1 = logger.timer(magobj, 'solving mo1 eqn', *cput1)

    occidxa = mo_occ[0] > 0
    occidxb = mo_occ[1] > 0
    mag_para = numpy.einsum('yji,xji->xy', mo1[0], h1[0])
    mag_para+= numpy.einsum('yji,xji->xy', mo1[1], h1[1])
    mag_para-= numpy.einsum('yji,xji,i->xy', mo1[0], s1[0], mo_energy[0][occidxa])
    mag_para-= numpy.einsum('yji,xji,i->xy', mo1[1], s1[1], mo_energy[1][occidxb])
    # + c.c.
    mag_para = mag_para + mag_para.conj()

    mag_para-= numpy.einsum('xij,yij->xy', s1[0][:,occidxa], mo_e1[0])
    mag_para-= numpy.einsum('xij,yij->xy', s1[1][:,occidxb], mo_e1[1])
    return -mag_para