lab-cosmo / librascal

A scalable and versatile library to generate representations for atomic-scale learning
https://lab-cosmo.github.io/librascal/
GNU Lesser General Public License v2.1
80 stars 17 forks source link

Feat/kvec generator #387

Closed kvhuguenin closed 3 years ago

kvhuguenin commented 3 years ago

Implemented class for generating the k-vectors (reciprocal space vectors) used for the k-space implementation of LODE and more general spherical expansion coefficients. The details and derivations of the algorithm used to generate the vectors is described in a supplementary document that can be provided if desired.

Tests are provided to check that the code behaves reasonably under realistic conditions as well as some more artificial tests to catch boundary cases.

Luthaf commented 3 years ago

The details and derivations of the algorithm used to generate the vectors is described in a supplementary document that can be provided if desired.

Could you summarize it in the documentation of Kvectors? Otherwise, it might be a good idea to add this to the librascal documentation.

agoscinski commented 3 years ago

So the pip installation has problems to find zlib (dependency matplotlib -> pillow -> zlib), so @kvhuguenin added apt-get install libjpeg-dev zlib1g-dev to the circle ci jobs before the pip installation as temporary solution. I think the better solution would be to update the docker images, but I do not have experience with this. Maybe @Luthaf do you have some input?

https://app.circleci.com/pipelines/github/cosmo-epfl/librascal/2735/workflows/fe45599f-b070-4204-9bb3-1d4e867098a3/jobs/24054

Luthaf commented 3 years ago

This is a bit of a strange behavior, I would expect us to get pre-built wheels instead of having pip rebuild whatever code is in Pillow. I would rather investigate in this direction before modifying the docker images.

If you look through the logs, the failing build contains two things saying it is building from source:

Previous builds that worked fine (https://app.circleci.com/pipelines/github/cosmo-epfl/librascal/2727/workflows/b8d9d737-fa46-45d4-9710-53eeed785e8e/jobs/23967) looked like this instead:

My best guess is that they just released Pillow 8.4.0, and either did not had time to publish wheels for Python 3.6, or decided to drop Python 3.6 support.


If we really need to modify them, the dockerfiles are in the repo (https://github.com/cosmo-epfl/librascal/blob/master/.circleci/Dockerfile), and I can give you access to the dockerhub organization so that you can publish new version of the image.

kvhuguenin commented 3 years ago

I have now updated and polished the code, the two important changes of which have been:

kvhuguenin commented 3 years ago

I am confused about the circleci notebooks test that failed. It is related to the zundel notebook. When I pushed my changes 3 days ago (commit 22d6e0f), all tests passed. During the entire work on this branch, I haven't touched a single Python file, and the only files I have modified are related to the kvecgen which as of now, isn't used by any other code. I saw that the zundel notebook was also causing problems in #382, although in my case, it somehow seems like matplotlib couldn't get the right dependencies for Greek letters. Do you have any idea what could be the reason for this? (or could it be that the current issue is related to the underlying cause of #382?)

Luthaf commented 3 years ago

So documenting the user-side of LODE & kvecgen together is fine for me, and can be left for a future PR.

The failure of the Zundel notebook looks different from #382 (which is a timeout). Might be related to the problem we have with pip installing stuff from sources?

Talking about that, this error when installing Pillow is quite strange: they released wheels (as visible here https://pypi.org/project/Pillow/#files) on the 15th of october. I'll try to give this a look.

kvhuguenin commented 3 years ago

Talking about that, this error when installing Pillow is quite strange: they released wheels (as visible here https://pypi.org/project/Pillow/#files) on the 15th of october. I'll try to give this a look.

Ok, thanks for looking into that. Let me know if there is anything else I can do on this branch in the meantime. Otherwise, I will just keep working on the PRs for the remaining LODE packages that will come once this one has been merged (I still have to write the tests and polish everything, so it will take a few days).

Luthaf commented 3 years ago

Ok, now that #388 have been merged, could you rebase this branch on top of master?

kvhuguenin commented 3 years ago

Thank you for all the suggestions. I have now pushed a version that has implemented all these changes. The largest two of which are:

kvhuguenin commented 3 years ago

Right now, for some reason I don't yet understand, the tests compiled with the clang compiler (that's what the clang-n tests are, right?) produce errors which seem to be due to the fact that the "rotation" matrices that are produced by the algorithm are not actual rotation matrices, i.e. they do not satisfy R^TR = RR^T=1. On my machine, the test runs fine. Is anybody familiar with this isse?

agoscinski commented 3 years ago

I am looking into this now

kvhuguenin commented 3 years ago

Oh nice! Thank you for the quick fix and lesseon @agoscinski ! I thought that using auto more might increase readability, but I should be more careful in the future then. Anyway, since this is the first time my code gets reviewed by somebody who actually knows how to do this, let me know if there is anything else that can be improved, both for this code specifically and also in terms of general programming practices @Luthaf and @agoscinski .

agoscinski commented 3 years ago

I am fine with the current state, just needs a rebase (or can be also squashed when merged, should be easier)