Example #1
0
def symmetrize_compact_force_constants(force_constants, primitive, level=1):
    """Symmetry force constants by translational and permutation symmetries.

    Parameters
    ----------
    force_constants: ndarray
        Compact force constants. Symmetrized force constants are overwritten.
        dtype=double
        shape=(n_patom,n_satom,3,3)
    primitive: Primitive
        Primitive cell
    level: int
        Controls the number of times the following steps repeated:
        1) Subtract drift force constants along row and column
        2) Average fc and fc.T

    """
    s2p_map = primitive.s2p_map
    p2s_map = primitive.p2s_map
    p2p_map = primitive.p2p_map
    permutations = primitive.atomic_permutations
    s2pp_map, nsym_list = get_nsym_list_and_s2pp(s2p_map, p2p_map,
                                                 permutations)
    try:
        import phonopy._phonopy as phonoc

        phonoc.perm_trans_symmetrize_compact_fc(force_constants, permutations,
                                                s2pp_map, p2s_map, nsym_list,
                                                level)
    except ImportError:
        text = ("Import error at phonoc.perm_trans_symmetrize_compact_fc. "
                "Corresponding pytono code is not implemented.")
        raise RuntimeError(text)
Example #2
0
def symmetrize_compact_force_constants(force_constants,
                                       supercell,
                                       primitive,
                                       level=2):
    """Symmetry force constants by translational and permutation symmetries.

    Here force constants are stored in a compact form:
    (n_patom, n_satom, 3, 3).

    For the symmetrization, permutation array is necessary.

    level controls the number of times the following steps repeated:
        1) transpose fc
        2) subtract drift-fc/n_satom from fc elements
    where fc is overwritten.

    """

    s2p_map = primitive.get_supercell_to_primitive_map()
    p2s_map = primitive.get_primitive_to_supercell_map()
    p2p_map = primitive.get_primitive_to_primitive_map()
    permutations = primitive.get_atomic_permutations()
    s2pp_map, nsym_list = get_nsym_list_and_s2pp(s2p_map, p2p_map,
                                                 permutations)

    try:
        import phonopy._phonopy as phonoc
        phonoc.perm_trans_symmetrize_compact_fc(force_constants, permutations,
                                                s2pp_map, p2s_map, nsym_list,
                                                level)
    except ImportError:
        print("Import error at phonoc.perm_trans_symmetrize_compact_fc.")
        print("Corresponding pytono code is not implemented.")
        import sys
        sys.exit(1)
Example #3
0
def symmetrize_compact_force_constants(force_constants,
                                       supercell,
                                       symmetry,
                                       s2p_map,
                                       p2s_map):
    """Symmetry force constants by translational and permutation symmetries.

    Here force constants are stored in a compact form:
    (n_patom, n_satom, 3, 3).

    For the symmetrization, permutation array is necessary.

    """

    rotations = []
    trans = []
    identity = np.eye(3, dtype='intc')

    for r, t in zip(symmetry.get_symmetry_operations()['rotations'],
                    symmetry.get_symmetry_operations()['translations']):
        if (r == identity).all():
            rotations.append(r)
            trans.append(t)

    permutations = _compute_all_sg_permutations(
        supercell.get_scaled_positions(),
        np.array(rotations, dtype='intc', order='C'),
        np.array(trans, dtype='double'),
        np.array(supercell.get_cell().T, dtype='double', order='C'),
        symmetry.get_symmetry_tolerance())

    try:
        import phonopy._phonopy as phonoc
        phonoc.perm_trans_symmetrize_compact_fc(force_constants,
                                                permutations,
                                                s2p_map,
                                                p2s_map)
    except ImportError:
        print("Import error at phonoc.perm_trans_symmetrize_compact_fc.")
        print("Corresponding pytono code is not implemented.")
        import sys
        sys.exit(1)