Gromacs
2024.4
|
#include <cstdio>
#include <memory>
API for structured and optimized calculation of positions.
This header declares an API for calculating positions in an automated way, for internal use by the selection engine. This is useful in particular with dynamic selections, because the same COM/COG positions may be needed in several contexts. The API makes it possible to optimize the evaluation such that any heavy calculation is only done once, and the results just copied if needed more than once. The functions also provide a convenient interface for keeping the whole gmx_ana_pos_t
structure up-to-date.
The API is documented in more detail in gmx::PositionCalculationCollection.
Classes | |
class | gmx::PositionCalculationCollection |
Collection of gmx_ana_poscalc_t structures for the same topology. More... | |
Macros | |
Flags for position calculation. | |
#define | POS_MASS 1 |
Use mass weighting. More... | |
#define | POS_COMPLMAX 2 |
Calculate positions for the same atoms in residues/molecules. More... | |
#define | POS_COMPLWHOLE 4 |
Calculate positions for whole residues/molecules. More... | |
#define | POS_DYNAMIC 16 |
Enable handling of changing calculation groups. More... | |
#define | POS_MASKONLY 32 |
Update gmx_ana_pos_t::m dynamically for an otherwise static calculation. More... | |
#define | POS_VELOCITIES 64 |
Calculate velocities of the positions. | |
#define | POS_FORCES 128 |
Calculate forces on the positions. | |
Enumerations | |
enum | e_poscalc_t { POS_ATOM, POS_RES, POS_MOL, POS_ALL, POS_ALL_PBC } |
Specifies the type of positions to be calculated. More... | |
Functions | |
void | gmx_ana_poscalc_set_flags (gmx_ana_poscalc_t *pc, int flags) |
Sets the flags for position calculation. More... | |
void | gmx_ana_poscalc_set_maxindex (gmx_ana_poscalc_t *pc, gmx_ana_index_t *g) |
Sets the maximum possible input index group for position calculation. More... | |
void | gmx_ana_poscalc_init_pos (gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p) |
Initializes positions for position calculation output. More... | |
void | gmx_ana_poscalc_free (gmx_ana_poscalc_t *pc) |
Frees the memory allocated for position calculation. More... | |
gmx::PositionCalculationCollection::RequiredTopologyInfo | gmx_ana_poscalc_required_topology_info (gmx_ana_poscalc_t *pc) |
Returns true if the position calculation requires topology information. More... | |
void | gmx_ana_poscalc_update (gmx_ana_poscalc_t *pc, gmx_ana_pos_t *p, gmx_ana_index_t *g, t_trxframe *fr, const t_pbc *pbc) |
Updates a single COM/COG structure for a frame. More... | |
#define POS_COMPLMAX 2 |
Calculate positions for the same atoms in residues/molecules.
If this flag is set, the positions are always calculated using the same atoms for each residue/molecule, even if the evaluation group contains only some of the atoms for some frames. The group passed to gmx_ana_poscalc_set_maxindex() is used to determine the atoms to use for the calculation.
Has no effect unless POS_DYNAMIC is set or if the calculation type is not POS_RES of POS_MOL.
#define POS_COMPLWHOLE 4 |
#define POS_DYNAMIC 16 |
Enable handling of changing calculation groups.
Can be used for static calculations as well, but implies a small performance penalty.
#define POS_MASKONLY 32 |
Update gmx_ana_pos_t::m
dynamically for an otherwise static calculation.
Has effect only if POS_DYNAMIC is not set.
#define POS_MASS 1 |
Use mass weighting.
If this flag is set, the positions will be calculated using mass weighting, i.e., one gets center-of-mass positions. Without the flag, center-of-geometry positions are calculated. Does not have any effect if the calculation type is POS_ATOM.
enum e_poscalc_t |
void gmx_ana_poscalc_free | ( | gmx_ana_poscalc_t * | pc | ) |
Frees the memory allocated for position calculation.
pc | Position calculation data to be freed. |
The pc
pointer is invalid after the call.
void gmx_ana_poscalc_init_pos | ( | gmx_ana_poscalc_t * | pc, |
gmx_ana_pos_t * | p | ||
) |
Initializes positions for position calculation output.
[in] | pc | Position calculation data structure. |
[out] | p | Output positions. |
Calls to gmx_ana_poscalc_update() using pc
should use only positions initialized with this function. The p->g
pointer is initialized to point to an internal group that contains the maximum index group set with gmx_ana_poscalc_set_maxindex().
gmx::PositionCalculationCollection::RequiredTopologyInfo gmx_ana_poscalc_required_topology_info | ( | gmx_ana_poscalc_t * | pc | ) |
Returns true if the position calculation requires topology information.
[in] | pc | Position calculation data to query. |
pc
requires for initialization and/or evaluation. void gmx_ana_poscalc_set_flags | ( | gmx_ana_poscalc_t * | pc, |
int | flags | ||
) |
Sets the flags for position calculation.
[in,out] | pc | Position calculation data structure. |
[in] | flags | New flags. |
flags
are added to the old flags. If calculation type is POS_ATOM, POS_MASS is automatically cleared. If both POS_DYNAMIC and POS_MASKONLY are provided, POS_DYNAMIC is cleared. If calculation type is not POS_RES or POS_MOL, POS_COMPLMAX and POS_COMPLWHOLE are automatically cleared.
void gmx_ana_poscalc_set_maxindex | ( | gmx_ana_poscalc_t * | pc, |
gmx_ana_index_t * | g | ||
) |
Sets the maximum possible input index group for position calculation.
[in,out] | pc | Position calculation data structure. |
[in] | g | Maximum index group for the calculation. |
Subsequent calls to gmx_ana_poscalc_update() should use only subsets of g
for evaluation.
The topology should have been set for the collection of which pc
is a member.
void gmx_ana_poscalc_update | ( | gmx_ana_poscalc_t * | pc, |
gmx_ana_pos_t * | p, | ||
gmx_ana_index_t * | g, | ||
t_trxframe * | fr, | ||
const t_pbc * | pbc | ||
) |
Updates a single COM/COG structure for a frame.
[in] | pc | Position calculation data. |
[in,out] | p | Output positions, initialized previously with gmx_ana_poscalc_init_pos() using pc . |
[in] | g | Index group to use for the update. |
[in] | fr | Current frame. |
[in] | pbc | PBC data, or NULL if no PBC should be used. |
gmx_ana_poscalc_init_frame() should be called for each frame before calling this function.