b3acfd35135c58a00cfc6433fbd773bee7198b91
[alexxy/gromacs.git] / src / gromacs / listed-forces / bonded.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2004, The GROMACS development team.
6  * Copyright (c) 2013,2014, by the GROMACS development team, led by
7  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8  * and including many others, as listed in the AUTHORS file in the
9  * top-level source directory and at http://www.gromacs.org.
10  *
11  * GROMACS is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public License
13  * as published by the Free Software Foundation; either version 2.1
14  * of the License, or (at your option) any later version.
15  *
16  * GROMACS is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with GROMACS; if not, see
23  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
25  *
26  * If you want to redistribute modifications to GROMACS, please
27  * consider that scientific software is very special. Version
28  * control is crucial - bugs must be traceable. We will be happy to
29  * consider code for inclusion in the official distribution, but
30  * derived work must not be called official GROMACS. Details are found
31  * in the README & COPYING files - if they are missing, get the
32  * official version at http://www.gromacs.org.
33  *
34  * To help us fund GROMACS development, we humbly ask that you cite
35  * the research papers on the package. Check out http://www.gromacs.org.
36  */
37 /*! \defgroup module_listed-forces Interactions between lists of particles
38  * \ingroup group_mdrun
39  *
40  * \brief Computes energies and forces for interactions between a
41  * small number of particles, e.g bonds.
42  *
43  * More functionality will move into this module shortly.
44  *
45  * \author Mark Abraham <mark.j.abraham@gmail.com>
46  *
47  */
48
49 /*! \file
50  *
51  * \brief
52  * This file contains function declarations necessary for mdrun and tools
53  * to compute energies and forces for bonded interactions.
54  *
55  * \author Mark Abraham <mark.j.abraham@gmail.com>
56  * \inpublicapi
57  * \ingroup module_listed-forces
58  */
59
60 #ifndef GMX_LISTED_FORCES_BONDED_H
61 #define GMX_LISTED_FORCES_BONDED_H
62
63 #include <stdio.h>
64
65 #include "gromacs/legacyheaders/nrnb.h"
66 #include "gromacs/legacyheaders/typedefs.h"
67
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71
72 struct t_graph;
73 struct t_pbc;
74
75 /*! \brief Returns the global topology atom number belonging to local atom index i.
76  * This function is intended for writing ascii output
77  * and returns atom numbers starting at 1.
78  * When global_atom_index=NULL returns i+1.
79  */
80 int glatnr(int *global_atom_index, int i);
81
82 /*! \brief Return whether this is an interaction that actually
83  * calculates a potential and works on multiple atoms (not e.g. a
84  * connection or a position restraint).
85  *
86  * \todo This function could go away when idef is not a big bucket of
87  * everything. */
88 gmx_bool
89 ftype_is_bonded_potential(int ftype);
90
91 /*! \brief Calculates all bonded force interactions. */
92 void calc_bonds(const gmx_multisim_t *ms,
93                 const t_idef *idef,
94                 const rvec x[], history_t *hist,
95                 rvec f[], t_forcerec *fr,
96                 const struct t_pbc *pbc, const struct t_graph *g,
97                 gmx_enerdata_t *enerd, t_nrnb *nrnb, real *lambda,
98                 const t_mdatoms *md,
99                 t_fcdata *fcd, int *ddgatindex,
100                 int force_flags);
101
102 /*! \brief As calc_bonds, but only determines the potential energy
103  * for the perturbed interactions.
104  * The shift forces in fr are not affected. */
105 void calc_bonds_lambda(const t_idef *idef,
106                        const rvec x[],
107                        t_forcerec *fr,
108                        const struct t_pbc *pbc, const struct t_graph *g,
109                        gmx_grppairener_t *grpp, real *epot, t_nrnb *nrnb,
110                        real *lambda,
111                        const t_mdatoms *md,
112                        t_fcdata *fcd, int *global_atom_index);
113
114 /*! \brief Position restraints require a different pbc treatment from other bondeds */
115 real posres(int nbonds,
116             const t_iatom forceatoms[], const t_iparams forceparams[],
117             const rvec x[], rvec f[], rvec vir_diag,
118             struct t_pbc *pbc,
119             real lambda, real *dvdlambda,
120             int refcoord_scaling, int ePBC, rvec comA, rvec comB);
121
122 /*! \brief Flat-bottom posres. Same PBC treatment as in normal position restraints */
123 real fbposres(int nbonds,
124               const t_iatom forceatoms[], const t_iparams forceparams[],
125               const rvec x[], rvec f[], rvec vir_diag,
126               struct t_pbc *pbc, int refcoord_scaling, int ePBC, rvec com);
127
128 /*! \brief Calculate bond-angle. No PBC is taken into account (use mol-shift) */
129 real bond_angle(const rvec xi, const rvec xj, const rvec xk,
130                 const struct t_pbc *pbc,
131                 rvec r_ij, rvec r_kj, real *costh,
132                 int *t1, int *t2);  /* out */
133
134 /*! \brief Calculate dihedral-angle. No PBC is taken into account (use mol-shift) */
135 real dih_angle(const rvec xi, const rvec xj, const rvec xk, const rvec xl,
136                const struct t_pbc *pbc,
137                rvec r_ij, rvec r_kj, rvec r_kl, rvec m, rvec n, /* out */
138                real *sign,
139                int *t1, int *t2, int *t3);
140
141 /*! \brief Do an update of the forces for dihedral potentials */
142 void do_dih_fup(int i, int j, int k, int l, real ddphi,
143                 rvec r_ij, rvec r_kj, rvec r_kl,
144                 rvec m, rvec n, rvec f[], rvec fshift[],
145                 const struct t_pbc *pbc, const struct t_graph *g,
146                 const rvec *x, int t1, int t2, int t3);
147
148 /*! \brief Make a dihedral fall in the range (-pi,pi) */
149 void make_dp_periodic(real *dp);
150
151 //! \cond
152 /*************************************************************************
153  *
154  *  Bonded force functions
155  *
156  *************************************************************************/
157 t_ifunc bonds, g96bonds, morse_bonds, cubic_bonds, FENE_bonds, restraint_bonds;
158 t_ifunc angles, g96angles, cross_bond_bond, cross_bond_angle, urey_bradley, quartic_angles, linear_angles;
159 t_ifunc restrangles;
160 t_ifunc pdihs, idihs, rbdihs;
161 t_ifunc restrdihs, cbtdihs;
162 t_ifunc tab_bonds, tab_angles, tab_dihs;
163 t_ifunc polarize, anharm_polarize, water_pol, thole_pol, angres, angresz, dihres, unimplemented;
164 //! \endcond
165
166 #ifdef __cplusplus
167 }
168 #endif
169
170 #endif