Ejemplo n.º 1
0
 def test_qr_R(self):
     A = init([[12, 6, -4], [-51, 167, 24], [4, -68, -41]])
     Q, R = A.qr()
     np.testing.assert_almost_equal(
         R, -init([[14, 0, 0], [21, 175, 0], [-14, -70, 35]])
     )
     np.testing.assert_almost_equal(A, Q * R)
Ejemplo n.º 2
0
 def test_qr_R(self):
     A = BlockDiagonalMatrix([3], [3])
     A.subblock[0] = init([[12, 6, -4], [-51, 167, 24], [4, -68, -41]])
     Q, R = A[0].qr()
     numpy.testing.assert_almost_equal(
         R, -init([[14, 0, 0], [21, 175, 0], [-14, -70, 35]]))
     numpy.testing.assert_almost_equal(A[0], Q * R)
Ejemplo n.º 3
0
    def setUp(self):
        n, _ = os.path.splitext(__file__)
        suppdir = n + ".d"
        self.ao2soint = os.path.join(suppdir, "AO2SOINT")

        self.dc = init([
           [ 2.10662148,    -0.44832042,     0.00000000,     0.10863721,     0.00000000,     -0.02702924,    -0.02702924],
           [-0.44832042,     1.97509195,    -0.00000000,    -0.61381008,     0.00000000,     -0.03765992,    -0.03765992],
           [ 0.00000000,    -0.00000000,     0.73437339,     0.00000000,     0.00000000,      0.54049192,    -0.54049192],
           [ 0.10863721,    -0.61381008,     0.00000000,     1.22749198,     0.00000000,      0.47809924,     0.47809924],
           [ 0.00000000,     0.00000000,     0.00000000,     0.00000000,     2.00000000,      0.00000000,     0.00000000],
           [-0.02702924,    -0.03765992,     0.54049192,     0.47809924,     0.00000000,      0.60856871,    -0.18702525],
           [-0.02702924,    -0.03765992,    -0.54049192,     0.47809924,     0.00000000,     -0.18702525,     0.60856871] 
        ])


        self.fcref = -init([
            [ 0.00000000,     0.00000000,     0.37936213,    -0.00000000,     0.00000000,      0.00253951,    -0.00253951],
            [-0.00000000,     0.00000000,     0.10878631,    -0.00000000,     0.00000000,     -0.01699688,     0.01699688],
            [-0.37936213,    -0.10878631,     0.00000000,   -11.60434639,     0.00000000,     -0.98565692,    -0.98565692],
            [ 0.00000000,     0.00000000,    11.60434639,     0.00000000,     0.00000000,      1.20385366,    -1.20385366],
            [ 0.00000000,     0.00000000,     0.00000000,     0.00000000,     0.00000000,      0.00000000,     0.00000000],
            [-0.00253951,     0.01699688,     0.98565692,    -1.20385366,     0.00000000,      0.00000000,    -0.36840521],
            [ 0.00253951,    -0.01699688,     0.98565692,     1.20385366,     0.00000000,      0.36840521,     0.00000000] 
        ])
Ejemplo n.º 4
0
Archivo: core.py Proyecto: vahtras/qcaf
 def lr_solve(self, ops="xyz", freqs=(0.), **kwargs):
     V1 = {op: v for op, v in zip(ops, self.get_rhs(*ops))}
     row_dim = V1[ops[0]].shape[0]
     E2 = full.init([self.e2n(i) for i in numpy.eye(row_dim)])
     S2 = full.init([self.s2n(i) for i in numpy.eye(row_dim)])
     solutions = {(op, freq): (V1[op] / (E2 - freq * S2))
                  for freq in freqs for op in ops}
     return solutions
Ejemplo n.º 5
0
 def setUp(self):
     Nod.S = init([[1.0, 0.1], [0.1, 1.0]])
     Nod.C = init([[0.7, 0.7], [0.7, -0.7]])
     self.alpha0 = Nod([0], [])
     self.alpha1 = Nod([1], [])
     self.beta0 = Nod([], [0])
     self.beta1 = Nod([], [1])
     self.ab00 = Nod([0], [0])
Ejemplo n.º 6
0
    def test_rephase_inplase(self):
        mat = init([[-1, 0], [0, 1]])
        none = mat.rephase_columns(inplace=True)

        assert none is None
        np.testing.assert_allclose(
            init([[-1, 0], [0, 1]]).rephase_columns(),
            init([[1, 0], [0, 1]])
        )
