[ WIP ] Support for charge changes in the HybTop protocol for explicitly solvated systems#1978
Open
hannahbaumann wants to merge 6 commits into
Open
[ WIP ] Support for charge changes in the HybTop protocol for explicitly solvated systems#1978hannahbaumann wants to merge 6 commits into
hannahbaumann wants to merge 6 commits into
Conversation
…for explicitly solvated systems
hannahbaumann
commented
May 18, 2026
| """ | ||
| Infer positive and negative ion residue names from a topology by | ||
| finding the most common monovalent ion of each charge type. | ||
| Falls back to NA/CL if none are found. |
Contributor
Author
There was a problem hiding this comment.
I'm doing this mostly because e.g. maestro doesn't always add ions (in the a2a example there were no negative ions in the system).
Contributor
Author
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
hannahbaumann
commented
May 20, 2026
| system_mapping: dict, | ||
| charge_difference: int, | ||
| solvent_component: SolventComponent, | ||
| positive_ion_resname: str, |
Contributor
Author
There was a problem hiding this comment.
use element or formal charge instead?
Contributor
Author
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1978 +/- ##
==========================================
- Coverage 94.94% 90.54% -4.40%
==========================================
Files 216 216
Lines 20481 20547 +66
==========================================
- Hits 19445 18604 -841
- Misses 1036 1943 +907
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
slochower
pushed a commit
to slochower/openfe
that referenced
this pull request
May 21, 2026
Replace the monolithic `_get_ion_and_water_parameters` with three focused functions that handle ion parameter lookup in order of preference: 1. Most abundant monovalent ion of the correct charge sign already present in the topology. 2. Divalent or wrong-sign ions are skipped by the monovalent filter. 3. If no suitable ion exists (e.g. zero ionic strength or a SolvatedPDBComponent without ions), a minimal single-ion system is built from the forcefield to obtain NA/CL parameters. This approach is adapted from OpenFE PR OpenFreeEnergy#1978. The key API change is that `handle_alchemical_waters` and `_handle_net_charge` now accept a `forcefield` (from the system generator) instead of a `solvent_component`, since what we actually need is the ability to parameterize an ion — not the component metadata. The mutation only modifies NonbondedForce parameters (charge, sigma, epsilon), leaving bonded terms untouched. This is safe for rigid water models (TIP3P, SPC/E) where geometry is enforced by SETTLE/SHAKE constraints rather than harmonic forces. Added documentation warning that flexible water models would produce unphysical forces on the ghost hydrogens. Also adds SolvatedPDBComponent support to `_validate_charge_difference` so membrane systems can use explicit charge correction.
7 tasks
|
No API break detected ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is just a first idea (and the
_get_ion_resnames_from_topologywas written together with Claude). This is mostly just to show the different things we have to consider, but I don't like the dictionary idea of known ions yet. Maybe it would also be ok to always use Cl and Na ions for explicitly solvated systems, no matter if other ion types were used as counterions?Checklist
newsentry, or the changes are not user-facing.pre-commit.ci autofix.Manual Tests: these are slow so don't need to be run every commit, only before merging and when relevant changes are made (generally at reviewer-discretion).
Developers certificate of origin