Skip to content

Commit

Permalink
Add option to pass potcar hash dict to validation
Browse files Browse the repository at this point in the history
  • Loading branch information
munrojm committed Jul 13, 2022
1 parent 46957e4 commit 9ecbee6
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions emmet-builders/emmet/builders/vasp/task_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from emmet.builders.settings import EmmetBuildSettings
from emmet.core.vasp.task_valid import TaskDocument
from emmet.core.vasp.calc_types.enums import CalcType
from emmet.core.vasp.validation import DeprecationMessage, ValidationDoc


Expand All @@ -14,6 +15,7 @@ def __init__(
self,
tasks: Store,
task_validation: Store,
potcar_hashes: Optional[Dict[CalcType, Dict[str, str]]] = None,
settings: Optional[EmmetBuildSettings] = None,
query: Optional[Dict] = None,
**kwargs,
Expand All @@ -24,29 +26,38 @@ def __init__(
Args:
tasks: Store of task documents
task_validation: Store of task_types for tasks
potcar_hashes: Optional dictionary of potcar hash data.
Mapping is calculation type -> potcar symbol -> hash value.
"""
self.tasks = tasks
self.task_validation = task_validation
self.settings = EmmetBuildSettings.autoload(settings)
self.query = query
self.kwargs = kwargs
self._potcar_hashes = None
self.potcar_hashes = potcar_hashes

# Set up potcar cache if appropriate
if self.settings.VASP_VALIDATE_POTCAR_HASHES:
from pymatgen.io.vasp.inputs import PotcarSingle
if not self.potcar_hashes:

potcar_hashes = defaultdict(dict) # type: dict
from pymatgen.io.vasp.inputs import PotcarSingle

for (calc_type, input_set) in self.settings.VASP_DEFAULT_INPUT_SETS.items():
functional = input_set.CONFIG["POTCAR_FUNCTIONAL"]
for potcar_symbol in input_set.CONFIG["POTCAR"].values():
potcar = PotcarSingle.from_symbol_and_functional(
symbol=potcar_symbol, functional=functional
)
potcar_hashes[calc_type][potcar_symbol] = potcar.get_potcar_hash()
hashes = defaultdict(dict) # type: dict

self._potcar_hashes = potcar_hashes
for (
calc_type,
input_set,
) in self.settings.VASP_DEFAULT_INPUT_SETS.items():
functional = input_set.CONFIG["POTCAR_FUNCTIONAL"]
for potcar_symbol in input_set.CONFIG["POTCAR"].values():
potcar = PotcarSingle.from_symbol_and_functional(
symbol=potcar_symbol, functional=functional
)
hashes[calc_type][potcar_symbol] = potcar.get_potcar_hash()

self.potcar_hashes = potcar_hashes
else:
self.potcar_hashes = None

super().__init__(
source=tasks,
Expand Down Expand Up @@ -78,7 +89,7 @@ def unary_function(self, item):
input_sets=self.settings.VASP_DEFAULT_INPUT_SETS,
LDAU_fields=self.settings.VASP_CHECKED_LDAU_FIELDS,
max_allowed_scf_gradient=self.settings.VASP_MAX_SCF_GRADIENT,
potcar_hashes=self._potcar_hashes,
potcar_hashes=self.potcar_hashes,
)

bad_tags = list(set(task_doc.tags).intersection(self.settings.DEPRECATED_TAGS))
Expand Down

0 comments on commit 9ecbee6

Please sign in to comment.