Skip to content

feat: implement fuzzy bond order analysis#5

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

feat: implement fuzzy bond order analysis#5
newtontech wants to merge 1 commit intomainfrom
fix/issue-2

Conversation

@newtontech
Copy link
Owner

Summary

This PR implements fuzzy bond order analysis based on electron density, providing a robust measure of bond strength using fuzzy atom partitioning. The implementation includes the FuzzyAtom dataclass, fuzzy bond order calculation functions, and integrates the Bonding class into the main module API.

Changes

  • pymultiwfn/init.py: Export Bonding class for API compatibility (from pymultiwfn import Bonding)
  • pymultiwfn/bonding/fuzzy.py: Complete fuzzy bond order implementation
    • FuzzyAtom dataclass with fuzzy partition factor and van der Waals radii
    • fuzzy_bond_order() function using density and overlap matrices
    • calculate_fuzzy_bond_order_matrix() for computing bond orders between all atom pairs
  • pymultiwfn/bonding/bonding.py: Added get_fuzzy_bond_order() and get_fuzzy_bond_order_matrix() methods
  • tests/bonding/test_fuzzy_bond_order.py: Comprehensive test suite with 16 tests

Testing

All 16 tests pass, covering:

  • Fuzzy atom definition and boundaries
  • Overlap population calculations
  • Bond order calculations for single (H₂), double (C₂H₄), triple (N₂), and aromatic (benzene) bonds
  • Bond order matrix generation (shape, symmetry, diagonal)
  • Input validation (negative indices, out-of-range, same atom)
16 passed in 0.06s

API Usage

from pymultiwfn import Bonding
bond = Bonding("molecule.fch")
fbo = bond.get_fuzzy_bond_order(atom_i=0, atom_j=1)
matrix = bond.get_fuzzy_bond_order_matrix()

Fixes #2

- Add Bonding class export to pymultiwfn/__init__.py for API compatibility
- Update fuzzy.py with complete fuzzy bond order implementation
  - FuzzyAtom dataclass with fuzzy partition factor
  - fuzzy_bond_order() function using density and overlap matrices
  - calculate_fuzzy_bond_order_matrix() for all atom pairs
- Update bonding.py with get_fuzzy_bond_order() and get_fuzzy_bond_order_matrix()
- Add comprehensive test suite with 16 tests covering:
  - Fuzzy atom definition
  - Overlap population calculations
  - Bond order calculations for single/double/triple/aromatic bonds
  - Bond order matrix generation
  - Input validation

Fixes #2
@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 Fuzzy Bond Order Analysis

1 participant