|
| 1 | +"""Core jobs for running VASP calculations.""" |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +import logging |
| 6 | +from dataclasses import dataclass, field |
| 7 | +from typing import TYPE_CHECKING |
| 8 | + |
| 9 | +from pymatgen.io.vasp.sets import MVLGWSet |
| 10 | + |
| 11 | +from atomate2.vasp.jobs.base import BaseVaspMaker, vasp_job |
| 12 | + |
| 13 | +if TYPE_CHECKING: |
| 14 | + from pathlib import Path |
| 15 | + |
| 16 | + from jobflow import Response |
| 17 | + from pymatgen.core.structure import Structure |
| 18 | + |
| 19 | + from atomate2.vasp.sets.base import VaspInputGenerator |
| 20 | + |
| 21 | + |
| 22 | +logger = logging.getLogger(__name__) |
| 23 | + |
| 24 | + |
| 25 | +@dataclass |
| 26 | +class MVLStaticMaker(BaseVaspMaker): |
| 27 | + """ |
| 28 | + Maker to create a static calculation compatible with Materials Virtual Lab GW jobs. |
| 29 | +
|
| 30 | + Parameters |
| 31 | + ---------- |
| 32 | + name : str |
| 33 | + The job name. |
| 34 | + input_set_generator : .VaspInputGenerator |
| 35 | + A generator used to make the input set. |
| 36 | + write_input_set_kwargs : dict |
| 37 | + Keyword arguments that will get passed to :obj:`.write_vasp_input_set`. |
| 38 | + copy_vasp_kwargs : dict |
| 39 | + Keyword arguments that will get passed to :obj:`.copy_vasp_outputs`. |
| 40 | + run_vasp_kwargs : dict |
| 41 | + Keyword arguments that will get passed to :obj:`.run_vasp`. |
| 42 | + task_document_kwargs : dict |
| 43 | + Keyword arguments that will get passed to :obj:`.TaskDoc.from_directory`. |
| 44 | + stop_children_kwargs : dict |
| 45 | + Keyword arguments that will get passed to :obj:`.should_stop_children`. |
| 46 | + write_additional_data : dict |
| 47 | + Additional data to write to the current directory. Given as a dict of |
| 48 | + {filename: data}. Note that if using FireWorks, dictionary keys cannot contain |
| 49 | + the "." character which is typically used to denote file extensions. To avoid |
| 50 | + this, use the ":" character, which will automatically be converted to ".". E.g. |
| 51 | + ``{"my_file:txt": "contents of the file"}``. |
| 52 | + """ |
| 53 | + |
| 54 | + name: str = "MVL static" |
| 55 | + input_set_generator: VaspInputGenerator = field( |
| 56 | + default_factory=lambda: MVLGWSet(mode="STATIC") |
| 57 | + ) |
| 58 | + |
| 59 | + @vasp_job |
| 60 | + def make( |
| 61 | + self, |
| 62 | + structure: Structure, |
| 63 | + prev_dir: str | Path | None = None, |
| 64 | + ) -> Response: |
| 65 | + """ |
| 66 | + Run a static calculation compatible with later Materials Virtual Lab GW jobs. |
| 67 | +
|
| 68 | + Parameters |
| 69 | + ---------- |
| 70 | + structure : .Structure |
| 71 | + A pymatgen structure object. |
| 72 | + prev_dir : str or Path or None |
| 73 | + A previous VASP calculation directory to copy output files from. |
| 74 | + """ |
| 75 | + return super().make.original(self, structure, prev_dir) |
| 76 | + |
| 77 | + |
| 78 | +@dataclass |
| 79 | +class MVLNonSCFMaker(BaseVaspMaker): |
| 80 | + """ |
| 81 | + Maker to create a non-scf calculation compatible with Materials Virtual Lab GW jobs. |
| 82 | +
|
| 83 | + Parameters |
| 84 | + ---------- |
| 85 | + name : str |
| 86 | + The job name. |
| 87 | + input_set_generator : .VaspInputGenerator |
| 88 | + A generator used to make the input set. |
| 89 | + write_input_set_kwargs : dict |
| 90 | + Keyword arguments that will get passed to :obj:`.write_vasp_input_set`. |
| 91 | + copy_vasp_kwargs : dict |
| 92 | + Keyword arguments that will get passed to :obj:`.copy_vasp_outputs`. |
| 93 | + run_vasp_kwargs : dict |
| 94 | + Keyword arguments that will get passed to :obj:`.run_vasp`. |
| 95 | + task_document_kwargs : dict |
| 96 | + Keyword arguments that will get passed to :obj:`.TaskDoc.from_directory`. |
| 97 | + stop_children_kwargs : dict |
| 98 | + Keyword arguments that will get passed to :obj:`.should_stop_children`. |
| 99 | + write_additional_data : dict |
| 100 | + Additional data to write to the current directory. Given as a dict of |
| 101 | + {filename: data}. Note that if using FireWorks, dictionary keys cannot contain |
| 102 | + the "." character which is typically used to denote file extensions. To avoid |
| 103 | + this, use the ":" character, which will automatically be converted to ".". E.g. |
| 104 | + ``{"my_file:txt": "contents of the file"}``. |
| 105 | + """ |
| 106 | + |
| 107 | + name: str = "MVL nscf" |
| 108 | + input_set_generator: VaspInputGenerator = field( |
| 109 | + default_factory=lambda: MVLGWSet(mode="DIAG") |
| 110 | + ) |
| 111 | + |
| 112 | + @vasp_job |
| 113 | + def make( |
| 114 | + self, |
| 115 | + structure: Structure, |
| 116 | + prev_dir: str | Path | None = None, |
| 117 | + ) -> Response: |
| 118 | + """ |
| 119 | + Run a static calculation compatible with later Materials Virtual Lab GW jobs. |
| 120 | +
|
| 121 | + Parameters |
| 122 | + ---------- |
| 123 | + structure : .Structure |
| 124 | + A pymatgen structure object. |
| 125 | + prev_dir : str or Path or None |
| 126 | + A previous VASP calculation directory to copy output files from. |
| 127 | + """ |
| 128 | + self.copy_vasp_kwargs.setdefault("additional_vasp_files", ("CHGCAR",)) |
| 129 | + |
| 130 | + return super().make.original(self, structure, prev_dir) |
| 131 | + |
| 132 | + |
| 133 | +@dataclass |
| 134 | +class MVLGWMaker(BaseVaspMaker): |
| 135 | + """ |
| 136 | + Maker to create Materials Virtual Lab GW jobs. |
| 137 | +
|
| 138 | + This class can make the jobs for the typical three stapes of the GW calculation. |
| 139 | +
|
| 140 | + Parameters |
| 141 | + ---------- |
| 142 | + name : str |
| 143 | + The job name. |
| 144 | + input_set_generator : .VaspInputGenerator |
| 145 | + A generator used to make the input set. |
| 146 | + write_input_set_kwargs : dict |
| 147 | + Keyword arguments that will get passed to :obj:`.write_vasp_input_set`. |
| 148 | + copy_vasp_kwargs : dict |
| 149 | + Keyword arguments that will get passed to :obj:`.copy_vasp_outputs`. |
| 150 | + run_vasp_kwargs : dict |
| 151 | + Keyword arguments that will get passed to :obj:`.run_vasp`. |
| 152 | + task_document_kwargs : dict |
| 153 | + Keyword arguments that will get passed to :obj:`.TaskDoc.from_directory`. |
| 154 | + stop_children_kwargs : dict |
| 155 | + Keyword arguments that will get passed to :obj:`.should_stop_children`. |
| 156 | + write_additional_data : dict |
| 157 | + Additional data to write to the current directory. Given as a dict of |
| 158 | + {filename: data}. Note that if using FireWorks, dictionary keys cannot contain |
| 159 | + the "." character which is typically used to denote file extensions. To avoid |
| 160 | + this, use the ":" character, which will automatically be converted to ".". E.g. |
| 161 | + ``{"my_file:txt": "contents of the file"}``. |
| 162 | + """ |
| 163 | + |
| 164 | + name: str = "MVL G0W0" |
| 165 | + input_set_generator: VaspInputGenerator = field( |
| 166 | + default_factory=lambda: MVLGWSet(mode="GW") |
| 167 | + ) |
| 168 | + |
| 169 | + @vasp_job |
| 170 | + def make( |
| 171 | + self, |
| 172 | + structure: Structure, |
| 173 | + prev_dir: str | Path | None = None, |
| 174 | + ) -> Response: |
| 175 | + """ |
| 176 | + Run a Materials Virtual Lab GW band structure VASP job. |
| 177 | +
|
| 178 | + Parameters |
| 179 | + ---------- |
| 180 | + structure : .Structure |
| 181 | + A pymatgen structure object. |
| 182 | + prev_dir : str or Path or None |
| 183 | + A previous VASP calculation directory to copy output files from. |
| 184 | + """ |
| 185 | + self.copy_vasp_kwargs.setdefault( |
| 186 | + "additional_vasp_files", ("CHGCAR", "WAVECAR", "WAVEDER") |
| 187 | + ) |
| 188 | + |
| 189 | + return super().make.original(self, structure, prev_dir) |
0 commit comments