maccallumlab/meld-openmm-plugin

Avoid duplicate calculations

jlmaccal opened this issue · 0 comments

Currently if a particular restraint (bond, dihedral, etc) is involved in multiple groups, MELD will calculate the energy and force multiple times, which is wasteful. This is particularly wasteful for secondary structures / fragments, where the same distances and angles are involved in many different groups.

What needs to happen:

  • When adding a restraint, check for duplicates.
  • If a duplicate is found, return the index of the previous restraint, rather than a new one
  • When activating restraints, rather than setting the weight to 1.0, increment the value by 1.0 instead.
    • This will ensure that the restraint is applied once for each group that it is activated in
  • NOTE: watch out for issues with race conditions due to multiple threads trying to increment at the same time. Possibly switch the weights to be long and use atomicAdd?