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