Skip to content

Commit

Permalink
fix assert bug for kpoints weight summation (#60)
Browse files Browse the repository at this point in the history
 add abs to assert
  • Loading branch information
AsymmetryChou authored Feb 2, 2024
1 parent e3327bc commit 7873b47
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dptb/utils/make_kpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def gamma_center(meshgrid=[1,1,1]):




def kmesh_sampling(meshgrid=[1,1,1], is_gamma_center=True):
""" Generate k-points using Monkhorst-Pack method based on given meshgrid. The k-points are centered at Gamma point by default.
Expand Down Expand Up @@ -207,7 +208,7 @@ def time_symmetry_reduce(meshgrid=[1,1,1], is_gamma_center=True):
k_points_with_tr = k_points_with_tr[k_sort_indx]
kweight = np.array(kweight)/len(k_points) # normalize the weight to one
kweight = kweight[k_sort_indx]
assert kweight.sum() == 1, "The sum of weight is not 1.0"
assert abs(kweight.sum() - 1.0) < 1e-5, "The sum of weight is not 1.0"

return k_points_with_tr, kweight

Expand Down

0 comments on commit 7873b47

Please sign in to comment.