Ejemplo n.º 7
0
 def test_Dab(self):
     na = 2
     nb = 1
     C = full.unit(3)
     da, db = dens.C2Dab(C, na, nb)
     daref = full.init([[1.0, 0.0, 0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0]])
     dbref = full.init([[1.0, 0.0, 0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]])
     np.testing.assert_almost_equal(da, daref)
     np.testing.assert_almost_equal(db, dbref)
Ejemplo n.º 8
0
def test_new_trials1(mod, qcp):
    td = {0.5: np.array([2.5, 1.5, 1.5, 0.5])}
    residuals = {('op', 0.5): full.init([1, 1, 0, 0])}
    b = full.init([[1, 0, 0, 0], [0, 0, 1, 0]])
    new_trials = qcp.generate_new_trials(residuals, td, b)

    npt.assert_allclose(new_trials.T, [
        [0., 1, 0., 0.],
        [0., 0., 0., 1],
    ])
Ejemplo n.º 9
0
def main():
    import argparse

    parser = argparse.ArgumentParser()

    parser.add_argument("-H", "--head", dest="head", action="store_true")
    parser.add_argument("-i", "--isordk", dest="isordk", action="store_true")
    parser.add_argument("-s", "--scfinp", dest="scfinp", action="store_true")
    parser.add_argument("-v", "--verbose", dest="verbose", action="store_true")
    parser.add_argument("-u", "--unpack", dest="unpack", action="store_true")
    parser.add_argument("-o", "--savetxt", dest="savetxt")
    parser.add_argument("-l", "--label")
    # breakpoint()
    parser.add_argument("aooneint")

    args = parser.parse_args()

    if args.head:
        head = readhead(args.aooneint)
        print("Header on AOONEINT")
        for k in head:
            if type(head[k]) is float:
                print("%s %10.5f" % (k, head[k]))
            else:
                print("%s %s" % (k, head[k]))

    if args.isordk:
        isordk = readisordk(args.aooneint)
        n = isordk["nucdep"]
        chrn = isordk["chrn"]
        cooo = isordk["cooo"]
        mxcent = len(chrn)
        print("nucdep=%i" % n + " mxcent=%i" % mxcent)
        print(full.init(chrn)[:n])
        print(full.init(cooo).reshape((3, mxcent))[:, :n])

    if args.scfinp:
        scfinp = readscfinp(args.aooneint)
        for k in scfinp:
            if type(scfinp[k]) is float and k != "dummy":
                print("%s%10.6f" % (k, scfinp[k]))
            else:
                print(k + " " + str(scfinp[k]))

    if args.label is not None:
        s1 = read(label=args.label, filename=args.aooneint)
        if args.unpack:
            s2 = s1.unpack()
            S = s2.unblock()
        else:
            S = s1
        if args.verbose:
            print("%s %s" % (args.label, str(S)))
        if args.savetxt:
            np.savetxt(args.savetxt, S)
Ejemplo n.º 10
0
 def test_gram_schmidt(self):
     S = BlockDiagonalMatrix([2], [2])
     v = BlockDiagonalMatrix([2], [2])
     Delta = 0.1
     S.subblock[0] = init([[1.0, Delta], [Delta, 1.0]])
     v.subblock[0] = init([[1.0, 0.0], [0.0, 1.0]])
     u = v.GS(S)
     u_ref = init([
         [1.0, 0.0],
         [-Delta / math.sqrt(1 - Delta**2), 1.0 / math.sqrt(1 - Delta**2)],
     ])
     numpy.testing.assert_almost_equal(u[0], u_ref)
Ejemplo n.º 11
0
 def test_qr_Q(self):
     A = BlockDiagonalMatrix([3], [3])
     A.subblock[0] = init([[12, 6, -4], [-51, 167, 24], [4, -68, -41]])
     Q, R = A.qr()
     numpy.testing.assert_almost_equal(
         Q[0],
         -init([
             [6.0 / 7, 3.0 / 7, -2.0 / 7],
             [-69.0 / 175, 158.0 / 175, 6.0 / 35],
             [-58.0 / 175, 6.0 / 175, -33.0 / 35],
         ]),
     )
