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

SOC WAVECARs and general cleanup #1861

Merged
merged 14 commits into from
Jun 8, 2020

Conversation

mturiansky
Copy link
Contributor

@mturiansky mturiansky commented Jun 3, 2020

Summary

  • add ability to read SOC WAVECARs
  • seemingly robust ability to determine if WAVECAR is from std, gam, or ncl binary
  • add conversion from WAVECAR to UNK files for wannier90 (will add needed support for UNKs from ncl calculations)

Additional dependencies introduced (if any)

None.

TODO (if any)

  • update evaluate_wavefunc and fft_mesh functions to handle ncl WAVECARs
  • update get_parchg for ncl WAVECARs
  • update old tests
  • add new tests for ncl WAVECAR
  • add UNK class + tests
  • add function to generate UNKs from WAVECAR
  • type annotations

Checklist

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

@mturiansky
Copy link
Contributor Author

The tests are failing because of sympy (not related to my work so far). Looks like check_assumptions is no longer in sympy.core.assumptions.

@mkhorton
Copy link
Member

mkhorton commented Jun 4, 2020

Thanks @mturiansky. As far as I can see it is still in sympy.core.assumptions, been meaning to take a look at this. Nevertheless not related to this PR, is this ready to merge except for this test?

@mturiansky
Copy link
Contributor Author

I still want to add the WAVECAR to UNK conversion. I'll mark it "ready for review" to turn it from a draft to a PR when it's ready.

@mkhorton
Copy link
Member

mkhorton commented Jun 4, 2020

Great, thanks.

@mturiansky
Copy link
Contributor Author

By the way, #1585 can probably be closed now, it was addressed previously but will definitely be addressed now.

Also, heads up @bernstei, I removed the "gamma" argument and replaced it with the "vasp_type" argument. If you don't specify "gamma" it will work fine, but if you specified "gamma" somewhere, then you will get a unexpected keyword TypeError.

@mturiansky mturiansky changed the title [WIP] SOC WAVECARs and general cleanup SOC WAVECARs and general cleanup Jun 5, 2020
@mturiansky mturiansky marked this pull request as ready for review June 5, 2020 23:41
@mturiansky
Copy link
Contributor Author

This PR is ready to merge. The failing circleci is not my fault.

That being said, I think I know how to fix it. I played around with your docker image and was able to fix the sympy error. The version of sympy that is installed by conda seems to be bad. My guess is that it was generated with an older python version and something with the module loading has changed. If you install sympy with pip instead of conda, everything works. However, I found that using "conda uninstall sympy" didn't uninstall things completely/correctly. Here is the sequence of commands I used:

$ docker pull materialsvirtuallab/circle-ci-pmg-py3:3.7.3
$ docker run --name test -it materialsvirtuallab/circle-ci-pmg-py3:3.7.3 bash

and then inside the docker container:

$ export PATH=$HOME/miniconda3/bin:$PATH
$ conda config --system --add channels conda-forge
$ # NOTE: no sympy in next command
$ conda create -q -n test-environment python=3.7 numpy scipy matplotlib cython pandas networkx pytest pip cmake h5py openbabel python-igraph
$ source activate test-environment
$ git clone https://github.com/materialsproject/pymatgen.git && cd pymatgen/
$ pip install --ignore-installed -r requirements.txt -r requirements-optional.txt -r requirements-dev.txt
$ pip install -e .
$ # now, check that it worked with one of the tests that failed before
$ pytest pymatgen/analysis/tests/test_surface_analysis.py

I hope that fixes things, @shyuep @mkhorton . You may need to clear the caches on circleci (is that a thing you can do? I haven't used circleci myself).

@mturiansky
Copy link
Contributor Author

See #1864

@mturiansky
Copy link
Contributor Author

Can I get a release once this is merged, please?

@mkhorton
Copy link
Member

mkhorton commented Jun 8, 2020

Sure thing, and thanks for investigating the failed test. CircleCI calculates a hash to determine if it needs to clear its cache, I'll check the logic there.

@mkhorton mkhorton merged commit d9a2e78 into materialsproject:master Jun 8, 2020
@mkhorton
Copy link
Member

mkhorton commented Jun 8, 2020

This PR is excellent, thanks for all your work on it.

@mturiansky mturiansky deleted the wavecar_so branch June 8, 2020 19:55
@mturiansky
Copy link
Contributor Author

Thanks! I noticed that CirceCI calculates a hash, but it only does this for the requirements*.txt files. When you change the CircleCI config file, which has the conda installation scripts, the cache isn't regenerated, so the changes don't propagate. I addressed this in my other pull request.

@mkhorton
Copy link
Member

mkhorton commented Jun 9, 2020

Release pushed. Trying out a new way of building wheels for PyPI for this release, let me know if there are any issues.

@mturiansky
Copy link
Contributor Author

Thanks, again! Seems to work well on my machine so far.

@mkhorton
Copy link
Member

mkhorton commented Jun 9, 2020

We are having an issue during building for Windows: https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=172210&view=logs&j=171a126d-c574-5c8c-1269-ff3b989e923d&t=1183ba29-a0b5-5324-8463-2a49ace9e213&l=2044

ImportError: cannot import name 'FortranEOFError'

Does this depend on a specific scipy version?

@mturiansky
Copy link
Contributor Author

Oh boy, I hadn't even thought of that. The fortran reader was added as early as v0.13, but the FortranEORError wasn't added until v1.4.0 as far as I can tell.

@mkhorton
Copy link
Member

mkhorton commented Jun 9, 2020

No worries, I can push a supplemental release if necessary.

@mangerij
Copy link

Is there documentation on this? Or an example on how to use it? :)

@mturiansky
Copy link
Contributor Author

Hi @mangerij , you can read the api documentation for the Wavecar here. There's a few different ways to use the code:

  • use the convenience functions like get_parchg or write_unks
  • use fft_mesh to get the pseudowavefunctions on a FFT grid
  • use the Wavecar.coeffs variable directly, which stores the pseudowavefunction coefficients on the reduced grid in reciprocal space (the grid points are in Wavecar.Gpoints)
    It really depends on what you're trying to do with it.

@mangerij
Copy link

mangerij commented Jun 23, 2020 via email

@mturiansky
Copy link
Contributor Author

I believe most of the code is IO limited. Definitely in reading in the WAVECAR, you're limited by IO. A few of the computations can be sped up using something like numba or cython in principle (for example, generating the Gpoints), but the speed up you'll gain is essentially negligible for large files like this.

For writing the UNK files, I think you're again mostly IO limited, but generating the FFT mesh could probably be sped up. Right now, it has a python loop that could probably be sped up with numba. If I have some time, I'll do some profiling and see if that would make a noticeable difference.

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