Repository navigation
Add alchemical free energies with ML intramolecular potentials - #559
Merged
Merged
Conversation
…ioning hydrogen masses.
…ules whose charges change.
This was referenced Dec 3, 2026
Merged
This branch was previously deployed
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 PR adds
interpolate="end_states"tosire.qm.create_engineandsire.qm.emle, so that the intramolecular energy of a perturbable molecule comes from an ML potential (e.g. ANI-2x, MACE, EMLE) at every λ, rather than the force field. This works for relative free energies with a merged molecule and for absolute free energies with a decoupled one. The intermolecular interactions stay MM (PME plus softcore), so the existing lambda schedules and softcore handle the alchemical transformation unchanged. Currently the QM region must be a whole perturbable molecule, so QM regions with link atoms, e.g. covalently bound ligands or mutated protein residues, aren't supported.Usage
How it works
(1 − ml)·(E_vac,0 + embed·E_emb,0) + ml·(E_vac,1 + embed·E_emb,1), wheremlandembedare new levers on theqmffforce, so any schedule can shape them per stage. The energies of each state's isolated atoms are subtracted, so that the energy added to OpenMM's buffer is small enough to be accurate in single precision. These cancel between the legs of a cycle.sr.qm.add_embedding_stagessetsembedto zero in the existing stages and adds anembedding_offstage at the start and anembedding_onstage at the end, which switch between mechanical and electrostatic embedding.embedis zero by default, so an engine with electrostatic embedding needs these stages. Each end state's embedding uses that state's MM charges, which is exact because the embedding is only on in the embedding stages, where the charges are held at their end-state values. Any schedule that hasembed > 0in a stage where MM charges change would see the charges of the two end states mixed byml, rather than the MM charges at that λ.(2, N), MM charges(2, M), QM positions(2, N, 3), MM positions(2, M, 3), the cell and, if it accepts them, MM groups(2, M). It returns the in vacuo energies(2,), or the in vacuo energies followed by embedding rows, which are summed. This isn't specific to EMLE: any model that returns its embedding energy separately can be used.Other changes
sire.qm.create_engineandsire.qm.emlenow raise an error if the QM atoms are in a perturbable molecule, which they previously corrupted (e.g.bond0becamebond00).PyQMForceandTorchQMForcestreams store the end-state data, and older streams still load.Validation
Unit tests compare energies and forces against independent torch calculations for synthetic models, ANI-2x and ANI2xEMLE at several λ, and check constraints, energy reuse and short dynamics.
With SOMD2 (support for this will follow in a separate PR), the ethane → methanol relative hydration free energy and the absolute hydration free energies of both molecules were run with MM, ANI-2x with mechanical embedding and ANI-2x with EMLE embedding. Mechanical embedding agrees with MM in every leg. The EMLE result is about 3.5 kcal/mol more negative, which matches the embedding stages and the known over-solvation of EMLE with fixed-charge LJ and TIP3P. The EMLE thermodynamic cycle closes (−0.19 ± 0.34 kcal/mol).