Example #1
0
def ao2mo(mf, mo_coeff, erifile):
    n4c, nmo = mo_coeff.shape
    n2c = n4c // 2
    c = mf.mol.light_speed
    ol = mo_coeff[:n2c]
    os = mo_coeff[n2c:] * (.5 / c)

    def run(mos, intor, dst, bound, blksize):
        logger.debug(mf, 'blksize = %d', blksize)
        r_outcore.general(mf.mol,
                          mos,
                          erifile,
                          dataname='tmp',
                          intor=intor,
                          verbose=mf.verbose)
        with h5py.File(erifile) as feri:
            for i0, i1 in prange(0, bound, blksize):
                logger.debug(mf, 'load %s %d', intor, i0)
                buf = feri[dst][i0:i1]
                # Add the contribution from 'tmp' to erifile
                buf += feri['tmp'][i0:i1]
                feri[dst][i0:i1] = buf
                buf = None

    r_outcore.general(mf.mol, (ol, ol, ol, ol),
                      erifile,
                      dataname='ericas',
                      intor='cint2e',
                      verbose=mf.verbose)
    blksize = max(1, int(512e6 / 16 / (nmo**3))) * nmo
    run((os, os, os, os), 'cint2e_spsp1spsp2', 'ericas', nmo * nmo, blksize)
    run((os, os, ol, ol), 'cint2e_spsp1', 'ericas', nmo * nmo, blksize)
    run((ol, ol, os, os), 'cint2e_spsp2', 'ericas', nmo * nmo, blksize)
    return 0
Example #2
0
def no_pair_ovov(mol, mo_coeff, erifile):
    '''
    2-electron integrals ( o v | o v ) for no-pair Hamiltonian under RKB basis
    '''
    c = lib.param.LIGHT_SPEED
    n4c, nmo = mo_coeff.shape
    n2c = n4c // 2
    nNeg = nmo // 2
    nocc = mol.nelectron
    nvir = nmo // 2 - nocc
    mo_pos_l = mo_coeff[:n2c,nNeg:]
    mo_pos_s = mo_coeff[n2c:,nNeg:] * (.5/c)
    Lo = mo_pos_l[:,:nocc]
    So = mo_pos_s[:,:nocc]
    Lv = mo_pos_l[:,nocc:]
    Sv = mo_pos_s[:,nocc:]

    dataname = 'dhf_ovov'
    def run(mos, intor):
        r_outcore.general(mol, mos, erifile,
                          dataname='tmp', intor=intor)
        blksize = 400
        nij = mos[0].shape[1] * mos[1].shape[1]
        with h5py.File(erifile) as feri:
            for i0, i1 in lib.prange(0, nij, blksize):
                buf = feri[dataname][i0:i1]
                buf += feri['tmp'][i0:i1]
                feri[dataname][i0:i1] = buf

    r_outcore.general(mol, (Lo, Lv, Lo, Lv), erifile,
                      dataname=dataname, intor='int2e_spinor')
    run((So, Sv, So, Sv), 'int2e_spsp1spsp2_spinor')
    run((So, Sv, Lo, Lv), 'int2e_spsp1_spinor'     )
    run((Lo, Lv, So, Sv), 'int2e_spsp2_spinor'     )
