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 authored and Luthaf committed Sep 1, 2023
1 parent efff403 commit bf415ce
Show file tree
Hide file tree
Showing 10 changed files with 517 additions and 335 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
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 SplinerFromFunction


# %%
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 = SplinerFromFunction(
radial_integral=laplacian_eigenstate_basis,
spline_cutoff=cutoff,
max_radial=max_radial,
max_angular=max_angular,
radial_integral_derivative=laplacian_eigenstate_basis_derivative,
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
13 changes: 13 additions & 0 deletions python/rascaline/rascaline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,16 @@
from .status import RascalError # noqa
from .systems import IntoSystem, SystemBase # noqa
from .version import __version__ # noqa


__all__ = [
"AtomicComposition",
"CalculatorBase",
"LodeSphericalExpansion",
"NeighborList",
"SoapPowerSpectrum",
"SoapRadialSpectrum",
"SortedDistances",
"SphericalExpansion",
"SphericalExpansionByPair",
]
219 changes: 0 additions & 219 deletions python/rascaline/rascaline/splines.py

This file was deleted.

3 changes: 2 additions & 1 deletion python/rascaline/rascaline/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import metatensor.core

from .power_spectrum import PowerSpectrum
from .splines import SplinerBase, SplinerFromFunction


__all__ = ["PowerSpectrum"]
__all__ = ["PowerSpectrum", "SplinerBase", "SplinerFromFunction"]


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

0 comments on commit bf415ce

Please sign in to comment.