예제 #1
0
파일: test_x2c.py 프로젝트: zzy2014/pyscf
    def test_get_hcore(self):
        myx2c = scf.RHF(mol).sfx2c1e()
        myx2c.with_x2c.get_xmat = lambda xmol: numpy.zeros((xmol.nao, xmol.nao))
        h1 = myx2c.with_x2c.get_hcore()
        ref = mol.intor('int1e_nuc')
        self.assertAlmostEqual(abs(h1 - ref).max(), 0, 12)

        with_x2c = x2c.X2C(mol)
        with_x2c.get_xmat = lambda xmol: numpy.zeros((xmol.nao_2c(), xmol.nao_2c()))
        h1 = with_x2c.get_hcore()
        ref = mol.intor('int1e_nuc_spinor')
        self.assertAlmostEqual(abs(h1 - ref).max(), 0, 12)
예제 #2
0
파일: test_x2c.py 프로젝트: pyscf/pyscf
    def test_lindep_xbasis(self):
        mol = gto.M(atom='C',
                    basis='''
C     S 
    0.823600000E+04    0.677199997E-03
    0.123500000E+04    0.427849998E-02
    0.280800000E+03    0.213575999E-01
    0.792700000E+02    0.821857997E-01
    0.255900000E+02    0.235071499E+00
    0.899700000E+01    0.434261298E+00
    0.331900000E+01    0.345733299E+00
    0.905900000E+00    0.392976999E-01
    0.364300000E+00   -0.895469997E-02
    0.128500000E+00    0.237739999E-02
C     S 
    0.823600000E+04   -0.144499989E-03
    0.123500000E+04   -0.915599933E-03
    0.280800000E+03   -0.460309966E-02
    0.792700000E+02   -0.182283987E-01
    0.255900000E+02   -0.558689959E-01
    0.899700000E+01   -0.126988891E+00
    0.331900000E+01   -0.170104988E+00
    0.905900000E+00    0.140976590E+00
    0.364300000E+00    0.598675956E+00
    0.128500000E+00    0.394868571E+00
C     S 
    0.905900000E+00    0.100000000E+01
C     S 
    0.128500000E+00    0.100000000E+01
C     P 
    0.187100000E+02    0.140738004E-01
    0.413300000E+01    0.869016023E-01
    0.120000000E+01    0.290201608E+00
    0.382700000E+00    0.500903913E+00
    0.120900000E+00    0.343523809E+00
C     P 
    0.382700000E+00    0.100000000E+01
C     P 
    0.120900000E+00    0.100000000E+01
C     D 
    0.109700000E+01    0.100000000E+01
C     D 
    0.318000000E+00    0.100000000E+01
C     F 
    0.761000000E+00    0.100000000E+01
''')
        xmol, c = x2c.X2C(mol).get_xmol(mol)
        self.assertEqual(xmol.nbas, 18)
        self.assertEqual(xmol.nao, 42)
        self.assertAlmostEqual(lib.fp(c), -5.480689638416739, 12)
