mirror of https://github.com/phonopy/phono3py.git
Increase mergin for an isotope-test
This commit is contained in:
parent
8973ca2090
commit
64bc1d9511
|
@ -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
|
||||
|
|
|
@ -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"])
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue