Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oashour committed May 6, 2024
1 parent 279c4cc commit 54a8954
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion darkmagic/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def _evaluate_serial(
for task in np.indices((nm, nv)).T.reshape(-1, 2):
im, iv = task[0], task[1]
print(
f"Rate calculation: {im * nv + iv + 1}/{(nv*nm)}.",
f"Rate calculation: {im + iv*nm + 1}/{(nv*nm)}.",
)
(
diff_rate[iv, im],
Expand Down
5 changes: 4 additions & 1 deletion darkmagic/numerics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MonkhorstPackGrid:

def __init__(
self,
N_grid: np.ndarray,
N_grid: ArrayLike,
shift: bool = True,
):
"""
Expand All @@ -33,10 +33,13 @@ def __init__(
N_grid (ArrayLike): The number of grid points along each reciprocal lattice vector.
shift (bool): Whether to shift the grid. Defaults to a shifted grid to avoid singularities in DWF.
"""
N_grid = np.array(N_grid)
s = np.array([1, 1, 1]) / 2 if shift else np.array([0, 0, 0])
# Generate grid and apply shifts
grid_indices = np.meshgrid(*[np.arange(n) for n in N_grid], indexing="ij")
k_list = np.stack(grid_indices, axis=-1).reshape(-1, 3) / N_grid
k_list += ((N_grid + 1) % 2 - N_grid // 2 + s) / N_grid
# Sort the k-points by their coordinates
self.k_frac = np.array(sorted(k_list, key=tuple), dtype=np.float64)
self.weights = np.ones_like(self.k_frac[:, 0], dtype=np.int64)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def test_phonon_material(
assert material.m_atoms[0] == pytest.approx(m_atom1 * const.amu_to_eV)
assert np.all(material.epsilon == eps)
assert np.all(material.born[0] == bec1)
grid = MonkhorstPackGrid([1, 1, 1], material, shift=False)
grid = MonkhorstPackGrid([1, 1, 1], shift=False)
freq, eigvec = material.get_eig(grid, with_eigenvectors=True)
assert freq.shape == (1, n_atoms * 3)
assert eigvec.shape == (1, n_atoms * 3, n_atoms, 3)
Expand Down

0 comments on commit 54a8954

Please sign in to comment.