Skip to content

Commit

Permalink
Fix POTCAR validation in cases where POTCAR_FUNCTIONAL oor TITEL are …
Browse files Browse the repository at this point in the history
…not recognized by PMG
  • Loading branch information
esoteric-ephemera authored and esoteric-ephemera committed Nov 3, 2023
1 parent 1750c8d commit 988503f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 105 deletions.
8 changes: 3 additions & 5 deletions pymatgen/io/validation/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
import json
from pathlib import Path
from typing import Dict, List, Type, TypeVar, Union
from typing import Dict, Type, TypeVar, Union

import requests
from monty.json import MontyDecoder
Expand All @@ -23,9 +23,7 @@ class IOValidationSettings(BaseSettings):
Settings for pymatgen-io-validation
"""

config_file: str = Field(
DEFAULT_CONFIG_FILE_PATH, description="File to load alternative defaults from"
)
config_file: str = Field(DEFAULT_CONFIG_FILE_PATH, description="File to load alternative defaults from")

VASP_KPTS_TOLERANCE: float = Field(
0.9,
Expand Down Expand Up @@ -128,4 +126,4 @@ def as_dict(self):
"""
HotPatch to enable serializing IOValidationSettings via Monty
"""
return self.dict(exclude_unset=True, exclude_defaults=True)
return self.dict(exclude_unset=True, exclude_defaults=True)
12 changes: 9 additions & 3 deletions pymatgen/io/validation/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,11 @@ def from_task_doc(
valid_potcar_summary_stats = {}
for valid_potcar in valid_input_set.potcar:
titel_no_spc = valid_potcar.TITEL.replace(" ", "")
valid_potcar_summary_stats[titel_no_spc] = potcar_summary_stats[
valid_input_set._config_dict["POTCAR_FUNCTIONAL"]
][titel_no_spc].copy()
valid_potcar_summary_stats[titel_no_spc] = (
potcar_summary_stats.get(valid_input_set._config_dict["POTCAR_FUNCTIONAL"], {})
.get(titel_no_spc, {})
.copy()
)

if potcar_summary_stats:
_check_potcars(reasons, warnings, potcars, valid_potcar_summary_stats)
Expand Down Expand Up @@ -359,6 +361,10 @@ def _check_potcars(
for potcar in potcars:
reference_summary_stats = valid_potcar_summary_stats.get(potcar["TITEL"].replace(" ", ""), [])

if len(reference_summary_stats) == 0:
incorrect_potcars.append(potcar["symbol"])
continue

key_match = False
data_match = False
for ref_psp in reference_summary_stats:
Expand Down
Loading

0 comments on commit 988503f

Please sign in to comment.