-
Notifications
You must be signed in to change notification settings - Fork 27
Created Nested_Angluar_Grid.ipynb #274
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
base: master
Are you sure you want to change the base?
Conversation
@marco-2023 remind me to discuss this with you in person. It will then be very helpful if you can help review this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the interesting work, I've gone over this, it's rather interesting (because it breaks some of my assumptions) and the results look great.
Some general comments:
-
I would recommend to run the code in jupyter notebook (especially the plots) for others to see the results without having to run your code. You can clear output of some cells that isn't needed.
-
Your result is rather interesting because it breaks the general assumption that less angular points are needed near the center (but could be explained since the integrand is also highest near the center). (However note that the molecular grids in
grid
are meant for integrating molecular system rather than atomic).

-
I gone over the subdivision scheme of the icosahedron, it makes sense to me. Couple of references for this are 1 and 2. This picture made the most sense to me:
.
-
When integrating any electron-density, I would recommend choosing a reference grid such that it integrates to the correct number of electrons. For example, changing
oned_grid = Trapezoidal(npoints=100)
to have 250 points or more should give you three-decimal place accuracy of 9.999sh versus 9.0sh. -
The methodology of converging using two consequent angular grids per radial point makes sense to me. However, the goal is to reduce the number of times the integrand is called, so you will need a way to track the new points, and only recompute the integrand for those new points.
-
Finally, I would recommend more complicated molecules, e.g. diatomics at different geometries as well!
The important comments I have is the process of choosing the quadrature weights:
-
This subdivision methodology is also the nested scheme for spherical quadrature used in the book "Spherical Harmonics and Approximations on the Unit Sphere" Section 5.2. If you choose the weights to be the area of the polygonal component, you get a O(1/N_l) convergence and for each division scheme the error should reduce by four (for twice-continuous function). They also give three other quadrature schemes R1-R3 (Section 5.2.2), that give a amazing: O(1/N^2) O(1/N^3) convergence.
What's also nice about this subdivision scheme is that the new set of points is also invariant under icosahedron group. -
I suspect that you don't need to do least-square solution on the quadrature weights. In-fact, if you plot the weights, they are all constant and most likely the area of polygon component. I haven't put much thought into this, but I would heavily look into this, and try to derive a formula.
- This is nice because spherical harmonics of odd degree are odd functions and so a constant weight alongside a symmetric grid points results in the integral of these spherical harmonics to always be zero.
Another comment that is relevant but probably won't help you
- When constructing any sort of Lebedev quadrature on the sphere, you don't just do a least-squares over all spherical harmonics. You remove the spherical-harmonics that are not invariant under some rotational group (e.g. icosahedron group). See Section 2.2.2. in 3 . This produces a over-determined solution whose results is not unique (although in your case this isn't a problem but just important to keep in mind). Also to keep in mind, there are a O(N^3) algorithm for constructing sphere quadrature that are invariant under icosahedral group "Rotationally invariant quadratures for the sphere".
Thanks @Ali-Tehrani and @izxle !
This is a really interesting observation. The idea of using the polygonal area is ideal, and does make it easier to also envision (eventually) angular refinement, but I note that the equivalence of R1, R2, and R3 in terms of convergence rate heavily depends on the "cancellation" which isn't going to be true for nonuniform triangulation. In all these grids, there is a "defect." Specifically, most vertices have 6 neighboring triangles, but this is only 5 for the original vertices of the icosahedron (and 4 for nested octahedral grids and 3 for nested tetrahedral grids). So as one moves away from the vertices, there is "less defect" and I expect the polygonal areas to be more constant. It is possible, I guess, that this all comes out in the wash: the fact that the apical point for example has only five triangular areas may be compensated by other factors. I am a big perplexed (but I didn't read very hard) that the formulas seem to use the midpoint of the edges (R1) or interior points (R2, R3), which we don't have access to. I would have guessed, then, that the appropriate weights were constant everywhere (unlikely due to the aforementioned defect) or equal to the surface area of the sphere that is closer to this point than any other (which requires a little nontrivial differential geometry, at least to me). It can probably be done (relatively) easily using the (generalized) Girard's theorem. I think the workflow is to construct the angles from the (geodesic) edges using a formula like this. It is nice if we don't have to solve equations for the weights, however. |
…ed radial grid size to 250 for better results.
@Ali-Tehrani do you have any thoughts on this? |
I am still curious about this, and can have an answer next week! I think I'm going to explore it computationally given the code is there. I don't think there is defect in the symmetry of the grid, but need to think/read more into it. |
Okay, I've gotten into a rabbit hole about this, sorry for the delay. I doubled checked, the initial icosahedron and first subdivision have equal weights, and they're precisely the spherical design. The next subdivision has four positive, unique weights, then the subdivision afterwards had negative weights, then subdivision afterwards had positive weights. These are the degrees that they correspond to, starting with the icosahedron, respectively, 2, 5, 11, 24, and 49. The number of points (12, 42, 162, 642, 2562) is usually double of Lebedev and Spherical design grids. I was wrong about the weights being the area, and also that the area of each triangle is equal (so there is a defect). I've implemented it using Girards thoerem, and played around with it. That led me to do a deep delve into literature. Particularly, this book chapter was a nice read To develop a subdivision scheme for spherical quadrature. Any spherical quadrature scheme is evaluated based on:
The nice thing about this subdivision is that the weights are usually positive, which is known to be a problem when enforcing polynomial accuracy (Section 4). The (area of triangle) centroid method I've talked about earlier always has positive weights, but they don't enforce polynomial accuracy. Other Nested Grids: Another nested grid is based on having equal-area points (Section 6.1), also known as HEALPix grids. They are very easy to implement. One could enforce polynomial accuracy, but it is a question whether the weights are positive and the number of points. Ideas: I think it would be nice to implement a general angular grid, where the user gives a random set of points (Section 5, scattered points), performs Delaunay triangulation, calculates the weights using triangle area, or it implements the calculated weights using this procedure, and tells the user if the weights are negative or absolute sum is large. |
I think if you add a point at the center of the triangle you end up with very non-equilateral triangulations. That's probably not ideal. Nesting always compromises accuracy. For our applications it is really important that they are nested. So I think just the weights that Ali mentions for the grids are fine; we could just store them and use them. It's unfortunate that there are negative weights in some cases, but that was true for some Lebedev grids too....probably it is inevitable. I also like the HEALPix grid which is, as @Ali-Tehrani notes, very easy to implement see equation two in the reference Ali gave and beautifully nested when Perhaps we just store the weights for the icosahedral division up to 2562 points and have HEALPix as a secondary option with slower growth? That would give us two options. I'm not averse to doing something with random weights too, though without nesting it's not directly useful for the applications I have in mind. One nice thing about the Theorem 10 that @Ali-Tehrani cites is that it gives a very good way to control what to do when one can satisfy the "interpolatory" property up to Perhaps the right workflow is to write generic code to construct the "best" interpolatory quadrature formula for a given set of points. Perhaps @Ali-Tehrani already has this from the study on the icosahedron? |
Sorry never mind, unfortunately, HEALPix isn't nested, I thought it was from naively looking at the pictures. But they are very good it seems like at adaptive grid refinement. I guess the only other nested grid that comes in-mind are doing Clenshaw-Curtis tensor product grids. These do cluster points at the poles, but I think if you rotate them to align with the bond axis, that might actually be a good thing. Also forgot to mention, the other benefit of positive weights is when the integrands are noisy. This is my guess, as to why the geoscience community cares so much. Also, only 6 points out of 642 that has negative weights, so it isn't too bad. I think solving for the nodes and weights, storing them as npz, and adding a method= The scatter points/random points I was thinking of having applications outside quantum chemistry. Or, more broadly towards geosciences, i.e. any of the methods within the two book chapters. I would suggest for the generic code to get quadrature on scatter points with enforced polynomial accuracy is to follow the same approach as Oscar but:
|
OK, so we have the icosahedral grid, which is awesome. @Ali-Tehrani 's idea for structuring the points makes sense. For the random points, I understand @Ali-Tehrani 's protocol. I would only add that the lower bound should decrease as the number of grid points increases, so maybe something like When one can't do a full fit with degree P.S. @Ali-Tehrani I also fell for the HEALPix based on the description. It looks so nested (even the formulas) but I didn't confirm. But from the paper you have above, it seems like a nesting scheme is possible and the code from that paper may implement it. Perhaps an interesting direction, as it gives a nice way to do adaptive grids in specific directions, which is (generically) hard. |
This PR adds an adaptive nested angular grid using icosphere subdivisions. The method iterates over radial grid points, refining the angular grid until the integral converges within a set threshold.
We welcome any feedback and suggestions to improve this implementation!