tools.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:amset 作者: hackingmaterials 项目源码 文件源码
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]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号