Skip to content

Commit

Permalink
Replace generate_splines by a more flexible class
Browse files Browse the repository at this point in the history
Also allow to calculate the derivative of the radial integral
numerically.
  • Loading branch information
PicoCentauri committed Sep 21, 2023
1 parent 7edc780 commit dea662e
Show file tree
Hide file tree
Showing 11 changed files with 524 additions and 341 deletions.
2 changes: 0 additions & 2 deletions docs/src/references/api/python/misc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ Miscelaneous
.. autoclass:: rascaline.Profiler
:members:
:undoc-members:

.. autofunction:: rascaline.generate_splines
1 change: 1 addition & 0 deletions docs/src/references/api/python/utils/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ Utility functions and classes that extend the core usage of rascaline.
:maxdepth: 1

power-spectrum
splines
1 change: 1 addition & 0 deletions docs/src/references/api/python/utils/splines.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. automodule:: rascaline.utils.splines
1 change: 0 additions & 1 deletion python/rascaline-torch/rascaline/torch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

__all__ = [
"AtomicComposition",
"CalculatorBase",
"LodeSphericalExpansion",
"NeighborList",
"SoapPowerSpectrum",
Expand Down
27 changes: 13 additions & 14 deletions python/rascaline/examples/splined-radial-integral.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""
.. _example-splines:
Splined radial integrals
========================
Expand All @@ -20,7 +22,8 @@
from scipy.special import jv
from scipy.special import spherical_jn as j_l

from rascaline import SphericalExpansion, generate_splines
from rascaline import SphericalExpansion
from rascaline.utils import RadialIntegralFromFunction


# %%
Expand Down Expand Up @@ -114,16 +117,16 @@ def laplacian_eigenstate_basis_derivative(n, el, r):
# %%
#
# The radial basis functions and their derivatives can be input into a spline
# generator. This will output the positions of the spline points, the
# generator class. This will output the positions of the spline points, the
# values of the basis functions evaluated at the spline points, and the
# corresponding derivatives.
spline_points = generate_splines(
laplacian_eigenstate_basis,
laplacian_eigenstate_basis_derivative,
max_radial,
max_angular,
cutoff,
requested_accuracy=1e-5,
spliner = RadialIntegralFromFunction(
radial_integral=laplacian_eigenstate_basis,
radial_integral_derivative=laplacian_eigenstate_basis_derivative,
spline_cutoff=cutoff,
max_radial=max_radial,
max_angular=max_angular,
accuracy=1e-5,
)

# %%
Expand All @@ -136,11 +139,7 @@ def laplacian_eigenstate_basis_derivative(n, el, r):
"max_radial": max_radial,
"max_angular": max_angular,
"center_atom_weight": 0.0,
"radial_basis": {
"TabulatedRadialIntegral": {
"points": spline_points,
}
},
"radial_basis": spliner.compute(),
"atomic_gaussian_width": 1.0, # ignored
"cutoff_function": {"Step": {}},
}
Expand Down
2 changes: 0 additions & 2 deletions python/rascaline/rascaline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
)
from .log import set_logging_callback # noqa
from .profiling import Profiler # noqa
from .splines import generate_splines # noqa
from .status import RascalError # noqa
from .systems import IntoSystem, SystemBase # noqa
from .version import __version__ # noqa


__all__ = [
"AtomicComposition",
"CalculatorBase",
"LodeSphericalExpansion",
"NeighborList",
"SoapPowerSpectrum",
Expand Down
219 changes: 0 additions & 219 deletions python/rascaline/rascaline/splines.py

This file was deleted.

6 changes: 2 additions & 4 deletions python/rascaline/rascaline/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import metatensor

from .power_spectrum import PowerSpectrum


__all__ = ["PowerSpectrum"]
from .power_spectrum import PowerSpectrum # noqa
from .splines import RadialIntegralFromFunction, RadialIntegralSplinerBase # noqa


# path that can be used with cmake to access the rascaline library and headers
Expand Down
Loading

0 comments on commit dea662e

Please sign in to comment.