Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zhubonan committed Jan 12, 2024
1 parent 4e38de7 commit 76a7da0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions easyunfold/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def generate(pc_file, code, sc_file, matrix, kpoints, time_reversal, out_file, n
else:
tmp = supercell.cell @ np.linalg.inv(primitive.cell)
transform_matrix = np.rint(tmp)
transform_matrix[transform_matrix == 0] = 0
if not np.allclose(tmp, transform_matrix, rtol=2e-2): # 2% mismatch tolerance
if np.allclose(transform_matrix @ primitive.cell, supercell.cell, rtol=5e-2): # 2-5% mismatch
click.echo(_quantitative_inaccuracy_warning)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_generate_agsbte2(agsbte2_project_dir):
'Warning: There is a lattice parameter mismatch in the range 2-5% between the primitive (multiplied by the '
'transformation matrix) and the supercell. This will lead to some quantitative inaccuracies in the '
'Brillouin Zone spacing (and thus effective masses) of the unfolded band structures.',
'(Guessed) Transform matrix:\n[[1.0, -0.0, 0.0], [1.0, -3.0, 1.0], [1.0, 1.0, -3.0]]',
'(Guessed) Transform matrix:\n[[1.0, 0.0, 0.0], [1.0, -3.0, 1.0], [1.0, 1.0, -3.0]]',
],
output,
)
Expand Down Expand Up @@ -217,7 +217,7 @@ def test_unfold(si_project_dir, tag):
if tag == '':
output = runner.invoke(easyunfold, ['unfold', '--data-file', 'test.json', 'effective-mass'])
assert 'Hole effective masses' in output.stdout
assert (r' 0 m_e -0.938459 8 [0.5, 0.0, 0.5] (X) [0.5, 0.25, 0.75] (W)' in output.stdout)
assert r'0 m_e 0.820036 8 [0.5, 0.0, 0.5] (X)' in output.stdout
# Plot effective mass
output = runner.invoke(
easyunfold,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_effective_mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
from pathlib import Path
import pytest
import numpy as np
from monty.serialization import loadfn
import easyunfold.effective_mass as em

Expand Down Expand Up @@ -42,16 +43,15 @@ def test_effective_mass(effective_mass_obj):
assert len(kdist) == len(effective_mass_obj.kpoints)

fdata = effective_mass_obj._get_fitting_data(0, 16, 1, 0, 3)
assert (fdata[0] == kdist[:3]).all()
assert len(fdata[1]) == 3
assert len(fdata[1]) == 6

assert len(output['electrons']) == 2
assert len(output['holes']) == 2

assert output['electrons'][0]['kpoint_label_from'] == '\\Gamma'
assert output['electrons'][0]['kpoint_label_to'] == 'L'
assert output['electrons'][0]['effective_mass'] == pytest.approx(0.39912256690278236)
assert output['electrons'][0]['effective_mass'] == pytest.approx(0.36959097872)

assert output['holes'][0]['kpoint_label_from'] == '\\Gamma'
assert output['holes'][0]['kpoint_label_to'] == 'L'
assert output['holes'][0]['effective_mass'] == pytest.approx(-5.972424721183893)
assert output['holes'][0]['effective_mass'] == pytest.approx(-3.36071124861)

0 comments on commit 76a7da0

Please sign in to comment.