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

BUG: cannot resolve CP2K reference #899

Closed
lory-w opened this issue Jun 24, 2024 · 0 comments
Closed

BUG: cannot resolve CP2K reference #899

lory-w opened this issue Jun 24, 2024 · 0 comments

Comments

@lory-w
Copy link
Contributor

lory-w commented Jun 24, 2024

Describe the bug
When running the CP2K workflow with RelaxBandStructureMaker, a ValidationError occurs in the TaskDocument schema due to improper handling of the cp2k_input and locpot fields. The error message is as follows:

Traceback (most recent call last):
File "/opt/conda/envs/ai-dopant/lib/python3.12/site-packages/jobflow/managers/local.py", line 114, in run_job
response = job.run(store=store)
^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/envs/ai-dopant/lib/python3.12/site-packages/jobflow/core/job.py", line 572, in run
self.resolve_args(store=store)
File "/opt/conda/envs/ai-dopant/lib/python3.12/site-packages/jobflow/core/job.py", line 678, in resolve_args
resolved_args = find_and_resolve_references(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/envs/ai-dopant/lib/python3.12/site-packages/jobflow/core/reference.py", line 473, in find_and_resolve_references
resolved_references = resolve_references(
^^^^^^^^^^^^^^^^^^^
File "/opt/conda/envs/ai-dopant/lib/python3.12/site-packages/jobflow/core/reference.py", line 361, in resolve_references
resolved_references[ref] = ref.resolve(
^^^^^^^^^^^^
File "/opt/conda/envs/ai-dopant/lib/python3.12/site-packages/jobflow/core/reference.py", line 179, in resolve
data = MontyDecoder().process_decoded(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/envs/ai-dopant/lib/python3.12/site-packages/monty/json.py", line 777, in process_decoded
return cls
(**d)
^^^^^^^^^
File "/opt/conda/envs/ai-dopant/lib/python3.12/site-packages/pydantic/main.py", line 176, in init
self.pydantic_validator.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 2 validation errors for TaskDocument
calcs_reversed.0.input.cp2k_input
Input should be a valid dictionary [type=dict_type, input_value=<pymatgen.io.cp2k.inputs....bject at 0x7f4e4eb21640>, input_type=Cp2kInput]
For further information visit https://errors.pydantic.dev/2.7/v/dict_type
calcs_reversed.0.output.locpot
Input should be a valid dictionary [type=dict_type, input_value=None, input_type=NoneType]

The relaxation was completed without errors. I tried to print the calcs_reversed.0.input.cp2k_input, which seems to be a valid dictionary:

 {'@module': 'pymatgen.io.cp2k.inputs', '@class': 'Cp2kInput', '@version': None, 'name': 'CP2K_INPUT', 'subsections': {'FORCE_EVAL': {'@module': 'pymatgen.io.cp2k.inputs', '@class': 'Section', '@version': None, 'name': 'FORCE_EVAL', 'subsections': {'SUBSYS': {'@module': 'pymatgen.io.cp2k.inputs', '@class': 'Section', '@version': None, 'name': 'SUBSYS', 'subsections': {'CELL': {'@module': 'pymatgen.io.cp2k.inputs', '@class': 'Section', '@version': None, 'name': 'CELL', 'subsections': {}, 'repeats': False, 'description': 'Lattice parameters and optional settings forcreating a the CELL', 'keywords': {'A': {'@module': 'pymatgen.io.cp2k.inputs', '@class': 'Keyword', 'name': 'A', 'values': [5.73820206, 0.0, 3.513635392819874e-16], 'description': None, 'repeats': False, 'units': None, 'verbose': True}, 'B': {'@module': 'pymatgen.io.cp2k.inputs', '@class': 'Keyword', 'name': 'B', 'values': [-4.960807293792336e-16, 8.10161313, 4.960807293792336e-16], 'description': None, 'repeats': False, 'units': None, 'verbose': True}, 'C': {'@module': 'pymatgen.io.cp2k.inputs', '@class': 'Keyword', 'name': 'C', 'values': [0.0, 0.0, 5.72649997], 'description': None, 'repeats': False, 'units': None, 'verbose': True}}, 'section_parameters': [], 'location': None, 'verbose': True, 'alias': None}, ...

and calcs_reversed.0.output.locpot is None.

Here is the test script I'm running

from pymatgen.core.structure import Structure
from atomate2.cp2k.jobs.core import RelaxMaker
from atomate2.cp2k.flows.core import BandStructureMaker, RelaxBandStructureMaker
from atomate2.cp2k.sets.core import RelaxSetGenerator
from jobflow import run_locally
from pymatgen.core import Lattice, Structure
from pymatgen.io.vasp import Kpoints

coords = [[0, 0, 0], [0.75,0.5,0.75]]
lattice = Lattice.from_parameters(a=3.84, b=3.84, c=3.84, alpha=120,
                                  beta=90, gamma=60)
test_structure = Structure(lattice, ["Si", "Si"], coords)

kpts = Kpoints(kpts = [(1, 1, 1),])

cp2k_input = {"preconditioner": "FULL_ALL",
              "rotation": False,
              "energy_gap": 0.001,
              "max_scf": 100,
              }
relax_input_generator = RelaxSetGenerator(user_input_settings = cp2k_input,
                                    user_kpoints_settings=kpts)

relax_maker = RelaxMaker(input_set_generator = relax_input_generator)

band_maker = BandStructureMaker(bandstructure_type = 'line')
relax_band_flow = RelaxBandStructureMaker(relax_maker = relax_maker,
                                          band_structure_maker=band_maker).make(test_structure)
run_locally(relax_band_flow, log=True, create_folders=True)

To Reproduce
Steps to reproduce the behavior:

  1. Run the test script with the current main branch.
  2. Observe the above error in the traceback.

Additional Information:
I have identified the cause of this issue and have a fix ready. I will be submitting a PR soon to address this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants