Skip to content

Commit

Permalink
FF: fix compute_force! for constrained systems
Browse files Browse the repository at this point in the history
Fixes: #138
Signed-off-by: Thomas Kemmer <[email protected]>
  • Loading branch information
tkemmer committed Dec 2, 2024
1 parent 4fc1b89 commit 12f33ad
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/forcefields/common/nonbonded_component.jl
Original file line number Diff line number Diff line change
Expand Up @@ -643,18 +643,18 @@ function compute_forces!(esi::ElectrostaticInteraction{T}) where {T<:Real}
end

function compute_forces!(nbc::NonBondedComponent{T}) where {T<:Real}
constrained_ids = getproperty.(getindex.(Ref(atoms(nbc.ff.system)), nbc.ff.constrained_atoms), :idx)

filter_pairs = (
isempty(constrained_ids)
? identity
: s -> filter(p -> (p.a1.idx constrained_ids) || (p.a2.idx constrained_ids), s)
)

map(compute_forces!, filter_pairs(nbc.lj_interactions))
map(compute_forces!, filter_pairs(nbc.hydrogen_bonds))
map(compute_forces!, filter_pairs(nbc.electrostatic_interactions))
if isempty(nbc.ff.constrained_atoms)
map(compute_forces!, nbc.lj_interactions)
map(compute_forces!, nbc.hydrogen_bonds)
map(compute_forces!, nbc.electrostatic_interactions)
else
constrained_ids = getproperty.(getindex.(Ref(atoms(nbc.ff.system)), nbc.ff.constrained_atoms), :idx)
filter_pairs = s -> (p for p in s if (p.a1.idx constrained_ids) || (p.a2.idx constrained_ids))

map(compute_forces!, filter_pairs(nbc.lj_interactions))
map(compute_forces!, filter_pairs(nbc.hydrogen_bonds))
map(compute_forces!, filter_pairs(nbc.electrostatic_interactions))
end
nothing
end

Expand Down

0 comments on commit 12f33ad

Please sign in to comment.