Skip to content
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

Fix the minor document error in POTCAR Setup. #3834

Merged
merged 1 commit into from
May 17, 2024

Conversation

hongyi-zhao
Copy link
Contributor

@hongyi-zhao hongyi-zhao commented May 16, 2024

closes #3830. see there for more details.

@DanielYang59
Copy link
Contributor

DanielYang59 commented May 17, 2024

I think these paths look correct to me, perhaps I'm wrong.

The potcar_PBE/LDA.54/ in the first two paths refers to the directory where the POTCARs are stored.

The last path looks a bit confusing, perhaps:

- pmg config --add PMG_VASP_PSP_DIR /path/to/pseudos/pmg_potcars/pmg_potcars
+ pmg config --add PMG_VASP_PSP_DIR /path/to/pseudos/pmg_potcars/POTCARs

@hongyi-zhao
Copy link
Contributor Author

hongyi-zhao commented May 17, 2024

For the last path looks a bit confusing, perhaps:

- pmg config --add PMG_VASP_PSP_DIR /path/to/pseudos/pmg_potcars/pmg_potcars
+ pmg config --add PMG_VASP_PSP_DIR /path/to/pseudos/pmg_potcars/POTCARs

No. The PMG_VASP_PSP_DIR must point to the top directory of potcars generated by pmg, aka, the pmg_potcars directory used here.

In my case, the relevant configuration and test information are as follows, for your reference only:

werner@x13dai-t:~$ cat ~/.pmgrc.yaml
PMG_DEFAULT_FUNCTIONAL: PBE_64
PMG_MAPI_KEY: <my-MAPI_KEY>
PMG_VASP_PSP_DIR: /home/werner/Public/hpc/vasp/pot/pmg_potcar

werner@x13dai-t:~$ ls -l ~/Public/hpc/vasp/pot/pmg_potcar
total 28
drwxrwxr-x 2 werner werner 12288  2月  3 16:43 POT_LDA_PAW_64
drwxrwxr-x 2 werner werner 16384  2月  3 16:43 POT_PAW_PBE_64

werner@x13dai-t:~$ pyenv shell datasci 
(datasci) werner@x13dai-t:~$ ipython
Python 3.11.1 (main, Dec 22 2022, 17:06:07) [GCC 12.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.
Installed qt5 event loop hook.
Shell is already running a gui event loop for qt5. Call with no arguments to disable the current loop.

In [1]: from mp_api.client import MPRester
   ...: from pymatgen.io.vasp.sets import MPRelaxSet
   ...: with MPRester() as mpr:
   ...:     structure = mpr.get_structure_by_material_id("mp-2469")
   ...: relax_set = MPRelaxSet(structure)
   ...: relax_set.user_potcar_functional = "PBE_64"  # Specifically designate the POTCAR functional as P
   ...: BE_64
   ...: try:
   ...:     potcar_symbols = relax_set.potcar_symbols
   ...:     print("Successfully prepared POTCAR metadata with PBE_64 functional. Here are the symbols:")
   ...: 
   ...:     print(potcar_symbols)
   ...: except Exception as e:
   ...:     print(f"Error occurred while attempting to prepare POTCAR metadata: {e}")
   ...: 
Retrieving MaterialsDoc documents: 100%|███████████████████████████████| 1/1 [00:00<00:00, 19508.39it/s]
Successfully prepared POTCAR metadata with PBE_64 functional. Here are the symbols:
['Cd', 'S']

The corresponding source code implementation is here:

def from_symbol_and_functional(
cls,
symbol: str,
functional: str | None = None,
) -> Self:
"""Make a PotcarSingle from a symbol and functional.
Args:
symbol (str): Symbol, e.g. Li_sv
functional (str): Functional, e.g. PBE
Returns:
PotcarSingle
"""
functional = functional or SETTINGS.get("PMG_DEFAULT_FUNCTIONAL", "PBE")
if functional is None:
raise ValueError("Cannot get functional.")
funcdir = cls.functional_dir[functional]
PMG_VASP_PSP_DIR = SETTINGS.get("PMG_VASP_PSP_DIR")
if PMG_VASP_PSP_DIR is None:
raise ValueError(
f"No POTCAR for {symbol} with {functional=} found. Please set the PMG_VASP_PSP_DIR in .pmgrc.yaml."
)
paths_to_try: list[str] = [
os.path.join(PMG_VASP_PSP_DIR, funcdir, f"POTCAR.{symbol}"),
os.path.join(PMG_VASP_PSP_DIR, funcdir, symbol, "POTCAR"),
]
for path in paths_to_try:
path = os.path.expanduser(path)
path = zpath(path)
if os.path.isfile(path):
return cls.from_file(path)
raise RuntimeError(
f"You do not have the right POTCAR with {functional=} and {symbol=} "
f"in your {PMG_VASP_PSP_DIR=}. Paths tried: {paths_to_try}"
)

See here for the related discussion.

@DanielYang59
Copy link
Contributor

DanielYang59 commented May 17, 2024

Make sense to me, sorry for the stupid question (I'm not an activate user of the pmg cli tool).

@janosh janosh merged commit 3f436de into materialsproject:master May 17, 2024
2 checks passed
@janosh
Copy link
Member

janosh commented May 17, 2024

thanks @hongyi-zhao for reporting and fixing! 👍

@janosh janosh added fix Bug fix PRs docs Documentation, examples, user guides labels May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation, examples, user guides fix Bug fix PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A minor document error in POTCAR Setup.
3 participants