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 Aug 1, 2023
1 parent 4648a26 commit 0033cb2
Show file tree
Hide file tree
Showing 9 changed files with 454 additions and 261 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,
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
33 changes: 22 additions & 11 deletions python/rascaline/rascaline/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
from . import utils # noqa
from .calculators import (
AtomicComposition,
CalculatorBase,
LodeSphericalExpansion,
NeighborList,
SoapPowerSpectrum,
SoapRadialSpectrum,
SortedDistances,
SphericalExpansion,
SphericalExpansionByPair,
)
from .log import set_logging_callback # noqa
from .profiling import Profiler # noqa
from .status import RascalError # noqa
from .systems import IntoSystem, SystemBase # noqa
from .version import __version__ # noqa


from .calculators import CalculatorBase # noqa isort: skip
from .calculators import AtomicComposition # noqa isort: skip
from .calculators import SortedDistances # noqa isort: skip
from .calculators import NeighborList # noqa isort: skip
from .calculators import LodeSphericalExpansion # noqa isort: skip
from .calculators import SphericalExpansion # noqa isort: skip
from .calculators import SphericalExpansionByPair # noqa isort: skip
from .calculators import SoapRadialSpectrum # noqa isort: skip
from .calculators import SoapPowerSpectrum # noqa isort: skip

from .splines import generate_splines # noqa isort: skip
__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 equistore.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 0033cb2

Please sign in to comment.