Skip to content

Add lattice rules for (hyper)cubic grid integration#293

Open
Ao-chuba wants to merge 3 commits into
theochem:masterfrom
Ao-chuba:feature/lattice-rules
Open

Add lattice rules for (hyper)cubic grid integration#293
Ao-chuba wants to merge 3 commits into
theochem:masterfrom
Ao-chuba:feature/lattice-rules

Conversation

@Ao-chuba
Copy link
Copy Markdown
Member

This PR implements lattice rules for efficient numerical integration over (hyper)cubic grids, addressing issue #241 .

Following the references provided in the issue (Sloan's paper and the UNSW lattice rules database), I've implemented rank-1 lattice rules as a new integration method.
Implementation :

  • New Lattice class using tabulated generating vectors from UNSW database
  • Supports embedded lattice rules (powers of 2, up to 2²⁰ points)
  • Equal-weight integration with formula: $\mathbf{x}_k = { \frac{k \cdot \mathbf{z}}{n} }$
  • Works with arbitrary parallelepipeds via affine transformation
  • Supports up to 50 dimensions (extensible to 3600+ if needed)
  • Includes basic interpolation via scipy.interpolate.LinearNDInterpolator

Testing:

  • Input validation, point generation, integration accuracy
  • Embedded property verification, interpolation, file I/O
Screenshot 2026-02-11 023415 closes #241

- Implement Lattice class with rank-1 lattice rules
- Support embedded lattice rules (powers of 2)
- Include tabulated generating vectors from UNSW (Order-2 weights)
- Add comprehensive test suite (25 tests, all passing)
- Support arbitrary parallelepipeds via affine transformation
- Addresses issue theochem#241
@PaulWAyers
Copy link
Copy Markdown
Member

@marco-2023 we should maybe talk about this next week?

@Ao-chuba
Copy link
Copy Markdown
Member Author

The Windows CI failure (Python 3.12 on OS windows-latest) is not caused by this PR.
its failing in test_angular.py::test_orthogonality_of_spherical_harmonic_at_high_degrees the cause being The test sets degree = 88 * 2, calling generate_real_spherical_harmonics(l_max=88) with 15,756 grid points. At utils.py:655:

spherical_harm = np.zeros(((l_max + 1) ** 2, numb_pts), dtype=np.longdouble)`

as for lattice test all pass.
image

@PaulWAyers @marco-2023

… add tests, change tolerance,override __getitem__"

This reverts commit 8a27314.
@Ao-chuba
Copy link
Copy Markdown
Member Author

Ao-chuba commented Apr 24, 2026

After looking into it more the CI failure was actually caused by the additional tests I added in that commit specifically test_error_convergence which created large grids consuming extra memory on the Windows runner. The angular test was right at the memory boundary, and the additional tests tipped it over. After reverting, the CI is green again.

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.

Lattice rules for (hyper)cubic grids

2 participants