Ejemplo n.º 1
0
def make_uranyl (x, flexible=6):
    """
    Return the "best" linear approximation to the uranyl geometry as a
    Fixed() func.
    """
    from pts.zmat import ZMat

    # Make uranyl linear:
    zmt = ZMat ([(None, None, None),
                 (1, None, None),
                 (1, 2, None)], base=1)

    # Bond length and the bond angle for uranyl, use the same Z-matrix
    # for uranyl:
    s = zmt.pinv (x)

    # Set the bond  lengths equal and 180 degrees  angle. Note that if
    # you plug these internal variables into z-matrix you will not get
    # zmt(s) ~  x even when s was  derived from x. That  is because of
    # the default orientation z-matrix chooses:
    s_bond = 1.79 # A or sum (s[:2]) / 2
    s = [s_bond, s_bond, pi]

    # Uranyl  may or  may not  be  fixed, but  to adjust  orientation,
    # rotate a rigid object:
    Y = Rigid (zmt (s))
    y = Y (Y.pinv (x))

    if flexible == 0:
        return Fixed (y)    # 0 dof
    elif flexible == 2:
        # liear uranyl with flexible bonds:
        def f (x):
            ra, rb = x
            return array ([[0., 0., 0.],
                           [0., 0., ra],
                           [0., 0., -rb]])
        return Affine (f, array ([0., 0.])) # 2 dof
    elif flexible == 6:
        # return Move (relate (x, zmt (s)), zmt)
        return ManyBody (Fixed (x[0:1]), Cartesian (x[1:3]), dof=[0, 6])
    else:
        assert False
Ejemplo n.º 2
0
def make_uranyl(x, flexible=6):
    """
    Return the "best" linear approximation to the uranyl geometry as a
    Fixed() func.
    """
    from pts.zmat import ZMat

    # Make uranyl linear:
    zmt = ZMat([(None, None, None), (1, None, None), (1, 2, None)], base=1)

    # Bond length and the bond angle for uranyl, use the same Z-matrix
    # for uranyl:
    s = zmt.pinv(x)

    # Set the bond  lengths equal and 180 degrees  angle. Note that if
    # you plug these internal variables into z-matrix you will not get
    # zmt(s) ~  x even when s was  derived from x. That  is because of
    # the default orientation z-matrix chooses:
    s_bond = 1.79  # A or sum (s[:2]) / 2
    s = [s_bond, s_bond, pi]

    # Uranyl  may or  may not  be  fixed, but  to adjust  orientation,
    # rotate a rigid object:
    Y = Rigid(zmt(s))
    y = Y(Y.pinv(x))

    if flexible == 0:
        return Fixed(y)  # 0 dof
    elif flexible == 2:
        # liear uranyl with flexible bonds:
        def f(x):
            ra, rb = x
            return array([[0., 0., 0.], [0., 0., ra], [0., 0., -rb]])

        return Affine(f, array([0., 0.]))  # 2 dof
    elif flexible == 6:
        # return Move (relate (x, zmt (s)), zmt)
        return ManyBody(Fixed(x[0:1]), Cartesian(x[1:3]), dof=[0, 6])
    else:
        assert False
Ejemplo n.º 3
0
atoms = read ("h2o.xyz")

x = atoms.get_positions ()

#
# Z-matrix for water:
#
zmt = ZMat ([(None, None, None),
             (1, None, None),
             (1, 2, None)], base=1)

#
# Initial values of internal coordinates:
#
s = zmt.pinv (x)
assert max (abs (s - zmt.pinv (zmt (s)))) < 1.0e-10

clean ()

with QFunc (atoms, calc) as f:
    f = Memoize (f, DirStore (salt="h2o, qm"))
    e = compose (f, zmt)

    print s, e (s)
    s, info = minimize (e, s, algo=1, ftol=1.0e-2, xtol=1.0e-2)
    print s, e (s), info["converged"]

#
# Internal coordinates:
#
Ejemplo n.º 4
0
calc = ParaGauss(cmdline=command, input="water.scm")

atoms = read("h2o.xyz")

x = atoms.get_positions()

#
# Z-matrix for water:
#
zmt = ZMat([(None, None, None), (1, None, None), (1, 2, None)], base=1)

#
# Initial values of internal coordinates:
#
s = zmt.pinv(x)
assert max(abs(s - zmt.pinv(zmt(s)))) < 1.0e-10

clean()

with QFunc(atoms, calc) as f:
    f = Memoize(f, DirStore(salt="h2o, qm"))
    e = compose(f, zmt)

    print s, e(s)
    s, info = minimize(e, s, algo=1, ftol=1.0e-2, xtol=1.0e-2)
    print s, e(s), info["converged"]

#
# Internal coordinates:
#