cersonsky-lab / AniSOAP

Library for computing anisotropy extension to SOAP descriptors
Apache License 2.0
8 stars 1 forks source link

5 incorporate normalization factors #6

Closed arthur-lin1027 closed 1 year ago

arthur-lin1027 commented 1 year ago

Starting a PR so I can show what each normalization method does.

arthur-lin1027 commented 1 year ago

Commit 3ad3c6c normalizes post-hoc and looks nice, but likely isn't correct because it only contains a normalization factor consisting only of the gto's gaussian width, not of the 3 axes of our anisotropic gaussian.

This results in a anisoap vector (at the end of doing the tensor product) that looks like this:

anisoap_scaled_v1

To obtain a normalization factor consisting of all three gaussian widths, I normalized within the pairwise expansion, as seen in this commit: cdb48a2

This results in a anisoap vector (at the end of doing the tensor product) that looks like this:

anisoap_scaled_v2

I'd love to hear your comments on how these look!

arthur-lin1027 commented 1 year ago

The normalization code is ready for review. It is pretty much the same as 3ad3c6c

arthur-lin1027 commented 1 year ago

I've completed my first iteration of orthonormalization. Orthonormalization functions are now all in the radial_basis.py function. The orthonormalized results perform well! Based off some rudimentary tests the orthonormalized results generally outperform the unnormalized results, and seems to be less prone to overfitting.

rosecers commented 1 year ago

I could go either way — if you keep the checks, they should have coinciding tests.

On 28 Jun 2023, at 17:35, arthur-lin1027 @.***> wrote:

@arthur-lin1027 commented on this pull request.

In anisoap/representations/radial_basis.py https://github.com/cersonsky-lab/anisoap/pull/6#discussion_r1245891014:

  • if not np.allclose(matrix, matrix.T):
  • raise ValueError("Matrix is not hermitian")
  • eva, eve = np.linalg.eigh(matrix)
  • if (eva < 0).all():
  • raise ValueError(
  • "Matrix is not positive semidefinite. Check that a valid gram matrix is passed."
  • ) Hmm in its current usage these checks will not be triggered. However, these are general purpose util functions that could theoretically be (mis)used elsewhere.

So, should it be the function's role to verify that the matrix is symmetric positive semidefinite, or should such a verification be done outside the function?

— Reply to this email directly, view it on GitHub https://github.com/cersonsky-lab/anisoap/pull/6#discussion_r1245891014, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALKVP3WANDINOYTJ35O2BD3XNSWUXANCNFSM6AAAAAAY6NPPWE. You are receiving this because your review was requested.

arthur-lin1027 commented 1 year ago

I don't know how to test for orthonormality... the numeric integration isn't great LOL. But I've been able to test for everything else.

arthur-lin1027 commented 1 year ago

Unfortunately this code does not pass when we are dealing with large number of lmax (I'm working with lmax=15, which is what is needed for the gay berne ellipsoids). For whatever reason, our gram matrix is no longer positive semidefinite and has negative eigenvalues, which I find surprising -- I'm suspecting this is a numerical stability issue, as when I perform the eigendecomposition on this matrix, and perform eve @ eva @ eve.T, I do not obtain my original matrix

arthur-lin1027 commented 1 year ago

With this latest commit I made on June 30, I first normalize the values in the tensor block, then perform orthonormalization using an overlap matrix consisting of the overlaps of normalized GTOs.

Previously, I was using an overlap matrix consisting of the overlaps of nonnormalized GTOs, which led to numerical stability issues. The code should now be ready to merge in pending a final review.