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

Redesigned metatensor-based Clebsch Gordan iterations #237

Merged
merged 105 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
19ef895
Stub module for CG iterations
jwa7 Jun 30, 2023
e9b4155
Class for calculating CG coeffs
jwa7 Jun 30, 2023
46361f1
dispatch stub
jwa7 Jun 30, 2023
2faf45a
`_clebsch_gordan_combine` core function
jwa7 Jun 30, 2023
155139d
Rough code from Alex to perform dense CG combine
jwa7 Jun 30, 2023
62130a2
add dense version
agoscinski Jul 3, 2023
5173fe5
option for sparse or not operation in core combine fxn
jwa7 Jul 3, 2023
77647df
First draft code for single center combine
jwa7 Jul 3, 2023
1280535
adding _create_combined_keys
agoscinski Jul 3, 2023
316fa93
_create_combined_keys now returns 3 labels
agoscinski Jul 3, 2023
b7cbb64
Single center code and stub for multi center
jwa7 Jul 3, 2023
c47e369
Temporary notebook for prototyping
jwa7 Jul 3, 2023
3252e52
API for combine to nu=2, no inversion yet
jwa7 Jul 7, 2023
e49b748
Lambda-SOAP prototype
jwa7 Jul 10, 2023
587ea52
lsoap prototype
jwa7 Jul 10, 2023
906d34c
example frame
jwa7 Jul 10, 2023
7805f5e
Merge branch 'master' into clebsch_gordan
jwa7 Jul 10, 2023
05e65b9
minor changes
jwa7 Jul 10, 2023
44399a0
Apply corrections for redundant corrections
jwa7 Jul 10, 2023
98f3228
import clebsch_gordan
jwa7 Jul 10, 2023
12d6ba4
Allow sparsification with species neighbors not necessarily in `frames`
jwa7 Jul 10, 2023
cdf94ed
Bug in ordering of property columns
jwa7 Jul 10, 2023
2bdd7dc
Multiplicities by tracking intermediate lambda (i.e. "k")
jwa7 Jul 13, 2023
fe65eb7
more prototyping
jwa7 Jul 13, 2023
c6d536b
fix property names for iterations
DivyaSuman14 Jul 18, 2023
eae5724
fixed bug in property values indexing
DivyaSuman14 Jul 21, 2023
947c60d
integretinog dense version into clebsch gordan
agoscinski Jul 23, 2023
deb0627
simplify sparse cg coeffs format
agoscinski Jul 23, 2023
45ad6fc
Merge branch 'master' into clebsch_gordan
jwa7 Jul 25, 2023
f763c4b
New example data
jwa7 Jul 26, 2023
f7c585d
Some cleaning up
jwa7 Jul 26, 2023
ba5b77e
Example `nu_target=3` iteration with new test system
jwa7 Jul 26, 2023
fa9fa88
Merge branch 'master' into clebsch_gordan
jwa7 Jul 31, 2023
39ec637
Old CG code for reference
jwa7 Jul 31, 2023
dd65be2
Test for equivariance
jwa7 Jul 31, 2023
ede6e4c
Change correction factor to sqrt of multiplicity. Easier testing!
jwa7 Jul 31, 2023
61b1b5f
Fxns to invert tensormap
jwa7 Jul 31, 2023
e669d51
Attempt at O(3) equivariance test
jwa7 Jul 31, 2023
3954cfd
Correctly account for phase convention in O(3) transformation
jwa7 Aug 2, 2023
610f415
Notebook updated with equivariance checks
jwa7 Aug 2, 2023
13e5e18
small tidy
jwa7 Aug 2, 2023
e535b93
module for the old CG iteration code (i.e. equistore examples / acdc_…
jwa7 Aug 2, 2023
7c5bd0c
Module for Wigner matrices, (S)O(3) transformations of TensorMaps
jwa7 Aug 2, 2023
6a5982d
Minor change
jwa7 Aug 2, 2023
7daaf4a
remove deprecated spherical.py
jwa7 Aug 2, 2023
4b6a9c2
lambda-SOAP wrapper, allow for parity filter on final iteration.
jwa7 Aug 2, 2023
35f5175
refactor test
agoscinski Aug 14, 2023
78ad39e
added orthogonality tests
agoscinski Aug 14, 2023
8d3fb19
cleanup tests to not recompute cg coeffs for every test
agoscinski Aug 14, 2023
c7fc221
remove input arg use_sparse when it can be inferred from cg_cache
agoscinski Aug 14, 2023
0cc2ac5
remove use_sparse in tests using _combine_single_center
agoscinski Aug 14, 2023
1f332a3
fix typos
agoscinski Aug 24, 2023
6bc6839
update notebook
jwa7 Sep 15, 2023
81e2ae4
Merge branch 'master' into clebsch_gordan
jwa7 Sep 15, 2023
bee22b4
to metatensor; lambda_filter; pre-compute all keys
jwa7 Sep 16, 2023
2400451
API redesign. Move CG coeffs to separate module.
jwa7 Sep 28, 2023
25916d7
Brief lambda-SOAP tutorial
jwa7 Sep 28, 2023
3889841
Fxn to return only the metadata of CG calcs
jwa7 Sep 28, 2023
1d6eaff
Merge branch 'master' into clebsch_gordan
jwa7 Oct 11, 2023
596cab9
changing dir structure
jwa7 Oct 11, 2023
9c6931d
local import
jwa7 Oct 11, 2023
07b5889
formatting
jwa7 Oct 11, 2023
d5db737
Merge branch 'master' into clebsch_gordan
jwa7 Oct 11, 2023
768b135
torch import
jwa7 Oct 11, 2023
9b7567b
adapt tests to new API
agoscinski Oct 12, 2023
0af495b
adapt test_combine_single_center_orthogonality test to new API
agoscinski Oct 12, 2023
b6d8de7
format tests
agoscinski Oct 12, 2023
b10f623
making more transparent what happens with the species neighbor in the…
agoscinski Oct 12, 2023
b2cedfe
Merge branch 'master' into clebsch_gordan
jwa7 Oct 13, 2023
c511ade
Add wigners as a core dependency
jwa7 Oct 17, 2023
827f9b3
sympy and mtops required
jwa7 Oct 18, 2023
4b37ccf
FiX SIGN CONVENTION! + some tests
jwa7 Oct 18, 2023
cce0bdc
add norm preserving test for combine_single_center_to_body_order
agoscinski Oct 18, 2023
33726e7
Add a (-1)^l factor to the power spectrum invariants
Luthaf Oct 18, 2023
b3dd92e
Get tests to run. One fails as expected - need to fix norm preservati…
jwa7 Oct 18, 2023
9868e36
Update notebook
jwa7 Oct 18, 2023
21ea9d3
Merge branch 'power-spectrum-factor' into clebsch_gordan
jwa7 Oct 18, 2023
fba7f33
Trying to fix norm preservation
jwa7 Oct 18, 2023
0d4415f
Add Alex's tests for the CG cache
jwa7 Oct 18, 2023
fa1514a
Fix norm preservation tests
jwa7 Nov 14, 2023
7e914f1
Docstring
jwa7 Nov 14, 2023
c10457d
Comment out normalization code
jwa7 Nov 15, 2023
89a4d94
Move combinations to dispatch
jwa7 Nov 15, 2023
7749dab
Move combine wrapper to dispatch, test for metadata-only computation
jwa7 Nov 15, 2023
72d2bd0
Remove archived files
jwa7 Nov 15, 2023
ad88220
Add some docs on rotation-adapted features, authored by @ecignoni
jwa7 Nov 15, 2023
6b843a8
Set up dispatch, remove unnecessary lsoap wrapper
jwa7 Nov 15, 2023
fc984f2
Better naming
jwa7 Nov 16, 2023
75f205e
Merge branch 'master' into clebsch_gordan
jwa7 Nov 16, 2023
27108d0
Match with master
jwa7 Nov 16, 2023
c505721
File endings
jwa7 Nov 16, 2023
6a32b20
Move rotations to test dir
jwa7 Nov 20, 2023
7fc8c6d
Remove rotations
jwa7 Nov 20, 2023
c143657
First attempt sparse accumulation of products
jwa7 Nov 20, 2023
995ca0d
Remove profile
jwa7 Nov 20, 2023
a36c3fd
Make the CG cache module private
jwa7 Nov 21, 2023
0521d44
Add mops to the dependencies
jwa7 Nov 22, 2023
80ef84d
New public API function names
jwa7 Nov 22, 2023
88f4ac4
Separate out removal of redundant keys. Some renaming.
jwa7 Nov 22, 2023
9ad960e
Change fxn signatures
jwa7 Nov 22, 2023
8d11a8b
Update API to take Labels selection
jwa7 Nov 22, 2023
f589abe
Remove not implemented function
jwa7 Nov 23, 2023
6dc7388
Make the CI happy
jwa7 Nov 23, 2023
148ed00
Ensure the CI truly has absolutely nothing to complain about
jwa7 Nov 23, 2023
6787833
Review edits
jwa7 Nov 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/explanations/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ all about.

concepts
soap
rotation_adapted
88 changes: 88 additions & 0 deletions docs/src/explanations/rotation_adapted.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Rotation-Adapted Features
=========================

Equivariance
------------

Descriptors like SOAP are translation, rotation, and permutation invariant.
Indeed, such invariances are extremely useful if one wants to learn an invariant target (e.g., the energy).
Being already encoded in the descriptor, the learning algorithm does not have to learn such a physical requirement.

The situation is different if the target is not invariant. For example, one may want to learn a dipole. The dipole rotates with a rotation of the molecule, and as such, invariant descriptors do not have the required symmetries for this task.

Instead, one would need a rotation equivariant descriptor.
Rotation equivariance means that, if I first rotate the structure and compute the descriptor, I obtain the same result as first computing the descriptor and then applying the rotation, i.e., the descriptor behaves correctly upon rotation operations.
Denoting a structure as :math:`A`, the function computing the descriptor as :math:`f(\cdot)`, and the rotation operator as :math:`\hat{R}`, rotation equivariance can be expressed as:

.. math::
:name: eq:equivariance

f(\hat{R} A) = \hat{R} f(A)

Of course, invariance is a special case of equivariance.


Rotation Equivariance of the Spherical Expansion
------------------------------------------------

The spherical expansion is a rotation equivariant descriptor.
Let's consider the expansion coefficients of :math:`\rho_i(\mathbf{r})`.
We have:

.. math::

\hat{R} \rho_i(\mathbf{r}) &= \sum_{nlm} c_{nlm}^{i} R_n(r) \hat{R} Y_l^m(\hat{\mathbf{r}}) \nonumber \\
&= \sum_{nlmm'} c_{nlm}^{i} R_n(r) D_{m,m'}^{l}(\hat{R}) Y_l^{m'}(\hat{\mathbf{r}}) \nonumber \\
&= \sum_{nlm} \left( \sum_{m'} D_{m',m}^l(\hat{R}) c_{nlm'}^{i}\right) B_{nlm}(\mathbf{r}) \nonumber

and noting that :math:`Y_l^m(\hat{R} \hat{\mathbf{r}}) = \hat{R} Y_l^m(\hat{\mathbf{r}})` and :math:`\hat{R}r = r`, equation :ref:`(1) <eq:equivariance>` is satisfied and we conclude that the expansion coefficients :math:`c_{nlm}^{i}` are rotation equivariant.
Indeed, each :math:`c_{nlm}^{i}` transforms under rotation as the spherical harmonics :math:`Y_l^m(\hat{\mathbf{r}})`.

Using the Dirac notation, the coefficient :math:`c_{nlm}^{i}` can be expressed as :math:`\braket{nlm\vert\rho_i}`.
Equivalently, and to stress the fact that this coefficient describes something that transforms under rotation as a spherical harmonics :math:`Y_l^m(\hat{\mathbf{r}})`, it is sometimes written as :math:`\braket{n\vert\rho_i;lm}`, i.e., the atomic density is "tagged" with a label that tells how it transforms under rotations.


Completeness Relations of Spherical Harmonics
---------------------------------------------

Spherical harmonics can be combined together using rules coming from standard theory of angular momentum:

.. math::
:name: eq:cg_coupling

\ket{lm} \propto \ket{l_1 l_2 l m} = \sum_{m_1 m_2} C_{m_1 m_2 m}^{l_1 l_2 l} \ket{l_1 m_1} \ket{l_2 m_2}

where :math:`C_{m_1 m_2 m}^{l_1 l_2 l}` is a Clebsch-Gordan (CG) coefficient.

Thanks to the one-to-one correspondence (under rotation) between :math:`c_{nlm}^{i}` and :math:`Y_l^m`,
:ref:`(2) <eq:cg_coupling>` means that one can take products of two spherical expansion coefficients (which amounts to considering density correlations), and combine them with CG coefficients to get new coefficients that transform as a single spherical harmonics.
This process is known as coupling, from the uncoupled basis of angular momentum (formed by the product of rotation eigenstates) to a coupled basis (a single rotation eigenstate).

One can also write the inverse of :ref:`(2) <eq:cg_coupling>`:

.. math::
:name: eq:cg_decoupling

\ket{l_1 m_1} \ket{l_2 m_2} = \sum_{l m} C_{m_1 m_2 m}^{l_1 l_2 l m} \ket{l_1 l_2 l m}

that express the product of two rotation eigenstates in terms of one. This process is known as decoupling.

Example: :math:`\lambda`-SOAP
-----------------------------

A straightforward application of :ref:`(2) <eq:cg_coupling>` is the construction of :math:`\lambda`-SOAP features.
Indeed, :math:`\lambda`-SOAP was created in order to have a rotation and inversion equivariant version of the 3-body density correlations.
The :math:`\lambda` represents the degree of a spherical harmonics, :math:`Y_{\lambda}^{\mu}(\hat{\mathbf{r}})`,
and it indicates that this descriptor can transform under rotations as a spherical harmonics, i.e., it is rotation equivariant.

It is then obtained by considering two expansion coefficients of the atomic density, and combining them with a CG iteration to a coupled basis,
as in :ref:`(2) <eq:cg_coupling>`.
The :math:`\lambda`-SOAP descriptor is then:

.. math::

\braket{n_1 l_1 n_2 l_2\vert\overline{\rho_i^{\otimes 2}, \sigma, \lambda \mu}} =
\frac{\delta_{\sigma, (-1)^{l_1 + l_2 + \lambda}}}{\sqrt{2 \lambda + 1}}
\sum_{m} C_{m (\mu-m) \mu}^{l_1 l_2 \lambda} c_{n_1 l_1 m}^{i} c_{n_2 l_2 (\mu - m)}^{i}

where we have assumed real spherical harmonics coefficients.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ classifiers = [

dependencies = [
"metatensor-core >=0.1.0,<0.2.0",
"wigners",
]

[project.urls]
Expand Down
1 change: 1 addition & 0 deletions python/rascaline/rascaline/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

from .clebsch_gordan import * # noqa
from .power_spectrum import PowerSpectrum # noqa
from .splines import ( # noqa
AtomicDensityBase,
Expand Down
7 changes: 7 additions & 0 deletions python/rascaline/rascaline/utils/clebsch_gordan/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from .clebsch_gordan import correlate_density, correlate_density_metadata # noqa


__all__ = [
"correlate_density",
"correlate_density_metadata",
]
Loading