df3a9c614552c0baa8b2dc3210e2a1b707eece14
[alexxy/gromacs.git] / src / gromacs / swap / swapcoords.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 2013, The GROMACS development team.
5  * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
6  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
7  * and including many others, as listed in the AUTHORS file in the
8  * top-level source directory and at http://www.gromacs.org.
9  *
10  * GROMACS is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * as published by the Free Software Foundation; either version 2.1
13  * of the License, or (at your option) any later version.
14  *
15  * GROMACS is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with GROMACS; if not, see
22  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
24  *
25  * If you want to redistribute modifications to GROMACS, please
26  * consider that scientific software is very special. Version
27  * control is crucial - bugs must be traceable. We will be happy to
28  * consider code for inclusion in the official distribution, but
29  * derived work must not be called official GROMACS. Details are found
30  * in the README & COPYING files - if they are missing, get the
31  * official version at http://www.gromacs.org.
32  *
33  * To help us fund GROMACS development, we humbly ask that you cite
34  * the research papers on the package. Check out http://www.gromacs.org.
35  */
36 /*! \libinternal
37  * \defgroup module_swap "Computational Electrophysiology" position swapping (swap)
38  * \ingroup group_mdrun
39  * \brief
40  * Implements the "Computational Electrophysiology" protocol.
41  *
42  * \author Carsten Kutzner <ckutzne@gwdg.de>
43  */
44 /*! \libinternal \file
45  * \brief
46  * The "Computational Electrophysiology" protocol for ion/water position swapping.
47  *
48  * \author Carsten Kutzner <ckutzne@gwdg.de>
49  * \inlibraryapi
50  * \ingroup module_swap
51  */
52 #ifndef GMX_SWAP_SWAPCOORDS_H
53 #define GMX_SWAP_SWAPCOORDS_H
54
55 #include <cstdio>
56
57 #include "gromacs/math/vectypes.h"
58 #include "gromacs/utility/basedefinitions.h"
59
60 struct gmx_domdec_t;
61 struct gmx_mtop_t;
62 struct gmx_output_env_t;
63 struct gmx_wallcycle;
64 struct swaphistory_t;
65 struct t_commrec;
66 struct t_inputrec;
67 class t_state;
68 struct t_swapcoords;
69 struct ObservablesHistory;
70
71 namespace gmx
72 {
73 class LocalAtomSetManager;
74 struct MdrunOptions;
75 }
76
77 /*! \brief Initialize ion / water position swapping ("Computational Electrophysiology").
78  *
79  * This routine does the memory allocation for various helper arrays, opens
80  * the output file, sets up swap data checkpoint writing, etc.
81  *
82  * \param[in] fplog         General output file, normally md.log.
83  * \param[in] ir            Structure containing MD input parameters, among those
84  *                          also the structure needed for position swapping.
85  * \param[in] fn            Output file name for swap data.
86  * \param[in] mtop          Molecular topology.
87  * \param[in] globalState   The global state, only used on the master rank.
88  * \param[in] oh            Contains struct with swap data that is read from or written to checkpoint.
89  * \param[in] cr            Pointer to MPI communication data.
90  * \param[in] atomSets      Manager tending to swap atom indices.
91  * \param[in] oenv          Needed to open the swap output XVGR file.
92  * \param[in] mdrunOptions  Options for mdrun.
93  */
94 void init_swapcoords(
95         FILE                     *fplog,
96         t_inputrec               *ir,
97         const char               *fn,
98         gmx_mtop_t               *mtop,
99         const t_state            *globalState,
100         ObservablesHistory       *oh,
101         t_commrec                *cr,
102         gmx::LocalAtomSetManager *atomSets,
103         const gmx_output_env_t   *oenv,
104         const gmx::MdrunOptions  &mdrunOptions);
105
106
107 /*! \brief Finalizes ion / water position swapping.
108  *
109  * \param[in] sc            Pointer to swap data.
110  */
111 void finish_swapcoords(t_swapcoords *sc);
112
113
114 /*! \brief "Computational Electrophysiology" main routine within MD loop.
115  *
116  * \param[in] cr       Pointer to MPI communication data.
117  * \param[in] step     The number of the MD time step.
118  * \param[in] t        The time.
119  * \param[in] ir       Structure containing MD input parameters, among those
120  *                     also the structure needed for position swapping.
121  * \param[in] wcycle   Count wallcycles of swap routines for diagnostic output.
122  * \param[in] x        Positions of home particles this node owns.
123  * \param[in] box      The simulation box.
124  * \param[in] bVerbose Should we be quiet or verbose?
125  * \param[in] bRerun   Are we doing a rerun?
126  *
127  * \returns Whether at least one pair of molecules was swapped.
128  */
129 gmx_bool do_swapcoords(
130         t_commrec        *cr,
131         int64_t           step,
132         double            t,
133         t_inputrec       *ir,
134         gmx_wallcycle    *wcycle,
135         rvec              x[],
136         matrix            box,
137         gmx_bool          bVerbose,
138         gmx_bool          bRerun);
139
140 #endif