当前位置: 首页>>代码示例>>Python>>正文


Python Structure.get_sites_in_sphere方法代码示例

本文整理汇总了Python中pymatgen.Structure.get_sites_in_sphere方法的典型用法代码示例。如果您正苦于以下问题:Python Structure.get_sites_in_sphere方法的具体用法?Python Structure.get_sites_in_sphere怎么用?Python Structure.get_sites_in_sphere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymatgen.Structure的用法示例。


在下文中一共展示了Structure.get_sites_in_sphere方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_string

# 需要导入模块: from pymatgen import Structure [as 别名]
# 或者: from pymatgen.Structure import get_sites_in_sphere [as 别名]
    def get_string(self):
        """
        Returns a string representation of atomic shell coordinates.

        Returns:
            String representation of Atomic Coordinate Shells.
        """
        center_index = self.struct.indices_from_symbol(self.central_atom)[0]
        center = self.struct[center_index].coords
        sphere = Structure.get_sites_in_sphere(self.struct, center, self.radius)

        row = []
        for i, site_dist in enumerate(sphere):
            site_symbol = re.sub(r"[^aA-zZ]+", "", site_dist[0].species_string)
            ipot = self.pot_dict[site_symbol]
            coords = site_dist[0].coords - center
            row.append(["{:f}".format(coords[0]), "{:f}".format(coords[1]),
                        "{:f}".format(coords[2]), ipot, site_symbol,
                        "{:f}".format(site_dist[1]), i])

        row_sorted = str(tabulate(sorted(row, key=itemgetter(5)),
                                  headers=["*       x", "y", "z", "ipot",
                                           "Atom", "Distance", "Number"]))
        atom_list = row_sorted.replace("--", "**")

        return ''.join(["ATOMS\n", atom_list, "\nEND\n"])
开发者ID:shyamd,项目名称:pymatgen,代码行数:28,代码来源:inputs.py

示例2: get_supercell_site

# 需要导入模块: from pymatgen import Structure [as 别名]
# 或者: from pymatgen.Structure import get_sites_in_sphere [as 别名]
def get_supercell_site(unit: Structure, supercell: Structure, site_i: int, image: tuple):
    coords = unit[site_i].frac_coords # get coords from unit_cell
    scale = np.array(unit.lattice.abc) / supercell.lattice.abc
    coords = coords * scale # Scale coords from supercell
    coords = coords + (scale * image) # scale coords to image
    sites = supercell.get_sites_in_sphere(supercell.lattice.get_cartesian_coords(coords), 0.001, include_index=True)
    if len(sites) != 1:
        raise Exception('Wrong number of sites at supercell destination {}'.format(sites))
    new_site = sites[0][2]
    return new_site
开发者ID:rtrottie,项目名称:VTST-Tools,代码行数:12,代码来源:get_migration.py

示例3: get_center_i

# 需要导入模块: from pymatgen import Structure [as 别名]
# 或者: from pymatgen.Structure import get_sites_in_sphere [as 别名]
def get_center_i(structure : Structure, element : Element, skew_positive=True, delta=0.05):
    center_coords = structure.lattice.get_cartesian_coords([0.5, 0.5, 0.5])
    sites = structure.get_sites_in_sphere(center_coords, 4, include_index=True)
    sites.sort(key=lambda x : x[1])
    best_i = None
    best_dist = 999999
    best_location = 3
    for (site, dist, i) in sites: #type: PeriodicSite
        if site.specie == element:
            if dist < best_dist+delta:
                if sum(1 - (site.frac_coords % 1)) < best_location:
                    best_i = i
                    best_dist = best_dist
                    best_location = sum(1 - site.frac_coords)
    if best_i:
        return best_i
    raise Exception('Could not find specified {}'.format(element))
开发者ID:rtrottie,项目名称:VTST-Tools,代码行数:19,代码来源:get_migration.py

示例4: remove_unstable_interstitials

# 需要导入模块: from pymatgen import Structure [as 别名]
# 或者: from pymatgen.Structure import get_sites_in_sphere [as 别名]
def remove_unstable_interstitials(structure: Structure, relaxed_interstitials: list, dist=0.2, site_indices=None):
    """

    :param structure: Structure decorated with all interstitials
    :param relaxed_interstitials: list of structures with interstitial as last index
    :param dist: tolerance for determining if site belongs to another site
    :return:
    """
    to_keep = list(range(len(relaxed_interstitials[0])-1))
    try:
        sga = SpacegroupAnalyzer(structure, symprec=0.1)
        structure = sga.get_symmetrized_structure()
    except TypeError:
        sga = SpacegroupAnalyzer(structure, symprec=0.01)
        structure = sga.get_symmetrized_structure()
    for ri in relaxed_interstitials:  #type:  Structure
        sites=structure.get_sites_in_sphere(ri.cart_coords[-1], dist, include_index=True)

        for indices in structure.equivalent_indices:  #look at all sets of equivalent indices
            index = sites[0][2]
            if index in to_keep: # Already keeping this index
                continue
            if index in indices:
                to_keep = to_keep + indices  #keep equivalent indices
                break

        if len(sites) != 1: # make sure only one site is found
            okay = False
            if len(sites) > 1:
                if all([ x[2] in indices for x in sites]):
                    okay = True
            if not okay:
                if site_indices:
                    raise Exception('Found {} sites for {}'.format(len(sites), site_indices[relaxed_interstitials.index(ri)]))
                raise Exception('Found {} sites'.format(len(sites)))
    to_remove = [i for i in range(len(structure)) if i not in to_keep]
    structure.remove_sites(to_remove)
    return structure
开发者ID:rtrottie,项目名称:VTST-Tools,代码行数:40,代码来源:get_migration.py


注:本文中的pymatgen.Structure.get_sites_in_sphere方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。