Based on the example here I tried to run the following code snippet:
from atomate2.vasp.jobs.core import RelaxMaker
from jobflow import run_locally
from pymatgen.core import Structure
from pymatgen.io.vasp.sets import MPRelaxSet
si_structure = Structure(
lattice=[[0, 2.73, 2.73], [2.73, 0, 2.73], [2.73, 2.73, 0]],
species=["Si", "Si"],
coords=[[0, 0, 0], [0.25, 0.25, 0.25]],
)
user_incar_settings = {
'ALGO': 'N',
'GGA': 'pe',
"ISPIN": 1,
}
vasp_input_set = MPRelaxSet(si_structure, user_potcar_functional="PBE_64", user_incar_settings=user_incar_settings)
relax_maker = RelaxMaker(input_set_generator=vasp_input_set)
relax_job = relax_maker.make(si_structure)
run_locally(relax_job, create_folders=True)
But the error is as follows:
/home/werner/.pyenv/versions/3.11.1/envs/datasci/lib/python3.11/site-packages/pymatgen/io/vasp/sets.py:275: BadInputSetWarning: Overriding the POTCAR functional is generally not recommended as it significantly affect the results of calculations and compatibility with other calculations done with the same input set. Note that some POTCAR symbols specified in the configuration file may not be available in the selected functional.
warnings.warn(
2024-06-21 18:10:59,835 INFO Started executing jobs locally
2024-06-21 18:10:59,838 INFO Starting job - relax (8ec030c7-77c1-431a-a99d-ac41cae94660)
2024-06-21 18:10:59,877 INFO relax failed with exception:
Traceback (most recent call last):
File "/home/werner/.pyenv/versions/3.11.1/envs/datasci/lib/python3.11/site-packages/jobflow/managers/local.py", line 114, in _run_job
response = job.run(store=store)
^^^^^^^^^^^^^^^^^^^^
File "/home/werner/.pyenv/versions/3.11.1/envs/datasci/lib/python3.11/site-packages/jobflow/core/job.py", line 583, in run
response = function(*self.function_args, **self.function_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/werner/Public/repo/github.com/materialsproject/atomate2.git/src/atomate2/vasp/jobs/base.py", line 217, in make
write_vasp_input_set(
File "/home/werner/Public/repo/github.com/materialsproject/atomate2.git/src/atomate2/vasp/files.py", line 204, in write_vasp_input_set
TypeError: VaspInput.write_input() got an unexpected keyword argument 'potcar_spec'
2024-06-21 18:10:59,877 INFO Finished executing jobs locally
Out[2]: {}
To solve this problem, I found the following dirty method:
(datasci) werner@x13dai-t:~/Public/repo/github.com/materialsproject/atomate2.git$ git show -1
commit baea9826926b446b2895d5839f54ab8116d038ef (HEAD -> main, hongyi-zhao/main)
Author: Hongyi Zhao <[email protected]>
Date: Fri Jun 21 19:02:13 2024 +0800
temporary fix for:
https://matsci.org/t/typeerror-vaspinput-write-input-got-an-unexpected-keyword-argument-potcar-spec/56073
diff --git a/src/atomate2/vasp/files.py b/src/atomate2/vasp/files.py
index d5c8c532..6e7dfadc 100644
--- a/src/atomate2/vasp/files.py
+++ b/src/atomate2/vasp/files.py
@@ -201,4 +201,6 @@ def write_vasp_input_set(
Path(filename).unlink()
logger.info("Writing VASP input set.")
- vis.write_input(directory, potcar_spec=potcar_spec, **kwargs)
+ # 从 kwargs 中删除 potcar_spec 参数
+ kwargs.pop('potcar_spec', None)
+ vis.write_input(directory, **kwargs)
However, this is obviously not an elegant solution. I want to know how to perfectly solve this problem while completely retaining the parameter without it being filtered out.
Regards,
Zhao