Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature restraint #105

Merged
merged 65 commits into from
Sep 18, 2023
Merged

Feature restraint #105

merged 65 commits into from
Sep 18, 2023

Conversation

chryswoods
Copy link
Contributor

From the changelog:

  • Added support for restraints to the OpenMM dynamics layer. Initial tested
    support for positional and distance/bond restraints is included, as well
    as experimental support for Boresch restraints. The restraint are documented
    in the :doc:tutorial <tutorial/part06/03_restraints>. This also documents
    new code to let you specify atoms that should be fixed in space.

  • Added support for alchemical restraints to the OpenMM dynamics layer.
    This lets you scale restraints as part of a λ-coordinate. This is
    documented in the :doc:tutorial <tutorial/part06/04_alchemical_restraints.
    Restraints can be named, meaning that you can scale different restraints
    at different stages and by different values across the λ-coordinate.

This is tested in tests/convert/test_openmm_restraints.py. The extra options added to the OpenMM layer are also documented in the cheatsheet, doc/source/cheatsheet/openmm.rst.

  • I confirm that I have merged the latest version of devel into this branch before issuing this pull request (e.g. by running git pull origin devel): [y]
  • I confirm that I have added a test for any new functionality in this pull request: [y]
  • I confirm that I have added documentation (e.g. a new tutorial page or detailed guide) for any new functionality in this pull request: [y]
  • I confirm that I have added a changelog entry to the changelog (we will add a link to this PR as part of the review): [y]
  • I confirm that I have permission to release this code under the GPL3 license: [y]

Suggested reviewers:

@lohedges, @mb2055

Any additional context of information?

This PR builds on and supersedes feature_soft.

I still need to write the tutorial for the general lambda lever and general perturbation. I will do this as part of the last of the three stages of this grand PR, feature_bond_breaking, when I will add support for ring-breaking perturbations.

…ll let you

easily get energies for different lambda values, plus control lambda in
a simulation.

As part of this, I have also updated the minimisation interface to inherit
from dynamics (so that you can minimise at different lambdas)

I have also ported in the new updateProperty code, adding a convenience
function to MolEditor so that the openmm interface can copy across
coordinates while minimising allocation and deallocation of memory
…trajectory. This

includes passing in lambda windows so that energies for different lambda values
can also be saved.

Also updated the code that extracts coordinates and velocies to use the faster
updatePropertyFrom function.
…on arguments.

Have these automatically convert to units from strings
…uring a dynamics simulation.

This can be nicely output as a pandas dataframe for further processing
…l metadata, plus to have

a null pointer if the Properties is empty. This should save some memory (given that
metadata is almost never used) plus should speed things up a little as there is no
need to allocate shared data for empty Properties objects.
…nks to properties

so that they can be accessed via alternate names. This is mainly useful for
merged molecules, e.g.

```
>>> mol = mols[0].edit().add_link("coordinates", "coordinates0").commit()
>>> mol.view()
```

would let the `coordinates0` property be used as `coordinates` when
viewing the molecule (or any other place that `coordinates`
was needed)
…ctions.

Added default LambdaSchedule if it is not set, plus added convenience
functions that make it easier to create standard types of schedule.

Fixed some bugs. Can now run free energy simulations for solvated
ethane->methanol :-)
…n reality, I won't,

instead relying on people minimising the system properly before running. I will
update the constraints for perturbable molecules to be based on the actual coordinates
of the atoms, rather than forcefield parameters
…mass of the

perturbing atoms so that automatically applied constraints apply equally to
both sides of the perturbation. This is important because internals that
are constrained don't have their energy evaluated.
…jectories. An empty one is

now created if you ask for one.

Also fixed a bug in Dynamics that meant that the time in the EnergyTrajectory was the
current simulation time, not the overall simulation time.
…bed internals. The code

was accidentally pulling internals from the perturbed state multiple times.

This fixes that bug, and adds a more complex merged molecule to the tests
(zanamivir to oseltamivir)

I've also updated the lever so that it can cope with missing forcefields. This
will make debugging easier :-)
…ions to or

from ghost atoms into custom ghost forcefields.

The custom forcefield is currently just a copy of the LJ potential, but it will
eventually become more complex once I've double-checked all the bookkeeping.

I am currently missing a small forcefield to handle the 1-4 nonbonded
interactions involving ghost atoms. Suspiciously though, the energies
are correct... (which more likely signals a bug)
…aLever ;-)

To make the bookkeeping easier, and avoid the expensive search over ALL exceptions
in the CLJFF, I am now handling all of the exceptions for perturbable molecules
manually, using the ExcludedPairs object. This lets me find the 1-4 terms
involving ghost atoms more easily, and also identify and manipulate them
using the lever.

