Exemplo n.º 1
0
def get_equivalent_smallest_vectors(atom_number_supercell,
                                    atom_number_primitive, supercell, symprec):
    s_pos = supercell.get_scaled_positions()
    svecs, multi = get_smallest_vectors(supercell.get_cell(),
                                        [s_pos[atom_number_supercell]],
                                        [s_pos[atom_number_primitive]],
                                        symprec=symprec)
    return svecs[0, 0]
Exemplo n.º 2
0
def get_smallest_vector_of_atom_pair(atom_number_supercell,
                                     atom_number_primitive,
                                     supercell: PhonopyAtoms, symprec):
    """Return smallest vectors of an atom pair in supercell."""
    s_pos = supercell.scaled_positions
    svecs, _ = get_smallest_vectors(
        supercell.cell,
        [s_pos[atom_number_supercell]],
        [s_pos[atom_number_primitive]],
        store_dense_svecs=True,
        symprec=symprec,
    )
    return svecs[0]
Exemplo n.º 3
0
def cutoff_force_constants(force_constants,
                           supercell,
                           primitive,
                           cutoff_radius,
                           symprec=1e-5):
    fc_shape = force_constants.shape
    if fc_shape[0] == fc_shape[1]:
        svecs, _ = get_smallest_vectors(supercell.get_cell(),
                                        supercell.get_scaled_positions(),
                                        supercell.get_scaled_positions(),
                                        symprec=symprec)
        min_distances = np.sqrt(np.sum(
            np.dot(svecs[:, :, 0, :], supercell.get_cell()) ** 2, axis=-1))
    else:
        svecs, _ = primitive.get_smallest_vectors()
        min_distances = np.sqrt(np.sum(
            np.dot(svecs[:, :, 0, :], primitive.get_cell()) ** 2, axis=-1))

    for i in range(fc_shape[0]):
        for j in range(fc_shape[1]):
            if min_distances[j, i] > cutoff_radius:
                force_constants[i, j] = 0.0
Exemplo n.º 4
0
def cutoff_force_constants(force_constants,
                           supercell,
                           primitive,
                           cutoff_radius,
                           symprec=1e-5):
    """Set zero to force constants outside of cutoff distance.

    Note
    ----
    `force_constants` is overwritten.

    """
    fc_shape = force_constants.shape

    if fc_shape[0] == fc_shape[1]:
        svecs, multi = get_smallest_vectors(
            supercell.cell,
            supercell.scaled_positions,
            supercell.scaled_positions,
            symprec=symprec,
            store_dense_svecs=primitive.store_dense_svecs,
        )
        lattice = supercell.cell
    else:
        svecs, multi = primitive.get_smallest_vectors()
        lattice = primitive.cell

    if primitive.store_dense_svecs:
        _svecs = svecs[multi[:, :, 1]]
    else:
        _svecs = svecs[:, :, 0, :]

    min_distances = np.sqrt(np.sum(np.dot(_svecs, lattice)**2, axis=-1))

    for i in range(fc_shape[0]):
        for j in range(fc_shape[1]):
            if min_distances[j, i] > cutoff_radius:
                force_constants[i, j] = 0.0