2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team,
6 * check out http://www.gromacs.org for more information.
7 * Copyright (c) 2012,2013, by the GROMACS development team, led by
8 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9 * others, as listed in the AUTHORS file in the top-level source
10 * directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
43 #include "visibility.h"
45 #include "gmxcomplex.h"
46 #include "gmx_wallcycle.h"
52 typedef real
*splinevec
[DIM
];
55 GMX_SUM_QGRID_FORWARD
, GMX_SUM_QGRID_BACKWARD
59 int gmx_pme_init(gmx_pme_t
*pmedata
, t_commrec
*cr
,
60 int nnodes_major
, int nnodes_minor
,
61 t_inputrec
*ir
, int homenr
,
62 gmx_bool bFreeEnergy
, gmx_bool bReproducible
, int nthread
);
63 /* Initialize the pme data structures resepectively.
64 * Return value 0 indicates all well, non zero is an error code.
68 int gmx_pme_reinit(gmx_pme_t
* pmedata
,
71 const t_inputrec
* ir
,
73 /* As gmx_pme_init, but takes most settings, except the grid, from pme_src */
75 int gmx_pme_destroy(FILE *log
, gmx_pme_t
*pmedata
);
76 /* Destroy the pme data structures resepectively.
77 * Return value 0 indicates all well, non zero is an error code.
80 #define GMX_PME_SPREAD_Q (1<<0)
81 #define GMX_PME_SOLVE (1<<1)
82 #define GMX_PME_CALC_F (1<<2)
83 #define GMX_PME_CALC_ENER_VIR (1<<3)
84 /* This forces the grid to be backtransformed even without GMX_PME_CALC_F */
85 #define GMX_PME_CALC_POT (1<<4)
86 #define GMX_PME_DO_ALL_F (GMX_PME_SPREAD_Q | GMX_PME_SOLVE | GMX_PME_CALC_F)
88 int gmx_pme_do(gmx_pme_t pme
,
89 int start
, int homenr
,
91 real chargeA
[], real chargeB
[],
92 matrix box
, t_commrec
*cr
,
93 int maxshift_x
, int maxshift_y
,
94 t_nrnb
*nrnb
, gmx_wallcycle_t wcycle
,
95 matrix lrvir
, real ewaldcoeff
,
96 real
*energy
, real lambda
,
97 real
*dvdlambda
, int flags
);
98 /* Do a PME calculation for the long range electrostatics.
99 * flags, defined above, determine which parts of the calculation are performed.
100 * Return value 0 indicates all well, non zero is an error code.
104 int gmx_pmeonly(gmx_pme_t pme
,
105 t_commrec
*cr
, t_nrnb
*mynrnb
,
106 gmx_wallcycle_t wcycle
,
107 real ewaldcoeff
, gmx_bool bGatherOnly
,
109 /* Called on the nodes that do PME exclusively (as slaves)
112 void gmx_pme_calc_energy(gmx_pme_t pme
, int n
, rvec
*x
, real
*q
, real
*V
);
113 /* Calculate the PME grid energy V for n charges with a potential
114 * in the pme struct determined before with a call to gmx_pme_do
115 * with at least GMX_PME_SPREAD_Q and GMX_PME_SOLVE specified.
116 * Note that the charges are not spread on the grid in the pme struct.
117 * Currently does not work in parallel or with free energy.
120 /* The following three routines are for PME/PP node splitting in pme_pp.c */
122 /* Abstract type for PME <-> PP communication */
123 typedef struct gmx_pme_pp
*gmx_pme_pp_t
;
125 gmx_pme_pp_t
gmx_pme_pp_init(t_commrec
*cr
);
126 /* Initialize the PME-only side of the PME <-> PP communication */
128 void gmx_pme_send_q(t_commrec
*cr
,
129 gmx_bool bFreeEnergy
, real
*chargeA
, real
*chargeB
,
130 int maxshift_x
, int maxshift_y
);
131 /* Send the charges and maxshift to out PME-only node. */
133 void gmx_pme_send_x(t_commrec
*cr
, matrix box
, rvec
*x
,
134 gmx_bool bFreeEnergy
, real lambda
,
136 gmx_large_int_t step
);
137 /* Send the coordinates to our PME-only node and request a PME calculation */
140 void gmx_pme_send_finish(t_commrec
*cr
);
141 /* Tell our PME-only node to finish */
144 void gmx_pme_send_switchgrid(t_commrec
*cr
, ivec grid_size
, real ewaldcoeff
);
145 /* Tell our PME-only node to switch to a new grid size */
148 void gmx_pme_send_resetcounters(t_commrec
*cr
, gmx_large_int_t step
);
149 /* Tell our PME-only node to reset all cycle and flop counters */
151 void gmx_pme_receive_f(t_commrec
*cr
,
152 rvec f
[], matrix vir
,
153 real
*energy
, real
*dvdlambda
,
155 /* PP nodes receive the long range forces from the PME nodes */
157 /* Return values for gmx_pme_recv_q_x */
159 pmerecvqxX
, /* calculate PME mesh interactions for new x */
160 pmerecvqxFINISH
, /* the simulation should finish, we should quit */
161 pmerecvqxSWITCHGRID
, /* change the PME grid size */
162 pmerecvqxRESETCOUNTERS
/* reset the cycle and flop counters */
165 int gmx_pme_recv_q_x(gmx_pme_pp_t pme_pp
,
167 real
**chargeA
, real
**chargeB
,
168 matrix box
, rvec
**x
, rvec
**f
,
169 int *maxshift_x
, int *maxshift_y
,
170 gmx_bool
*bFreeEnergy
, real
*lambda
,
172 gmx_large_int_t
*step
,
173 ivec grid_size
, real
*ewaldcoeff
);
175 /* With return value:
176 * pmerecvqxX: all parameters set, chargeA and chargeB can be NULL
177 * pmerecvqxFINISH: no parameters set
178 * pmerecvqxSWITCHGRID: only grid_size and *ewaldcoeff are set
179 * pmerecvqxRESETCOUNTERS: *step is set
182 void gmx_pme_send_force_vir_ener(gmx_pme_pp_t pme_pp
,
184 real energy
, real dvdlambda
,
186 /* Send the PME mesh force, virial and energy to the PP-only nodes */