Skip to content

Commit

Permalink
fix: change the setting of force in group_force_object to accumulation
Browse files Browse the repository at this point in the history
This should better match what the existing apply_force does.
  • Loading branch information
HanatoK committed Sep 17, 2024
1 parent ba5f391 commit 2a29cf0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/colvaratoms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ void cvm::atom_group::apply_force(cvm::rvector const &force)

auto ag_force = get_group_force_object();
for (size_t i = 0; i < size(); ++i) {
ag_force.set_atom_force(i, atoms[i].mass / total_mass * force);
ag_force.add_atom_force(i, atoms[i].mass / total_mass * force);
}
}

Expand Down Expand Up @@ -1515,9 +1515,9 @@ cvm::atom_group::group_force_object::~group_force_object() {
}
}

void cvm::atom_group::group_force_object::set_atom_force(size_t i, const cvm::rvector& force) {
void cvm::atom_group::group_force_object::add_atom_force(size_t i, const cvm::rvector& force) {
if (m_has_fitting_force) {
m_ag->group_forces[i] = force;
m_ag->group_forces[i] += force;
} else {
// Apply the force directly if we don't use fitting
(*m_ag)[i].apply_force(force);
Expand Down
2 changes: 1 addition & 1 deletion src/colvaratoms.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class colvarmodule::atom_group
public:
group_force_object(cvm::atom_group* ag);
~group_force_object();
void set_atom_force(size_t i, const cvm::rvector& force);
void add_atom_force(size_t i, const cvm::rvector& force);
private:
cvm::atom_group* m_ag;
cvm::atom_group* m_group_for_fit;
Expand Down
2 changes: 1 addition & 1 deletion src/colvarcomp_distances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ void colvar::cartesian::apply_force(colvarvalue const &force)
for (j = 0; j < dim; j++) {
f[axes[j]] = force.vector1d_value[dim*ia + j];
}
ag_force.set_atom_force(ia, f);
ag_force.add_atom_force(ia, f);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/colvarcomp_rotations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void colvar::orientation::apply_force(colvarvalue const &force)
FQ[1] * dq0_2[1] +
FQ[2] * dq0_2[2] +
FQ[3] * dq0_2[3];
ag_force.set_atom_force(ia, f_ia);
ag_force.add_atom_force(ia, f_ia);
}
}
}
Expand Down

0 comments on commit 2a29cf0

Please sign in to comment.