Convert some config.h macros to use 0/1
[gromacs.git] / src / gromacs / imd / imd.h
blobcd27b816a9370cc5d12eaf97157036e21860dfeb
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2014,2015,2016, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
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.
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.
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.
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.
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.
36 /*! \libinternal
37 * \defgroup module_imd Interactive molecular dynamics (IMD)
38 * \ingroup group_mdrun
40 * \brief
41 * Allows mdrun to interface with VMD via the interactive molecular dynamics
42 * (IMD) protocol.
44 * \author Martin Hoefling, Carsten Kutzner <ckutzne@gwdg.de>
48 /*! \libinternal \file
50 * \brief
51 * This file contains datatypes and function declarations necessary for mdrun
52 * to interface with VMD via the interactive molecular dynamics protocol.
54 * \author Martin Hoefling, Carsten Kutzner <ckutzne@gwdg.de>
56 * \inlibraryapi
57 * \ingroup module_imd
60 #ifndef GMX_IMD_IMD_H
61 #define GMX_IMD_IMD_H
63 #include "config.h"
65 #include "gromacs/math/vectypes.h"
66 #include "gromacs/timing/wallcycle.h"
68 #if GMX_NATIVE_WINDOWS
69 #include <Windows.h>
70 #define NOFLAGS 0
71 #endif
73 struct gmx_domdec_t;
74 struct gmx_enerdata_t;
75 struct gmx_mtop_t;
76 struct gmx_output_env_t;
77 struct t_filenm;
78 struct t_gmx_IMD;
79 struct t_IMD;
80 struct t_inputrec;
81 struct t_state;
83 static const char IMDstr[] = "IMD:"; /**< Tag output from the IMD module with this string. */
85 /*! \brief Writes out the group of atoms selected for interactive manipulation.
87 * Called by grompp.
88 * The resulting file has to be read in by VMD if one wants it to connect to mdrun.
90 * \param bIMD Only springs into action if bIMD is TRUE. Otherwise returns directly.
91 * \param ir Structure containing MD input parameters, among those
92 * the IMD data structure.
93 * \param state The current state of the MD system.
94 * \param sys The global, complete system topology.
95 * \param nfile Number of files.
96 * \param fnm Filename struct.
98 void write_IMDgroup_to_file(gmx_bool bIMD, t_inputrec *ir, t_state *state,
99 gmx_mtop_t *sys, int nfile, const t_filenm fnm[]);
102 /*! \brief Make a selection of the home atoms for the IMD group.
104 * Should be called at every domain decomposition.
105 * Each node checks which of the atoms from "ind" are local and puts its local
106 * atom numbers into the "ind_local" array. Furthermore, in "xa_ind" it is
107 * stored at which position each local atom belongs in the assembled/collective
108 * array, so that on the master node all positions can be merged into the
109 * assembled array correctly.
111 * \param bIMD Only springs into action if bIMD is TRUE. Otherwise returns directly.
112 * \param dd Structure containing domain decomposition data.
113 * \param imd The IMD group of atoms.
115 void dd_make_local_IMD_atoms(gmx_bool bIMD, gmx_domdec_t *dd, t_IMD *imd);
118 /*! \brief Initializes (or disables) IMD.
120 * This function is called before the main MD loop over time steps,
121 * and it must be called prior to any call to dd_partition_system if in parallel.
123 * \param ir The inputrec structure containing the MD input parameters
124 * including a pointer to the IMD data structure.
125 * \param cr Information structure for MPI communication.
126 * \param top_global The topology of the whole system.
127 * \param fplog General output file, normally md.log.
128 * \param defnstimd Default IMD update (=communication) frequency.
129 * \param x The starting positions of the atoms.
130 * \param nfile Number of files.
131 * \param fnm Struct containing file names etc.
132 * \param oenv Output options.
133 * \param imdport Port to use for IMD connections.
134 * \param Flags Flags passed over from main, used to determine
135 * whether or not we are appending.
137 void init_IMD(t_inputrec *ir, t_commrec *cr, gmx_mtop_t *top_global,
138 FILE *fplog, int defnstimd, rvec x[],
139 int nfile, const t_filenm fnm[], const gmx_output_env_t *oenv,
140 int imdport, unsigned long Flags);
143 /*! \brief IMD required in this time step?
144 * Also checks for new IMD connection and syncs the nodes.
146 * \param bIMD Only springs into action if bIMD is TRUE. Otherwise returns directly.
147 * \param step The time step.
148 * \param cr Information structure for MPI communication.
149 * \param bNS Is this a neighbor searching step?
150 * \param box The simulation box.
151 * \param x The local atomic positions on this node.
152 * \param ir The inputrec structure containing the MD input parameters
153 * including a pointer to the IMD data structure.
154 * \param t The time.
155 * \param wcycle Count wallcycles of IMD routines for diagnostic output.
157 * \returns Whether or not we have to do IMD communication at this step.
159 gmx_bool do_IMD(gmx_bool bIMD, gmx_int64_t step, t_commrec *cr,
160 gmx_bool bNS,
161 matrix box, rvec x[], t_inputrec *ir, double t,
162 gmx_wallcycle_t wcycle);
165 /*! \brief Get the IMD update frequency.
167 * \param IMDsetup Opaque pointer to IMD private data.
169 * \returns The current IMD update/communication frequency
171 int IMD_get_step(t_gmx_IMD *IMDsetup);
174 /*! \brief Add external forces from a running interactive molecular dynamics session.
176 * \param bIMD Returns directly if bIMD is FALSE.
177 * \param imd The IMD data structure.
178 * \param cr Information structure for MPI communication.
179 * \param f The forces.
180 * \param wcycle Count wallcycles of IMD routines for diagnostic output.
182 void IMD_apply_forces(gmx_bool bIMD, t_IMD *imd,
183 t_commrec *cr, rvec *f,
184 gmx_wallcycle_t wcycle);
187 /*! \brief Copy energies and convert to float from enerdata to the IMD energy record.
189 * We do no conversion, so units in client are SI!
191 * \param bIMD Only springs into action if bIMD is TRUE. Otherwise returns directly.
192 * \param imd The IMD data structure.
193 * \param enerd Contains the GROMACS energies for the different interaction types.
194 * \param step The time step.
195 * \param bHaveNewEnergies Only copy energies if we have done global summing of them before.
198 void IMD_fill_energy_record(gmx_bool bIMD, t_IMD *imd, gmx_enerdata_t *enerd,
199 gmx_int64_t step, gmx_bool bHaveNewEnergies);
202 /*! \brief Send positions and energies to the client.
204 * \param imd The IMD data structure.
206 void IMD_send_positions(t_IMD *imd);
209 /*! \brief Calls IMD_prepare_energies() and then IMD_send_positions().
211 * \param bIMD Returns directly if bIMD is FALSE.
212 * \param bIMDstep If true, transfer the positions. Otherwise just update the time step and potentially the energy record.
213 * \param imd The IMD data structure.
214 * \param enerd Contains the GROMACS energies for the different interaction types.
215 * \param step The time step.
216 * \param bHaveNewEnergies Only update the energy record if we have done global summing of the energies.
217 * \param wcycle Count wallcycles of IMD routines for diagnostic output.
220 void IMD_prep_energies_send_positions(gmx_bool bIMD, gmx_bool bIMDstep,
221 t_IMD *imd, gmx_enerdata_t *enerd,
222 gmx_int64_t step, gmx_bool bHaveNewEnergies,
223 gmx_wallcycle_t wcycle);
225 /*! \brief Finalize IMD and do some cleaning up.
227 * Currently, IMD finalize closes the force output file.
229 * \param bIMD Returns directly if bIMD is FALSE.
230 * \param imd The IMD data structure.
232 void IMD_finalize(gmx_bool bIMD, t_IMD *imd);
234 #endif