|
5 | 5 | * A plugin for distributing platform-agnostic OpenMM Forces * |
6 | 6 | * * |
7 | 7 | * Copyright (c) 2024 Charlles Abreu * |
8 | | -* https://github.com/RedesignScience/openmm-cpp-forces * |
| 8 | + * https://github.com/RedesignScience/openmm-cpp-forces * |
9 | 9 | * -------------------------------------------------------------------------- */ |
10 | 10 |
|
11 | 11 | #include "internal/CompositeRMSDForceImpl.h" |
@@ -70,9 +70,11 @@ void CompositeRMSDForceImpl::updateParameters(int systemSize) { |
70 | 70 | referencePos.push_back(positions[i] - center); |
71 | 71 | } |
72 | 72 |
|
73 | | - sumRefPosSquared = 0.0; |
| 73 | + sumRefPosSq = 0.0; |
74 | 74 | for (auto& p : referencePos) |
75 | | - sumRefPosSquared += p.dot(p); |
| 75 | + sumRefPosSq += p.dot(p); |
| 76 | + |
| 77 | + resetForces = true; |
76 | 78 | } |
77 | 79 |
|
78 | 80 | void CompositeRMSDForceImpl::initialize(ContextImpl& context) { |
@@ -138,7 +140,7 @@ double CompositeRMSDForceImpl::computeForce(ContextImpl& context, const vector<V |
138 | 140 |
|
139 | 141 | // Compute the RMSD. |
140 | 142 |
|
141 | | - double sum = sumRefPosSquared; |
| 143 | + double sum = sumRefPosSq; |
142 | 144 | for (auto& p : centeredPos) |
143 | 145 | sum += p.dot(p); |
144 | 146 |
|
@@ -166,6 +168,11 @@ double CompositeRMSDForceImpl::computeForce(ContextImpl& context, const vector<V |
166 | 168 |
|
167 | 169 | // Rotate the reference positions and compute the forces. |
168 | 170 |
|
| 171 | + if (resetForces) { |
| 172 | + fill(forces.begin(), forces.end(), Vec3(0, 0, 0)); |
| 173 | + resetForces = false; |
| 174 | + } |
| 175 | + |
169 | 176 | index = 0; |
170 | 177 | for (auto& group : groups) { |
171 | 178 | double scale = 1.0 / (rmsd*group.size()); |
|
0 commit comments