本文整理汇总了Python中pymatgen.symmetry.analyzer.SpacegroupAnalyzer.get_neighbors方法的典型用法代码示例。如果您正苦于以下问题:Python SpacegroupAnalyzer.get_neighbors方法的具体用法?Python SpacegroupAnalyzer.get_neighbors怎么用?Python SpacegroupAnalyzer.get_neighbors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.symmetry.analyzer.SpacegroupAnalyzer
的用法示例。
在下文中一共展示了SpacegroupAnalyzer.get_neighbors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_redf
# 需要导入模块: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer [as 别名]
# 或者: from pymatgen.symmetry.analyzer.SpacegroupAnalyzer import get_neighbors [as 别名]
def get_redf(struct, cutoff=None, dr=0.05):
"""
This function permits the calculation of the crystal structure-inherent electronic radial
distribution function (ReDF) according to Willighagen et al., Acta Cryst., 2005, B61, 29-36.
The ReDF is a structure-integral RDF (i.e., summed over all sites) in which the positions of
neighboring sites are weighted by electrostatic interactions inferred from atomic partial
charges. Atomic charges are obtained from the ValenceIonicRadiusEvaluator class.
Args:
struct (Structure): input Structure object.
cutoff (float): distance up to which the ReDF is to be
calculated (default: longest diagaonal in primitive cell)
dr (float): width of bins ("x"-axis) of ReDF (default: 0.05 A).
Returns:
(dict) a copy of the electronic radial distribution functions (ReDF) as a dictionary.
The distance list ("x"-axis values of ReDF) can be accessed via key 'distances';
the ReDF itself via key 'redf'.
"""
if dr <= 0:
raise ValueError("width of bins for ReDF must be >0")
# make primitive
struct = SpacegroupAnalyzer(struct).find_primitive() or struct
# add oxidation states
struct = ValenceIonicRadiusEvaluator(struct).structure
if cutoff is None:
# set cutoff to longest diagonal
a = struct.lattice.matrix[0]
b = struct.lattice.matrix[1]
c = struct.lattice.matrix[2]
cutoff = max(
[np.linalg.norm(a + b + c), np.linalg.norm(-a + b + c), np.linalg.norm(a - b + c),
np.linalg.norm(a + b - c)])
nbins = int(cutoff / dr) + 1
redf_dict = {"distances": np.array([(i + 0.5) * dr for i in range(nbins)]),
"redf": np.zeros(nbins, dtype=np.float)}
for site in struct.sites:
this_charge = float(site.specie.oxi_state)
neighs_dists = struct.get_neighbors(site, cutoff)
for neigh, dist in neighs_dists:
neigh_charge = float(neigh.specie.oxi_state)
bin_index = int(dist / dr)
redf_dict["redf"][bin_index] += (this_charge * neigh_charge) / (struct.num_sites * dist)
return redf_dict