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

ABINIT DFPT SHG #1060

Open
wants to merge 160 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
160 commits
Select commit Hold shift + click to select a range
3aa383b
Abinit workflows: static, non-scf and relaxation.
davidwaroquiers Oct 18, 2022
bd6eef1
Auto-update pre-commit hooks
davidwaroquiers Nov 14, 2022
4bb9fa1
Various changes based on GP's comments.
davidwaroquiers Mar 22, 2023
1dd5498
Merge remote-tracking branch 'upstream/main' into abinit_workflows
davidwaroquiers Mar 22, 2023
1310afb
Removed usage of pmg_serialize.
davidwaroquiers Mar 22, 2023
a5e0998
Fixed issues with changes in current atomate2.
davidwaroquiers Mar 23, 2023
e90797f
Fixed linting.
davidwaroquiers Mar 23, 2023
94c0021
More linting.
davidwaroquiers Mar 23, 2023
cd536cb
More modifications + refactored tests to functions only.
davidwaroquiers Mar 23, 2023
74a2158
change logic of input set generator. update tests
gpetretto Apr 17, 2023
458377a
update abipy version
gpetretto Apr 17, 2023
46f6470
Merge remote-tracking branch 'upstream/main' into abinit2
gpetretto Apr 17, 2023
ebe4411
fix lint
gpetretto Apr 17, 2023
676432a
more lint
gpetretto Apr 17, 2023
7208438
Merge pull request #54 from davidwaroquiers/update/pre-commit-autoupdate
davidwaroquiers May 5, 2023
ed25422
Merge pull request #90 from gpetretto/abinit2
davidwaroquiers May 5, 2023
01cb553
Merge branch 'main' into abinit_workflows
davidwaroquiers May 5, 2023
e813487
DfptFlowMaker reformatted
VicTrqt May 24, 2023
a7180b0
typos jobs/core.py
VicTrqt May 24, 2023
f9d94c5
RF Jobs Maker
VicTrqt May 24, 2023
adf5732
Some debug
VicTrqt Jun 12, 2023
ec3a5e8
NLO WF run_locally
VicTrqt Aug 9, 2023
1913c0a
Output dijk epsij
VicTrqt Sep 3, 2023
9164ab4
Merge remote-tracking branch 'upstream/main' into abinit_workflows
davidwaroquiers Sep 4, 2023
70507e2
Remove debug print
VicTrqt Sep 12, 2023
fe2fb7f
chksymbreak 0 GS
VicTrqt Sep 12, 2023
72293e0
chksymbreak 0 GS again since 0=None...
VicTrqt Sep 12, 2023
adfae4b
chksymbreak 0 GS again, needed AFTER user_kpoint_settings
VicTrqt Sep 12, 2023
ba420ba
Pull trunk main
VicTrqt Sep 15, 2023
8522bde
Merge remote-tracking branch 'upstream/main' into abinit_workflows
davidwaroquiers Sep 18, 2023
d29c6f2
Merge branch 'main' of github.com:materialsproject/atomate2 into abin…
VicTrqt Nov 8, 2023
b35d654
PR review start
VicTrqt Nov 10, 2023
aef6164
linting
VicTrqt Nov 21, 2023
56542f8
Merge branch 'main' of github.com:materialsproject/atomate2 into abin…
VicTrqt Nov 21, 2023
f937f30
linting+pytest
VicTrqt Nov 22, 2023
1c852e8
Start schemas like Aims/CP2K
VicTrqt Nov 24, 2023
03745f0
Start schemas like Aims/CP2K
VicTrqt Nov 24, 2023
ff1ac26
lumi
VicTrqt Dec 5, 2023
573e151
lumi
VicTrqt Dec 5, 2023
3e5c979
abinit schemas
VicTrqt Dec 11, 2023
343f7df
Optional
VicTrqt Dec 11, 2023
4e08f40
test print files
VicTrqt Dec 12, 2023
c7c30c7
remove schemas/core from import
VicTrqt Dec 12, 2023
b3eccc8
outdata files
VicTrqt Dec 12, 2023
cc7fa26
remove if TYPE_CHECKING Vector3D
VicTrqt Dec 12, 2023
4ba9597
gsr abinit version
VicTrqt Dec 12, 2023
49b8bae
abinit_objects to None for the time being
VicTrqt Dec 13, 2023
242a067
trajectory
VicTrqt Dec 13, 2023
03ea099
debugging
VicTrqt Dec 18, 2023
09b1406
functioning abinit workflows schemas
VicTrqt Dec 21, 2023
840c9e7
Merge branch 'main' of github.com:materialsproject/atomate2 into abin…
VicTrqt Dec 21, 2023
8f5279d
Merge branch 'main' of github.com:materialsproject/atomate2
VicTrqt Jan 3, 2024
aedd4cc
debug
VicTrqt Jan 5, 2024
44c53f5
switch critical_events into objects instead of str
VicTrqt Jan 10, 2024
05c3472
autoparal 1 GS
VicTrqt Feb 10, 2024
70de862
Merge branch 'abinit_workflows_dfpt_shg' of github.com:VicTrqt/atomat…
VicTrqt Feb 10, 2024
f6569c7
fix how to check for unconverged states
VicTrqt Feb 14, 2024
c9222c3
remove Molecule
VicTrqt Feb 14, 2024
81aec5c
remove unused PrevOutput + use atomate2.utils.datetime + factory Call…
VicTrqt Feb 14, 2024
3db722a
linting
VicTrqt Feb 15, 2024
c339dac
remove critical_events from calculation
VicTrqt Feb 15, 2024
37a617a
remove commented code
VicTrqt Feb 15, 2024
689a616
linting
VicTrqt Feb 19, 2024
e840f9b
linting + pass tests
VicTrqt Feb 19, 2024
2bbfba4
pull trunk main
VicTrqt Feb 29, 2024
f61f72d
Merge branch 'main' of github.com:materialsproject/atomate2 into abin…
VicTrqt Mar 1, 2024
ed197c3
pull trunk main
VicTrqt Mar 12, 2024
293cabd
linting
VicTrqt Mar 12, 2024
d1a0e3c
pull origin abinit_workflows
VicTrqt Mar 14, 2024
ccfe34f
clean pull origin abinit_workflows
VicTrqt Mar 14, 2024
ea0686d
begin update
VicTrqt Mar 25, 2024
1406f8a
pull trunk main
VicTrqt Apr 9, 2024
528c7a2
update Merge DDB + fix wall/cpu-time field schema
VicTrqt Apr 11, 2024
76f831e
linting
VicTrqt Apr 11, 2024
6f44b93
pull trunk main
VicTrqt Apr 11, 2024
d512411
include pseudos in schemas input field + linting
VicTrqt Apr 11, 2024
5fe421c
Merge branch 'main' of github.com:materialsproject/atomate2
VicTrqt Apr 11, 2024
aeee107
Merge branch 'main' of github.com:VicTrqt/atomate2
VicTrqt Apr 11, 2024
4e5597a
Merge branch 'main' of github.com:VicTrqt/atomate2 into abinit_workfl…
VicTrqt Apr 11, 2024
461f3ad
add test DdkMaker
VicTrqt Apr 12, 2024
b95465b
remove useless testing tol
VicTrqt Apr 12, 2024
d8ada74
modif prev_outputs test_response
VicTrqt Apr 12, 2024
3b95eb2
add test DdeMaker
VicTrqt Apr 12, 2024
a5c5d0d
Merge branch 'main' of github.com:materialsproject/atomate2 into abin…
VicTrqt Apr 17, 2024
a3e3809
use scf_for_phonons factory for static step, factory_kwargs for kpoin…
VicTrqt Apr 17, 2024
362b135
remove testing tol
VicTrqt Apr 18, 2024
94ef40f
remove restart_from for mrgddb job
VicTrqt Jun 24, 2024
258b9d9
remove critical events for mrgddb
VicTrqt Jun 24, 2024
19e1c5f
simplify mrgddb resolve_dep_exts and merge MrgddbSetGenerator into Mr…
VicTrqt Jun 24, 2024
5297c3b
turn shg classmethod into subclass
VicTrqt Jun 24, 2024
01a0ac9
check consistency DDK, DDE, DTE, Mrgddb
VicTrqt Jun 24, 2024
861f6d2
add check for output None
VicTrqt Jun 25, 2024
40014fc
use default(field) for DdkMaker and co. in run_ddk_rf
VicTrqt Jun 25, 2024
8c9b64c
create generic run_rf
VicTrqt Jun 26, 2024
e7e350b
put core of DdkMaker,... into new ResponseMaker
VicTrqt Jun 26, 2024
9f2a69f
new AbiBroadInputGenerator as common super class of all other Abinit …
VicTrqt Jun 26, 2024
b39fc29
add testing possibility
VicTrqt Jun 26, 2024
4fd27c3
debug
VicTrqt Jun 26, 2024
37581a0
start AnaddbMaker
VicTrqt Jun 27, 2024
a8e6c0e
finish functional AnaddbMaker
VicTrqt Jun 28, 2024
d8740de
linting
VicTrqt Jun 28, 2024
d8b1f60
pull trunk main
VicTrqt Jun 28, 2024
0a03331
linting
VicTrqt Jun 28, 2024
bfda61a
linting
VicTrqt Jun 28, 2024
55c5dd6
linting
VicTrqt Jul 1, 2024
8c96fb3
fix test ddk and dde to handle prev_outputs as gz
VicTrqt Jul 16, 2024
fd54870
tests dte and mrgddb + modif flatten prev_outputs mrgddb
VicTrqt Jul 17, 2024
8c49db9
add tests anaddb
VicTrqt Jul 17, 2024
96f8674
store DDB + add LDA PSP
VicTrqt Jul 22, 2024
5a11071
store _POT files
VicTrqt Jul 22, 2024
92b43e9
save _POT is optional
VicTrqt Jul 22, 2024
1d2e8fd
stored files as generic object + fix encode/decode bytes data
VicTrqt Jul 23, 2024
b1a93bc
Merge branch 'main' of github.com:materialsproject/atomate2 into abin…
VicTrqt Jul 23, 2024
22025bf
linting
VicTrqt Jul 23, 2024
018b211
linting
VicTrqt Jul 23, 2024
ad68670
add TODO
VicTrqt Jul 24, 2024
1149895
change output of Flow to allow gzip/del files
VicTrqt Jul 29, 2024
0277c8f
add del_gzip job + ScfConvergenceWarning for Ddk for unconverged case
VicTrqt Jul 30, 2024
8726768
fix del_gzip
VicTrqt Jul 30, 2024
631341e
linting
VicTrqt Jul 30, 2024
42038ce
review Guido PR
VicTrqt Jul 31, 2024
ded305a
address some comments of Guido
VicTrqt Jul 31, 2024
f1c7abf
address gpetretto's review
VicTrqt Jul 31, 2024
9ab1b23
add dir of del_gzip_files to zip
VicTrqt Jul 31, 2024
69a3b26
fix del_gzip_files
VicTrqt Aug 2, 2024
f2f315d
fix dfpt flow ddk append_name
VicTrqt Aug 2, 2024
6d06014
fix dfpt flow ddk append_name
VicTrqt Aug 2, 2024
a7db2ee
linting
VicTrqt Aug 2, 2024
03b62fa
stop_jobflow for ResponseMaker
VicTrqt Aug 8, 2024
e51bde7
fix files_to_store, strip_hostname, mrgddb_report
VicTrqt Aug 26, 2024
00590dd
linting
VicTrqt Sep 17, 2024
103038d
fix stop_jobflow_on_failure
VicTrqt Sep 17, 2024
1fb11a8
fix del_gzip_files bc strip_hostname
VicTrqt Sep 18, 2024
9599178
fix
VicTrqt Sep 20, 2024
a8808b1
fix name ddk job in dfpt flow
VicTrqt Sep 23, 2024
ed853c8
pull trunk main + fix linting
VicTrqt Sep 30, 2024
6a49091
fix run_mrgddb and run_anaddb + AbinitPseudoDoc
VicTrqt Oct 1, 2024
e9df035
use iterflow to clean flow
VicTrqt Oct 1, 2024
3055638
fix cleaning function
VicTrqt Oct 1, 2024
2469f1a
history_dirs in AbinitTaskDoc + fix clean_flow
VicTrqt Oct 2, 2024
ce55074
allow parallelization for anaddb
VicTrqt Oct 2, 2024
846d3aa
remove some comments
VicTrqt Oct 2, 2024
3a90dce
remove some comments
VicTrqt Oct 2, 2024
4a704f1
merge review PR
VicTrqt Oct 2, 2024
52f1a1f
fix check 1DEN files ext
VicTrqt Oct 3, 2024
ae91bf1
Merge branch 'abinit_workflows_dfpt_shg_new_review-PR' into abinit_wo…
VicTrqt Oct 3, 2024
7ac2662
add test flows dfpt shg
VicTrqt Oct 4, 2024
f4ce054
Merge branch 'abinit_workflows_dfpt_shg_new_review-PR' into abinit_wo…
VicTrqt Oct 4, 2024
b110095
add test flow shg
VicTrqt Oct 4, 2024
05d1884
Merge branch 'abinit_workflows_dfpt_shg_new_review-PR' into abinit_wo…
VicTrqt Oct 4, 2024
078e3b1
fix comments
VicTrqt Oct 10, 2024
bc95b4a
Merge branch 'main' of github.com:materialsproject/atomate2 into abin…
VicTrqt Oct 10, 2024
8a12e54
remove unconventional tests
VicTrqt Oct 10, 2024
11fc0ea
Merge branch 'main' of github.com:materialsproject/atomate2 into abin…
VicTrqt Nov 26, 2024
bd336d5
tmp abipy github requirement
VicTrqt Nov 26, 2024
38073cd
linting
VicTrqt Nov 26, 2024
f532d27
linting
VicTrqt Nov 26, 2024
4bbda09
fix test generate_dte_perts abipy manager
VicTrqt Nov 26, 2024
9832136
install abinit in env pytest
VicTrqt Nov 26, 2024
7b4a66a
add skip to dfpt test
VicTrqt Nov 26, 2024
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
4 changes: 1 addition & 3 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,12 @@ jobs:

