3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2004, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * Gromacs Runs On Most of All Computer Systems
41 #include "gmxcomplex.h"
42 #include "gmx_wallcycle.h"
48 typedef real *splinevec[DIM];
50 enum { GMX_SUM_QGRID_FORWARD, GMX_SUM_QGRID_BACKWARD };
52 int gmx_pme_init(gmx_pme_t *pmedata,t_commrec *cr,
53 int nnodes_major,int nnodes_minor,
54 t_inputrec *ir,int homenr,
55 gmx_bool bFreeEnergy, gmx_bool bReproducible, int nthread);
56 /* Initialize the pme data structures resepectively.
57 * Return value 0 indicates all well, non zero is an error code.
60 int gmx_pme_reinit(gmx_pme_t * pmedata,
63 const t_inputrec * ir,
65 /* As gmx_pme_init, but takes most settings, except the grid, from pme_src */
67 int gmx_pme_destroy(FILE *log,gmx_pme_t *pmedata);
68 /* Destroy the pme data structures resepectively.
69 * Return value 0 indicates all well, non zero is an error code.
72 #define GMX_PME_SPREAD_Q (1<<0)
73 #define GMX_PME_SOLVE (1<<1)
74 #define GMX_PME_CALC_F (1<<2)
75 #define GMX_PME_CALC_ENER_VIR (1<<3)
76 /* This forces the grid to be backtransformed even without GMX_PME_CALC_F */
77 #define GMX_PME_CALC_POT (1<<4)
78 #define GMX_PME_DO_ALL_F (GMX_PME_SPREAD_Q | GMX_PME_SOLVE | GMX_PME_CALC_F)
80 int gmx_pme_do(gmx_pme_t pme,
81 int start, int homenr,
83 real chargeA[], real chargeB[],
84 matrix box, t_commrec *cr,
85 int maxshift_x, int maxshift_y,
86 t_nrnb *nrnb, gmx_wallcycle_t wcycle,
87 matrix lrvir, real ewaldcoeff,
88 real *energy, real lambda,
89 real *dvdlambda, int flags);
90 /* Do a PME calculation for the long range electrostatics.
91 * flags, defined above, determine which parts of the calculation are performed.
92 * Return value 0 indicates all well, non zero is an error code.
95 int gmx_pmeonly(gmx_pme_t pme,
96 t_commrec *cr, t_nrnb *mynrnb,
97 gmx_wallcycle_t wcycle,
98 real ewaldcoeff, gmx_bool bGatherOnly,
100 /* Called on the nodes that do PME exclusively (as slaves)
103 void gmx_pme_calc_energy(gmx_pme_t pme,int n,rvec *x,real *q,real *V);
104 /* Calculate the PME grid energy V for n charges with a potential
105 * in the pme struct determined before with a call to gmx_pme_do
106 * with at least GMX_PME_SPREAD_Q and GMX_PME_SOLVE specified.
107 * Note that the charges are not spread on the grid in the pme struct.
108 * Currently does not work in parallel or with free energy.
111 /* The following three routines are for PME/PP node splitting in pme_pp.c */
113 /* Abstract type for PME <-> PP communication */
114 typedef struct gmx_pme_pp *gmx_pme_pp_t;
116 gmx_pme_pp_t gmx_pme_pp_init(t_commrec *cr);
117 /* Initialize the PME-only side of the PME <-> PP communication */
119 void gmx_pme_send_q(t_commrec *cr,
120 gmx_bool bFreeEnergy, real *chargeA, real *chargeB,
121 int maxshift_x, int maxshift_y);
122 /* Send the charges and maxshift to out PME-only node. */
124 void gmx_pme_send_x(t_commrec *cr, matrix box, rvec *x,
125 gmx_bool bFreeEnergy, real lambda,
127 gmx_large_int_t step);
128 /* Send the coordinates to our PME-only node and request a PME calculation */
130 void gmx_pme_send_finish(t_commrec *cr);
131 /* Tell our PME-only node to finish */
133 void gmx_pme_send_switch(t_commrec *cr, ivec grid_size, real ewaldcoeff);
134 /* Tell our PME-only node to switch to a new grid size */
136 void gmx_pme_receive_f(t_commrec *cr,
137 rvec f[], matrix vir,
138 real *energy, real *dvdlambda,
140 /* PP nodes receive the long range forces from the PME nodes */
142 int gmx_pme_recv_q_x(gmx_pme_pp_t pme_pp,
143 real **chargeA, real **chargeB,
144 matrix box, rvec **x,rvec **f,
145 int *maxshift_x, int *maxshift_y,
146 gmx_bool *bFreeEnergy, real *lambda,
148 gmx_large_int_t *step,
149 ivec grid_size, real *ewaldcoeff);
151 /* Receive charges and/or coordinates from the PP-only nodes.
152 * Returns the number of atoms, or -1 when the run is finished.
153 * In the special case of a PME grid size switch request, -2 is returned
154 * and grid_size and *ewaldcoeff are set, which are otherwise not set.
157 void gmx_pme_send_force_vir_ener(gmx_pme_pp_t pme_pp,
159 real energy, real dvdlambda,
161 /* Send the PME mesh force, virial and energy to the PP-only nodes */