Skip to content

Commit

Permalink
Exclude to/from ghost interactions from ghost_14ff. [closes #239]
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Sep 27, 2024
1 parent 1028bca commit 1894153
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 12 additions & 1 deletion wrapper/Convert/SireOpenMM/lambdalever.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1438,12 +1438,23 @@ double LambdaLever::setLambda(OpenMM::Context &context,
// don't set LJ terms for ghost atoms
if (atom0_is_ghost or atom1_is_ghost)
{
// are the atoms perturbing from ghosts?
const auto from_ghost0 = perturbable_mol.getFromGhostIdxs().contains(atom0);
const auto from_ghost1 = perturbable_mol.getFromGhostIdxs().contains(atom1);
// are the atoms perturbing to ghosts?
const auto to_ghost0 = perturbable_mol.getToGhostIdxs().contains(atom0);
const auto to_ghost1 = perturbable_mol.getToGhostIdxs().contains(atom1);

// is this interaction between an to/from ghost atom?
const auto to_from_ghost = (from_ghost0 and to_ghost1) or (from_ghost1 and to_ghost0);

cljff->setExceptionParameters(
boost::get<0>(idxs[j]),
boost::get<0>(p), boost::get<1>(p),
boost::get<2>(p), 1e-9, 1e-9);

if (ghost_14ff != 0)
// exclude 14s for to/from ghost interactions
if (not to_from_ghost and ghost_14ff != 0)
{
// this is a 1-4 parameter - need to update
// the ghost 1-4 forcefield
Expand Down
6 changes: 5 additions & 1 deletion wrapper/Convert/SireOpenMM/sire_to_openmm_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,11 @@ OpenMMMetaData SireOpenMM::sire_to_openmm_system(OpenMM::System &system,
boost::get<2>(p), 1e-9,
1e-9, true);

if (coul_14_scl != 0 or lj_14_scl != 0)
// Whether this is a to/from ghost interaction.
auto to_from_ghost = (from_ghost_idxs.contains(atom0) and to_ghost_idxs.contains(atom1)) or
(from_ghost_idxs.contains(atom1) and to_ghost_idxs.contains(atom0));

if (not to_from_ghost and (coul_14_scl != 0 or lj_14_scl != 0))
{
// this is a 1-4 interaction that should be added
// to the ghost-14 forcefield
Expand Down

0 comments on commit 1894153

Please sign in to comment.