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, 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.
38 #include "visibility.h"
45 /* Should be called after generating or reading mtop,
46 * to set some compute intesive variables to avoid
47 * N^2 operations later on.
51 gmx_mtop_finalize(gmx_mtop_t *mtop);
54 /* Returns the total number of charge groups in mtop */
57 ncg_mtop(const gmx_mtop_t *mtop);
59 /* Removes the charge groups, i.e. makes single atom charge groups, in mtop */
61 void gmx_mtop_remove_chargegroups(gmx_mtop_t *mtop);
64 /* Abstract data type for looking up atoms by global atom number */
65 typedef struct gmx_mtop_atomlookup *gmx_mtop_atomlookup_t;
67 /* Initialize atom lookup by global atom number */
70 gmx_mtop_atomlookup_init(const gmx_mtop_t *mtop);
72 /* As gmx_mtop_atomlookup_init, but optimized for atoms involved in settle */
75 gmx_mtop_atomlookup_settle_init(const gmx_mtop_t *mtop);
77 /* Destroy a gmx_mtop_atomlookup_t data structure */
80 gmx_mtop_atomlookup_destroy(gmx_mtop_atomlookup_t alook);
83 /* Returns a pointer to the t_atom struct belonging to atnr_global.
84 * This can be an expensive operation, so if possible use
85 * one of the atom loop constructs below.
89 gmx_mtop_atomnr_to_atom(const gmx_mtop_atomlookup_t alook,
94 /* Returns a pointer to the molecule interaction array ilist_mol[F_NRE]
95 * and the local atom number in the molecule belonging to atnr_global.
99 gmx_mtop_atomnr_to_ilist(const gmx_mtop_atomlookup_t alook,
101 t_ilist **ilist_mol,int *atnr_offset);
104 /* Returns the molecule block index
105 * and the molecule number in the block
106 * and the atom number offset for the atom indices in moltype
107 * belonging to atnr_global.
111 gmx_mtop_atomnr_to_molblock_ind(const gmx_mtop_atomlookup_t alook,
113 int *molb,int *molnr,int *atnr_mol);
116 /* Returns atom name, global resnr and residue name of atom atnr_global */
119 gmx_mtop_atominfo_global(const gmx_mtop_t *mtop,int atnr_global,
120 char **atomname,int *resnr,char **resname);
123 /* Abstract type for atom loop over all atoms */
124 typedef struct gmx_mtop_atomloop_all *gmx_mtop_atomloop_all_t;
126 /* Initialize an atom loop over all atoms in the system.
127 * The order of the atoms will be as in the state struct.
128 * Only use this when you really need to loop over all atoms,
129 * i.e. when you use groups which might differ per molecule,
130 * otherwise use gmx_mtop_atomloop_block.
133 gmx_mtop_atomloop_all_t
134 gmx_mtop_atomloop_all_init(const gmx_mtop_t *mtop);
136 /* Loop to the next atom.
137 * When not at the end:
138 * returns TRUE and at_global,
139 * writes the global atom number in *at_global
140 * and sets the pointer atom to the t_atom struct of that atom.
141 * When at the end, destroys aloop and returns FALSE.
143 * gmx_mtop_atomloop_all_t aloop;
144 * aloop = gmx_mtop_atomloop_all_init(mtop)
145 * while (gmx_mtop_atomloop_all_next(aloop,&at_global,&atom)) {
151 gmx_mtop_atomloop_all_next(gmx_mtop_atomloop_all_t aloop,
152 int *at_global,t_atom **atom);
154 /* Return the atomname, the residue number and residue name
155 * of the current atom in the loop.
158 gmx_mtop_atomloop_all_names(gmx_mtop_atomloop_all_t aloop,
159 char **atomname,int *resnr,char **resname);
161 /* Return the a pointer to the moltype struct of the current atom
162 * in the loop and the atom number in the molecule.
165 gmx_mtop_atomloop_all_moltype(gmx_mtop_atomloop_all_t aloop,
166 gmx_moltype_t **moltype,int *at_mol);
169 /* Abstract type for atom loop over atoms in all molecule blocks */
170 typedef struct gmx_mtop_atomloop_block *gmx_mtop_atomloop_block_t;
172 /* Initialize an atom loop over atoms in all molecule blocks the system.
175 gmx_mtop_atomloop_block_t
176 gmx_mtop_atomloop_block_init(const gmx_mtop_t *mtop);
178 /* Loop to the next atom.
179 * When not at the end:
181 * sets the pointer atom to the t_atom struct of that atom
182 * and return the number of molecules corresponding to this atom.
183 * When at the end, destroys aloop and returns FALSE.
185 * gmx_mtop_atomloop_block_t aloop;
186 * aloop = gmx_mtop_atomloop_block_init(mtop)
187 * while (gmx_mtop_atomloop_block_next(aloop,&atom,&nmol)) {
193 gmx_mtop_atomloop_block_next(gmx_mtop_atomloop_block_t aloop,
194 t_atom **atom,int *nmol);
197 /* Abstract type for ilist loop over all ilists */
198 typedef struct gmx_mtop_ilistloop *gmx_mtop_ilistloop_t;
200 /* Initialize an ilist loop over all molecule types in the system. */
203 gmx_mtop_ilistloop_init(const gmx_mtop_t *mtop);
206 /* Loop to the next molecule,
207 * When not at the end:
208 * returns TRUE and a pointer to the next array ilist_mol[F_NRE],
209 * writes the number of molecules for this ilist in *nmol.
210 * When at the end, destroys iloop and returns FALSE.
214 gmx_mtop_ilistloop_next(gmx_mtop_ilistloop_t iloop,
215 t_ilist **ilist_mol,int *nmol);
218 /* Abstract type for ilist loop over all ilists of all molecules */
219 typedef struct gmx_mtop_ilistloop_all *gmx_mtop_ilistloop_all_t;
221 /* Initialize an ilist loop over all molecule types in the system.
222 * Only use this when you really need to loop over all molecules,
223 * i.e. when you use groups which might differ per molecule,
224 * otherwise use gmx_mtop_ilistloop.
227 gmx_mtop_ilistloop_all_t
228 gmx_mtop_ilistloop_all_init(const gmx_mtop_t *mtop);
230 /* Loop to the next molecule,
231 * When not at the end:
232 * returns TRUE and a pointer to the next array ilist_mol[F_NRE],
233 * writes the atom offset which should be added to iatoms in atnr_offset.
234 * When at the end, destroys iloop and returns FALSE.
238 gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t iloop,
239 t_ilist **ilist_mol,int *atnr_offset);
242 /* Returns the total number of interactions in the system of type ftype */
245 gmx_mtop_ftype_count(const gmx_mtop_t *mtop,int ftype);
248 /* Returns a charge group index for the whole system */
251 gmx_mtop_global_cgs(const gmx_mtop_t *mtop);
254 /* Returns a single t_atoms struct for the whole system */
257 gmx_mtop_global_atoms(const gmx_mtop_t *mtop);
260 /* Make all charge groups the size of one atom.
261 * When bKeepSingleMolCG==TRUE keep charge groups for molecules
262 * that consist of a single charge group.
265 gmx_mtop_make_atomic_charge_groups(gmx_mtop_t *mtop,gmx_bool bKeepSingleMolCG);
268 /* Generate a 'local' topology for the whole system.
269 * When ir!=NULL the free energy interactions will be sorted to the end.
273 gmx_mtop_generate_local_top(const gmx_mtop_t *mtop,const t_inputrec *ir);
276 /* Converts a gmx_mtop_t struct to t_topology.
277 * All memory relating only to mtop will be freed.
281 gmx_mtop_t_to_t_topology(gmx_mtop_t *mtop);