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

General spliner class #212

Merged
merged 4 commits into from
Sep 21, 2023
Merged

General spliner class #212

merged 4 commits into from
Sep 21, 2023

Conversation

PicoCentauri
Copy link
Collaborator

@PicoCentauri PicoCentauri commented Aug 1, 2023

  • Replace generate_splines by a more flexible class
  • Allow to calculate the derivative of the radial integral numerically
  • Add linter for to check docstrings for double backticked strings which should be links to the Python documentation
  • Some minor cleanup to the rascaline __init__.py, i.e. adding an __all__ list.

Splitting the code into a SplinerBase and SplinerFromFunction class sounds maybe like an overkill here. However, this is only the first commit and should serve as a discussion basis for the architecture of the classes. After we agree on the design I will use the base class to extend the splining classes to more real and also kspace splining classes.


📚 Documentation preview 📚: https://rascaline--212.org.readthedocs.build/en/212/

@github-actions
Copy link

github-actions bot commented Aug 1, 2023

Here is a pre-built version of the code in this pull request: wheels.zip, you can install it locally by unzipping wheels.zip and using pip to install the file matching your system

Copy link
Collaborator

@frostedoyster frostedoyster left a comment

Choose a reason for hiding this comment

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

The design looks good to me, although the derived class isn't doing much additional work. Maybe we could ask for a third person's opinion on this

python/rascaline/tests/utils/splines.py Outdated Show resolved Hide resolved
python/rascaline/rascaline/utils/splines.py Show resolved Hide resolved
@PicoCentauri
Copy link
Collaborator Author

We have to repbase again metatensor but otherwise should be fine.

Copy link
Owner

@Luthaf Luthaf left a comment

Choose a reason for hiding this comment

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

looks good, I have some comments on minor API points & naming

python/rascaline-torch/rascaline/torch/__init__.py Outdated Show resolved Hide resolved
python/rascaline/rascaline/__init__.py Outdated Show resolved Hide resolved
python/rascaline/rascaline/utils/__init__.py Outdated Show resolved Hide resolved
Comment on lines 63 to 65
Note that the integration range was deliberately left ambiguous since it depends
on the radial basis, i.e. for the GTO basis, :math:`r \in R^+` is used, while
:math:`r \in [0, cutoff]` for the monomial basis.
Copy link
Owner

Choose a reason for hiding this comment

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

I still disagree with this formulation ^_^. this is always an integral to +\infty, but sometime the function to integrate is 0 outside of the cutoff, so the integral can be simplified. But we can always define it as an integral from 0 to +\infty.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fine for me to change it.

python/rascaline/rascaline/utils/splines.py Show resolved Hide resolved
Comment on lines 321 to 319
:parameter center_contribution: Contribution of the central atom required for LODE
calculations.
Copy link
Owner

Choose a reason for hiding this comment

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

This should point to the corresponding property documentation in the base class

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The properties are private. I don't know what we should point to.

Copy link
Owner

Choose a reason for hiding this comment

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

then we can duplicate the documentation here instead. I mainly want to have a definition of what "Contribution of the central atom required for LODE" means.

python/rascaline/examples/splined-radial-integral.py Outdated Show resolved Hide resolved
import numpy as np


class SplinerBase(ABC):
Copy link
Owner

Choose a reason for hiding this comment

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

since this is specifically for tabulated radial integral, I think it should be reflected somewhere in the name:

Suggested change
class SplinerBase(ABC):
class RadialIntegralSplinerBase(ABC):

return interpolated_values


class SplinerFromFunction(SplinerBase):
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
class SplinerFromFunction(SplinerBase):
class RadialIntegralFromFunction(SplinerBase):

Comment on lines 304 to 306
1-D array containing the values of the radial integral. :parameter cutoff:
Spherical cutoff for the radial basis :parameter max_angular: number of radial
components
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
1-D array containing the values of the radial integral. :parameter cutoff:
Spherical cutoff for the radial basis :parameter max_angular: number of radial
components
1-D array containing the values of the radial integral.
:parameter cutoff: Spherical cutoff for the radial basis

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks. Always these issues with the auto formatting.


# The hardcoded displacement is a only a valid choice of the positions are in a
# reasonable range.
assert np.abs(positions).mean() >= 1.0
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should we do a propper raise here? Probably it is better...

Copy link
Owner

Choose a reason for hiding this comment

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

would be nice yes =)

@PicoCentauri PicoCentauri force-pushed the splinerclass branch 2 times, most recently from 201c48d to 7299d88 Compare September 21, 2023 13:08
Copy link
Owner

@Luthaf Luthaf left a comment

Choose a reason for hiding this comment

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

Looks good, once CI is happy we can merge!

Comment on lines +5 to +7
Classes for generating spline points which can be used as input for the for the radial
integral hyper paramater option. For an complete example for the LE how to use the
classes see :ref:`example-splines`.
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
Classes for generating spline points which can be used as input for the for the radial
integral hyper paramater option. For an complete example for the LE how to use the
classes see :ref:`example-splines`.
Classes for generating spline points which can be used as input for the radial
integral hyper parameter option. For an complete example on how to use the
classes see :ref:`example-splines`.

:members:
:show-inheritance:

.. autoclass:: rascaline.utils.RadialIntegralFromFunction
Copy link
Owner

Choose a reason for hiding this comment

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

we should pick a place for these. I see you like to have them in the module docstring, and I prefer them in the docs sources. Let's chat about it in the meeting later today?

Comment on lines +324 to +325
radial basis function and :math:`n` the current radial channel. This should be
implemented in the child classes.
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
radial basis function and :math:`n` the current radial channel. This should be
implemented in the child classes.
radial basis function and :math:`n` the current radial channel. This should be
precomputed and provided separately.

@PicoCentauri PicoCentauri merged commit dea662e into master Sep 21, 2023
24 checks passed
@PicoCentauri PicoCentauri deleted the splinerclass branch September 21, 2023 15:02
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.

3 participants