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

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from

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

Signed-off-by: Aaron Kaplan <33381112+esoteric-ephemera@users.noreply.github.com>
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

self._parse(parse_dos, parse_eigen, parse_projected_eigen)

@classmethod
def _parse_hdf5_value(cls, val: Any) -> Any:

Choose a reason for hiding this comment

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

Instead of parsing the whole vaspout.h5 at once and creating a dictionary. The required information can be parsed directly using the full string as follows.

  1. To extract the ENCUT from the input/incar we can use np.float64(h5_file['input/incar/ENCUT']) or np.float64(h5_file['input']['incar']['ENCUT'])
  2. To extract array like data, use np.array(h5_file[...]), etc

This will not require lot of memory. Only the data needed will be accessed instead of storing the whole file as dictionary in memory. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Essentially all attributes of the HDF5 file are accessed by the Vaspout object so I think it's more natural just to read the whole file in as a python dict. This also makes the code cleaner/more consistent than an approach which cherry picks different attr's with different types

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.

None yet

3 participants