Example #1
0
def s2n(N, tmpdir='/tmp', Sg=1, Sv=1):
    """
    S[2]*N linear transformation:
    <[q,k]> = <[E(Sg)_{ij}, k_{kl}, E(Sv)_{kl}]> = 
            = k_{kl} [E_{il}d(kj) - E(kj)d(il)]
            = k(jl)E(SgSv)(il) - k(ki)E(SgSv)(kj)
            = D(SgSv)k.T(ij) - k.TD(SgSv)(ij)
            = [D(SgSv), k.T](ij)
    """


    SIRIFC = os.path.join(tmpdir, 'SIRIFC')
    AOONEINT = os.path.join(tmpdir, 'AOONEINT')
    AOTWOINT = os.path.join(tmpdir, 'AOTWOINT')
    LUINDF = os.path.join(tmpdir, 'LUINDF')

    ifc = sirifc.sirifc(SIRIFC)
    cmo = ifc.cmo.unblock()

    S = one.read('OVERLAP',  filename=AOONEINT).unblock().unpack()

    da, db = dens.Dab(SIRIFC)

    kN = rspvec.tomat(N, ifc, tmpdir=tmpdir).T
    kn = cmo*kN*cmo.T

    dak = (kn.T*S*da - da*S*kn.T)
    dbk = (kn.T*S*db - db*S*kn.T)*Sv

    gv = -rspvec.tovec(cmo.T*S*(dak+Sg*dbk)*S*cmo, ifc)

    return gv
Example #2
0
 def test_tovec(self):
     Nx = rspvec.read("XDIPLEN", propfile=self.RSPVEC)["XDIPLEN"]
     kx = rspvec.tomat(Nx, self.ifc, tmpdir=self.tmpdir)
     Nx = rspvec.tovec(kx, self.ifc, tmpdir=self.tmpdir)
     this = Nx[44]
     ref = 0.75732690
     assert this == approx(ref)
Example #3
0
def e2n(N, tmpdir='/tmp', hfx=1, Sg=1, Sv=1):
    """
    E[2]*N linear transformation:

     [k,F] = [k(pq)E(Sv)(pq), F(rs)E(rs)]
           = k(pq)F(rs) (E(ps)d(rq) - E(rq)d(ps))
           = k(pq)F(ps)E(ps) - k(pq)F(rp)E(rq)
           = [k,F](pq)E(pq)
           = kF
    <[q,kF]> = <[E_{pq}, kF(rs)E(rs)]>
             = kF(rs) <E(ps)d(rq) - E(rq)d(ps)>
             = kF(qs)D(ps) - kF(rp)D(rq)
             = [D, kF.T](pq)
    kD = <[k, E(pq)]>
       = <[k(rs) E(rs), E(pq)]>
       = k(rs) (E(rq)d(ps) - E(ps)d(rq))
       = k(rp)D(rq) - k(qs)D(ps)
       = [k.T, D](p,q)
    Fk = F[kD]
    """

    SIRIFC = os.path.join(tmpdir, 'SIRIFC')
    AOONEINT = os.path.join(tmpdir, 'AOONEINT')
    AOTWOINT = os.path.join(tmpdir, 'AOTWOINT')
    LUINDF = os.path.join(tmpdir, 'LUINDF')

    ifc = sirifc.sirifc(SIRIFC)
    cmo = get_cmo(AOONEINT, SIRIFC)

    h = one.read('ONEHAMIL', filename=AOONEINT).unblock().unpack()
    S = one.read('OVERLAP',  filename=AOONEINT).unblock().unpack().view(util.full.matrix)

    da, db = get_densities(SIRIFC)

    kN = rspvec.tomat(N, ifc, tmpdir=tmpdir).view(util.full.matrix).T
    kn = (cmo*kN*cmo.T).view(util.full.matrix)

    dak = (kn.T*S*da - da*S*kn.T)
    dbk = (kn.T*S*db - db*S*kn.T)*Sv


    (fa, fb), = two.fockab((da, db),  filename=AOTWOINT, hfx=hfx)
    fa += h; fb += h
    (fak, fbk), = two.fockab((dak, dbk), filename=AOTWOINT, hfx=hfx)

    kfa = (S*kn*fa - fa*kn*S)
    kfb = (S*kn*fb - fb*kn*S)*Sv

    fa = fak + kfa
    fb = fbk + kfb

    gao = S*(da*fa.T + Sg*db*fb.T) - (fa.T*da + Sg*fb.T*db)*S
    gm = cmo.T*gao*cmo

    # sign convention <[q,[k,F]]> = -E[2]*N
    gv = - rspvec.tovec(gm, ifc)

    return gv
