Пример #1
0
def test__from_data():
    """ test vmatrix.from_data
    """
    vma = vmatrix.from_data(
        syms=vmatrix.symbols(CH4O_VMA),
        key_mat=vmatrix.key_matrix(CH4O_VMA),
        name_mat=vmatrix.name_matrix(CH4O_VMA),
    )
    assert vma == CH4O_VMA
Пример #2
0
def string(zma):
    """ write a z-matrix to a string
    """
    zma_str = aw.zmatrix.write(
        syms=_v_.symbols(var_(zma)),
        key_mat=_v_.key_matrix(var_(zma), shift=1),
        name_mat=_v_.name_matrix(var_(zma)),
        val_dct=values(zma, angstrom=True, degree=True)
    )
    return zma_str
Пример #3
0
def string(zma, one_indexed=True, angstrom=True, degree=True):
    """ write a z-matrix to a string
    """
    shift = 1 if one_indexed else 0
    zma_str = aw.zmatrix.write(
        syms=_v_.symbols(var_(zma)),
        key_mat=_v_.key_matrix(var_(zma), shift=shift),
        name_mat=_v_.name_matrix(var_(zma)),
        val_dct=values(zma, angstrom=angstrom, degree=degree)
    )
    return zma_str
Пример #4
0
def set_values(zma, val_dct):
    """ set coordinate values for the z-matrix
    """
    vma = var_(zma)
    _names = _v_.names(vma)
    assert set(val_dct.keys()) <= set(_names)

    new_val_dct = values(zma).copy()
    new_val_dct.update(val_dct)
    return automol.create.zmatrix.from_data(
        _v_.symbols(vma), _v_.key_matrix(vma), _v_.name_matrix(vma),
        new_val_dct)
Пример #5
0
def set_names(zma, name_dct):
    """ set coordinate names for the z-matrix
    """
    orig_vma = var_(zma)
    vma = _v_.set_names(orig_vma, name_dct)
    name_mat = _v_.name_matrix(vma)

    name_dct = dict(zip(numpy.ravel(_v_.name_matrix(orig_vma)),
                        numpy.ravel(name_mat)))
    val_dct = {name_dct[orig_name]: val
               for orig_name, val in values(zma).items()}

    return automol.create.zmatrix.from_data(
        _v_.symbols(vma), _v_.key_matrix(vma), name_mat, val_dct)
Пример #6
0
def is_valid(zma):
    """ is this a valid zmatrix?
    """
    ret = hasattr(zma, '__len__') and len(zma) == 2
    if ret:
        vma, val_dct = zma
        ret = _v_.is_valid(vma) and set(_v_.names(vma)) == set(val_dct)
        if ret:
            try:
                automol.create.zmatrix.from_data(
                    _v_.symbols(vma), _v_.key_matrix(vma),
                    _v_.name_matrix(vma), val_dct)
            except AssertionError:
                ret = False
    return ret
Пример #7
0
def from_geometry(vma, geo):
    """ determine z-matrix from v-matrix and geometry
    """
    assert _v_.symbols(vma) == automol.geom.symbols(geo)
    val_dct = {}
    coo_dct = _v_.coordinates(vma, multi=False)
    dist_names = _v_.distance_names(vma)
    cent_names = _v_.central_angle_names(vma)
    dih_names = _v_.dihedral_angle_names(vma)
    for name, coo in coo_dct.items():
        if name in dist_names:
            val_dct[name] = automol.geom.distance(geo, *coo)
        elif name in cent_names:
            val_dct[name] = automol.geom.central_angle(geo, *coo)
        elif name in dih_names:
            val_dct[name] = automol.geom.dihedral_angle(geo, *coo)

    zma = automol.create.zmatrix.from_data(
        symbols=_v_.symbols(vma), key_matrix=_v_.key_matrix(vma),
        name_matrix=_v_.name_matrix(vma), values=val_dct)
    return zma
Пример #8
0
def key_matrix(zma, shift=0):
    """ coordinate atom keys, by z-matrix row and column
    """
    return _v_.key_matrix(var_(zma), shift=shift)