Skip to content

Commit

Permalink
Add test for aims density conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
tpurcell90 committed Aug 5, 2024
1 parent 9c64933 commit fce8930
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/pymatgen/util/testing/aims.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def comp_system(
generator_cls: type,
properties: list[str] | None = None,
prev_dir: str | None | Path = None,
user_kpt_settings: dict[str, Any] | None = None,
) -> None:
"""Compare files generated by tests with ones in reference directories.
Expand All @@ -96,16 +97,24 @@ def comp_system(
generator_cls (type): The class of the generator
properties (list[str] | None): The list of properties to calculate
prev_dir (str | Path | None): The previous directory to pull outputs from
user_kpt_settings (dict[str, Any] | None): settings for k-point density in FHI-aims
Raises:
AssertionError: If the input files are not the same
"""
if user_kpt_settings is None:
user_kpt_settings = {}

k_point_density = user_params.pop("k_point_density", 20)

try:
generator = generator_cls(user_params=user_params, k_point_density=k_point_density)
generator = generator_cls(
user_params=user_params,
k_point_density=k_point_density,
user_kpoints_settings=user_kpt_settings,
)
except TypeError:
generator = generator_cls(user_params=user_params)
generator = generator_cls(user_params=user_params, user_kpoints_settings=user_kpt_settings)

input_set = generator.get_input_set(structure, prev_dir, properties)
input_set.write_input(work_dir / test_name)
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"species_dir": "/home/tpurcell/git/atomate2/tests/aims/species_dir/light",
"k_grid": [
12,
12,
12
6,
4
]
}
5 changes: 4 additions & 1 deletion tests/io/aims/test_sets/test_static_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from pathlib import Path

import numpy as np

from pymatgen.io.aims.sets.core import StaticSetGenerator
from pymatgen.util.testing.aims import O2, Si, comp_system

Expand All @@ -19,7 +21,8 @@ def test_static_si(tmp_path):

def test_static_si_no_kgrid(tmp_path):
parameters = {"species_dir": "light"}
comp_system(Si, parameters, "static-no-kgrid-si", tmp_path, ref_path, StaticSetGenerator)
Si_supercell = Si.make_supercell(np.array([[1, 0, 0], [0, 2, 0], [0, 0, 3]]), in_place=False)
comp_system(Si_supercell, parameters, "static-no-kgrid-si", tmp_path, ref_path, StaticSetGenerator)


def test_static_o2(tmp_path):
Expand Down

0 comments on commit fce8930

Please sign in to comment.