Ejemplo n.º 12
0
 def test_gram_schmidt(self):
     Delta = 0.1
     S = init([[1.0, Delta], [Delta, 1.0]])
     v = init([[1.0, 0.0], [0.0, 1.0]])
     u = v.GS(S)
     u_ref = init(
         [
             [1.0, 0.0],
             [-Delta/sqrt(1 - Delta**2), 1.0/sqrt(1 - Delta**2)]
         ]
     )
     np.testing.assert_almost_equal(u, u_ref)
Ejemplo n.º 13
0
 def test_qr_Q(self):
     A = init([[12, 6, -4], [-51, 167, 24], [4, -68, -41]])
     Q, R = A.qr()
     np.testing.assert_almost_equal(
         Q,
         -init(
             [
                 [6.0 / 7, 3.0 / 7, -2.0 / 7],
                 [-69.0 / 175, 158.0 / 175, 6.0 / 35],
                 [-58.0 / 175, 6.0 / 175, -33.0 / 35],
             ]
         ),
     )
Ejemplo n.º 14
0
 def test_gram_schmidt_as_transformation(self):
     Delta = 0.1
     S = init([[1.0, Delta], [Delta, 1.0]])
     v = init([[1.0, 0.0], [0.0, 1.0]])
     T = v.GST(S)
     u = v * T
     u_ref = init(
         [
             [1.0, 0.0],
             [-Delta/sqrt(1 - Delta**2), 1.0/sqrt(1 - Delta**2)]
         ]
     )
     np.testing.assert_almost_equal(u, u_ref)
Ejemplo n.º 15
0
def test_new_trials1(mod, qcp):
    td = {0.5: np.array([2.5, 1.5,  1.5, 0.5])}
    residuals = {('op', 0.5): full.init([1, 1, 0, 0])}
    b = full.init([[1, 0, 0, 0], [0, 0, 1, 0]])
    new_trials = qcp.generate_new_trials(residuals, td, b)


    npt.assert_allclose(new_trials.T, 
        [
            [0., 1, 0., 0.],
            [0., 0., 0., 1],
        ]
    )
Ejemplo n.º 16
0
    def setUp(self):
        """
        """
      
        VBTest.setUp(self, 'test_h2_c')
#
# Setup VB wave function
#
        Nod.C=full.init(
            [
                [0.7633862173, 0.3075441467, 
                0.0000000000, 0.0000000000, 0.0328937818, 
                0, 0, 0, 0, 0],
                [0, 0, 0, 0, 0, 
                0.7633862173, 0.3075441467,
                0.0000000000, 0.0000000000, -0.0328937818]
            ]
        )

        ion_a = Structure([Nod([0],[0])], [1.0])
        ion_b = Structure([Nod([1],[1])], [1.0])
        cov = Structure([Nod([0],[1]),Nod([1],[0])], [1.0, 1.0])
        self.WF=WaveFunctionND(
          [cov, ion_a, ion_b],[0.83675, 0.09850, 0.09850],
          tmpdir=self.tmpdir
          )
        self.WF.normalize()
Ejemplo n.º 17
0
 def test_rephase_copy(self):
     mat = init([[-1, 0], [0, 1]])
     mat2 = mat.rephase_columns()
     np.testing.assert_allclose(
         mat2,
         [[1, 0], [0, 1]],
     )