- name: Install conda dependencies
run: |
micromamba install -n a2 -c conda-forge enumlib packmol bader openbabel openff-toolkit==0.16.2 openff-interchange==0.3.22 --yes
micromamba install -n a2 -c conda-forge enumlib packmol bader openbabel abinit openff-toolkit==0.16.2 openff-interchange==0.3.22 --yes

- name: Install dependencies
run: |
micromamba activate a2
python -m pip install --upgrade pip
mkdir -p ~/.abinit/pseudos
cp -r tests/test_data/abinit/pseudos/ONCVPSP-PBE-SR-PDv0.4 ~/.abinit/pseudos
uv pip install .[strict,strict-forcefields,tests,abinit]
uv pip install torch-runstats
uv pip install --no-deps nequip==0.5.6
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ dependencies = [
]

[project.optional-dependencies]
abinit = ["abipy>=0.9.3"]
#abinit = ["abipy>=0.9.3"]
abinit = ["abipy @ git+https://github.com/abinit/abipy.git"] # tmp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we merge this, we would definitely need a new abipy version.

amset = ["amset>=0.4.15", "pydash"]
cclib = ["cclib"]
mp = ["mp-api>=0.37.5"]
Expand Down
154 changes: 151 additions & 3 deletions src/atomate2/abinit/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,44 @@

