Beispiel #1
0
    def neighboring_atom_indices(self):
        result = set()
        for v in self.vacancy_indices:
            distances = Distances(self._defective_structure,
                                  self._perfect_structure[v].frac_coords)
            result.update(distances.coordination().neighboring_atom_indices)
        for i in self.inserted_indices:
            distances = Distances(self._defective_structure,
                                  self._defective_structure[i].frac_coords)
            result.update(distances.coordination().neighboring_atom_indices)

        return sorted(list(result))
Beispiel #2
0
def test_coord_distances(mocker, ortho_conventional):
    mock = mocker.patch("pydefect.util.structure_tools.defaults")
    mock.cutoff_distance_factor = 3.9051248 / 2.5 + 1e-5  # = 1.562
    distances = Distances(ortho_conventional, center_coord=[0.5, 0.5, 0.5])

    actual = distances.coordination(include_on_site=True)
    expected = Coordination({"H": [2.5, 3.0, 3.5], "He": [0.0, 3.91]},
                            3.905,
                            neighboring_atom_indices=[1, 2, 3, 4, 7])
    assert actual == expected

    actual = distances.coordination()
    expected = Coordination({"H": [2.5, 3.0, 3.5], "He": [3.91]},
                            3.905,
                            neighboring_atom_indices=[1, 2, 3, 4])
    assert actual == expected
def find_inequivalent_coords(structure: Structure,
                             df: DataFrame) -> List[CoordInfo]:
    result = []
    initial_sg = StructureSymmetrizer(structure).sg_number
    added_structure = Structure.from_dict(structure.as_dict())
    start_index = len(structure)
    for _, column in df.iterrows():
        coords = [column.a, column.b, column.c]
        assert Element.Og not in structure.composition.elements
        added_structure.append(Element.Og, coords)
    end_index = len(added_structure)

    symmetrizer = StructureSymmetrizer(added_structure)

    if initial_sg != symmetrizer.sg_number:
        logger.warning("The symmetry has changed, meaning all the symmetry "
                       "equivalent sites do not exist.")

    sym_data = symmetrizer.spglib_sym_data
    _indices = [i for i in range(start_index, end_index)]
    repr_atom_pairs = zip(sym_data["equivalent_atoms"][_indices], _indices)

    key = lambda x: x[0]
    for _, equiv_sites in groupby(sorted(repr_atom_pairs, key=key), key=key):
        coords, quantity = [], []
        for repr_idx, atom_idx in equiv_sites:
            fcoord = added_structure[atom_idx].frac_coords
            coords.append(tuple(fcoord))
            key = "ave_value" if "ave_value" in df else "value"
            quantity.append(df[key][atom_idx - start_index])
            if repr_idx == atom_idx:
                site_sym = sym_data["site_symmetry_symbols"][atom_idx]
                distances = Distances(structure, fcoord)
                coordination = distances.coordination()

        coord_info = CoordInfo(site_symmetry=remove_dot(site_sym),
                               coordination=coordination,
                               frac_coords=coords,
                               quantities=quantity)
        result.append(coord_info)
    return result
Beispiel #4
0
 def interstitial_coords(self, idx: int):
     interstitial = self.interstitials[idx]
     distances = Distances(self.structure, interstitial.frac_coords)
     return distances.coordination(include_on_site=True)
Beispiel #5
0
 def coords(self, name):
     site = self.sites[name]
     coord = list(self.structure[site.equivalent_atoms[0]].frac_coords)
     distances = Distances(self.structure, coord)
     return distances.coordination()