Skip to content

Commit cc2f016

Browse files
lint
1 parent 01c2cb0 commit cc2f016

File tree

5 files changed

+72
-72
lines changed

5 files changed

+72
-72
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Rationale
5757
| IMAGES | IMAGES must be set to 0 to match MP calculations. |
5858
| INIWAV | INIWAV must be set as the VASP default of 1 to be consistent with MP calculations. |
5959
| ISPIN | All values of ISPIN are allowed, though it should be noted that virtuall all MP calculations permit spin symmetry breaking, and have ferromagnetic, antiferrogmanetic, or nonmagnetic ordering. |
60-
| ISMEAR | The appropriate ISMEAR depends on the bandgap of the material (which cannot be known a priori). As per the VASP manual: for metals (bandgap = 0), any ISMEAR value in [0, 1, 2] is acceptable. For nonmetals (bandgap > 0), any ISMEAR value in [-5, 0] is acceptable. Hence, for those who are performing normal relaxations/static calculations and want to ensure their calculations are MP-compatible, we recommend setting ISMEAR to 0. |
60+
| ISMEAR | The appropriate ISMEAR depends on the bandgap of the material (which cannot be known a priori). As per the VASP manual: for metals (bandgap = 0), any ISMEAR value in [0, 1, 2] is acceptable. For nonmetals (bandgap > 0), any ISMEAR value in [-5, 0] is acceptable. Hence, for those who are performing normal relaxations/static calculations and want to ensure their calculations are MP-compatible, we recommend setting ISMEAR to 0. |
6161
| ISIF | MP allows any ISIF $\geq 2$. This value is restricted as such simply because all ISIF values $\geq 2$ output the complete stress tensor. |
6262
| ISYM | ISYM must be one of -1, 0, 1, 2, except for when the relevant MP input set uses a hybrid functional, in which case ISYM=3 is also allowed. |
6363
| ISTART | ISTART must be one of: 0, 1, 2. |
@@ -110,4 +110,4 @@ Rationale
110110
| SYMPREC | SYMPREC must be less than or equal to 1e-3 (as this is the maximum value that the Custodian package will set SYMPREC as of March 2024). |
111111
| SIGMA | There are several rules for setting SIGMA: <ol> <li> SIGMA must be $\leq 0.05$ for non-metals (bandgap $> 0$). </li> <li> SIGMA must be $\leq 0.2$ for a metal (bandgap = 0). </li> <li> For metals, the SIGMA value must be small enough that the entropy term in the energy is $\leq$ 1 meV/atom (as suggested by the VASP manual). </li> </ol> |
112112
| VCA | MP data does not include Virtual Crystal Approximation (VCA) calculations from VASP. As such, this parameter should not be set. |
113-
| VASP version | The following versions of VASP are allowed: 5.4.4 or $>$6.0.0. Versions $<=$ 5.4.3 are not allowed. Version 6.3.1, for example, is allowed. |
113+
| VASP version | The following versions of VASP are allowed: 5.4.4 or $>$6.0.0. Versions $<=$ 5.4.3 are not allowed. Version 6.3.1, for example, is allowed. |

examples/MP_compliant_job.py

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from __future__ import annotations
32

43
from emmet.core.utils import jsanitize
@@ -9,117 +8,110 @@
98
from pymatgen.core import Structure, Lattice
109

1110

12-
def get_GaAs_structure(
13-
a0 : float = 5.6
14-
) -> Structure:
11+
def get_GaAs_structure(a0: float = 5.6) -> Structure:
1512

16-
lattice_vectors = a0*np.array([
17-
[0.0 if i == j else 0.5 for j in range(3)]
18-
for i in range(3)
19-
])
13+
lattice_vectors = a0 * np.array([[0.0 if i == j else 0.5 for j in range(3)] for i in range(3)])
2014
return Structure(
21-
lattice = Lattice(lattice_vectors),
22-
species = ["Ga","As"],
23-
coords = [[0.125, 0.125, 0.125], [0.875, 0.875, 0.875]],
15+
lattice=Lattice(lattice_vectors),
16+
species=["Ga", "As"],
17+
coords=[[0.125, 0.125, 0.125], [0.875, 0.875, 0.875]],
2418
coords_are_cartesian=False,
2519
)
2620

27-
def assign_meta(flow, metadata : dict, name : str | None = None):
28-
if hasattr(flow,"jobs"):
21+
22+
def assign_meta(flow, metadata: dict, name: str | None = None):
23+
if hasattr(flow, "jobs"):
2924
for ijob in range(len(flow.jobs)):
30-
assign_meta(flow.jobs[ijob],metadata,name=name)
25+
assign_meta(flow.jobs[ijob], metadata, name=name)
3126
if name:
3227
flow.name = name
3328
else:
3429
flow.metadata = metadata.copy()
3530
if name:
3631
flow.name = name
3732

