-
Notifications
You must be signed in to change notification settings - Fork 18
Redesigned metatensor-based Clebsch Gordan iterations #237
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
Merged
Merged
Changes from 93 commits
Commits
Show all changes
105 commits
Select commit
Hold shift + click to select a range
19ef895
Stub module for CG iterations
jwa7 e9b4155
Class for calculating CG coeffs
jwa7 46361f1
dispatch stub
jwa7 2faf45a
`_clebsch_gordan_combine` core function
jwa7 155139d
Rough code from Alex to perform dense CG combine
jwa7 62130a2
add dense version
agoscinski 5173fe5
option for sparse or not operation in core combine fxn
jwa7 77647df
First draft code for single center combine
jwa7 1280535
adding _create_combined_keys
agoscinski 316fa93
_create_combined_keys now returns 3 labels
agoscinski b7cbb64
Single center code and stub for multi center
jwa7 c47e369
Temporary notebook for prototyping
jwa7 3252e52
API for combine to nu=2, no inversion yet
jwa7 e49b748
Lambda-SOAP prototype
jwa7 587ea52
lsoap prototype
jwa7 906d34c
example frame
jwa7 7805f5e
Merge branch 'master' into clebsch_gordan
jwa7 05e65b9
minor changes
jwa7 44399a0
Apply corrections for redundant corrections
jwa7 98f3228
import clebsch_gordan
jwa7 12d6ba4
Allow sparsification with species neighbors not necessarily in `frames`
jwa7 cdf94ed
Bug in ordering of property columns
jwa7 2bdd7dc
Multiplicities by tracking intermediate lambda (i.e. "k")
jwa7 fe65eb7
more prototyping
jwa7 c6d536b
fix property names for iterations
DivyaSuman14 eae5724
fixed bug in property values indexing
DivyaSuman14 947c60d
integretinog dense version into clebsch gordan
agoscinski deb0627
simplify sparse cg coeffs format
agoscinski 45ad6fc
Merge branch 'master' into clebsch_gordan
jwa7 f763c4b
New example data
jwa7 f7c585d
Some cleaning up
jwa7 ba5b77e
Example `nu_target=3` iteration with new test system
jwa7 fa9fa88
Merge branch 'master' into clebsch_gordan
jwa7 39ec637
Old CG code for reference
jwa7 dd65be2
Test for equivariance
jwa7 ede6e4c
Change correction factor to sqrt of multiplicity. Easier testing!
jwa7 61b1b5f
Fxns to invert tensormap
jwa7 e669d51
Attempt at O(3) equivariance test
jwa7 3954cfd
Correctly account for phase convention in O(3) transformation
jwa7 610f415
Notebook updated with equivariance checks
jwa7 13e5e18
small tidy
jwa7 e535b93
module for the old CG iteration code (i.e. equistore examples / acdc_…
jwa7 7c5bd0c
Module for Wigner matrices, (S)O(3) transformations of TensorMaps
jwa7 6a5982d
Minor change
jwa7 7daaf4a
remove deprecated spherical.py
jwa7 4b6a9c2
lambda-SOAP wrapper, allow for parity filter on final iteration.
jwa7 35f5175
refactor test
agoscinski 78ad39e
added orthogonality tests
agoscinski 8d3fb19
cleanup tests to not recompute cg coeffs for every test
agoscinski c7fc221
remove input arg use_sparse when it can be inferred from cg_cache
agoscinski 0cc2ac5
remove use_sparse in tests using _combine_single_center
agoscinski 1f332a3
fix typos
agoscinski 6bc6839
update notebook
jwa7 81e2ae4
Merge branch 'master' into clebsch_gordan
jwa7 bee22b4
to metatensor; lambda_filter; pre-compute all keys
jwa7 2400451
API redesign. Move CG coeffs to separate module.
jwa7 25916d7
Brief lambda-SOAP tutorial
jwa7 3889841
Fxn to return only the metadata of CG calcs
jwa7 1d6eaff
Merge branch 'master' into clebsch_gordan
jwa7 596cab9
changing dir structure
jwa7 9c6931d
local import
jwa7 07b5889
formatting
jwa7 d5db737
Merge branch 'master' into clebsch_gordan
jwa7 768b135
torch import
jwa7 9b7567b
adapt tests to new API
agoscinski 0af495b
adapt test_combine_single_center_orthogonality test to new API
agoscinski b6d8de7
format tests
agoscinski b10f623
making more transparent what happens with the species neighbor in the…
agoscinski b2cedfe
Merge branch 'master' into clebsch_gordan
jwa7 c511ade
Add wigners as a core dependency
jwa7 827f9b3
sympy and mtops required
jwa7 4b37ccf
FiX SIGN CONVENTION! + some tests
jwa7 cce0bdc
add norm preserving test for combine_single_center_to_body_order
agoscinski 33726e7
Add a (-1)^l factor to the power spectrum invariants
Luthaf b3dd92e
Get tests to run. One fails as expected - need to fix norm preservati…
jwa7 9868e36
Update notebook
jwa7 21ea9d3
Merge branch 'power-spectrum-factor' into clebsch_gordan
jwa7 fba7f33
Trying to fix norm preservation
jwa7 0d4415f
Add Alex's tests for the CG cache
jwa7 fa1514a
Fix norm preservation tests
jwa7 7e914f1
Docstring
jwa7 c10457d
Comment out normalization code
jwa7 89a4d94
Move combinations to dispatch
jwa7 7749dab
Move combine wrapper to dispatch, test for metadata-only computation
jwa7 72d2bd0
Remove archived files
jwa7 ad88220
Add some docs on rotation-adapted features, authored by @ecignoni
jwa7 6b843a8
Set up dispatch, remove unnecessary lsoap wrapper
jwa7 fc984f2
Better naming
jwa7 75f205e
Merge branch 'master' into clebsch_gordan
jwa7 27108d0
Match with master
jwa7 c505721
File endings
jwa7 6a32b20
Move rotations to test dir
jwa7 7fc8c6d
Remove rotations
jwa7 c143657
First attempt sparse accumulation of products
jwa7 995ca0d
Remove profile
jwa7 a36c3fd
Make the CG cache module private
jwa7 0521d44
Add mops to the dependencies
jwa7 80ef84d
New public API function names
jwa7 88f4ac4
Separate out removal of redundant keys. Some renaming.
jwa7 9ad960e
Change fxn signatures
jwa7 8d11a8b
Update API to take Labels selection
jwa7 f589abe
Remove not implemented function
jwa7 6dc7388
Make the CI happy
jwa7 148ed00
Ensure the CI truly has absolutely nothing to complain about
jwa7 6787833
Review edits
jwa7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,4 @@ all about. | |
|
|
||
| concepts | ||
| soap | ||
| rotation_adapted | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ classifiers = [ | |
|
|
||
| dependencies = [ | ||
| "metatensor-core >=0.1.0,<0.2.0", | ||
| "wigners", | ||
| ] | ||
|
|
||
| [project.urls] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
python/rascaline/rascaline/utils/clebsch_gordan/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| from .cg_coefficients import ClebschGordanReal | ||
| from .clebsch_gordan import ( # noqa | ||
| single_center_combine_to_order, | ||
| single_center_combine_metadata_to_order, | ||
| ) | ||
|
|
||
|
|
||
| __all__ = [ | ||
| "ClebschGordanReal", | ||
| "single_center_combine_to_order", | ||
| "single_center_combine_metadata_to_order", | ||
| ] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.