Example #3
0
def ao2mo(mf, mo_coeff, erifile):
    n4c, nmo = mo_coeff.shape
    n2c = n4c // 2
    nN = nmo // 2
    nocc = int(mf.mo_occ.sum())
    nP = nN + nocc
    nvir = nmo - nP
    c = lib.param.LIGHT_SPEED
    ol = mo_coeff[:n2c]
    os = mo_coeff[n2c:] * (.5 / c)
    ol0 = ol[:, nN:nP]
    os0 = os[:, nN:nP]
    ol1 = ol[:, :nP]
    os1 = os[:, :nP]
    ol2 = ol[:, nP:]
    os2 = os[:, nP:]
    ol3 = ol[:, :nN]
    os3 = os[:, :nN]
    ol4 = ol[:, nN:]
    os4 = os[:, nN:]

    def run(mos, intor, dst, bound, blksize):
        logger.debug(mf, 'blksize = %d', blksize)
        r_outcore.general(mf.mol,
                          mos,
                          erifile,
                          dataname='tmp',
                          intor=intor,
                          verbose=mf.verbose)
        with h5py.File(erifile) as feri:
            for i0, i1 in prange(0, bound, blksize):
                logger.debug(mf, 'load %s %d', intor, i0)
                buf = feri[dst][i0:i1]
                buf += feri['tmp'][i0:i1]
                feri[dst][i0:i1] = buf
                buf = None

    r_outcore.general(mf.mol, (ol0, ol2, ol1, ol2),
                      erifile,
                      dataname='ij',
                      intor='cint2e',
                      verbose=mf.verbose)
    blksize = max(1, int(512e6 / 16 / (nvir * nP * nvir))) * nvir
    run((os0, os2, os1, os2), 'cint2e_spsp1spsp2', 'ij', nocc * nvir, blksize)
    run((os0, os2, ol1, ol2), 'cint2e_spsp1', 'ij', nocc * nvir,
        blksize)  #ssll
    run((ol0, ol2, os1, os2), 'cint2e_spsp2', 'ij', nocc * nvir, blksize)

    r_outcore.general(mf.mol, (ol0, ol3, ol4, ol3),
                      erifile,
                      dataname='ia',
                      intor='cint2e',
                      verbose=mf.verbose)
    blksize = max(1, int(512e6 / 16 / (nN * nN * nN))) * nN
    run((os0, os3, os4, os3), 'cint2e_spsp1spsp2', 'ia', nocc * nN, blksize)
    run((os0, os3, ol4, ol3), 'cint2e_spsp1', 'ia', nocc * nN, blksize)
    run((ol0, ol3, os4, os3), 'cint2e_spsp2', 'ia', nocc * nN, blksize)
Example #4
0
 def run(mos, intor):
     r_outcore.general(mol, mos, erifile,
                       dataname='tmp', intor=intor)
     blksize = 400
     nij = mos[0].shape[1] * mos[1].shape[1]
     with h5py.File(erifile) as feri:
         for i0, i1 in lib.prange(0, nij, blksize):
             buf = feri[dataname][i0:i1]
             buf += feri['tmp'][i0:i1]
             feri[dataname][i0:i1] = buf
Example #5
0
 def run(mos, intor, dst, bound, blksize):
     logger.debug(mf, 'blksize = %d', blksize)
     r_outcore.general(mf.mol,
                       mos,
                       erifile,
                       dataname='tmp',
                       intor=intor,
                       verbose=mf.verbose)
     with h5py.File(erifile) as feri:
         for i0, i1 in prange(0, bound, blksize):
             logger.debug(mf, 'load %s %d', intor, i0)
             buf = feri[dst][i0:i1]
             buf += feri['tmp'][i0:i1]
             feri[dst][i0:i1] = buf
             buf = None
Example #6
0
'''
MO integral transformation for spinor integrals
'''

import h5py
from pyscf import gto
from pyscf import scf
from pyscf import lib
from pyscf.ao2mo import r_outcore

mol = gto.M(
    atom = '''
    O   0.   0.       0.
    H   0.   -0.757   0.587
    H   0.   0.757    0.587
    ''',
    basis = 'sto3g',
)

mf = scf.DHF(mol).run()

n4c, nmo = mf.mo_coeff.shape
n2c = n4c // 2
nNeg = nmo // 2
mo = mf.mo_coeff[:n2c,nNeg:]
r_outcore.general(mol, (mo, mo, mo, mo), 'llll.h5', intor='int2e_spinor')
with h5py.File('llll.h5', 'r') as f:
    print('Number of DHF molecular orbitals %s' % (nmo//2))
    print('MO integrals for large component orbitals. Shape = %s'
          % str(f['eri_mo'].shape))