33+
3834
def get_MP_compliant_r2SCAN_flow(
39-
structure : Structure,
40-
user_incar_settings : dict | None = None,
41-
metadata : dict | None = None,
42-
name : str | None = None
35+
structure: Structure, user_incar_settings: dict | None = None, metadata: dict | None = None, name: str | None = None
4336
) -> Flow:
44-
37+
4538
from atomate2.vasp.jobs.mp import MPMetaGGAStaticMaker
4639
from atomate2.vasp.powerups import update_user_incar_settings
4740

4841
maker = MPMetaGGAStaticMaker()
4942

5043
user_incar_settings = user_incar_settings or {}
5144
if len(user_incar_settings) > 0:
52-
maker = update_user_incar_settings(
53-
maker, incar_updates = user_incar_settings
54-
)
45+
maker = update_user_incar_settings(maker, incar_updates=user_incar_settings)
5546

5647
flow = maker.make(structure)
5748

5849
metadata = metadata or {}
59-
assign_meta(flow,metadata,name=name)
50+
assign_meta(flow, metadata, name=name)
6051

6152
return flow
6253

63-
def run_job_fully_locally(flow, job_store = None):
54+
55+
def run_job_fully_locally(flow, job_store=None):
6456

6557
from jobflow import run_locally, JobStore
6658
from maggma.stores import MemoryStore
6759

6860
if job_store is None:
6961
job_store = JobStore(MemoryStore(), additional_stores={"data": MemoryStore()})
70-
71-
response = run_locally(flow, store = job_store, create_folders = True)
62+
63+
response = run_locally(flow, store=job_store, create_folders=True)
7264
uuid = list(response)[0]
7365
return response[uuid][1].output
7466

67+
7568
def MP_compliant_calc():
7669

7770
structure = get_GaAs_structure()
7871
flow = get_MP_compliant_r2SCAN_flow(
79-
structure = structure,
80-
user_incar_settings = { # some forward-looking settings
72+
structure=structure,
73+
user_incar_settings={ # some forward-looking settings
8174
"LREAL": False,
8275
"LMAXMIX": 6,
83-
"LCHARG": False, # following tags just set for convenience
76+
"LCHARG": False, # following tags just set for convenience
8477
"LWAVE": False,
8578
"LAECHG": False,
8679
"NCORE": 16,
87-
"KPAR": 2
88-
}
80+
"KPAR": 2,
81+
},
8982
)
9083
return run_job_fully_locally(flow)
9184

85+
9286
def MP_non_compliant_calc():
9387

9488
structure = get_GaAs_structure()
9589
flow = get_MP_compliant_r2SCAN_flow(
96-
structure = structure,
97-
user_incar_settings = { # some backward-looking settings
98-
"ENCUT": 450.,
99-
"ENAUG": 900.,
90+
structure=structure,
91+
user_incar_settings={ # some backward-looking settings
92+
"ENCUT": 450.0,
93+
"ENAUG": 900.0,
10094
"KSPACING": 0.5,
101-
"LCHARG": False, # following tags just set for convenience
95+
"LCHARG": False, # following tags just set for convenience
10296
"LWAVE": False,
10397
"LAECHG": False,
10498
"NCORE": 16,
105-
"KPAR": 2
106-
}
99+
"KPAR": 2,
100+
},
107101
)
108102
return run_job_fully_locally(flow)
109103

104+
110105
def MP_flows() -> None:
111-
106+
112107
compliant_task_doc = MP_compliant_calc()
113-
dumpfn(jsanitize(compliant_task_doc),"./MP_compatible_GaAs_r2SCAN_static.json.gz")
108+
dumpfn(jsanitize(compliant_task_doc), "./MP_compatible_GaAs_r2SCAN_static.json.gz")
114109

115110
non_compliant_task_doc = MP_non_compliant_calc()
116-
dumpfn(jsanitize(non_compliant_task_doc),"./MP_incompatible_GaAs_r2SCAN_static.json.gz")
111+
dumpfn(jsanitize(non_compliant_task_doc), "./MP_incompatible_GaAs_r2SCAN_static.json.gz")
117112

118-
def generate_task_documents(
119-
cdir,
120-
task_id : str | None = None,
121-
filename : str | None = None
122-
) -> TaskDocument:
113+
114+
def generate_task_documents(cdir, task_id: str | None = None, filename: str | None = None) -> TaskDocument:
123115

