Skip to content

[PR-4] feat: implement HRR (Eq. 67) and complete OS+HGP two-electron integral pipeline#238

Draft
San1357 wants to merge 9 commits intotheochem:masterfrom
San1357:feat/HRR-complete-pipeline
Draft

[PR-4] feat: implement HRR (Eq. 67) and complete OS+HGP two-electron integral pipeline#238
San1357 wants to merge 9 commits intotheochem:masterfrom
San1357:feat/HRR-complete-pipeline

Conversation

@San1357
Copy link

@San1357 San1357 commented Mar 6, 2026

Summary

What Changed

File Lines What
gbasis/integrals/_two_elec_int_improved.py +200 HRR + complete pipeline implementation
tests/test_two_elec_int_improved.py +200 14 tests (VRR + ETR + HRR + pipeline)

Mathematical Reference

The Horizontal Recursion Relation (Eq. 67) is:

$$[a, b+1_i | c, d] = [a+1_i, b | c, d] + (A-B)_i [a, b | c, d]$$

where angular momentum is transferred from center A to center B (and similarly C to D).

How To Test

# Run tests
pytest tests/test_two_elec_int_improved.py -v

# Check coverage
python -m pytest tests/test_two_elec_int_improved.py --cov=gbasis.integrals._two_elec_int_improved --cov-report=term-missing

# Check formatting & linting
black --check gbasis/integrals/_two_elec_int_improved.py tests/test_two_elec_int_improved.py
ruff check gbasis/integrals/_two_elec_int_improved.py tests/test_two_elec_int_improved.py

# Verify existing tests not broken
pytest tests/ --timeout=120

Proof That It Works

Tests (16 passed)

image

Check coverage

image

Black: Clean & Ruff: Clean

image

Existing tests: Not broken

307 passed, 279 skipped, 1 xfailed, 4 warnings in 67.52s (0:01:07)

First Checklist

  • Tests added for each new function
  • All 9 tests pass
  • Black formatted
  • Ruff linting clean
  • Existing tests not broken
  • Docstrings in numpydoc format
  • No new dependencies added (uses existing numpy)
  • Pure Python only (no C/Fortran)

Scope of this PR

  • This PR completes the full OS+HGP pipeline for two-electron integrals (VRR → ETR → Contract → HRR)
  • Adds _vertical_recursion_relation (VRR)
  • Adds _electron_transfer_recursion (ETR)
  • Adds _optimized_contraction with per-center vectorized norm computation
  • Adds _horizontal_recursion_relation (HRR)
  • Adds compute_two_electron_integrals_os_hgp (full pipeline)
  • Does NOT modify any existing code
  • Does NOT change any existing tests

Second Checklist

  • Write a good description of what the PR does.
  • Add tests for each unit of code added (e.g. function, class)
  • Update documentation
  • Squash commits that can be grouped together
  • Rebase onto master

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

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.

1 participant