Skip to content

fix: [Phase 3] Implement Delocalization Index (DI)#7

Open
newtontech wants to merge 1 commit intomainfrom
fix/issue-4
Open

fix: [Phase 3] Implement Delocalization Index (DI)#7
newtontech wants to merge 1 commit intomainfrom
fix/issue-4

Conversation

@newtontech
Copy link
Owner

Summary

This PR implements the Delocalization Index (DI) for analyzing electron pair sharing and aromaticity in molecular systems. The implementation includes 2-center and 3-center DI calculations, aromaticity indices (AI, PDI, FLU), and bond classification based on DI values.

Changes

  • pymultiwfn/bonding/delocalization.py: New module implementing:

    • delocalization_index(): 2-center DI calculation
    • three_center_delocalization_index(): 3-center DI for multi-center bonds
    • calculate_di_matrix(): Full DI matrix generation
    • classify_bond_from_di(): Bond type classification
    • calculate_aromaticity_index(): Ring aromaticity measure
    • calculate_pdi(): Para-Delocalization Index for 6-membered rings
    • calculate_flu(): Aromatic Fluctuation Index
    • DelocalizationIndex class: Main analysis interface
  • pymultiwfn/bonding/init.py: Updated to export new DI classes and functions

  • tests/bonding/test_delocalization_index.py: Comprehensive test suite with 35 passing tests covering:

    • Basic DI calculations
    • 3-center DI symmetry
    • DI matrix properties
    • Bond classification
    • Aromaticity indices
    • Class initialization and methods

Testing

All 35 tests pass:

  • TestDelocalizationIndexFunction: 6 tests
  • TestThreeCenterDI: 2 tests
  • TestDIMatrix: 3 tests
  • TestBondClassification: 6 tests
  • TestAromaticityIndices: 6 tests
  • TestDelocalizationIndexClass: 9 tests
  • TestDelocalizationResult: 3 tests

API Example

from pymultiwfn.bonding import DelocalizationIndex

di = DelocalizationIndex(wfn)
di_val = di.get_delocalization_index(atom_i=0, atom_j=1)
print(f"DI: {di_val:.3f} e")

# For aromaticity analysis
ring_atoms = [0, 1, 2, 3, 4, 5]  # benzene ring
ai = di.get_aromaticity_index(ring_atoms)
pdi = di.get_pdi(ring_atoms)
flu = di.get_flu(ring_atoms)
print(f"Aromaticity Index: {ai:.3f}")
print(f"PDI: {pdi:.3f} e")
print(f"FLU: {flu:.3f}")

Fixes #4

- Add delocalization.py module with 2-center and 3-center DI calculations
- Implement aromaticity indices (AI, PDI, FLU) from DI matrices
- Add bond classification based on DI values
- Create comprehensive test suite with 35 passing tests
- Update bonding __init__.py to export new DI classes and functions

Fixes #4
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

🤖 Hi @newtontech, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@github-actions
Copy link

github-actions bot commented Mar 2, 2026

🤖 I'm sorry @newtontech, but I was unable to process your request. Please see the logs for more details.

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.

[Phase 3] Implement Delocalization Index (DI)

1 participant