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

Update cube.py #2121

Merged
merged 5 commits into from
Apr 28, 2021
Merged

Update cube.py #2121

merged 5 commits into from
Apr 28, 2021

Conversation

nwinner
Copy link
Contributor

@nwinner nwinner commented Apr 28, 2021

Summary

  • Feature 1: Spherical masks of the cube data is now supported
  • Feature 2: Using spherical masks, atomic site averages and totals are now supported natively. These can be used, respectively, for getting the average electrostatic potential around a site using a V_HARTREE file from CP2K or the total spin on a site using a SPIN_DENSITY file from CP2K. These features are useful as an alternative to Bader partitioning for these properties when the bader executable is not available.
  • Fix 1: Previously, cube files were loaded using for loops, which was prohibitively slow for files >1Gb. Now it is done with numpy and is much faster.

TODO (if any)

  • While not necessary, it would be nice to support multiprocessing for the atomic site functions. These can be pretty expensive when the cube files are >1Gb. I previously used the multiprocessing module for this, but ran into some errors while trying it out. It was exceeding the memory available for the Drone, and since the Drone is supposed to be automatic/not require user modifications, I removed multiprocessing for robustness, but it would be nice to have it back at some point.
  • New tests for the class methods have not been added yet.

Checklist

Work-in-progress pull requests are encouraged, but please put [WIP]
in the pull request title.

Before a pull request can be merged, the following items must be checked:

  • [x ] Code is in the standard Python style. The easiest way to handle this
    is to run the following in the correct sequence on your local machine. Start with running
    black on your new code. This will automatically reformat
    your code to PEP8 conventions and removes most issues. Then run
    pycodestyle, followed by
    flake8.
  • [x ] Docstrings have been added in the Google docstring format.
    Run pydocstyle on your code.
  • [ x] Type annotations are highly encouraged. Run mypy to type check your code.
  • Tests have been added for any new functionality or bug fixes.
  • [x ] All linting and tests pass.

Note that the CI system will run all the above checks. But it will be much more efficient if you already fix most
errors prior to submitting the PR. It is highly recommended that you use the pre-commit hook provided in the pymatgen
repository. Simply cp pre-commit .git/hooks and a check will be run prior to allowing commits.

Updated the cube file loading to use number instead of looping, which is much faster. Also added functions for atomic site averaging and planar averaging, which are common use cases for cube files.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.7%) to 82.995% when pulling 270e3d9 on nwinner:patch-2 into df0f9ba on materialsproject:master.

@shyuep shyuep merged commit 2bc5a5d into materialsproject:master Apr 28, 2021
@shyuep
Copy link
Member

shyuep commented Apr 28, 2021

Thanks!

@nwinner nwinner deleted the patch-2 branch April 28, 2021 20:05
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

Successfully merging this pull request may close these issues.

None yet

3 participants