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

Add support for vaspout.h5, improvements to potcar handling #3680

Merged
merged 36 commits into from
Mar 10, 2025

Conversation

esoteric-ephemera
Copy link
Contributor

@esoteric-ephemera esoteric-ephemera commented Mar 9, 2024

Summary

The vaspout.h5 file appears to be a replacement for / supplement to the vasprun.xml file, and has been available in certain VASP versions >= 6. This PR aims to add support for parsing this file.

However the vaspout.h5 file appears to be still in development. For example, no electronic self-consistency info is included in it as of 11 April, 2024, but there is a PR on VASP's py4vasp GH to add OSZICAR info to vaspout.h5

Major changes:

  • Add support for parsing vaspout.h5 through pymatgen.io.vasp.outputs.Vaspout. This subclasses Vasprun in the spirit that the two should contain roughly the same information now.
  • Add .from_str method to pymatgen.io.vasp.inputs.Potcar (needed because vaspout.h5 stores the complete potcar as a str)
    • To avoid issues of copyright, there's a kwarg, store_potcar, to enable/disable storing the full POTCAR or its just spec
  • The structure at each ionic_step now has site_properties with the s, p, d,...-resolved and tot charge / magnetization, if applicable. This is the same format as Outcar.charge and Outcar.magnetization, but added as a site property at each ionic step instead of a top-level attr for only the final structure

Some related changes for VASP I/O

  • Add spec attr to PotcarSingle and Potcar. This standardizes the POTCAR spec attr added to vasprun.xml and vaspout.h5 objects
  • Add from_spec method to Potcar, which attempts to generate a POTCAR with a consistent functional just from the spec. Note that multiple matches are possible, this only takes the first consistent match.

Todos

  • Some information currently contained in vasprun.xml appears not to be available in vaspout.h5. That might change in the near future, or I may be mistaken
  • Support for selective dynamics (if applicable)
  • Various TODO's sprinkled through current code
  • Tests

@esoteric-ephemera esoteric-ephemera marked this pull request as draft March 9, 2024 00:06
@janosh janosh added io Input/output functionality vasp Vienna Ab initio Simulation Package feature PRs with new features, not enhancements to existing features labels Mar 9, 2024
@esoteric-ephemera esoteric-ephemera changed the title Add support for vaspout.h5 Add support for vaspout.h5, improvements to potcar handling Mar 21, 2024
@janosh
Copy link
Member

janosh commented Apr 11, 2024

there's going to be a new pmg release soon to close #3744. do we want to get this in before that? let us know if others can help with this PR

Copy link

coderabbitai bot commented Apr 11, 2024

Important

Auto Review Skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@esoteric-ephemera
Copy link
Contributor Author

This isn't super urgent for release. What I'd like to do is ensure that this works across a wider variety of vaspout's, and make sure that all fields currently included in the vaspout are being mapped correctly to the PMG object

Rn, it doesn't seems like vaspout.h5 has the same level of detail as vasprun.xml so figuring out a way to handle that would also be good

Copy link

@Shibu778 Shibu778 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following features can be included to extract information from one-shot band-structure calculation.



@requires(h5py is not None, "h5py must be installed to read vaspout.h5")
class Vaspout(Vasprun):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add following parameter and attributes to the class.

  1. dos_kpoints_opt
  2. eigenvalues_kpoints_opt
  3. projectors_kpoints_opt
    It will be useful in case of one-shot calculation of bandstructure. Particularly, it is useful while doing HSE calculations (ref), which requires adding the kpoints with fake weights for hartree-fock calculations(ref). One-shot calculations reduces the two step calculations to one-step with two kpoints file, i.e., KPOINTS and KPOINTS_OPT.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'll get on this next, will also bring the PR up to date with #3509

@mkhorton
Copy link
Member

mkhorton commented Jun 9, 2024

Thanks for this PR @esoteric-ephemera. Do you happen to know if magnetic moments are now stored in the vaspout.h5?

Previously these were not available in the vasprun.xml, although perhaps they have since been added and we haven't noticed. I do see a MAGDIPOLOUT key.

@esoteric-ephemera
Copy link
Contributor Author

esoteric-ephemera commented Jun 10, 2024

Hi @mkhorton, yes both the magnetic moments and charges are stored in vaspout.h5, and thankfully to normal floating point precision

I need to revisit this PR soon - will try to this week or next

@janosh janosh force-pushed the master branch 2 times, most recently from e3fbc67 to 41e6d99 Compare August 3, 2024 19:01
@mkhorton
Copy link
Member

mkhorton commented Mar 7, 2025

Saw this is stale, that's no problem but wondered if you were expecting any updates to this. I saw VASP 6.5 is out with some further hdf5 support.

More generally, given there is now first-party support for parsing from the VASP developers in py4vasp, do you have any new thoughts on how this should fit in with pymatgen? Should development of parsing continue to be done in parallel, or are there scenarios where having a dep on py4vasp might make sense?

@esoteric-ephemera
Copy link
Contributor Author

Sorry @mkhorton, I'll try to get this synced up tomorrow to merge. The only thing I wanted to add was KPOINTS_OPT parsing, which I think I have enough test files for

In general, I don't think we can nor want to chase VASP's support for their own schemas but that's a discussion worth having with the p4vasp team

@esoteric-ephemera esoteric-ephemera marked this pull request as ready for review March 10, 2025 16:57
@esoteric-ephemera
Copy link
Contributor Author

Hey @mkhorton @shyuep - I think this is ready for review. Some features are missing to bring Vaspout to full parity with Vasprun. That might be due to the schema of Vaspout being not fixed yet (there are already code blocks that support older / newer versions of Vaspout schemas) or something I missed

Either way, I think it's best we have a template to add to / modify as Vaspout is developed

@shyuep shyuep enabled auto-merge (squash) March 10, 2025 17:07
@shyuep
Copy link
Member

shyuep commented Mar 10, 2025

Thanks. I will merge and release. I think we can do the usual approach of release first then iterate as necessary. It is a format still in flux but no reason why we cannot support it now first.

@shyuep shyuep disabled auto-merge March 10, 2025 17:09
@shyuep shyuep merged commit f91f8d5 into materialsproject:master Mar 10, 2025
42 checks passed
@esoteric-ephemera esoteric-ephemera deleted the vaspout branch March 13, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature PRs with new features, not enhancements to existing features io Input/output functionality vasp Vienna Ab initio Simulation Package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants