Skip to content

Commit

Permalink
Add missing rotation in orientation component
Browse files Browse the repository at this point in the history
Issue identified by @HanatoK (#713 (comment))
  • Loading branch information
giacomofiorin committed Sep 17, 2024
1 parent e1220bd commit af9fc1e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/colvarcomp_rotations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,21 @@ void colvar::orientation::apply_force(colvarvalue const &force)
if (!atoms->noforce) {
rot_deriv_impl->prepare_derivative(rotation_derivative_dldq::use_dq);
cvm::vector1d<cvm::rvector> dq0_2;
for (size_t ia = 0; ia < atoms->size(); ia++) {
rot_deriv_impl->calc_derivative_wrt_group2(ia, nullptr, &dq0_2);
for (size_t i = 0; i < 4; i++) {
(*atoms)[ia].apply_force(FQ[i] * dq0_2[i]);

if (atoms->is_enabled(f_ag_rotate)) {
auto const rot_inv = atoms->rot.inverse().matrix();
for (size_t ia = 0; ia < atoms->size(); ia++) {
rot_deriv_impl->calc_derivative_wrt_group2(ia, nullptr, &dq0_2);
for (size_t i = 0; i < 4; i++) {
(*atoms)[ia].apply_force(rot_inv * (FQ[i] * dq0_2[i]));
}
}
} else {
for (size_t ia = 0; ia < atoms->size(); ia++) {
rot_deriv_impl->calc_derivative_wrt_group2(ia, nullptr, &dq0_2);
for (size_t i = 0; i < 4; i++) {
(*atoms)[ia].apply_force(FQ[i] * dq0_2[i]);
}
}
}
}
Expand Down

0 comments on commit af9fc1e

Please sign in to comment.