materialsproject / emmet

Be a master builder of databases of material properties. Avoid the Kragle.
https://materialsproject.github.io/emmet/
Other
49 stars 63 forks source link

[Help Wanted]: Can not parse trajectory of VASP optimization directory #1021

Closed wangzyphysics closed 4 hours ago

wangzyphysics commented 1 month ago

Problem

when trying to parse the structure optimization direcotry of VASP, i encounter this error:

> python run.py 
Traceback (most recent call last):
  File "/home/xxx/workplace/mp-1198074-prim/run.py", line 5, in <module>
    d = TaskDoc.from_directory("./", store_trajectory=StoreTrajectoryOption.FULL)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/softs/miniconda3/envs/emmet/lib/python3.12/site-packages/emmet/core/tasks.py", line 481, in from_directory
    analysis = AnalysisDoc.from_vasp_calc_docs(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/softs/miniconda3/envs/emmet/lib/python3.12/site-packages/emmet/core/tasks.py", line 305, in from_vasp_calc_docs
    max_force = _get_max_force(final_calc)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/softs/miniconda3/envs/emmet/lib/python3.12/site-packages/emmet/core/tasks.py", line 851, in _get_max_force
    forces: Optional[Union[np.ndarray, List]] = calc_doc.output.ionic_steps[-1].forces
                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
TypeError: 'NoneType' object is not subscriptable

and the context of run.py is :

from emmet.core.tasks import TaskDoc
from emmet.core.vasp.calculation import StoreTrajectoryOption

d = TaskDoc.from_directory("./", store_trajectory=StoreTrajectoryOption.FULL)
print(d)

How should i fix this?

Proposed Solution

None

Alternatives

No response

tsmathis commented 4 weeks ago

Hi @wangzyphysics, the traceback from your error implies that the calculation doc that is being generated from your calculation directory is missing the output.ionic_steps field, which might be hard to diagnose on our end.

But for starters, what version of emmet-core are you using?

wangzyphysics commented 4 weeks ago

Hi @wangzyphysics, the traceback from your error implies that the calculation doc that is being generated from your calculation directory is missing the output.ionic_steps field, which might be hard to diagnose on our end.

But for starters, what version of emmet-core are you using?

Thanks for your kind reply. Yes, the taskdoc.output has no attribute ionic_steps, but the truth is that my calculation is converged after 42 ionic steps. There is no error found in calculation.

The version of emmet-core is '0.83.6'.

> python
Python 3.12.3 | packaged by Anaconda, Inc. | (main, May  6 2024, 19:46:43) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import emmet.core
>>> emmet.core.__version__
'0.83.6'
>>> 

I noticed that the newest version now is '0.83.8', so i upgrade the emmet.core but the error is same as before.

The example directory named mp-1198074-prim.zip (about 4.8M) has been uploaded for your reference.

Thanks again and looking forward to your reply.

munrojm commented 4 weeks ago

I think I can recreate the issue. Going to look into it further.

tsmathis commented 1 week ago

@wangzyphysics, was this calculation ran using custodian?

wangzyphysics commented 1 week ago

@wangzyphysics, was this calculation ran using custodian?

No, it's a normal VASP calculation. And i suppose this issue has been fixed in the latest version, right?

tsmathis commented 1 week ago

The recent version addressed the ionic_steps issue you reported, but the .from_directory() method is expecting some custodian specific files. This should be able to work on standard VASP calculations though and should be addressed.

tsmathis commented 1 week ago

@wangzyphysics , can you upgrade to the latest version of emmet-core and see if your issue is fixed?

wangzyphysics commented 21 hours ago

@wangzyphysics , can you upgrade to the latest version of emmet-core and see if your issue is fixed?

I have tested the latest version of emmet-core (0.84.1), and the issue is definitely fixed!

Thank you, and thanks to all the developers!

tsmathis commented 4 hours ago

Great, glad things are working for you now. And thanks again for bringing this to our attention.