2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2013, The GROMACS development team.
5 * Copyright (c) 2013,2014,2015,2016,2017 by the GROMACS development team.
6 * Copyright (c) 2018,2019,2020,2021, 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.
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.
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.
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.
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.
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.
38 * \defgroup module_swap "Computational Electrophysiology" position swapping (swap)
39 * \ingroup group_mdrun
41 * Implements the "Computational Electrophysiology" protocol.
43 * \author Carsten Kutzner <ckutzne@gwdg.de>
45 /*! \libinternal \file
47 * The "Computational Electrophysiology" protocol for ion/water position swapping.
49 * \author Carsten Kutzner <ckutzne@gwdg.de>
51 * \ingroup module_swap
53 #ifndef GMX_SWAP_SWAPCOORDS_H
54 #define GMX_SWAP_SWAPCOORDS_H
60 #include "gromacs/math/vectypes.h"
61 #include "gromacs/utility/basedefinitions.h"
65 struct gmx_output_env_t;
73 struct ObservablesHistory;
77 enum class StartingBehavior;
79 class LocalAtomSetManager;
83 * Creates a module for Computational Electrophysiology swapping.
85 std::unique_ptr<IMDModule> createSwapCoordinatesModule();
89 /*! \brief Initialize ion / water position swapping ("Computational Electrophysiology").
91 * This routine does the memory allocation for various helper arrays, opens
92 * the output file, sets up swap data checkpoint writing, etc. and returns it.
94 * \param[in] fplog General output file, normally md.log.
95 * \param[in] ir Structure containing MD input parameters, among those
96 * also the structure needed for position swapping.
97 * \param[in] fn Output file name for swap data.
98 * \param[in] mtop Molecular topology.
99 * \param[in] globalState The global state, only used on the master rank.
100 * \param[in] oh Contains struct with swap data that is read from or written to checkpoint.
101 * \param[in] cr Pointer to MPI communication data.
102 * \param[in] atomSets Manager tending to swap atom indices.
103 * \param[in] oenv Needed to open the swap output XVGR file.
104 * \param[in] mdrunOptions Options for mdrun.
105 * \param[in] startingBehavior Describes whether this is a restart appending to output files
107 t_swap* init_swapcoords(FILE* fplog,
108 const t_inputrec* ir,
110 const gmx_mtop_t& mtop,
111 const t_state* globalState,
112 ObservablesHistory* oh,
114 gmx::LocalAtomSetManager* atomSets,
115 const gmx_output_env_t* oenv,
116 const gmx::MdrunOptions& mdrunOptions,
117 gmx::StartingBehavior startingBehavior);
120 /*! \brief Finalizes ion / water position swapping, if it was active.
122 * \param[in] s Pointer to swap data.
124 void finish_swapcoords(t_swap* s);
127 /*! \brief "Computational Electrophysiology" main routine within MD loop.
129 * \param[in] cr Pointer to MPI communication data.
130 * \param[in] step The number of the MD time step.
131 * \param[in] t The time.
132 * \param[in] ir Structure containing MD input parameters
133 * \param[in,out] s The structure needed for position swapping.
134 * \param[in] wcycle Count wallcycles of swap routines for diagnostic output.
135 * \param[in] x Positions of home particles this node owns.
136 * \param[in] box The simulation box.
137 * \param[in] bVerbose Should we be quiet or verbose?
138 * \param[in] bRerun Are we doing a rerun?
140 * \returns Whether at least one pair of molecules was swapped.
142 gmx_bool do_swapcoords(t_commrec* cr,
145 const t_inputrec* ir,
147 gmx_wallcycle* wcycle,