from __future__ import annotations

import contextlib
import logging
import os
from pathlib import Path
from typing import TYPE_CHECKING

from abipy.flowtk.utils import abi_extensions
from jobflow.core.job import job
from monty.serialization import loadfn

from atomate2 import SETTINGS
from atomate2.abinit.utils.common import INDIR_NAME
from atomate2.common.files import delete_files, gzip_files
from atomate2.utils.file_client import FileClient, auto_fileclient
from atomate2.utils.path import strip_hostname

if TYPE_CHECKING:
from collections.abc import Iterable
from pathlib import Path

from abipy.abio.inputs import AbinitInput
from pymatgen.core.structure import Structure

from atomate2.abinit.sets.anaddb import AnaddbInputGenerator
from atomate2.abinit.sets.base import AbinitInputGenerator
from atomate2.abinit.sets.mrgddb import MrgddbInputGenerator

__all__ = [
"del_gzip_files",
"fname2ext",
"load_abinit_input",
"out_to_in",
"write_abinit_input_set",
"write_anaddb_input_set",
"write_mrgddb_input_set",
]

logger = logging.getLogger(__name__)


ALL_ABIEXTS = abi_extensions()


Expand All @@ -37,6 +52,10 @@ def fname2ext(filepath: Path | str) -> None | str:
if "_" not in filename:
return None
ext = filename.split("_")[-1].replace(".nc", "")
if "1WF" in ext:
ext = "1WF"
if "DEN" in ext and ext[-1].isdigit():
ext = "1DEN"
if ext not in ALL_ABIEXTS:
return None
return ext
Expand Down Expand Up @@ -98,10 +117,11 @@ def load_abinit_input(
AbinitInput
The AbinitInput object.
"""
dirpath = strip_hostname(dirpath) # TODO: to FileCLient?
abinit_input_file = os.path.join(dirpath, f"{fname}")
if not os.path.exists(abinit_input_file):
raise NotImplementedError(
f"Cannot load AbinitInput from directory without {fname} file."
f"Cannot load AbinitInput from directory {dirpath} without {fname} file."
)

return loadfn(abinit_input_file)
Expand Down Expand Up @@ -139,3 +159,131 @@ def write_abinit_input_set(
raise RuntimeError("AbinitInputSet is not valid.")

ais.write_input(directory=directory, make_dir=True, overwrite=False)


def write_mrgddb_input_set(
input_set_generator: MrgddbInputGenerator,
prev_outputs: str | Path | list[str] | None = None,
directory: str | Path = ".",
) -> None:
"""Write the mrgddb input using a given generator.

Parameters
----------
input_set_generator
The input generator used to write the mrgddb inputs.
prev_outputs
The list of previous directories needed for the calculation.
directory
Directory in which to write the abinit inputs.
"""
mrgis = input_set_generator.get_input_set(
prev_outputs=prev_outputs,
workdir=directory,
)
if not mrgis.validate():
raise RuntimeError(
"MrgddbInputSet is not valid. Some previous outputs \
do not exist."
)

mrgis.write_input(directory=directory, make_dir=True, overwrite=False)


def write_anaddb_input_set(
structure: Structure,
input_set_generator: AnaddbInputGenerator,
prev_outputs: str | Path | list[str] | None = None,
directory: str | Path = ".",
) -> None:
"""Write the anaddb input using a given generator.

Parameters
----------
input_set_generator
The input generator used to write the anaddb inputs.
prev_outputs
The list of previous directories needed for the calculation.
directory
Directory in which to write the abinit inputs.
"""
anais = input_set_generator.get_input_set(
structure=structure,
prev_outputs=prev_outputs,
)
if not anais.validate():
raise RuntimeError(
"AnaddbInputSet is not valid. Some previous outputs \
do not exist."
)

anais.write_input(directory=directory, make_dir=True, overwrite=False)


# TODO: does not take the directories of the store_inputs
@job
def del_gzip_files(
outputs: list,
exclude_files_from_zip: list[str | Path] | None = None,
delete: bool = True,
exclude_files_from_del: list[str | Path] | None = None,
include_files_to_del: list[str | Path] | None = None,
) -> None:
r"""Delete and gzip files from a previous Job or Flow.

Parameters
----------
outputs
Outputs of the Job or Flow that needs its files deleted/compressed.
exclude_files_from_zip
Filenames to exclude from the compression.
Supports glob file matching, e.g., "\*.dat".
delete: bool = True,
Activates the deletion of the files or not.
exclude_files_from_del
Filenames to exclude from the compression.
Supports glob file matching, e.g., "\*.dat".
include_files_to_del
Filenames to include as a list of str or Path objects given relative to
directory. Glob file paths are supported, e.g. "\*.dat". If ``None``, all files
in the directory will be deleted.
"""
dirs_to_clean = []
for o in outputs:
with contextlib.suppress(TypeError, AttributeError):
dirs_to_clean.append(o.dir_name)
with contextlib.suppress(TypeError, AttributeError, KeyError):
dirs_to_clean.extend(o["dirs"])
with contextlib.suppress(TypeError, AttributeError, KeyError):
dirs_to_clean.append(o["dir_name"]) # to zip run_rf and generate_perts
with contextlib.suppress(TypeError, AttributeError, KeyError):
dirs_to_clean.extend(
o.history_dirs
) # to clean dirs unconverged and restarted

recursiv_dirs_to_clean = []
for dz_ in dirs_to_clean:
dz = strip_hostname(dz_)
recursiv_dirs_to_clean.append(Path(dz))
for root, _, _ in os.walk(dz):
recursiv_dirs_to_clean.append(Path(root))
# to take its own directory into account
recursiv_dirs_to_clean.append(Path(os.getcwd()))

if delete:
if include_files_to_del is None:
include_files_to_del = SETTINGS.ABINIT_FILES_TO_DEL
for d in recursiv_dirs_to_clean:
delete_files(
directory=strip_hostname(d),
include_files=include_files_to_del,
exclude_files=exclude_files_from_del,
allow_missing=True,
)

for d in recursiv_dirs_to_clean:
gzip_files(
directory=strip_hostname(d),
exclude_files=exclude_files_from_zip,
force=True,
)
Loading
Loading