f22341e10205e2a4cd5112608169e970129699f3
[alexxy/gromacs.git] / src / gromacs / ewald / pme.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
38 #ifndef GMX_EWALD_PME_H
39 #define GMX_EWALD_PME_H
40
41 #include <stdio.h>
42
43 #include "gromacs/legacyheaders/network.h"
44 #include "gromacs/legacyheaders/typedefs.h"
45 #include "gromacs/math/gmxcomplex.h"
46 #include "gromacs/timing/wallcycle.h"
47 #include "gromacs/timing/walltime_accounting.h"
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52
53 enum {
54     GMX_SUM_GRID_FORWARD, GMX_SUM_GRID_BACKWARD
55 };
56
57 int gmx_pme_init(gmx_pme_t *pmedata, t_commrec *cr,
58                  int nnodes_major, int nnodes_minor,
59                  t_inputrec *ir, int homenr,
60                  gmx_bool bFreeEnergy_q, gmx_bool bFreeEnergy_lj,
61                  gmx_bool bReproducible, int nthread);
62 /* Initialize the pme data structures resepectively.
63  * Return value 0 indicates all well, non zero is an error code.
64  */
65
66 int gmx_pme_destroy(FILE *log, gmx_pme_t *pmedata);
67 /* Destroy the pme data structures resepectively.
68  * Return value 0 indicates all well, non zero is an error code.
69  */
70
71 #define GMX_PME_SPREAD        (1<<0)
72 #define GMX_PME_SOLVE         (1<<1)
73 #define GMX_PME_CALC_F        (1<<2)
74 #define GMX_PME_CALC_ENER_VIR (1<<3)
75 /* This forces the grid to be backtransformed even without GMX_PME_CALC_F */
76 #define GMX_PME_CALC_POT      (1<<4)
77
78 /* These values label bits used for sending messages to PME nodes using the
79  * routines in pme_pp.c and shouldn't conflict with the flags used there
80  */
81 #define GMX_PME_DO_COULOMB    (1<<13)
82 #define GMX_PME_DO_LJ         (1<<14)
83
84 #define GMX_PME_DO_ALL_F  (GMX_PME_SPREAD | GMX_PME_SOLVE | GMX_PME_CALC_F)
85
86 int gmx_pme_do(gmx_pme_t pme,
87                int start,       int homenr,
88                rvec x[],        rvec f[],
89                real chargeA[],  real chargeB[],
90                real c6A[],      real c6B[],
91                real sigmaA[],   real sigmaB[],
92                matrix box,      t_commrec *cr,
93                int  maxshift_x, int maxshift_y,
94                t_nrnb *nrnb,    gmx_wallcycle_t wcycle,
95                matrix vir_q,    real ewaldcoeff_q,
96                matrix vir_lj,   real ewaldcoeff_lj,
97                real *energy_q,  real *energy_lj,
98                real lambda_q, real lambda_lj,
99                real *dvdlambda_q, real *dvdlambda_lj,
100                int flags);
101 /* Do a PME calculation for the long range electrostatics and/or LJ.
102  * flags, defined above, determine which parts of the calculation are performed.
103  * Return value 0 indicates all well, non zero is an error code.
104  */
105
106 int gmx_pmeonly(gmx_pme_t pme,
107                 t_commrec *cr,     t_nrnb *mynrnb,
108                 gmx_wallcycle_t wcycle,
109                 gmx_walltime_accounting_t walltime_accounting,
110                 real ewaldcoeff_q, real ewaldcoeff_lj,
111                 t_inputrec *ir);
112 /* Called on the nodes that do PME exclusively (as slaves)
113  */
114
115 void gmx_pme_calc_energy(gmx_pme_t pme, int n, rvec *x, real *q, real *V);
116 /* Calculate the PME grid energy V for n charges with a potential
117  * in the pme struct determined before with a call to gmx_pme_do
118  * with at least GMX_PME_SPREAD and GMX_PME_SOLVE specified.
119  * Note that the charges are not spread on the grid in the pme struct.
120  * Currently does not work in parallel or with free energy.
121  */
122
123 void gmx_pme_send_parameters(t_commrec *cr,
124                              const interaction_const_t *ic,
125                              gmx_bool bFreeEnergy_q, gmx_bool bFreeEnergy_lj,
126                              real *chargeA, real *chargeB,
127                              real *sqrt_c6A, real *sqrt_c6B,
128                              real *sigmaA, real *sigmaB,
129                              int maxshift_x, int maxshift_y);
130 /* Send the charges and maxshift to out PME-only node. */
131
132 void gmx_pme_send_coordinates(t_commrec *cr, matrix box, rvec *x,
133                               gmx_bool bFreeEnergy_q, gmx_bool bFreeEnergy_lj,
134                               real lambda_q, real lambda_lj,
135                               gmx_bool bEnerVir, int pme_flags,
136                               gmx_int64_t step);
137 /* Send the coordinates to our PME-only node and request a PME calculation */
138
139 void gmx_pme_send_finish(t_commrec *cr);
140 /* Tell our PME-only node to finish */
141
142 void gmx_pme_send_resetcounters(t_commrec *cr, gmx_int64_t step);
143 /* Tell our PME-only node to reset all cycle and flop counters */
144
145 void gmx_pme_receive_f(t_commrec *cr,
146                        rvec f[], matrix vir_q, real *energy_q,
147                        matrix vir_lj, real *energy_lj,
148                        real *dvdlambda_q, real *dvdlambda_lj,
149                        float *pme_cycles);
150 /* PP nodes receive the long range forces from the PME nodes */
151
152 #ifdef __cplusplus
153 }
154 #endif
155
156 #endif