コード例 #1
0
ファイル: compare_geos.py プロジェクト: chrinide/pts
def main(argv):
    format = None
    zmat = None

    while argv[0].startswith("--"):
        if argv[0] == '--format':
            format = argv[1]
            argv = argv[2:]
        elif argv[0] == '--zmatrix':
            __, zmat, v_name, __, __, __, __ = read_zmt_from_file(argv[1])
            argv = argv[2:]
        elif argv[0] == '--help':
            print __doc__
            return

    geo1 = read(argv[0], format=format)
    geos = [read(arg, format=format) for arg in argv[1:]]

    if zmat == None:
        fun = Cartesian()
    else:
        fun = ZMat(zmat)

    symbols = geo1.get_chemical_symbols()
    assert len(geos) > 0

    for geo in geos:
        assert geo.get_chemical_symbols() == symbols
        compare(geo1.get_positions(), geo.get_positions(), symbols, fun)
コード例 #2
0
ファイル: mmrism.py プロジェクト: alexei-matveev/bgy3d
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
コード例 #3
0
ファイル: mmrism.py プロジェクト: bo-li/bgy3d
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
コード例 #4
0
ファイル: read_inputs.py プロジェクト: chrinide/pts
def get_transformation(zmi, len_carts, zmt_format):
    # extract data from (several) zmatrices
    if zmt_format == "gx":
        datas = [read_zmt_from_gx(zm) for zm in zmi]
    elif zmt_format == "gauss":
        datas = [read_zmt_from_gauss(zm) for zm in zmi]
    else:
        datas = [read_zmt_from_file(zm) for zm in zmi]

    names, zmat, var_nums, mult, d_nums, size_sys, size_nums, size_carts, mask1 = restructure(
        datas)

    # decide if global positioning is needed
    # it is needed if there are more than one option, first one checks for
    # if there are cartesian coordinates
    with_globs = (len_carts > size_sys) or len(zmat) > 1
    # gx mask, only valid if gx's zmat is for complete system
    if with_globs:
        mask1 = None
    else:
        mask1 = mask1[0]

    # first only the zmatrix functions, allow multiple use of variables
    funcs = []
    quats = []

    # build function for every zmatrix
    for i, zm, va_nm, mul in zip(range(len(var_nums)), zmat, var_nums, mult):
        fun = ZMat(zm)

        # some variables are used several times
        if mul > 0:
            fun = With_equals(fun, va_nm)

        # global positioning needed
        if with_globs:
            fun = With_globals(fun)
            quats.append(True)
            # attention, this changes number of internal coordinates
            # belonging to this specific zmatrix
            size_nums[i] = size_nums[i] + 6
        else:
            quats.append(False)

        funcs.append(fun)

    # if not all variables are used up, the rest are in Cartesians
    if len_carts > size_sys:
        funcs.append(Cartesian())
        # there is also some need to specify their sizes
        size_nums.append(len_carts - size_sys)
        size_carts.append(len_carts - size_sys)
        quats.append(False)
        d_nums.append([])

    # how many atoms per single function
    # needed for Mergefuncs.pinv
    size_carts = [s / 3. for s in size_carts]

    # now merge the functions to one:
    if len(size_nums) > 1:
        func = Mergefuncs(funcs, size_nums, size_carts)
    else:
        # no need to merge a single function
        func = funcs[0]

    return func, d_nums, quats, size_nums, mask1
コード例 #5
0
ファイル: run3.py プロジェクト: alexei-matveev/bgy3d
        except:
            pass

command = "salloc -n16 mpirun ~/darcs/ttfs-mac/runqm"

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)
コード例 #6
0
ファイル: test_nc.py プロジェクト: chrinide/pts
    Function for generating starting values.  Use a mask to reduce the
    complete vector.
    """
    vec_red = []
    for i, m in enumerate(mask):
         if m:
             vec_red.append(vec[i])
    return asarray(vec_red)

if testfun == "zmat":
    """
    Zmatrix  description  with a  starting  values  for nice  symmetry
    behaviour. Lenth to be equal in C2V symmetry fullfil this at start
    to an accuracy of < 1e-15 Angstrom.
    """
    func = ZMat([(), (0,), (0, 1), (1, 2, 0)])

    min1 = [var1, var1, var3, var1, var3, var4]
    min2 = [var1, var1, var3, var1, var3, 2 * pi -var4]
    middle = [var1, var1, var3, var1, var3, var8]

elif testfun == "zmate":
    """
    Zmatrix and startingvalues as in zmat2. But in this case there are
    added some variables for global  orientation, set to zero on every
    position at start.
    """
    func1 = ZMat([(), (0,), (0, 1), (1, 2, 0)])
    func = With_globals(func1)

    min1 = [var1, var1, var3, var1, var3, var4, 0. ,0. ,0. ,0. ,0. ,0. ]
コード例 #7
0
        except:
            pass


command = "salloc -n16 mpirun ~/darcs/ttfs-mac/runqm"

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)