예제 #3
0
def writeSOCIntegrals(mc,
                      ncasorbs=None,
                      rdm1=None,
                      pictureChange1e="bp",
                      pictureChange2e="bp",
                      uncontract=True):
    from pyscf.x2c import x2c, sfx2c1e
    from pyscf.lib.parameters import LIGHT_SPEED
    LIGHT_SPEED = 137.0359895000
    alpha = 1.0 / LIGHT_SPEED

    if (uncontract):
        xmol, contr_coeff = x2c.X2C().get_xmol(mc.mol)
    else:
        xmol, contr_coeff = mc.mol, numpy.eye(mc.mo_coeff.shape[0])

    rdm1ao = rdm1
    if (rdm1 is None):
        rdm1ao = 1. * mc.make_rdm1()
    if len(rdm1ao.shape) > 2: rdm1ao = (rdm1ao[0] + rdm1ao[1])

    if (uncontract):
        dm = reduce(numpy.dot, (contr_coeff, rdm1ao, contr_coeff.T))
    else:
        dm = 1. * rdm1ao
    np, nc = contr_coeff.shape[0], contr_coeff.shape[1]

    hso1e = numpy.zeros((3, np, np))
    h1e_1c, x, rp = sfx2c1e.SpinFreeX2C(mc.mol).get_hxr(mc.mol,
                                                        uncontract=uncontract)

    #two electron terms
    if (pictureChange2e == "bp"):
        h2ao = -(alpha)**2 * 0.5 * xmol.intor(
            'cint2e_p1vxp1_sph', comp=3, aosym='s1')
        h2ao = h2ao.reshape(3, np, np, np, np)
        hso1e += 1. * (numpy.einsum('ijklm,lm->ijk', h2ao, dm) - 1.5 *
                       (numpy.einsum('ijklm, kl->ijm', h2ao, dm) +
                        numpy.einsum('ijklm,mj->ilk', h2ao, dm)))
    elif (pictureChange2e == "x2c"):
        dm1 = dm / 2.
        pLL, pLS, pSS = get_p(dm1, x, rp)
        #kint = get_kint(xmol)
        #hso1e += -(alpha)**2*0.5*get_fso2e_withkint(kint,x,rp,pLL,pLS,pSS)
        hso1e += -(alpha)**2 * 0.5 * get_fso2e(xmol, x, rp, pLL, pLS, pSS)
    elif (pictureChange2e == "none"):
        hso1e *= 0.0
    else:
        print(pictureChane2e, "not a valid option")
        exit(0)

    #MF 1 electron term
    if (pictureChange1e == "bp"):
        hso1e += (alpha)**2 * 0.5 * get_wso(xmol)
    elif (pictureChange1e == "x2c1"):
        dm /= 2.
        pLL, pLS, pSS = get_p(dm, x, rp)
        wso = (alpha)**2 * 0.5 * get_wso(xmol)
        hso1e += get_hso1e(wso, x, rp)
    elif (pictureChange1e == "x2cn"):
        h1e_2c = x2c.get_hcore(xmol)

        for i in range(np):
            for j in range(np):
                if (abs(h1e_2c[2 * i, 2 * j + 1].imag) > 1.e-8):
                    hso1e[0][i, j] -= h1e_2c[2 * i, 2 * j + 1].imag * 2.
                if (abs(h1e_2c[2 * i, 2 * j + 1].real) > 1.e-8):
                    hso1e[1][i, j] -= h1e_2c[2 * i, 2 * j + 1].real * 2.
                if (abs(h1e_2c[2 * i, 2 * j].imag) > 1.e-8):
                    hso1e[2][i, j] -= h1e_2c[2 * i, 2 * j].imag * 2.
    else:
        print(pictureChane1e, "not a valid option")
        exit(0)

    h1ao = numpy.zeros((3, nc, nc))
    if (uncontract):
        for ic in range(3):
            h1ao[ic] = reduce(numpy.dot,
                              (contr_coeff.T, hso1e[ic], contr_coeff))
    else:
        h1ao = 1. * hso1e

    ncore, ncas = mc.ncore, mc.ncas
    if (ncasorbs is not None):
        ncas = ncasorbs
    mo_coeff = mc.mo_coeff
    h1 = numpy.einsum('xpq,pi,qj->xij', h1ao, mo_coeff,
                      mo_coeff)[:, ncore:ncore + ncas, ncore:ncore + ncas]
    print1Int(h1, 'SOC')
예제 #4
0
'''

from pyscf import lib
from pyscf import gto
from pyscf.x2c import x2c, sfx2c1e

mol = gto.M(
    verbose=0,
    atom='''8  0  0.     0
              1  0  -0.757 0.587
              1  0  0.757  0.587''',
    basis='ccpvdz',
)

# Transform operator 1/|r-R_O|
x2cobj = x2c.X2C(mol)
with mol.with_rinv_origin((0., 0., 0.)):
    # Pass the integral names to the function picture_change
    even_operator = ('int1e_rinv_spinor', 'int1e_sprinvsp_spinor')
    v = x2cobj.picture_change(even_operator)
    print(v.shape)

# Transform dipole operator r
x2cobj = x2c.X2C(mol)
with mol.with_common_orig((0., 0., 0.)):
    # Function picture_change also supports operators in matrix representation
    c = lib.param.LIGHT_SPEED
    xmol = x2cobj.get_xmol()[0]
    rLL = xmol.intor('int1e_r_spinor')
    rSS = xmol.intor('int1e_sprsp_spinor') * (.5 / c)**2
    even_operator = (rLL, rSS)