Skip to content

feat(openmm,jax): add Urey-Bradley term support (#116)#191

Merged
ericchansen merged 2 commits intomasterfrom
feat/issue-116-urey-bradley
Mar 30, 2026
Merged

feat(openmm,jax): add Urey-Bradley term support (#116)#191
ericchansen merged 2 commits intomasterfrom
feat/issue-116-urey-bradley

Conversation

@ericchansen
Copy link
Copy Markdown
Owner

Summary

Add Urey-Bradley (1-3 distance) term support for CHARMM force fields. Closes #116.

Changes

File Change
q2mm/models/forcefield.py Optional ub_force_constant/ub_equilibrium on AngleParam, extended param vector with UB tail section
q2mm/backends/mm/openmm.py UB terms via HarmonicBondForce on 1-3 atom pairs, with parameter update support
q2mm/backends/mm/jax_engine.py _ub_energy() function, UB topology in JaxHandle, wired into both harmonic and MM3 branches
q2mm/backends/mm/_jax_common.py compute_param_offsets() gains n_vdw_types param and "ub" offset key

Design

  • UB params append to the end of the param vector (after vdW), preserving backward compatibility
  • _ub_angles property filters to angles with UB params set
  • E_UB = k_UB * (r_13 - r_13_0)^2 (harmonic bond between outer angle atoms)

Testing

  • 29 new tests covering FF model, param vector round-trip, OpenMM/JAX energy, and cross-engine parity
  • 781 total tests pass with no regressions

Add Urey-Bradley (UB) 1-3 distance interactions for CHARMM force fields.
UB terms are optional per-angle parameters (ub_force_constant, ub_equilibrium)
appended to the tail of the parameter vector for backward compatibility.

Changes:
- AngleParam: add optional ub_force_constant and ub_equilibrium fields
- ForceField: extend param vector, bounds, labels, and indices for UB tail
- OpenMM backend: add HarmonicBondForce for UB terms, update_forcefield support
- JAX backend: add _ub_energy function, compile UB into JIT energy closure
- _jax_common: add n_vdw_types param and 'ub' offset to compute_param_offsets
- Tests: 29 new tests covering FF, OpenMM, JAX, and cross-engine parity

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 29, 2026 19:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Urey–Bradley (1–3 distance) term support for CHARMM-style force fields across the ForceField model plus OpenMM and JAX backends, with tests verifying energy behavior and cross-engine parity.

Changes:

  • Extend AngleParam and ForceField param-vector handling to include optional UB parameters appended after vdW.
  • Add UB term evaluation to OpenMM (via HarmonicBondForce) and to the JAX engine energy function/topology.
  • Add a comprehensive UB-focused test suite and update parameter-cycling expectations.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
q2mm/models/forcefield.py Adds optional UB fields to AngleParam and appends UB params to the param vector + indices/bounds/labels.
q2mm/backends/mm/openmm.py Builds and updates UB terms using HarmonicBondForce on 1–3 atom pairs.
q2mm/backends/mm/jax_engine.py Implements _ub_energy, adds UB topology mapping, and includes UB energy in both harmonic/MM3 branches.
q2mm/backends/mm/_jax_common.py Extends param-offset computation to account for vdW block size and adds "ub" offset.
test/test_urey_bradley.py New tests for UB param-vector integration, OpenMM/JAX energy, and parity.
test/test_parameter_cycling.py Updates expected parameter-type keys to include ub_k/ub_eq.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread q2mm/backends/mm/openmm.py Outdated
Comment thread q2mm/backends/mm/openmm.py
- Check both ub_force_constant and ub_equilibrium are non-None before
  creating or updating Urey-Bradley terms
- Raise ValueError if only one is set (configuration error)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ericchansen ericchansen merged commit a7fc623 into master Mar 30, 2026
11 checks passed
@ericchansen ericchansen deleted the feat/issue-116-urey-bradley branch March 30, 2026 17:37
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.

feat(openmm): Add Urey-Bradley term support (CHARMM)

2 participants