Skip to content

Added basic recipe for FHI-Aims , with support for static, relax and … #2710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/about/contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Additional contributions were made by the individuals listed [here](https://gith

- [@kumaranu](https://github.com/kumaranu): NewtonNet recipes.
- [@nekkrad](https://github.com/nekkrad): ONETEP recipes.
- [@BCAyers2000](https://github.com/BCAyers2000): FHI-Aims recipes.
- [@rwexler](https://github.com/rwexler): Defect utilities and EMT defect recipe.
- [@samblau](https://github.com/samblau): Custom Q-Chem calculator, Q-Chem recipes.
- [@tomdemeyere](https://github.com/tomdemeyere): Custom Espresso calculator, Espresso recipes.
Expand Down
14 changes: 14 additions & 0 deletions docs/install/codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ If you plan to use TBLite with quacc, you will need to install the tblite interf

Refer to the [TBLite documentation](https://tblite.readthedocs.io/en/latest/tutorial/parallel.html) for details on how to parallelize calculations and adjust the memory limits.

## FHI-aims

If you plan on using FHI-aims with quacc, you will need to obtain and install FHI-aims. This can be done as described in the [Get the Code](https://fhi-aims.org/get-the-code-menu/get-the-code) section of the FHI-aims website.

At minimum, you will need to define and set `AIMS_BIN` to be the path to the FHI-aims executable and `AIMS_SPECIES_DEFAULTS` to be the path to the species defaults directory. This can be done as described in the section on ["Modifying Quacc Settings"](../user/settings/settings.md).

An example is provided below on how to define the commands in your `~/.bashrc`:

```bash
export QUACC_AIMS_BIN="/path/to/aims.x"
export QUACC_AIMS_PARALLEL_CMD="mpirun -np 4"
export QUACC_AIMS_SPECIES_DEFAULTS="/path/to/fhi-aims/species_defaults/defaults_2020/"
```

## VASP

To use quacc with VASP, you will need to define several environment variables, as described in the section on ["Modifying Quacc Settings"](../user/settings/settings.md). The most important are listed below:
Expand Down
1 change: 1 addition & 0 deletions src/quacc/recipes/aims/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Recipes for FHI-Aims."""
161 changes: 161 additions & 0 deletions src/quacc/recipes/aims/_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
"""Base jobs for FHI-aims."""

from __future__ import annotations

Check warning on line 3 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L3

Added line #L3 was not covered by tests

from pathlib import Path
from typing import TYPE_CHECKING

Check warning on line 6 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L5-L6

Added lines #L5 - L6 were not covered by tests

from ase.calculators.aims import Aims, AimsProfile

Check warning on line 8 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L8

Added line #L8 was not covered by tests

from quacc import get_settings
from quacc.runners.ase import Runner
from quacc.schemas.ase import Summarize
from quacc.utils.dicts import recursive_dict_merge
from quacc.utils.kpts import kspacing_to_grid

Check warning on line 14 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L10-L14

Added lines #L10 - L14 were not covered by tests

if TYPE_CHECKING:
from typing import Any

from ase.atoms import Atoms

from quacc.types import Filenames, OptParams, RunSchema, SourceDirectory


def run_and_summarize(

Check warning on line 24 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L24

Added line #L24 was not covered by tests
atoms: Atoms,
calc_defaults: dict[str, Any] | None = None,
calc_swaps: dict[str, Any] | None = None,
additional_fields: dict[str, Any] | None = None,
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
) -> RunSchema:
"""
Base function to carry out FHI-aims recipes.

Parameters
----------
atoms
Atoms object
calc_defaults
The default calculator parameters.
calc_swaps
Custom kwargs for the FHI-aims calculator. Set a value to
`quacc.Remove` to remove a pre-existing key entirely. For a list of available
keys, refer to the [ase.calculators.aims.Aims][] calculator.
additional_fields
Any additional fields to supply to the summarizer.
copy_files
Files to copy (and decompress) from source to the runtime directory.

Returns
-------
RunSchema
Dictionary of results from [quacc.schemas.ase.Summarize.run][]
"""
calc = prep_calculator(atoms, calc_defaults=calc_defaults, calc_swaps=calc_swaps)
final_atoms = Runner(atoms, calc, copy_files=copy_files).run_calc()

Check warning on line 55 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L54-L55

Added lines #L54 - L55 were not covered by tests

return Summarize(move_magmoms=True, additional_fields=additional_fields).run(

Check warning on line 57 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L57

Added line #L57 was not covered by tests
final_atoms, atoms
)


def run_and_summarize_opt(

Check warning on line 62 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L62

Added line #L62 was not covered by tests
atoms: Atoms,
calc_defaults: dict[str, Any] | None = None,
calc_swaps: dict[str, Any] | None = None,
opt_defaults: dict[str, Any] | None = None,
opt_params: OptParams | None = None,
additional_fields: dict[str, Any] | None = None,
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
) -> RunSchema:
"""
Base function to carry out FHI-aims recipes with ASE optimizers.

Parameters
----------
atoms
Atoms object
calc_defaults
The default calculator parameters.
calc_swaps
Custom kwargs for the FHI-aims calculator. Set a value to
`quacc.Remove` to remove a pre-existing key entirely. For a list of available
keys, refer to the [ase.calculators.aims.Aims][] calculator.
opt_defaults
The default optimization parameters.
opt_params
Dictionary of custom kwargs for the optimization process. For a list
of available keys, refer to [quacc.runners.ase.Runner.run_opt][].
additional_fields
Any additional fields to supply to the summarizer.
copy_files
Files to copy (and decompress) from source to the runtime directory.

Returns
-------
RunSchema
Dictionary of results from [quacc.schemas.ase.Summarize.run][]
"""
opt_flags = recursive_dict_merge(opt_defaults, opt_params)
calc = prep_calculator(atoms, calc_defaults=calc_defaults, calc_swaps=calc_swaps)
dyn = Runner(atoms, calc, copy_files=copy_files).run_opt(**opt_flags)

Check warning on line 101 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L99-L101

Added lines #L99 - L101 were not covered by tests

return Summarize(move_magmoms=True, additional_fields=additional_fields).opt(dyn)

Check warning on line 103 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L103

Added line #L103 was not covered by tests


def prep_calculator(

Check warning on line 106 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L106

Added line #L106 was not covered by tests
atoms: Atoms,
calc_defaults: dict[str, Any] | None = None,
calc_swaps: dict[str, Any] | None = None,
) -> Aims:
"""
Prepare the FHI-aims calculator.

Parameters
----------
atoms
Atoms object
calc_defaults
The default calculator parameters.
calc_swaps
Custom kwargs for the FHI-aims calculator. Set a value to
`quacc.Remove` to remove a pre-existing key entirely. For a list of available
keys, refer to the [ase.calculators.aims.Aims][] calculator.

Returns
-------
Aims
The FHI-aims calculator.
"""
calc_flags = recursive_dict_merge(calc_defaults or {}, calc_swaps or {})
settings = get_settings()
species_dir = calc_flags.pop("species_dir", None)

Check warning on line 132 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L130-L132

Added lines #L130 - L132 were not covered by tests

if not any(atoms.pbc):
for key in ["kspacing", "k_grid", "k_grid_density"]:
if key in calc_flags:
calc_flags.pop(key)
elif (

Check warning on line 138 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L134-L138

Added lines #L134 - L138 were not covered by tests
"kspacing" in calc_flags
and "k_grid" not in calc_flags
and "k_grid_density" not in calc_flags
):
kspacing = calc_flags.pop("kspacing")
calc_flags["k_grid"] = kspacing_to_grid(atoms, kspacing)

Check warning on line 144 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L143-L144

Added lines #L143 - L144 were not covered by tests

if "spin" not in calc_flags and hasattr(atoms, "get_initial_magnetic_moments"):
magmoms = atoms.get_initial_magnetic_moments()
if magmoms is not None and any(abs(m) > 1e-6 for m in magmoms):
calc_flags["spin"] = "collinear"

Check warning on line 149 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L146-L149

Added lines #L146 - L149 were not covered by tests

aims_cmd = f"{settings.AIMS_PARALLEL_CMD} {settings.AIMS_BIN}"
species_path = settings.AIMS_SPECIES_DEFAULTS
if species_dir:
species_path = Path(species_path) / species_dir

Check warning on line 154 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L151-L154

Added lines #L151 - L154 were not covered by tests

return Aims(

Check warning on line 156 in src/quacc/recipes/aims/_base.py

View check run for this annotation

Codecov / codecov/patch

src/quacc/recipes/aims/_base.py#L156

Added line #L156 was not covered by tests
profile=AimsProfile(
command=aims_cmd.strip(), default_species_directory=str(species_path)
),
**calc_flags,
)
Loading
Loading