Skip to content

Commit

Permalink
Merge pull request #293 from phonopy/test-tolerance
Browse files Browse the repository at this point in the history
Increase margin for an isotope-test
  • Loading branch information
atztogo authored Nov 12, 2024
2 parents 3b2742e + 72b179d commit ff7be8c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 61 deletions.
56 changes: 0 additions & 56 deletions .github/workflows/phono3py-pytest-conda-numpy2.yml

This file was deleted.

2 changes: 1 addition & 1 deletion doc/random-displacements.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(random-displacements)=
# Force constants calculation with randan displacements of atoms
# Force constants calculation with random displacements of atoms

Random displacements and corresponding forces in supercells can be employed as a
displacement-force dataset for computing force constants. This requires an
Expand Down
2 changes: 1 addition & 1 deletion test/other/test_isotope.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_Phono3pyIsotope_grg(si_pbesol_grg, lang):
iso.grid.grid_matrix, [[-15, 15, 15], [15, -15, 15], [15, 15, -15]]
)
iso.run([23, 103], lang=lang)
np.testing.assert_allclose(si_pbesol_grg_iso, iso.gamma[0], atol=2e-3)
np.testing.assert_allclose(si_pbesol_grg_iso, iso.gamma[0], atol=3e-3)


@pytest.mark.parametrize("lang", ["C", "Py"])
Expand Down
8 changes: 5 additions & 3 deletions test/sscha/test_sscha.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ def get_supercell_phonon(ph3):
return SupercellPhonon(supercell, fc2, frequency_factor_to_THz=factor)


def mass_sand(matrix, mass):
def mass_sand(matrix: np.ndarray, mass: np.ndarray) -> np.ndarray:
"""Calculate mass sandwich."""
return ((matrix * mass).T * mass).T


def mass_inv(matrix, mass):
def mass_inv(matrix: np.ndarray, mass: np.ndarray, tol: float = 1e-5) -> np.ndarray:
"""Calculate inverse mass sandwich."""
bare = mass_sand(matrix, mass)
inv_bare = np.linalg.pinv(bare)
eigvals, eigvecs = np.linalg.eigh(bare)
inv_eigvals = [1 / x if x > tol else 0 for x in eigvals]
inv_bare = (eigvecs * inv_eigvals) @ eigvecs.T
return mass_sand(inv_bare, mass)


Expand Down

0 comments on commit ff7be8c

Please sign in to comment.