124116
from atomate.vasp.drones import VaspDrone
125117
from emmet.core.mpid import MPID
@@ -132,10 +124,11 @@ def generate_task_documents(
132124
task_doc = TaskDocument(**task_doc_dict)
133125

134126
if filename:
135-
dumpfn(jsanitize(task_doc),filename)
136-
127+
dumpfn(jsanitize(task_doc), filename)
128+
137129
return task_doc
138130

131+
139132
if __name__ == "__main__":
140133

141-
MP_flows()
134+
MP_flows()

pymatgen/io/validation/check_potcar.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,23 @@ def check(self, reasons: list[str], valid_input_set: VaspInputSet, structure: St
110110
"other errors have been seen. Hence, it is marked as invalid."
111111
)
112112

113-
def compare_potcar_stats(self, potcar_stats_1: dict, potcar_stats_2 : dict) -> bool:
114-
""" Utility function to compare PotcarSingle._summary_stats. """
115-
116-
if (
117-
not all(potcar_stats_1.get(key) for key in ("keywords","stats",))
118-
or (not all(potcar_stats_2.get(key) for key in ("keywords","stats",)))
113+
def compare_potcar_stats(self, potcar_stats_1: dict, potcar_stats_2: dict) -> bool:
114+
"""Utility function to compare PotcarSingle._summary_stats."""
115+
116+
if not all(
117+
potcar_stats_1.get(key)
118+
for key in (
119+
"keywords",
120+
"stats",
121+
)
122+
) or (
123+
not all(
124+
potcar_stats_2.get(key)
125+
for key in (
126+
"keywords",
127+
"stats",
128+
)
129+
)
119130
):
120131
return False
121132

@@ -127,10 +138,10 @@ def compare_potcar_stats(self, potcar_stats_1: dict, potcar_stats_2 : dict) -> b
127138
data_match = False
128139
if key_match:
129140
data_diff = [
130-
abs(potcar_stats_1["stats"].get(key,{}).get(stat) - potcar_stats_2["stats"].get(key,{}).get(stat)) # type: ignore
141+
abs(potcar_stats_1["stats"].get(key, {}).get(stat) - potcar_stats_2["stats"].get(key, {}).get(stat)) # type: ignore
131142
for stat in ["MEAN", "ABSMEAN", "VAR", "MIN", "MAX"]
132143
for key in ["header", "data"]
133144
]
134145
data_match = all(np.array(data_diff) < self.data_match_tol)
135-
136-
return key_match and data_match
146+
147+
return key_match and data_match

pymatgen/io/validation/validation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from typing import TYPE_CHECKING
3838

3939
if TYPE_CHECKING:
40-
from typing import Any, Union
40+
from typing import Any
4141

4242
SETTINGS = IOValidationSettings()
4343
_vasp_defaults = loadfn(SETTINGS.VASP_DEFAULTS_FILENAME)
@@ -97,7 +97,7 @@ class Config: # noqa
9797
@classmethod
9898
def from_task_doc(
9999
cls,
100-
task_doc: Union[TaskDoc | TaskDocument],
100+
task_doc: TaskDoc | TaskDocument,
101101
input_sets: dict[str, ImportString] = SETTINGS.VASP_DEFAULT_INPUT_SETS,
102102
check_potcar: bool = True,
103103
kpts_tolerance: float = SETTINGS.VASP_KPTS_TOLERANCE,
@@ -123,7 +123,7 @@ def from_task_doc(
123123
initial equillibriation period. Note this is in eV per atom.
124124
"""
125125

126-
if isinstance(task_doc,TaskDocument):
126+
if isinstance(task_doc, TaskDocument):
127127
task_doc = TaskDoc(**task_doc.model_dump())
128128

129129
bandgap = task_doc.output.bandgap

tests/test_validation.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ def test_vasp_version_check(test_dir, object_name):
552552
temp_task_doc.input.parameters["ISPIN"] = 2
553553
run_check(temp_task_doc, "POTENTIAL BUG --> We believe", False)
554554

555+
555556
def test_task_document(test_dir):
556557

557558
from emmet.core.vasp.task_valid import TaskDocument
@@ -561,21 +562,16 @@ def test_task_document(test_dir):
561562
str(test_dir / "vasp" / "TaskDocuments" / "MP_compatible_GaAs_r2SCAN_static_TaskDocument.json.gz")
562563
)
563564
calcs["non-compliant"] = loadfn(
564-
str(test_dir / "vasp" / "TaskDocuments" / "MP_incompatible_GaAs_r2SCAN_static_TaskDocument.json.gz")
565+
str(test_dir / "vasp" / "TaskDocuments" / "MP_incompatible_GaAs_r2SCAN_static_TaskDocument.json.gz")
565566
)
566567

567568
valid_docs = {}
568569
for calc in calcs:
569-
valid_docs[calc] = ValidationDoc.from_task_doc(
570-
TaskDocument(**calcs[calc])
571-
)
570+
valid_docs[calc] = ValidationDoc.from_task_doc(TaskDocument(**calcs[calc]))
572571

573572
assert valid_docs["compliant"].valid
574573
assert not valid_docs["non-compliant"].valid
575574

576-
expected_reasons = ["KPOINTS","ENCUT","ENAUG"]
575+
expected_reasons = ["KPOINTS", "ENCUT", "ENAUG"]
577576
for expected_reason in expected_reasons:
578-
assert any(
579-
expected_reason in reason
580-
for reason in valid_docs["non-compliant"].reasons
581-
)
577+
assert any(expected_reason in reason for reason in valid_docs["non-compliant"].reasons)

0 commit comments

Comments
 (0)