Example #4
0
    def setUp(self):
        n, e = os.path.splitext(__file__)
        self.suppdir = n + ".d"

        self.A = "XDIPLEN"
        self.B = "YDIPLEN"
        self.C = "XDIPLEN"

        AOONEINT = os.path.join(self.suppdir, 'AOONEINT')
        S = one.read(label="OVERLAP", filename=AOONEINT).unblock().unpack()

        SIRIFC = os.path.join(self.suppdir, 'SIRIFC')
        self.ifc = sirifc.sirifc(SIRIFC)
        cmo = self.ifc.cmo.unblock()
        da, db = dens.Dab(ifc_=self.ifc)
        self.D = cmo.T * S * (da + db) * S * cmo

        RSPVEC = os.path.join(self.suppdir, 'RSPVEC')
        rspvecs = rspvec.read(self.A, self.B, self.C, propfile=RSPVEC)
        self.NA = rspvecs[(self.A, 0)]
        self.NB = rspvecs[(self.B, 0)]
        self.NC = rspvecs[(self.C, 0)]

        self.kA = rspvec.tomat(self.NA, self.ifc, tmpdir=self.suppdir)
        self.kB = rspvec.tomat(self.NB, self.ifc, tmpdir=self.suppdir).T
        self.kC = rspvec.tomat(self.NC, self.ifc, tmpdir=self.suppdir).T

        AOPROPER = os.path.join(self.suppdir, 'AOPROPER')
        #a, b, c = [cmo.T*x*cmo for x in prop.read(A, B, C, filename=AOPROPER, unpack=True)]
        global pmat
        pmat = prop.read(self.A,
                         self.B,
                         self.C,
                         filename=AOPROPER,
                         unpack=True)
        self.a, self.b, self.c = [cmo.T * x * cmo for x in pmat]
Example #5
0
def a2bc(A, B, C):

    AOONEINT = os.path.join(tmp, "AOONEINT")
    AOPROPER = os.path.join(tmp, "AOPROPER")
    RSPVEC   = os.path.join(tmp, "RSPVEC")
    SIRIFC   = os.path.join(tmp, "SIRIFC")

    NB = rspvec.read(B, RSPVEC)
    NC = rspvec.read(C, RSPVEC)

    ifc = sirifc.sirifc(SIRIFC)
    cmo = ifc.cmo.unblock()
    dc,do = dens.ifc(ifc=ifc)
    d = dc+do
    a = cmo.T*prop.read(A, AOPROPER).unpack()*cmo
    kB = rspvec.tomat(NB, ifc, tmpdir = tmp).T
    kC = rspvec.tomat(NC, ifc, tmpdir = tmp).T

    S = one.read(label = "OVERLAP", filename = AOONEINT).unblock().unpack()
    D = cmo.T*S*d*S*cmo
    A2B = (.5*(kC^(kB^a))&D)
    A2C = (.5*(kB^(kC^a))&D)

    return A2B + A2C
Example #6
0
def main(*args, **kwargs):

    labs = args
    tmpdir = kwargs.get("tmpdir", ".")
    ranks = kwargs.get('rank', (0, 0, 0))
    pars = [ (-1)**r for r in ranks]

    ifc = sirifc.sirifc(os.path.join(tmpdir, "SIRIFC"))
    cmo = ifc.cmo.unblock()

    AOONEINT = os.path.join(tmpdir, "AOONEINT")
    AOPROPER = os.path.join(tmpdir, "AOPROPER")
    RSPVEC   = os.path.join(tmpdir, "RSPVEC")

    vecs = rspvec.read(*labs, propfile=RSPVEC)[0]
    kappa = [rspvec.tomat(vec, ifc).T for vec in vecs]
    kappa[0] = kappa[0].T
    a, b, c = [cmo.T*x*cmo for x in prop.read(*labs, filename=AOPROPER)]

    NA = vecs[0]
    kA, kB, kC = kappa
    pA, pB, pC = [{ "lab":lab, "rank":rank, 'kappa':k} for lab, rank, k in zip(labs, ranks, kappa)]

    da, db = dens.Dab(ifc_=ifc)
    d = da + db
    
    S = one.read(label = "OVERLAP", filename = AOONEINT).unblock().unpack()
    D = cmo.T*S*d*S*cmo

    E3BC = E3(pB, pC, ifc, tmpdir=tmpdir)
    AE3BC = -NA&E3BC
    B2C = (-(kA^(kC^b))&D)
    C2B = (-(kA^(kB^c))&D)
    A2B = (.5*(kC^(kB^a))&D)
    A2C = (.5*(kB^(kC^a))&D)
    #print "E3BC",E3BC
    val = AE3BC
    print("E3  %14.8f %14.8f" % (AE3BC, val))
    val += B2C
    print("B2C %14.8f %14.8f" % (B2C, val))
    val += C2B
    print("C2B %14.8f %14.8f" % (C2B, val))
    val += A2B
    print("A2B %14.8f %14.8f" % (A2B, val))
    val += A2C
    print("A2C %14.8f %14.8f" % (A2C, val))
    
    return val
Example #7
0
 def vec2mat(self, vec):
     ifc = self._sirifc()
     mat = rspvec.tomat(vec, ifc)
     return mat
Example #8
0
 def test_tovec(self):
     ref = rspvec.read("XDIPLEN", propfile=self.RSPVEC)["XDIPLEN"]
     kx = rspvec.tomat(ref, self.ifc, tmpdir=self.tmpdir)
     this = rspvec.tovec(kx, self.ifc, tmpdir=self.tmpdir)
     np.testing.assert_almost_equal(this, ref)
Example #9
0
 def test_tomat(self):
     Nx = rspvec.read("XDIPLEN", propfile=self.RSPVEC)["XDIPLEN"]
     kx = rspvec.tomat(Nx, self.ifc, tmpdir=self.tmpdir)
     this = kx[5, 7]
     ref = -2.34009730
     assert this == approx(ref)