This is currently broken though, as I haven't excluded everything that
needs excluding... Will try again another time ;-)

WIP
…LJFF. This is

to re-use the information that sire already has, and to also make it easier
to put the full set of exceptions (with scale factors) into OpenMMMolecule.

This will also make it easier to perturb these scale factors, which will
be needed once we support bond breaking / making in a perturbation.
… involving

ghost atoms. These now give the correct energy. The code is a little slow to
now create the context (1-3 seconds) - I think because it is going over all intra-atomic
pairs. I will need to explore some optimisations.
… speeds

things up a bit, as we now don't need to build a large exceptions list
and feed it serially to openmm. We only fully manage the exceptions
ourselves for perturbable molecules.
…maps when

updating coordinates / velocities. This is needed so that the results
of one stage (e.g. minimisation) go back into the right property
for the next stage for that perturbable molecule (e.g. the minimised
coordinates go into `coordinates0` rather than `coordinates` for the
perturbable molecules)
and control perturbations, e.g.

```
>>> import sire as sr
>>> mols = sr.load_test_files("merged_ligand.s3")
>>> mols.perturbation().view()
```

will view the perturbation as a movie in a jupyter notebook.

There is an option to shrink ghost atoms. This will pull these atoms
inside their connected atoms as they become ghosts.

The animation looks cool, and really helps visualise what is happening
across lambda. I just need to find a way to control the colors / sizes
of the atoms in nglview, plus also specify the bonding myself rather
than having nglview work it out automatically.
…morph` module.

Broken out the functionality to shrink ghost atoms to a new `shrink_ghost_atoms`
function. Initial testing suggests that 0.6 A is a reasonable default length
(shrinks without leading to NaN errors)

Added soft core LJ potential, using a per-atom shift_delta parameter that
will be scaled with lambda :-)

Added this to both the CLJ force and NB14 force.
…have full LJ and coulomb

softening, which seems to work well.

Added option to `SOMMContext` to return energies in sire units. This is switched
on by default, as I have surprised myself too many times with units errors ;-)
…e found

Updated the changelog so that it matches the upcoming 2023.3.2 release

Merged in all changes from `main`
@chryswoods chryswoods temporarily deployed to sire-build September 11, 2023 15:49 — with GitHub Actions Inactive
@chryswoods chryswoods temporarily deployed to sire-build September 11, 2023 15:49 — with GitHub Actions Inactive
@chryswoods chryswoods temporarily deployed to sire-build September 11, 2023 15:49 — with GitHub Actions Inactive
@chryswoods chryswoods temporarily deployed to sire-build September 11, 2023 15:49 — with GitHub Actions Inactive
@chryswoods chryswoods temporarily deployed to sire-build September 11, 2023 15:49 — with GitHub Actions Inactive
@chryswoods chryswoods mentioned this pull request Sep 11, 2023
… exchange moves

between `sire.mol.Dynamics` objects. This is general replica exchange, allowing
changes in lambda, temperature or pressure between replicas.

Moved all of the minimisation functionality into `DynamicsData` and added a
`minimise()` function to `Dynamics`. This makes it easier to add minimisation
into a dynamics run, without having to create a new context. Also makes
it easier to add minimisation to the beginning of lambda replica runs.
…l let

you change the temperature or pressure of a running dynamics simulation.

This will cause a NotImplementedError though, as I haven't yet added the
function to change the temperature or pressure in the integrator, nor
rescale the velocities if that is desired.
… when shared

properties are off.

Also fixed a streaming bug in Frame
…s to give a better-shaped

PMF for ethane to methanol
Changed this to a length so we are not a factor of 10 out in the OpenMM code!
…d api.

Fixed issue where a System has a space, but it isn't shared, meaning that
it is lost when the System is converted to OpenMM
@chryswoods chryswoods temporarily deployed to sire-build September 18, 2023 12:46 — with GitHub Actions Inactive
@chryswoods chryswoods temporarily deployed to sire-build September 18, 2023 12:46 — with GitHub Actions Inactive
@chryswoods chryswoods temporarily deployed to sire-build September 18, 2023 12:46 — with GitHub Actions Inactive
@chryswoods chryswoods temporarily deployed to sire-build September 18, 2023 12:46 — with GitHub Actions Inactive
@chryswoods chryswoods merged commit 3268808 into devel Sep 18, 2023
@chryswoods chryswoods deleted the feature_restraint branch September 18, 2023 19:04
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.

[BUG] OpenMM converter not matching exclusions between the default and custom forces
1 participant