Skip to content

Commit

Permalink
Ensure fc has full shape.
Browse files Browse the repository at this point in the history
  • Loading branch information
atztogo committed Aug 19, 2024
1 parent 4be4f05 commit 1001bf9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/phelel/api_phelel.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ def run_derivatives(self, phe_input: PhelelDataset):
Note
----
After calculation, temporary raw data may be deleted.
Force constants are created to have full matrix shape.
"""
if self._fft_mesh is None:
Expand All @@ -417,10 +418,16 @@ def run_derivatives(self, phe_input: PhelelDataset):

if phe_input.phonon_dataset is not None:
self._prepare_phonon(
dataset=phe_input.phonon_dataset, forces=phe_input.forces
dataset=phe_input.phonon_dataset,
forces=phe_input.forces,
calculate_full_force_constants=True,
)
else:
self._prepare_phonon(dataset=self._dataset, forces=phe_input.forces)
self._prepare_phonon(
dataset=self._dataset,
forces=phe_input.forces,
calculate_full_force_constants=True,
)
self._dVdu.run(loc_pots[0], loc_pots[1:], self._dataset["first_atoms"])
self._dDijdu.run(
Dijs[0],
Expand Down
16 changes: 14 additions & 2 deletions test/interface/vasp/test_derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,16 @@ def test_read_files_C111():


def test_create_derivatives_C111():
"""Test creating derivatives with C-1x1x1."""
"""Test creating derivatives with C-1x1x1.
Check force constants have the full matrix shape.
"""
phelel = _get_phelel_C111("phelel_disp_C111.yaml")
dir_names = [cwd / "C111_disp-000", cwd / "C111_disp-001"]
create_derivatives(phelel, dir_names, subtract_rfs=True, log_level=1)
fc = phelel.force_constants
assert fc.shape[0] == fc.shape[1]


def test_read_files_C111_ncl():
Expand All @@ -74,10 +80,16 @@ def test_read_files_C111_ncl():


def test_create_derivatives_C111_ncl():
"""Test creating derivatives with non-collinear case of C-1x1x1."""
"""Test creating derivatives with non-collinear case of C-1x1x1.
Check force constants have the full matrix shape.
"""
phelel = _get_phelel_C111("phelel_disp_C111.yaml")
dir_names = [cwd / "C111-ncl_disp-000", cwd / "C111-ncl_disp-001"]
create_derivatives(phelel, dir_names, subtract_rfs=True, log_level=1)
fc = phelel.force_constants
assert fc.shape[0] == fc.shape[1]


def _get_phelel_C111(phelel_yaml_filename: str) -> Phelel:
Expand Down

0 comments on commit 1001bf9

Please sign in to comment.