Skip to content

Commit

Permalink
Add support for use_structure_charge keyword in FHI-aims input gene…
Browse files Browse the repository at this point in the history
…rator (#4111)
  • Loading branch information
ansobolev authored Oct 21, 2024
1 parent f4e2838 commit ddf96bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pymatgen/io/aims/sets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,14 @@ class AimsInputGenerator(InputGenerator):
parameters for the FHI-aims calculator
user_kpoints_settings (dict[str, Any]): The settings
used to create the k-grid parameters for FHI-aims
use_structure_charge (bool): If set to True, then the overall charge of the
structure (structure.charge) is used to set the `charge` variable in the
`control.in`. Default is False.
"""

user_params: dict[str, Any] = field(default_factory=dict)
user_kpoints_settings: dict[str, Any] = field(default_factory=dict)
use_structure_charge: bool = False

def get_input_set(
self,
Expand Down Expand Up @@ -321,6 +325,9 @@ def _get_input_parameters(

parameter_updates = self.get_parameter_updates(structure, prev_parameters)
params = recursive_update(params, parameter_updates)
# Add the structure charge (useful for defect workflows)
if self.use_structure_charge:
params["charge"] = structure.charge

# Override default parameters with user_params
params = recursive_update(params, self.user_params)
Expand Down
11 changes: 11 additions & 0 deletions tests/io/aims/sets/test_static_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ def test_static_si(tmp_path):
comp_system(Si, parameters, "static-si", tmp_path, REF_PATH, StaticSetGenerator)


def test_static_o2_charge(tmp_path):
parameters = {
"species_dir": "light",
"k_grid": [2, 2, 2],
}
Si.set_charge(1)
generator = StaticSetGenerator(parameters, use_structure_charge=True)
input_set = generator.get_input_set(Si)
assert "charge 1" in input_set.control_in


def test_static_si_no_kgrid(tmp_path):
parameters = {"species_dir": "light"}
Si_supercell = Si.make_supercell([1, 2, 3], in_place=False)
Expand Down

0 comments on commit ddf96bf

Please sign in to comment.