Collective Variables Module - Developer Documentation
|
A helper class for applying forces on an atom group in a way that is aware of the fitting group. NOTE: you are encouraged to use get_group_force_object() to get an instance of group_force_object instead of constructing directly. More...
#include <colvaratoms.h>
Public Member Functions | |
group_force_object (cvm::atom_group *ag) | |
Constructor of group_force_object. More... | |
~group_force_object () | |
Destructor of group_force_object. | |
void | add_atom_force (size_t i, const cvm::rvector &force) |
Apply force to atom i. More... | |
Private Member Functions | |
void | apply_force_with_fitting_group () |
Private Attributes | |
cvm::atom_group * | m_ag |
cvm::atom_group * | m_group_for_fit |
bool | m_has_fitting_force |
A helper class for applying forces on an atom group in a way that is aware of the fitting group. NOTE: you are encouraged to use get_group_force_object() to get an instance of group_force_object instead of constructing directly.
cvm::atom_group::group_force_object::group_force_object | ( | cvm::atom_group * | ag | ) |
Constructor of group_force_object.
ag | The pointer to the atom group that forces will be applied on. |
void cvm::atom_group::group_force_object::add_atom_force | ( | size_t | i, |
const cvm::rvector & | force | ||
) |
Apply force to atom i.
i | The i-th of atom in the atom group. |
force | The force being added to atom i. |
The function can be used as follows,
There are actually two scenarios under the hood: (i) If the atom group does not have a fitting group, then the force is added to atom i directly; (ii) If the atom group has a fitting group, the force on atom i will just be temporary stashed into ag->group_forces. At the end of the loop of apply_force(), the destructor ~group_force_object() will be called, which then call apply_force_with_fitting_group(). The forces on the main group will be rotated back by multiplying ag->group_forces with the inverse rotation. The forces on the fitting group (if enableFitGradients is on) will be calculated by calling calc_fit_forces.