-
Notifications
You must be signed in to change notification settings - Fork 124
Add updated MP workflows + cleanup #1139
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1bec0b4
Update pyproject.toml
JaGeo 944070e
Update pyproject.toml
JaGeo 82a6305
test a new pymatgen version
JaGeo 283ebe3
Update pyproject.toml
JaGeo c693d61
Update test_utils.py
JaGeo 0752e93
Merge branch 'main' into Fix-mpapi
JaGeo 7375bb3
redraft mp flows
esoteric-ephemera 667ecf1
Merge remote-tracking branch 'jageo/Fix-mpapi' into updated_mp
esoteric-ephemera b729f98
split off openff tests
esoteric-ephemera c697722
remove deprecated flows (completely forgot at the start of the year
esoteric-ephemera 7c56e00
fix pin in strict openff wf
esoteric-ephemera 7a2953a
correctly partition tests?
esoteric-ephemera fdb216f
revert openff_md test ref change
esoteric-ephemera 645385e
openff test over py310-312
esoteric-ephemera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,10 +15,15 @@ | |
from jobflow import Flow, Maker | ||
from pymatgen.io.vasp.sets import LobsterSet | ||
|
||
from atomate2.common.jobs.utils import remove_workflow_files | ||
from atomate2.common.utils import _recursive_get_dir_names | ||
from atomate2.lobster.jobs import LobsterMaker | ||
from atomate2.vasp.flows.core import DoubleRelaxMaker | ||
from atomate2.vasp.flows.lobster import VaspLobsterMaker | ||
from atomate2.vasp.jobs.mp import ( | ||
MP24PreRelaxMaker, | ||
MP24RelaxMaker, | ||
MP24StaticMaker, | ||
MPGGARelaxMaker, | ||
MPGGAStaticMaker, | ||
MPMetaGGARelaxMaker, | ||
|
@@ -29,6 +34,7 @@ | |
logger = logging.getLogger(__name__) | ||
|
||
if TYPE_CHECKING: | ||
from collections.abc import Sequence | ||
from pathlib import Path | ||
|
||
from pymatgen.core.structure import Structure | ||
|
@@ -194,6 +200,95 @@ def make(self, structure: Structure, prev_dir: str | Path | None = None) -> Flow | |
return Flow(jobs=jobs, output=output, name=self.name) | ||
|
||
|
||
@dataclass | ||
class MP24DoubleRelaxMaker(DoubleRelaxMaker): | ||
"""MP24 PBEsol + r2SCAN double relaxation workflow. | ||
|
||
Parameters | ||
---------- | ||
name : str | ||
Name of the flows produced by this maker. | ||
relax_maker1 : .BaseVaspMaker | ||
Maker to generate the first relaxation. | ||
relax_maker2 : .BaseVaspMaker | ||
Maker to generate the second relaxation. | ||
""" | ||
|
||
name: str = "MP24 double relax" | ||
relax_maker1: Maker | None = field(default_factory=MP24PreRelaxMaker) | ||
relax_maker2: Maker = field( | ||
default_factory=lambda: MP24RelaxMaker( | ||
copy_vasp_kwargs={"additional_vasp_files": ("WAVECAR", "CHGCAR")} | ||
) | ||
) | ||
|
||
|
||
@dataclass | ||
class MP24DoubleRelaxStaticMaker(Maker): | ||
"""MP24 workflow to relax a structure with r2SCAN. | ||
|
||
Optionally, files can be automatically cleaned following completion | ||
of the workflow. By default, WAVECAR files are removed. | ||
|
||
Parameters | ||
---------- | ||
name : str | ||
Name of the flows produced by this maker. | ||
relax_maker : .BaseVaspMaker | ||
Maker to generate the relaxation. | ||
static_maker : .BaseVaspMaker | ||
Maker to generate the static calculation before the relaxation. | ||
clean_files : Sequence of str or None | ||
If a list of strings, names of files to remove following the workflow. | ||
By default, this removes the WAVECAR files (gzipped or not). | ||
""" | ||
|
||
name: str = "MP24 r2SCAN workflow" | ||
relax_maker: Maker = field(default_factory=MP24DoubleRelaxMaker) | ||
static_maker: Maker = field( | ||
default_factory=lambda: MP24StaticMaker( | ||
copy_vasp_kwargs={"additional_vasp_files": ("WAVECAR", "CHGCAR")} | ||
) | ||
) | ||
clean_files: Sequence[str] | None = ("WAVECAR",) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One last point: we also delete wavecars in the lobster workflow. Might be worth to make this consistent in the future. |
||
|
||
def make(self, structure: Structure, prev_dir: str | Path | None = None) -> Flow: | ||
"""Relax a structure with r2SCAN. | ||
|
||
Parameters | ||
---------- | ||
structure : .Structure | ||
A pymatgen structure object. | ||
prev_dir : str or Path or None | ||
A previous VASP calculation directory to copy output files from. | ||
|
||
Returns | ||
------- | ||
Flow | ||
A flow containing the MP relaxation workflow. | ||
""" | ||
relax_flow = self.relax_maker.make(structure=structure, prev_dir=prev_dir) | ||
|
||
static_job = self.static_maker.make( | ||
structure=relax_flow.output.structure, prev_dir=relax_flow.output.dir_name | ||
) | ||
|
||
jobs = [relax_flow, static_job] | ||
|
||
self.clean_files = self.clean_files or [] | ||
if len(self.clean_files) > 0: | ||
directories: list[str] = [] | ||
_recursive_get_dir_names(jobs, directories) | ||
cleanup = remove_workflow_files( | ||
directories=directories, | ||
file_names=self.clean_files, | ||
allow_zpath=True, | ||
) | ||
jobs += [cleanup] | ||
|
||
return Flow(jobs=jobs, output=static_job.output, name=self.name) | ||
|
||
|
||
# update potcars to 54, use correct W potcar | ||
# use staticmaker for compatibility | ||
@dataclass | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.