Skip to content

Partial hessian#1338

Open
Phorbol wants to merge 7 commits intoACEsuit:developfrom
Phorbol:partial-hessian
Open

Partial hessian#1338
Phorbol wants to merge 7 commits intoACEsuit:developfrom
Phorbol:partial-hessian

Conversation

@Phorbol
Copy link
Copy Markdown

@Phorbol Phorbol commented Jan 24, 2026

This PR adds inference-time partial Hessian support (ASE FixAtoms-style constraints), plus a convenience API to produce the free-atom 2D Hessian submatrix compatible with ASE vibrations workflows, while preserving backward compatibility with MACE’s existing Hessian output layout.

  • Core: partial Hessian computation

    • Extend Hessian routines in [utils.py] to accept an optional indices/hessian_indices argument so only selected atoms’ force components are differentiated (computes only required Hessian rows).
    • Thread hessian_indices through get_outputs and the energy models in [models.py](MACE, ScaleShiftMACE, MACELES).
  • ASE calculator: constraints → free indices

    • Update MACECalculator.get_hessian in [mace.py] to derive free_indices via ase.vibrations.data.VibrationsData.indices_from_constraints(atoms) when available, with a FixAtoms fallback.
    • Keep the original return shape (3N, N, 3) for compatibility; rows for fixed atoms are zero-filled, free-atom rows contain the computed partial Hessian rows.
  • New API: free-atom 2D Hessian for ASE vib

    • Add MACECalculator.get_hessian_2d_free(atoms) -> (H2d, free_indices) in [mace.py], returning a (3*Nfree, 3*Nfree) Hessian submatrix (from the (3N, N, 3) tensor) plus free_indices.
    • Include a ready-to-run example in the method docstring using VibrationsData.from_2d(...).
  • Tests

    • Add/update [test_partial_hessian.py] to verify:
      • fixed-atom Hessian rows are zero,
      • free-atom rows match the full Hessian rows,
      • get_hessian_2d_free matches the corresponding free-atom submatrix extracted from the full Hessian.

@Phorbol Phorbol changed the base branch from main to develop January 24, 2026 03:07
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.

2 participants