added Verlet scheme and NxN non-bonded functionality
[gromacs.git] / include / mtop_util.h
blobc43e33512909d1a8f0bfae683665b64775084d63
1 /*
2 *
3 * This source code is part of
4 *
5 * G R O M A C S
6 *
7 * GROningen MAchine for Chemical Simulations
8 *
9 * VERSION 3.2.0
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
32 * And Hey:
33 * Gromacs Runs On Most of All Computer Systems
35 #include "typedefs.h"
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
41 /* Should be called after generating or reading mtop,
42 * to set some compute intesive variables to avoid
43 * N^2 operations later on.
45 void
46 gmx_mtop_finalize(gmx_mtop_t *mtop);
49 /* Returns the total number of charge groups in mtop */
50 int
51 ncg_mtop(const gmx_mtop_t *mtop);
53 /* Removes the charge groups, i.e. makes single atom charge groups, in mtop */
54 void gmx_mtop_remove_chargegroups(gmx_mtop_t *mtop);
57 /* Abstract data type for looking up atoms by global atom number */
58 typedef struct gmx_mtop_atomlookup *gmx_mtop_atomlookup_t;
60 /* Initialize atom lookup by global atom number */
61 gmx_mtop_atomlookup_t
62 gmx_mtop_atomlookup_init(const gmx_mtop_t *mtop);
64 /* As gmx_mtop_atomlookup_init, but optimized for atoms involved in settle */
65 gmx_mtop_atomlookup_t
66 gmx_mtop_atomlookup_settle_init(const gmx_mtop_t *mtop);
68 /* Destroy a gmx_mtop_atomlookup_t data structure */
69 void
70 gmx_mtop_atomlookup_destroy(gmx_mtop_atomlookup_t alook);
73 /* Returns a pointer to the t_atom struct belonging to atnr_global.
74 * This can be an expensive operation, so if possible use
75 * one of the atom loop constructs below.
77 void
78 gmx_mtop_atomnr_to_atom(const gmx_mtop_atomlookup_t alook,
79 int atnr_global,
80 t_atom **atom);
83 /* Returns a pointer to the molecule interaction array ilist_mol[F_NRE]
84 * and the local atom number in the molecule belonging to atnr_global.
86 void
87 gmx_mtop_atomnr_to_ilist(const gmx_mtop_atomlookup_t alook,
88 int atnr_global,
89 t_ilist **ilist_mol,int *atnr_offset);
92 /* Returns the molecule block index
93 * and the molecule number in the block
94 * and the atom number offset for the atom indices in moltype
95 * belonging to atnr_global.
97 void
98 gmx_mtop_atomnr_to_molblock_ind(const gmx_mtop_atomlookup_t alook,
99 int atnr_global,
100 int *molb,int *molnr,int *atnr_mol);
103 /* Returns atom name, global resnr and residue name of atom atnr_global */
104 void
105 gmx_mtop_atominfo_global(const gmx_mtop_t *mtop,int atnr_global,
106 char **atomname,int *resnr,char **resname);
109 /* Abstract type for atom loop over all atoms */
110 typedef struct gmx_mtop_atomloop_all *gmx_mtop_atomloop_all_t;
112 /* Initialize an atom loop over all atoms in the system.
113 * The order of the atoms will be as in the state struct.
114 * Only use this when you really need to loop over all atoms,
115 * i.e. when you use groups which might differ per molecule,
116 * otherwise use gmx_mtop_atomloop_block.
118 gmx_mtop_atomloop_all_t
119 gmx_mtop_atomloop_all_init(const gmx_mtop_t *mtop);
121 /* Loop to the next atom.
122 * When not at the end:
123 * returns TRUE and at_global,
124 * writes the global atom number in *at_global
125 * and sets the pointer atom to the t_atom struct of that atom.
126 * When at the end, destroys aloop and returns FALSE.
127 * Use as:
128 * gmx_mtop_atomloop_all_t aloop;
129 * aloop = gmx_mtop_atomloop_all_init(mtop)
130 * while (gmx_mtop_atomloop_all_next(aloop,&at_global,&atom)) {
131 * ...
134 gmx_bool
135 gmx_mtop_atomloop_all_next(gmx_mtop_atomloop_all_t aloop,
136 int *at_global,t_atom **atom);
138 /* Return the atomname, the residue number and residue name
139 * of the current atom in the loop.
141 void
142 gmx_mtop_atomloop_all_names(gmx_mtop_atomloop_all_t aloop,
143 char **atomname,int *resnr,char **resname);
145 /* Return the a pointer to the moltype struct of the current atom
146 * in the loop and the atom number in the molecule.
148 void
149 gmx_mtop_atomloop_all_moltype(gmx_mtop_atomloop_all_t aloop,
150 gmx_moltype_t **moltype,int *at_mol);
153 /* Abstract type for atom loop over atoms in all molecule blocks */
154 typedef struct gmx_mtop_atomloop_block *gmx_mtop_atomloop_block_t;
156 /* Initialize an atom loop over atoms in all molecule blocks the system.
158 gmx_mtop_atomloop_block_t
159 gmx_mtop_atomloop_block_init(const gmx_mtop_t *mtop);
161 /* Loop to the next atom.
162 * When not at the end:
163 * returns TRUE
164 * sets the pointer atom to the t_atom struct of that atom
165 * and return the number of molecules corresponding to this atom.
166 * When at the end, destroys aloop and returns FALSE.
167 * Use as:
168 * gmx_mtop_atomloop_block_t aloop;
169 * aloop = gmx_mtop_atomloop_block_init(mtop)
170 * while (gmx_mtop_atomloop_block_next(aloop,&atom,&nmol)) {
171 * ...
174 gmx_bool
175 gmx_mtop_atomloop_block_next(gmx_mtop_atomloop_block_t aloop,
176 t_atom **atom,int *nmol);
179 /* Abstract type for ilist loop over all ilists */
180 typedef struct gmx_mtop_ilistloop *gmx_mtop_ilistloop_t;
182 /* Initialize an ilist loop over all molecule types in the system. */
183 gmx_mtop_ilistloop_t
184 gmx_mtop_ilistloop_init(const gmx_mtop_t *mtop);
187 /* Loop to the next molecule,
188 * When not at the end:
189 * returns TRUE and a pointer to the next array ilist_mol[F_NRE],
190 * writes the number of molecules for this ilist in *nmol.
191 * When at the end, destroys iloop and returns FALSE.
193 gmx_bool
194 gmx_mtop_ilistloop_next(gmx_mtop_ilistloop_t iloop,
195 t_ilist **ilist_mol,int *nmol);
198 /* Abstract type for ilist loop over all ilists of all molecules */
199 typedef struct gmx_mtop_ilistloop_all *gmx_mtop_ilistloop_all_t;
201 /* Initialize an ilist loop over all molecule types in the system.
202 * Only use this when you really need to loop over all molecules,
203 * i.e. when you use groups which might differ per molecule,
204 * otherwise use gmx_mtop_ilistloop.
206 gmx_mtop_ilistloop_all_t
207 gmx_mtop_ilistloop_all_init(const gmx_mtop_t *mtop);
209 /* Loop to the next molecule,
210 * When not at the end:
211 * returns TRUE and a pointer to the next array ilist_mol[F_NRE],
212 * writes the atom offset which should be added to iatoms in atnr_offset.
213 * When at the end, destroys iloop and returns FALSE.
215 gmx_bool
216 gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t iloop,
217 t_ilist **ilist_mol,int *atnr_offset);
220 /* Returns the total number of interactions in the system of type ftype */
222 gmx_mtop_ftype_count(const gmx_mtop_t *mtop,int ftype);
225 /* Returns a charge group index for the whole system */
226 t_block
227 gmx_mtop_global_cgs(const gmx_mtop_t *mtop);
230 /* Returns a single t_atoms struct for the whole system */
231 t_atoms
232 gmx_mtop_global_atoms(const gmx_mtop_t *mtop);
235 /* Make all charge groups the size of one atom.
236 * When bKeepSingleMolCG==TRUE keep charge groups for molecules
237 * that consist of a single charge group.
239 void
240 gmx_mtop_make_atomic_charge_groups(gmx_mtop_t *mtop,gmx_bool bKeepSingleMolCG);
243 /* Generate a 'local' topology for the whole system.
244 * When ir!=NULL the free energy interactions will be sorted to the end.
246 gmx_localtop_t *
247 gmx_mtop_generate_local_top(const gmx_mtop_t *mtop,const t_inputrec *ir);
250 /* Converts a gmx_mtop_t struct to t_topology.
251 * All memory relating only to mtop will be freed.
253 t_topology
254 gmx_mtop_t_to_t_topology(gmx_mtop_t *mtop);
256 #ifdef __cplusplus
258 #endif