def get_closest_k(kpoint, ref_ks, return_diff=False):
"""
returns the list of difference between kpoints. If return_diff True, then
for a given kpoint the minimum distance among distances with ref_ks is
returned or just the reference kpoint that results if not return_diff
Args:
kpoint (1x3 array): the coordinates of the input k-point
ref_ks ([1x3 array]): list of reference k-points from which the
distance with initial_ks are calculated
return_diff (bool): if True, the minimum distance is returned
Returns (1x3 array):
"""
min_dist_ik = np.array([norm(ki - kpoint) for ki in ref_ks]).argmin()
if return_diff:
return kpoint - ref_ks[min_dist_ik]
else:
return ref_ks[min_dist_ik]
评论列表
文章目录