Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / selection / centerofmass.h
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
9  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11  * Copyright (c) 2001-2009, The GROMACS development team,
12  * check out http://www.gromacs.org for more information.
13
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * as published by the Free Software Foundation; either version 2
17  * of the License, or (at your option) any later version.
18  *
19  * If you want to redistribute modifications, please consider that
20  * scientific software is very special. Version control is crucial -
21  * bugs must be traceable. We will be happy to consider code for
22  * inclusion in the official distribution, but derived work must not
23  * be called official GROMACS. Details are found in the README & COPYING
24  * files - if they are missing, get the official version at www.gromacs.org.
25  *
26  * To help us fund GROMACS development, we humbly ask that you cite
27  * the papers on the package - you can find them in the top README file.
28  *
29  * For more info, check our website at http://www.gromacs.org
30  */
31 /*! \file
32  * \brief API for calculation of centers of mass/geometry.
33  *
34  * This header defines a few functions that can be used to calculate
35  * centers of mass/geometry for a group of atoms.
36  * These routines can be used independently of the other parts of the
37  * library, but they are also used internally by the selection engine.
38  * In most cases, it should not be necessary to call these functions
39  * directly.
40  * Instead, one should write an analysis tool such that it gets all
41  * positions through selections.
42  *
43  * The functions in the header can be divided into a few groups based on the
44  * parameters they take. The simplest group of functions calculates the center
45  * of a single group of atoms:
46  *  - gmx_calc_cog(): Calculates the center of geometry (COG) of a given
47  *    group of atoms.
48  *  - gmx_calc_com(): Calculates the center of mass (COM) of a given group
49  *    of atoms.
50  *  - gmx_calc_comg(): Calculates either the COM or COG, based on a
51  *    boolean flag.
52  *
53  * A second set of routines is provided for calculating the centers for groups
54  * that wrap over periodic boundaries (gmx_calc_cog_pbc(), gmx_calc_com_pbc(),
55  * gmx_calc_comg_pbc()). These functions are slower, because they need to
56  * adjust the center iteratively.
57  *
58  * It is also possible to calculate centers for several groups of atoms in
59  * one call. The functions gmx_calc_cog_block(), gmx_calc_com_block() and
60  * gmx_calc_comg_block() take an index group and a partitioning of that index
61  * group (as a \c t_block structure), and calculate the centers for
62  * each group defined by the \c t_block structure separately.
63  *
64  * Finally, there is a function gmx_calc_comg_blocka() that takes both the
65  * index group and the partitioning as a single \c t_blocka structure.
66  *
67  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
68  * \ingroup module_selection
69  */
70 #ifndef GMX_SELECTION_CENTEROFMASS_H
71 #define GMX_SELECTION_CENTEROFMASS_H
72
73 #include "../legacyheaders/typedefs.h"
74
75 /** Calculate a single center of geometry. */
76 int
77 gmx_calc_cog(t_topology *top, rvec x[], int nrefat, atom_id index[], rvec xout);
78 /** Calculate a single center of mass. */
79 int
80 gmx_calc_com(t_topology *top, rvec x[], int nrefat, atom_id index[], rvec xout);
81 /** Calculate force on a single center of geometry. */
82 int
83 gmx_calc_cog_f(t_topology *top, rvec f[], int nrefat, atom_id index[], rvec fout);
84 /** Calculate a single center of mass/geometry. */
85 int
86 gmx_calc_comg(t_topology *top, rvec x[], int nrefat, atom_id index[],
87               bool bMass, rvec xout);
88 /** Calculate force on a single center of mass/geometry. */
89 int
90 gmx_calc_comg_f(t_topology *top, rvec f[], int nrefat, atom_id index[],
91                 bool bMass, rvec fout);
92
93 /** Calculate a single center of geometry iteratively, taking PBC into account. */
94 int
95 gmx_calc_cog_pbc(t_topology *top, rvec x[], t_pbc *pbc,
96                  int nrefat, atom_id index[], rvec xout);
97 /** Calculate a single center of mass iteratively, taking PBC into account. */
98 int
99 gmx_calc_com_pbc(t_topology *top, rvec x[], t_pbc *pbc,
100                  int nrefat, atom_id index[], rvec xout);
101 /** Calculate a single center of mass/geometry iteratively with PBC. */
102 int
103 gmx_calc_comg_pbc(t_topology *top, rvec x[], t_pbc *pbc,
104                   int nrefat, atom_id index[], bool bMass, rvec xout);
105
106 /** Calculate centers of geometry for a blocked index. */
107 int
108 gmx_calc_cog_block(t_topology *top, rvec x[], t_block *block,
109                    atom_id index[], rvec xout[]);
110 /** Calculate centers of mass for a blocked index. */
111 int
112 gmx_calc_com_block(t_topology *top, rvec x[], t_block *block,
113                    atom_id index[], rvec xout[]);
114 /** Calculate forces on centers of geometry for a blocked index. */
115 int
116 gmx_calc_cog_f_block(t_topology *top, rvec f[], t_block *block,
117                      atom_id index[], rvec fout[]);
118 /** Calculate centers of mass/geometry for a blocked index. */
119 int
120 gmx_calc_comg_block(t_topology *top, rvec x[], t_block *block,
121                     atom_id index[], bool bMass, rvec xout[]);
122 /** Calculate forces on centers of mass/geometry for a blocked index. */
123 int
124 gmx_calc_comg_f_block(t_topology *top, rvec f[], t_block *block,
125                       atom_id index[], bool bMass, rvec fout[]);
126 /** Calculate centers of mass/geometry for a set of blocks; */
127 int
128 gmx_calc_comg_blocka(t_topology *top, rvec x[], t_blocka *block,
129                      bool bMass, rvec xout[]);
130 /** Calculate forces on centers of mass/geometry for a set of blocks; */
131 int
132 gmx_calc_comg_f_blocka(t_topology *top, rvec x[], t_blocka *block,
133                        bool bMass, rvec xout[]);
134
135 #endif