Пример #1
0
def test__struct_check():
    """ test geom.is_atom
        test geom.is_linear
    """

    assert geom.is_atom(H_GEO)
    assert not geom.is_atom(C2H2CLF_GEO)

    assert not geom.is_linear(H_GEO)
    assert geom.is_linear(H2_GEO)
    assert not geom.is_linear(C2H2CLF_GEO)
    assert geom.is_linear(HCCH_GEO)
Пример #2
0
def format_coords(geo):
    """ format the coords section
    """

    # Get the number of atoms
    natoms = len(geo)

    # Get the geometry information
    symbols = geom.symbols(geo)
    coordinates = geom.coordinates(geo)
    masses = geom.masses(geo)
    print(masses)

    # Build a string with the formatted coordinates string
    if geom.is_atom(geo):
        geo_str = '{0:<4s}{1:<6d}'.format(symbols[0], masses[0])
    else:
        geo_str = '{0} \n'.format(str(natoms))
        for symbol, mass, coords in zip(symbols, masses, coordinates):
            coords = [coord * phycon.BOHR2ANG for coord in coords]
            coords_str = '{0:>14.8f}{1:>14.8f}{2:>14.8f}'.format(
                coords[0], coords[1], coords[2])
            geo_str += '{0:<4s}{1:<6.0f}{2}\n'.format(symbol, mass, coords_str)
        # Remove final newline character from the string
        geo_str = geo_str.rstrip()

    return natoms, geo_str
Пример #3
0
def format_coords(geo):
    """ format the coords section
    """

    # Get the number of atoms
    natoms = len(geo)

    # Get the geometry information
    symbs = geom.symbols(geo)
    coords = geom.coordinates(geo)
    masses = tuple(round(mass) for mass in geom.masses(geo))

    # Build a string with the formatted coordinates string
    if geom.is_atom(geo):
        geo_str = f'{symbs[0]:<4s}{masses[0]:<6d}'
    else:
        geo_str = f'{str(natoms)} \n'
        for symb, mass, xyzs in zip(symbs, masses, coords):
            _xyzs = [x * phycon.BOHR2ANG for x in xyzs]
            xyzs_str = f'{_xyzs[0]:>14.8f}{_xyzs[1]:>14.8f}{_xyzs[2]:>14.8f}'
            geo_str += f'{symb:<4s}{mass:<6.0f}{xyzs_str}\n'
        # Remove final newline character from the string
        geo_str = geo_str.rstrip()

    return natoms, geo_str
Пример #4
0
def determine_struct_type(geo):
    """ determines the linear string
    """

    # Remove dummy atoms
    geo = [coords for coords in geo if coords[0] != 'X']

    if geom.is_atom(geo):
        struct_type = 'Monoatomic'
    else:
        if geom.is_linear(geo):
            struct_type = 'Linear'
        else:
            struct_type = 'Nonlinear'

    return struct_type