Skip to content
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

Add additional_fields to all @jobs #2405

Merged
merged 2 commits into from
Aug 10, 2024
Merged
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
12 changes: 9 additions & 3 deletions src/quacc/recipes/dftb/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from quacc.recipes.dftb._base import run_and_summarize

if TYPE_CHECKING:
from typing import Literal
from typing import Any, Literal

from ase.atoms import Atoms

Expand All @@ -21,6 +21,7 @@ def static_job(
method: Literal["GFN1-xTB", "GFN2-xTB", "DFTB"] = "GFN2-xTB",
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
kpts: tuple | list[tuple] | dict | None = None,
additional_fields: dict[str, Any] | None = None,
**calc_kwargs,
) -> RunSchema:
"""
Expand All @@ -36,6 +37,8 @@ def static_job(
k-point grid to use.
copy_files
Files to copy (and decompress) from source to the runtime directory.
additional_fields
Additional fields to add to the results dictionary.
**calc_kwargs
Custom kwargs for the calculator that would override the
calculator defaults. Set a value to `quacc.Remove` to remove a pre-existing key
Expand All @@ -60,7 +63,7 @@ def static_job(
atoms,
calc_defaults=calc_defaults,
calc_swaps=calc_kwargs,
additional_fields={"name": "DFTB+ Static"},
additional_fields={"name": "DFTB+ Static"} | (additional_fields or {}),
copy_files=copy_files,
)

Expand All @@ -72,6 +75,7 @@ def relax_job(
kpts: tuple | list[tuple] | dict | None = None,
relax_cell: bool = False,
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
additional_fields: dict[str, Any] | None = None,
**calc_kwargs,
) -> RunSchema:
"""
Expand All @@ -90,6 +94,8 @@ def relax_job(
positions.
copy_files
Files to copy (and decompress) from source to the runtime directory.
additional_fields
Additional fields to add to the results dictionary.
**calc_kwargs
Custom kwargs for the calculator that would override the
calculator defaults. Set a value to `quacc.Remove` to remove a pre-existing key
Expand Down Expand Up @@ -118,6 +124,6 @@ def relax_job(
atoms,
calc_defaults=calc_defaults,
calc_swaps=calc_kwargs,
additional_fields={"name": "DFTB+ Relax"},
additional_fields={"name": "DFTB+ Relax"} | (additional_fields or {}),
copy_files=copy_files,
)
16 changes: 14 additions & 2 deletions src/quacc/recipes/emt/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from quacc.schemas.ase import Summarize

if TYPE_CHECKING:
from typing import Any

from ase.atoms import Atoms

from quacc.types import Filenames, OptParams, OptSchema, RunSchema, SourceDirectory
Expand All @@ -24,6 +26,7 @@
def static_job(
atoms: Atoms,
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
additional_fields: dict[str, Any] | None = None,
**calc_kwargs,
) -> RunSchema:
"""
Expand All @@ -35,6 +38,8 @@ def static_job(
Atoms object
copy_files
Files to copy (and decompress) from source to the runtime directory.
additional_fields
Additional fields to add to the results dictionary.
**calc_kwargs
Custom kwargs for the EMT calculator. Set a value to
`quacc.Remove` to remove a pre-existing key entirely. For a list of available
Expand All @@ -49,7 +54,9 @@ def static_job(
calc = EMT(**calc_kwargs)
final_atoms = Runner(atoms, calc, copy_files=copy_files).run_calc()

return Summarize(additional_fields={"name": "EMT Static"}).run(final_atoms, atoms)
return Summarize(
additional_fields={"name": "EMT Static"} | (additional_fields or {})
).run(final_atoms, atoms)


@job
Expand All @@ -58,6 +65,7 @@ def relax_job(
relax_cell: bool = False,
opt_params: OptParams | None = None,
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
additional_fields: dict[str, Any] | None = None,
**calc_kwargs,
) -> OptSchema:
"""
Expand All @@ -74,6 +82,8 @@ def relax_job(
of available keys, refer to [quacc.runners.ase.Runner.run_opt][].
copy_files
Files to copy (and decompress) from source to the runtime directory.
additional_fields
Additional fields to add to the results dictionary.
**calc_kwargs
Custom kwargs for the EMT calculator. Set a value to
`quacc.Remove` to remove a pre-existing key entirely. For a list of available
Expand All @@ -92,4 +102,6 @@ def relax_job(
relax_cell=relax_cell, **opt_params
)

return Summarize(additional_fields={"name": "EMT Relax"}).opt(dyn)
return Summarize(
additional_fields={"name": "EMT Relax"} | (additional_fields or {})
).opt(dyn)
9 changes: 8 additions & 1 deletion src/quacc/recipes/emt/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from quacc.utils.dicts import recursive_dict_merge

if TYPE_CHECKING:
from typing import Any

from ase.atoms import Atoms
from ase.md.md import MolecularDynamics

Expand All @@ -32,6 +34,7 @@ def md_job(
pressure_bar: float | None = None,
md_params: MDParams | None = None,
copy_files: SourceDirectory | dict[SourceDirectory, Filenames] | None = None,
additional_fields: dict[str, Any] | None = None,
**calc_kwargs,
) -> DynSchema:
"""
Expand All @@ -56,6 +59,8 @@ def md_job(
keys, refer to [quacc.runners.ase.Runner.run_md][].
copy_files
Files to copy (and decompress) from source to the runtime directory.
additional_fields
Additional fields to add to the results dictionary.
**calc_kwargs
Custom kwargs for the EMT calculator. Set a value to
`quacc.Remove` to remove a pre-existing key entirely. For a list of available
Expand All @@ -80,4 +85,6 @@ def md_job(
calc = EMT(**calc_kwargs)
dyn = Runner(atoms, calc, copy_files=copy_files).run_md(dynamics, **md_params)

return Summarize(additional_fields={"name": "EMT MD"}).md(dyn)
return Summarize(
additional_fields={"name": "EMT MD"} | (additional_fields or {})
).md(dyn)
16 changes: 13 additions & 3 deletions src/quacc/recipes/espresso/bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def bands_pw_job(
line_density: float = 20,
force_gamma: bool = True,
test_run: bool = False,
additional_fields: dict[str, Any] | None = None,
**calc_kwargs,
) -> RunSchema:
"""
Expand Down Expand Up @@ -78,6 +79,8 @@ def bands_pw_job(
test_run
If True, a test run is performed to check that the calculation input_data is correct or
to generate some files/info if needed.
additional_fields
Additional fields to add to the results dictionary.
**calc_kwargs
Additional keyword arguments to pass to the Espresso calculator. Set a value to
`quacc.Remove` to remove a pre-existing key entirely. See the docstring of
Expand Down Expand Up @@ -108,7 +111,7 @@ def bands_pw_job(
template=EspressoTemplate("pw", test_run=test_run, outdir=prev_outdir),
calc_defaults=calc_defaults,
calc_swaps=calc_kwargs,
additional_fields={"name": "pw.x bands"},
additional_fields={"name": "pw.x bands"} | (additional_fields or {}),
copy_files=copy_files,
)

Expand All @@ -123,6 +126,7 @@ def bands_pp_job(
) = None,
prev_outdir: SourceDirectory | None = None,
test_run: bool = False,
additional_fields: dict[str, Any] | None = None,
**calc_kwargs,
) -> RunSchema:
"""
Expand All @@ -148,6 +152,8 @@ def bands_pp_job(
test_run
If True, a test run is performed to check that the calculation input_data is correct or
to generate some files/info if needed.
additional_fields
Additional fields to add to the results dictionary.
**calc_kwargs
Additional keyword arguments to pass to the Espresso calculator. Set a value to
`quacc.Remove` to remove a pre-existing key entirely. See the docstring of
Expand All @@ -163,7 +169,8 @@ def bands_pp_job(
template=EspressoTemplate("bands", test_run=test_run, outdir=prev_outdir),
calc_defaults={},
calc_swaps=calc_kwargs,
additional_fields={"name": "bands.x post-processing"},
additional_fields={"name": "bands.x post-processing"}
| (additional_fields or {}),
copy_files=copy_files,
)

Expand All @@ -178,6 +185,7 @@ def fermi_surface_job(
) = None,
prev_outdir: SourceDirectory | None = None,
test_run: bool = False,
additional_fields: dict[str, Any] | None = None,
**calc_kwargs,
) -> RunSchema:
"""
Expand All @@ -202,6 +210,8 @@ def fermi_surface_job(
test_run
If True, a test run is performed to check that the calculation input_data is correct or
to generate some files/info if needed.
additional_fields
Additional fields to add to the results dictionary.
**calc_kwargs
Additional keyword arguments to pass to the Espresso calculator. Set a value to
`quacc.Remove` to remove a pre-existing key entirely. See the docstring of
Expand All @@ -217,7 +227,7 @@ def fermi_surface_job(
template=EspressoTemplate("fs", test_run=test_run, outdir=prev_outdir),
calc_defaults={},
calc_swaps=calc_kwargs,
additional_fields={"name": "fs.x fermi_surface"},
additional_fields={"name": "fs.x fermi_surface"} | (additional_fields or {}),
copy_files=copy_files,
)

Expand Down
Loading
Loading