materialsproject / pymatgen

Python Materials Genomics (pymatgen) is a robust materials analysis code that defines classes for structures and molecules with support for many electronic structure codes. It powers the Materials Project.
https://pymatgen.org
Other
1.48k stars 850 forks source link

ValueError: Missing basis information for POTCAR symbol: Cd_GW. Please provide the basis manually. #3893

Open hongyi-zhao opened 2 months ago

hongyi-zhao commented 2 months ago

I tried to create the input files using this example for vasp and lobster via lobsterpy as follows, but failed:

$ cat create_and_test_potcar.py 
from pymatgen.io.vasp.inputs import Potcar, PotcarSingle
import os

# Specify the required elements
potcar_symbols = ["Cd_GW", "F"]

# Specify the POTCAR functional
functional = "PBE_64"  # Ensure using the correct functional set

# Print the POTCAR file path for each element
for symbol in potcar_symbols:
    try:
        # Create PotcarSingle object for the symbol and functional
        potcar_single = PotcarSingle.from_symbol_and_functional(symbol, functional)
        if potcar_single:
            functional_dir_dict = potcar_single.functional_dir
            if functional in functional_dir_dict:
                functional_dir = functional_dir_dict[functional]
                potcar_path = os.path.join(functional_dir, symbol, "POTCAR")
                print(f"{symbol} POTCAR created successfully.")
                print(f"Element: {potcar_single.element}")
                print(f"Symbol: {potcar_single.symbol}")
                print(f"Functional: {potcar_single.functional}")
                print(f"Number of electrons: {potcar_single.nelectrons}")
                print(f"Potential type: {potcar_single.potential_type}")
                print(f"POTCAR file path: {potcar_path}")
            else:
                print(f"Functional {functional} not found in directory dictionary.")
        else:
            print(f"POTCAR file for {symbol} with functional {functional} not found.")
    except Exception as e:
        print(f"Error occurred for symbol {symbol}: {e}")

# Create Potcar object
try:
    potcar = Potcar(potcar_symbols, functional)
    # Write the Potcar to a file
    potcar.write_file("POTCAR")
    # Read the generated POTCAR file
    potcar_read = Potcar.from_file("POTCAR")
    # Print POTCAR information
    # print(potcar_read)
except Exception as e:
    print(f"Error occurred while creating or reading POTCAR: {e}")
$ python create_and_test_potcar.py 
Cd_GW POTCAR created successfully.
Element: Cd
Symbol: Cd_GW
Functional: PBE
Number of electrons: 12.0
Potential type: PAW
POTCAR file path: POT_PAW_PBE_64/Cd_GW/POTCAR
F POTCAR created successfully.
Element: F
Symbol: F
Functional: PBE
Number of electrons: 7.0
Potential type: PAW
POTCAR file path: POT_PAW_PBE_64/F/POTCAR

$ lobsterpy create-inputs --overwrite
/home/werner/Public/repo/github.com/materialsproject/pymatgen.git/pymatgen/io/lobster/inputs.py:642: UserWarning: These POTCARs are not compatible with Lobster up to version 4.1.0.
 The keywords SHA256 and COPYR cannot be handled by Lobster 
 and will lead to wrong results.
  warnings.warn(
Traceback (most recent call last):
  File "/home/werner/.pyenv/versions/datasci/bin/lobsterpy", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/werner/Public/repo/github.com/JaGeo/LobsterPy.git/lobsterpy/cli.py", line 33, in main
    run(args)
  File "/home/werner/Public/repo/github.com/JaGeo/LobsterPy.git/lobsterpy/cli.py", line 987, in run
    list_basis_dict = Lobsterin.get_all_possible_basis_functions(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/werner/Public/repo/github.com/materialsproject/pymatgen.git/pymatgen/io/lobster/inputs.py", line 401, in get_all_possible_basis_functions
    max_basis = Lobsterin.get_basis(
                ^^^^^^^^^^^^^^^^^^^^
  File "/home/werner/Public/repo/github.com/materialsproject/pymatgen.git/pymatgen/io/lobster/inputs.py", line 376, in get_basis
    raise ValueError(
ValueError: Missing basis information for POTCAR symbol: Cd_GW. Please provide the basis manually.

See https://github.com/JaGeo/LobsterPy/issues/304#issuecomment-2187919611 for the related discussion.

Regards, Zhao

JaGeo commented 2 months ago

We are a team of 2-3 people working on this. It is simply not yet implemented.

The code has been built for PBE POTCARs, 54. This is also the default in the LOBSTER input sets.

JaGeo commented 2 months ago

We could add a note that it has only been implemented for PBE_54 if there isn't already.

hongyi-zhao commented 2 months ago

We could add a note that it has only been implemented for PBE_54 if there isn't already.

I think, for this purpose, you only need to adapt/update/enhance the following information accordingly:

ValueError: Missing basis information for POTCAR symbol: Cd_GW. Please provide the basis manually.