Ejemplo n.º 18
0
def read(*args, **kwargs):
    """Read property integral"""
    propfile = kwargs.get("filename")
    if not propfile:
        tmpdir = pathlib.Path(kwargs.get("tmpdir", "/tmp"))
        propfile = tmpdir / "AOPROPER"

    unpack = kwargs.get("unpack", True)
    AOPROPER = FortranBinary(propfile)
    mat = {}
    for rec in AOPROPER:
        buf = rec.read(32, "c")
        # stars, data, symtype, label = (
        #      buf[:8], buf[8:16], buf[16:24], buf[24:32]
        #      )
        b"".join(buf[:8])
        symtype = b"".join(buf[16:24])
        blabel = b"".join(buf[24:32]).strip()

        bargs = (s.encode() for s in args)
        if blabel.strip() in bargs:
            label = blabel.decode()
            rec = next(AOPROPER)
            buffer_ = rec.read(len(rec) // 8, "d")
            if symtype == b"SQUARE  ":
                n = int(round(math.sqrt(len(buffer_))))
                mat[label] = full.init(buffer_).reshape((n, n))
            else:
                mat[label] = np.array(buffer_).view(full.triangular)
                mat[label].anti = symtype == b"ANTISYMM"
    if unpack:
        return tuple([mat[lab].unpack() for lab in args])
    else:
        return tuple([mat[lab] for lab in args])
Ejemplo n.º 19
0
 def test_newton_step_with_update(self):
     x0 = [0.75133256,0.74762074, -0.69209032]
     self.pfg.x = x0
     dL = self.pfg.lagrangian_derivative()
     d2L = self.pfg.lagrangian_hessian()
     self.pfg.x = self.pfg.x - dL(x0, self.pfg)/d2L(x0, self.pfg)
     ref_x1 = full.init([0.70827179, 0.70834183, -0.70514972])
     numpy.testing.assert_allclose(self.pfg.x, ref_x1)
Ejemplo n.º 20
0
    def test_imag_polarizability_total(self):

        self.m.set_imag_pol()
        ref_Am = full.init([
            [1.228334, 0.000000, 0.000000],
            [0.000000, 1.228335, 0.000000],    
            [0.000000, 0.000000, 1.228333]])
        Am = self.m.Am[0]
        np.testing.assert_allclose(Am, ref_Am, rtol=1e-6, atol=1e-6)
Ejemplo n.º 21
0
    def test_h1diag(self):
        diref = full.init([
            [0.5370962, 0.33768834, 0.0],
            [0.33768834, 0.21231469, 0.0],
            [0.0, 0.0, 0.0],
        ])

        di, da = dens.h1diag(1, 1, filename=self.tmpdir / "AOONEINT")
        np.testing.assert_almost_equal(di, diref)
Ejemplo n.º 22
0
Archivo: core.py Proyecto: vahtras/vb
 def structure_weights(self):
     """
     Returns structure weights
     w_S = C(S) sum(T) <S|T>C(T)
     """
     SO = self.structure_overlap()
     C = full.init(self.coef)
     SOC = SO*C
     W = [c*sc for c, sc in zip(C, SOC)]
     return W
Ejemplo n.º 23
0
    def test_real_polarizability_total(self):

        self.m.set_real_pol()
        ref_Am = full.init([
            [30.854533, -0.000004,  0.000000],
            [-0.000004, 30.854527,  0.000000],    
            [ 0.000000,  0.000000, 30.854522]
            ])
        Am = self.m.Am[0]
        np.testing.assert_allclose(Am, ref_Am, rtol=1e-6, atol=1e-6)
Ejemplo n.º 24
0
    def test_imag_polarizability_total(self):

        self.m.set_imag_pol()
        ref_Am = full.init([
            [0.063679, -0.000000,  0.000000],
            [-0.000004, 0.063679,  0.000000],    
            [ 0.000000,  0.000000, 2.767574]
            ])
        Am = self.m.Am[0]
        np.testing.assert_allclose(Am, ref_Am, rtol=1e-5, atol=1e-5)
Ejemplo n.º 25
0
    def test_real_polarizability_total(self, mf):

        mf.set_real_pol()
        ref_Am = full.init([
            [30.854533, -0.000004, 0.000000],
            [-0.000004, 30.854527, 0.000000],
            [0.000000, 0.000000, 30.854522],
        ])
        Am = mf.Am[0]
        np.testing.assert_allclose(Am, ref_Am, rtol=1e-6, atol=1e-6)
Ejemplo n.º 26
0
    def test_real_polarizability_total(self):

        self.m.set_real_pol()
        ref_Am = full.init([
            [7.626564, 0.000000, 0.000000],
            [0.000000, 7.626564, 0.000000],    
            [0.000000, 0.000000,42.786381]
            ])
        Am = self.m.Am[0]
        np.testing.assert_allclose(Am, ref_Am, rtol=1e-5, atol=1e-5)
Ejemplo n.º 27
0
    def test_imag_polarizability_total(self, mf):

        mf.set_imag_pol()
        ref_Am = full.init([
            [1.228334, 0.000000, 0.000000],
            [0.000000, 1.228335, 0.000000],
            [0.000000, 0.000000, 1.228333],
        ])
        Am = mf.Am[0]
        np.testing.assert_allclose(Am, ref_Am, rtol=1e-6, atol=1e-6)
Ejemplo n.º 28
0
 def test_c1d(self):
     C = full.init(np.random.random((3, 2)).T)
     np.testing.assert_allclose(
         dens.C1D(C, 1),
         [
             [0.301196, 0.330805, 0.232507],
             [0.330805, 0.363324, 0.255364],
             [0.232507, 0.255364, 0.179483],
         ],
         atol=1e-6,
     )
Ejemplo n.º 29
0
 def __init__(self, p, f, g, *args, **kwargs):
     self.p = full.init(p)
     self.l = numpy.ones(len(kwargs['constraints']))
     Minimizer.__init__(
         self, 
         self.x, self.lagrangian(), g=self.lagrangian_derivative(),
         method=kwargs.get('method', 'BFGS'), constraints=())
     self.fp = f
     self.gp = g
     self.hp = kwargs.get('hessian', None)
     self.cp = kwargs['constraints']
Ejemplo n.º 30
0
    def test_imag_polarizability_total(self, molfrag):

        molfrag.set_imag_pol()
        ref_Am = full.init(
            [
                [0.063679, -0.000000, 0.000000],
                [-0.000004, 0.063679, 0.000000],
                [0.000000, 0.000000, 2.767574],
            ]
        )
        Am = molfrag.Am[0]
        np.testing.assert_allclose(Am, ref_Am, rtol=1e-5, atol=1e-5)
Ejemplo n.º 31
0
 def test_solver_start_covalent(self):
     start_covalent = full.init(
         [1.0, 0.1, 0.1] + [
             1., .1, 0., 0., 0.1, 0., 0., 0., 0., 0,
             0., 0., 0., 0., 0., 1., .1, 0., 0., -0.1
             ]
         )
     result = scipy.optimize.minimize(
         self.wf_energy, start_covalent, jac=self.wf_gradient, args=(self.wf),
         constraints=self.constraints, method='SLSQP'
     )
     self.assertAlmostEqual(result.fun, -1.14660543)
Ejemplo n.º 32
0
    def test_real_polarizability_total(self, molfrag):

        molfrag.set_real_pol()
        ref_Am = full.init(
            [
                [7.626564, 0.000000, 0.000000],
                [0.000000, 7.626564, 0.000000],
                [0.000000, 0.000000, 42.786381],
            ]
        )
        Am = molfrag.Am[0]
        np.testing.assert_allclose(Am, ref_Am, rtol=1e-5, atol=1e-5)
Ejemplo n.º 33
0
 def test_orbital_overlap(self):
     ref_overlap = full.init([
     [ 1.000000,  0.000000,   0.000000,   0.000000,   0.074261,  0.064405],
     [-0.000000,  1.000000,   0.000000,   0.000000,   0.214777,  0.361800],
     [ 0.000000,  0.000000,   1.000000,   0.000000,   0.000000,  0.000000],
     [ 0.000000,  0.000000,   0.000000,   1.000000,   0.000000,  0.000000],
     [ 0.074261,  0.214777,   0.000000,   0.000000,   1.000000, -0.419052],
     [ 0.064405,  0.361800,   0.000000,   0.000000,  -0.419052,  1.000000]
     ])
     self.wf.normalize_mo()
     overlap = self.wf.C.T*Nod.S*self.wf.C
     print(overlap); print(ref_overlap)
     np.testing.assert_allclose(overlap, ref_overlap, atol=1e-6)
Ejemplo n.º 34
0
    def setUp(self):
        """Setup supporting directory"""
        name, _ = os.path.splitext(__file__)
        self.suppdir = name + ".d"

        self.faref = init([
            [2.02818057, 0.26542036, 0.00000000, 0.06037429, 0.00000000, 0.00000000],
            [0.26542036, 0.74551226, 0.00000000, 0.28646605, 0.00000000, 0.00000000],
            [0.00000000, 0.00000000, 1.01061061, -0.47343699, 0.00000000, 0.00000000],
            [0.06037429, 0.28646605, -0.47343699, 0.86039561, 0.00000000, 0.00000000],
            [0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.01061061, 0.00000000],
            [0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.01061061],
            ])

        self.fbref = init([
            [2.07812203, 0.35828051, 0.00000000, 0.09571548, 0.00000000, 0.00000000],
            [0.35828051, 1.03607456, 0.00000000, 0.40151695, 0.00000000, 0.00000000],
            [0.00000000, 0.00000000, 1.07479494, -0.50700370, 0.00000000, 0.00000000],
            [0.09571548, 0.40151695, -0.50700370, 0.93374109, 0.00000000, 0.00000000],
            [0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.07479494, 0.00000000],
            [0.00000000, 0.00000000, 0.00000000, 0.00000000, 0.00000000, 1.07479494],
            ])
Ejemplo n.º 35
0
 def setUp(self):
     """Opimize x+y constrained to a circle"""
     # Initial values
     self.p0 = (1.0, 0.0)
     self.p1 = (SQRTH, SQRTH)
     self.l0 = (1.0,)
     self.l1 = (-SQRTH,)
     self.x0 = self.p0 + self.l0 # (p, l)
     self.x1 = self.p1 + self.l1 # (p, l)
     #
     self.f = lambda p: -(p[0] + p[1])
     self.g = lambda p: full.init((-1.0, -1.0))
     self.h = lambda p: full.matrix((2, 2))
     self.c = (
         {'type': 'eq',
          'fun': lambda p: p[0]**2 + p[1]**2  - 1.0,
          'jac': lambda p: full.init((2*p[0], 2*p[1])),
          'hes': lambda p: full.init([[2, 0], [0, 2]])
         },
         )
     self.pfg = LagrangianMinimizer(
         self.p0, self.f, self.g, hessian=self.h, constraints=self.c
         )
Ejemplo n.º 36
0
Archivo: core.py Proyecto: vahtras/vb
 def structure_hamiltonian(self):
     """Returns Hamiltonian matrix in basis of structures"""
     SH = []
     # Structures left
     for S in self.structs:
         for T in self.structs:
             #Determinants in left structure
             H = 0
             for K, CKS in zip(S.nods, S.coef):
                 for L, CLT in zip(T.nods, T.coef):
                     KL = BraKet(K, L)
                     H += CKS*CLT*(KL.energy((self.h, self.h)) + self.Z)*KL.overlap()
             SH.append(H)
     LS = len(self.structs)
     return full.init(SH).reshape((LS, LS))
Ejemplo n.º 37
0
Archivo: core.py Proyecto: vahtras/vb
    def __init__(self, nods, coef, normalize=True):
        if len(nods) != len(coef):
            raise StructError

        self.nods = nods
        self.assert_consistent_electron_number()

        self.coef = full.init(coef)
        #
        # Also have MOs as a structure member
        # In BOVB these are unique to a structure
        # reference the first determinant MO
        #
        self._C = nods[0].C

        if normalize:
            self.normalize()
Ejemplo n.º 38
0
Archivo: core.py Proyecto: vahtras/vb
 def __init__(self, structs, coef, VBSCF=True, tmpdir=None, blockdims=None):
     self.structs = structs
     self.coef = full.init(coef)
     if tmpdir is not None:
         self.tmpdir = tmpdir
         self.qcifc.set_workdir(tmpdir)
     self.Z = self.qcifc.get_nuclear_repulsion()
     self.h = self.qcifc.get_one_el_hamiltonian()
     BraKet.tmpdir = self.tmpdir
     BraKet.qcifc = self.qcifc
     #
     # For VBSCF all structures share orbitals
     #
     if VBSCF:
         self.C = Nod.C
     else:
         raise NotImplementedError
     self.blockdims = blockdims
Ejemplo n.º 39
0
    def setUp(self):
        self.tmp = os.path.join(os.path.dirname(__file__), 'test_h2_c')
        def tmp(fil):
            return os.path.join(self.tmp, fil)

        self.qcifc = QuantumChemistry.get_factory('Dalton', tmpdir=self.tmp)
        vb.Nod.tmpdir = self.tmp
        vb.Nod.C = full.matrix((10, 2))
        vb.Nod.C[0, 0] = 1.0
        vb.Nod.C[5, 1] = 1.0
        vb.Nod.S = self.qcifc.get_overlap()
        self.blockdims = ((5, 5), (1, 1))
        self.wf = vb.WaveFunction(
            [vb.Structure(
                [vb.Nod([0], [1]), vb.Nod([1], [0])],
                [1.0, 1.0]
                ),
             vb.Structure([vb.Nod([0], [0])], [1.0]),
             vb.Structure([vb.Nod([1], [1])], [1.0]),
            ],
            [1.0, 0.0, 0.0],
            tmpdir = self.tmp,
            blockdims=self.blockdims
        )

        # In this setup we have local expansions of mos, leading to a block diagonal C
        self.final = full.matrix(13)
        self.final_coef =[0.83675, 0.09850, 0.09850]
        self.final[:3] = self.final_coef
        self.final_C = full.init([
            [0.7633862173, 0.3075441467, 0.0, 0.0, 0.0328947818,0,0,0,0,0],
            [0,0,0,0,0, 0.7633862173, 0.3075441467, 0.0, 0.0, -0.0328947818]
            ])
        self.final[3:8] = self.final_C[:5, 0]
        self.final[8:13] = self.final_C[5:, 1]

        self.wf.normalize_structures()
        self.xfg = VBMinimizer(self.wf)
Ejemplo n.º 40
0
Archivo: core.py Proyecto: vahtras/vb
    def normgrad(self):
        """
        #  N = <0|0>
        # dN = 2<d0|0>
        """
        NGS = []
        r, c = Nod.C.shape
        n_orb_grad = full.matrix((r, c))
        #
        for S, CS in zip(self.structs, self.coef):
            GS = 0
            for T, CT in zip(self.structs, self.coef):
                GS += (S*T)*CT
                for K, CK in zip(S.nods, S.coef):
                    for L, CL in zip(T.nods, T.coef):
                        n_orb_grad += (CS*CT*CK*CL) * \
                            BraKet(K, L).right_overlap_gradient()
            NGS.append(GS)

        n_struct_grad = full.init(NGS)
        n_struct_grad *= 2
        n_orb_grad *= 2
        return (n_struct_grad, n_orb_grad[:, :])
Ejemplo n.º 41
0
Archivo: core.py Proyecto: vahtras/qcaf
 def setup_trials(self, vectors, td=None, b=None, renormalize=True):
     """
     Set up initial trial vectors from a set of intial guesses
     """
     trials = []
     for (op, freq), vec in vectors.items():
         if td is not None:
             v = vec / td[freq]
         else:
             v = vec
         if numpy.linalg.norm(v) > SMALL:
             trials.append(v)
             if freq > SMALL:
                 trials.append(swap(v))
     new_trials = full.init(trials)
     if b is not None:
         new_trials = new_trials - b * b.T * new_trials
     if trials and renormalize:
         t = get_transform(new_trials)
         truncated = new_trials * t
         S12 = (truncated.T * truncated).invsqrt()
         new_trials = truncated * S12
     return new_trials
Ejemplo n.º 42
0
from util.full import init

Z = [8.0, 1.0, 1.0]
Rc = init([0.00000000, 0.00000000, 0.48860959])
Dtot = [0, 0, -0.76539388]
Daa = init([
    [0.00000000, 0.00000000, -0.28357300],
    [0.15342658, 0.00000000, 0.12734703],
    [-0.15342658, 0.00000000, 0.12734703],
])
QUc = init([-7.31176220, 0.0, 0.0, -5.43243232, 0.0, -6.36258665])
QUN = init([4.38968295, 0.0, 0.0, 0.0, 0.0, 1.75400326])
QUaa = init([
    [
        -3.29253618, 0.00000000, 0.00000000, -4.54316657, 0.00000000,
        -4.00465380
    ],
    [
        -0.13213704, 0.00000000, 0.24980518, -0.44463288, 0.00000000,
        -0.26059139
    ],
    [
        -0.13213704, 0.00000000, -0.24980518, -0.44463288, 0.00000000,
        -0.26059139
    ],
])
Fab = init([
    [-0.11e-03, 0.55e-04, 0.55e-04],
    [0.55e-04, -0.55e-04, 0.16e-30],
    [0.55e-04, 0.16e-30, -0.55e-04],
])
Ejemplo n.º 43
0
 def test_unit(self):
     identity = init([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
     np.testing.assert_almost_equal(unit(3), identity)
Ejemplo n.º 44
0
 def test_struct_mo_propagated(self):
     ab = Structure([self.ab00], [1.0])
     ab.C = init([1,2,3,4])
     self.assertEqual(id(ab.C), id(ab.nods[0].C))
Ejemplo n.º 45
0
 def test_unit2(self):
     identity = init([[2, 0, 0], [0, 2, 0], [0, 0, 2]])
     np.testing.assert_almost_equal(unit(3, factor=2), identity)
Ejemplo n.º 46
0
def test_s2n_S():
    refs2 = matrix.diag([1, -1])
    s2 = init([oli.s2n(n, tmpdir=suppdir) for n in unit(2)])
    assert_(s2, refs2)
Ejemplo n.º 47
0
import os
from util.full import init

Z = [8., 1., 1.]
Rc = init([0.00000000,  0.00000000,  0.48860959])
Dtot = [0, 0, -0.76539388]
Daa = init([
    [ 0.00000000, 0.00000000, -0.28357300],
    [ 0.15342658, 0.00000000,  0.12734703],
    [-0.15342658, 0.00000000,  0.12734703],
])
QUc = init([-7.31176220, 0., 0., -5.43243232, 0., -6.36258665])
QUN = init([4.38968295, 0., 0., 0., 0., 1.75400326])
QUaa = init([
    [-3.29253618, 0.00000000, 0.00000000, -4.54316657, 0.00000000, -4.00465380],
    [-0.13213704, 0.00000000, 0.24980518, -0.44463288, 0.00000000, -0.26059139],
    [-0.13213704, 0.00000000,-0.24980518, -0.44463288, 0.00000000, -0.26059139]
])
Fab = init([
    [-0.11E-03,  0.55E-04,  0.55E-04],
    [ 0.55E-04, -0.55E-04,  0.16E-30],
    [ 0.55E-04,  0.16E-30, -0.55E-04]
    ])
Lab = init([
    [0.11E-03, 0.28E-03, 0.28E-03],
    [0.28E-03, 0.17E-03, 0.22E-03],
    [0.28E-03, 0.22E-03, 0.17E-03]
    ])
la = init([
[0.0392366,-27.2474016 , 27.2081650],
[0.0358964, 27.2214515 ,-27.2573479],
Ejemplo n.º 48
0
 def test_setup_initial_multiplier(self):
     self.pfg.x = full.init(self.p0 + self.l0)
     numpy.testing.assert_allclose(self.pfg.l, self.l0)
Ejemplo n.º 49
0
 def test_setup_final_multiplier(self):
     self.pfg.x = full.init(self.p1 + self.l1)
     numpy.testing.assert_allclose(self.pfg.l, self.l1)
Ejemplo n.º 50
0
 def test_setup_initial_function(self):
     self.pfg.x = full.init(self.p0 + self.l0)
     numpy.testing.assert_allclose(self.pfg.fp(self.pfg.p), -1.0)
Ejemplo n.º 51
0
 def x(self):
     _x = full.init(tuple(self.p) + tuple(self.l))
     return _x
Ejemplo n.º 52
0
def test_e2n_S():
    refe2 = init([[0.78643356, -0.50624296], [-0.50624296, 0.78643356]])
    e2 = [oli.e2n(n, tmpdir=suppdir) for n in unit(2)]
    assert_(e2, refe2)
Ejemplo n.º 53
0
 def test_svd(self):
     A = init([[1, 1, sqrt(3)], [-1, -1, 0]])
     u, s, v = A.svd()
     np.testing.assert_almost_equal(A, u * s * v.T)
Ejemplo n.º 54
0
 def test_dihedral_eclipsed(self):
     A = init([1, 1, 0])
     B = init([1, 0, 0])
     C = init([0, 0, 0])
     D = init([0, 1, 0])
     np.testing.assert_equal(A.dihedral(B, C, D), 0)
Ejemplo n.º 55
0
 def test_setup_initial_point(self):
     self.pfg.x = full.init(self.p0 + self.l0)
     numpy.testing.assert_allclose(self.pfg.p, self.p0)
Ejemplo n.º 56
0
def test_e2n_S():
    refe2 = init([[0.91587038, -0.00000000], [0.00000000, 0.91587038]])
    e2 = init([oli.e2n(n, tmpdir=suppdir) for n in unit(2)])
    assert_(e2, refe2)
Ejemplo n.º 57
0
 def test_minimize_from_final_plus_noise(self):
     self.pfg.x = full.init(self.p1 + self.l1) + 1e-4*numpy.random.random(3)
     self.pfg.minimize()
     numpy.testing.assert_allclose(self.pfg.p, self.p1, atol=1e-4)
Ejemplo n.º 58
0
 def test_setup_final_point(self):
     self.pfg.x = full.init(self.p1 + self.l1)
     numpy.testing.assert_allclose(self.pfg.p, self.p1)
Ejemplo n.º 59
0
Archivo: core.py Proyecto: vahtras/vb
 def structure_overlap(self):
     """Calculate structure overlap matrix"""
     return full.init([[s*t for t in self.structs] for s in self.structs])