Skip to content

Replace the Ahrens-Beylkin grid of degree 39 by the rule with 572 points - #357

Merged
marco-2023 merged 1 commit into
theochem:masterfrom
ARYAMANN7279:fix/ahrens-beylkin-39-572
Nov 23, 2026
Merged

marco-2023 merged 1 commit into
theochem:masterfrom
ARYAMANN7279:fix/ahrens-beylkin-39-572

Conversation

@ARYAMANN7279

Copy link
Copy Markdown

The tabulated Ahrens-Beylkin grid of degree 39 (552 points) is not a valid quadrature rule. Its weights sum to 0.9632 * 4 pi, so it does not even integrate a constant, and it was used silently for any request of degree 38 or 39 or of size 552. I found it by checking that every tabulated angular grid integrates (u . x)^k exactly up to its degree: all 450 grids of the four families pass except this one.

Cause. The data came from IntegratorXX (#317), where the same grid was reported as wavefunction91/IntegratorXX#108 by @susilehtola, who also found the reason in wavefunction91/IntegratorXX#113: the rule in the paper (Ahrens and Beylkin, Proc. R. Soc. A 465, 3103 (2009)) has 572 nodes, and the 20 nodes of the orbit of the face centres of the icosahedron are missing in the file with 552 rows. The missing weight is exactly the deficit: 20 * 0.0230948723 = 4 pi - sum(w).

Change.

  • Add the 20 face centres of the icosahedron (made from the 12 vertices already in the grid) with the weight (4 pi - sum(w)) / 20, and store the result as ahrens_beylkin_39_572.npz instead of ahrens_beylkin_39_552.npz. The size in AHRENS_BEYLKIN_NPOINTS changes from 552 to 572.
  • The new grid has unit points, positive weights summing to 4 pi, integrates all polynomials up to degree 39 with an error of 1.4e-14, and fails at degree 40 (1.2e-12), as a rule of degree 39 should. It agrees with the table of IntegratorXX#113 to 3e-14 in the points and 5e-15 in the weights, which I did not use to make it.
  • A request for degree 38 or 39, or a size from 493 to 572, now returns the 572 points grid. A request for a size of exactly 552 used to return the broken grid and now returns this one too, with the existing "size is used" warning.
  • New test test_every_packaged_grid_is_a_quadrature_of_its_degree: for each of the 450 tabulated grids it checks the unit norm of the points, the sum of the weights, and the integral of (u . x)^k for random directions and k up to min(degree, 30). It fails on master for this grid only and it takes about 20 s.

I did not touch the other Ahrens-Beylkin grids (#318): all of them pass the test. The existing test file passes (489 tests).

The tabulated grid of 552 points for degree 39 is not a quadrature rule: its weights sum to 0.9632 * 4 pi, and no choice of weights for its points integrates the polynomials of degree 39. The table of the paper has 572 nodes, because the 20 nodes of the orbit of the face centres of the icosahedron were lost in the data file with 552 rows.

Add the 20 face centres with the weight that gives the sum of 4 pi, 0.0230948723 (all weights are positive). The grid integrates all polynomials up to degree 39 with an error of 1e-14 and fails at degree 40, as a rule of degree 39 should. It agrees with the table of IntegratorXX (issue 108, pull request 113) to 3e-14.

Requests for degree 38 and 39, or for sizes up to 572, now give this grid.

Add a test that checks the points and the weights of every tabulated angular grid. It fails for the old grid and is the only failure of the 450 grids.
@ARYAMANN7279

Copy link
Copy Markdown
Author

The workflows of this PR are waiting for approval to run, because it is my first PR to this repository. Locally the whole test suite passes with the change (1199 passed, 1 skipped), including the new test, which fails on master for the grid with 552 points only.

@marco-2023, you added the Ahrens-Beylkin grids in #317, so could you have a look, and approve the workflows if that is ok? If you plan to regenerate the whole family for #318, this PR can also just serve as the check for the existing grids.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The change replaces a large numerical quadrature table, and confirming degree-39 accuracy and packaged-data loading requires unavailable NumPy-based tests and binary-data validation.

No open issues 🎉

What changed in this PR

This pull request replaces the invalid 552-point Ahrens-Beylkin degree-39 quadrature rule with the corrected 572-point rule and adds validation for packaged angular grids.

Changes:

  • Updates the Ahrens-Beylkin size-to-degree mapping from 552 to 572 points.
  • Preserves selection of the corrected rule for degree 38–39 and sizes 493–572.
  • Adds parametrized tests for point normalization, weight sums, and polynomial integration.
File Description
src/​grid/​tests/​test_angular.py Adds parametrized validation of point norms, weight sums, and polynomial integration across packaged angular grids.
src/​grid/​angular.py Updates the Ahrens-Beylkin degree-39 mapping to use the corrected 572-point rule and adds grid validation coverage.

Review effort: Lite

@PaulWAyers PaulWAyers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@marco-2023
marco-2023 merged commit dbc4fe1 into theochem:master Nov 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants