minor fixes in ditribution files
[gromacs/qmmm-gamess-us.git] / include / mtop_util.h
blobc11505fcc988bea892543aac1c5bf4c1c82cea2d
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 #ifdef HAVE_CONFIG_H
36 #include <config.h>
37 #endif
39 #include "typedefs.h"
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
45 /* Should be called after generating or reading mtop,
46 * to set some compute intesive variables to avoid
47 * N^2 operations later on.
49 extern void
50 gmx_mtop_finalize(gmx_mtop_t *mtop);
53 /* Returns the total number of charge groups in mtop */
54 extern int
55 ncg_mtop(const gmx_mtop_t *mtop);
58 /* Returns a pointer to the t_atom struct belonging to atnr_global.
59 * This can be an expensive operation, so if possible use
60 * one of the atom loop constructs below.
62 extern void
63 gmx_mtop_atomnr_to_atom(const gmx_mtop_t *mtop,int atnr_global,
64 t_atom **atom);
67 /* Returns a pointer to the molecule interaction array ilist_mol[F_NRE]
68 * and the local atom number in the molecule belonging to atnr_global.
70 extern void
71 gmx_mtop_atomnr_to_ilist(const gmx_mtop_t *mtop,int atnr_global,
72 t_ilist **ilist_mol,int *atnr_offset);
75 /* Returns the molecule block index
76 * and the molecule number in the block
77 * and the atom number offset for the atom indices in moltype
78 * belonging to atnr_global.
80 extern void
81 gmx_mtop_atomnr_to_molblock_ind(const gmx_mtop_t *mtop,int atnr_global,
82 int *molb,int *molnr,int *atnr_mol);
85 /* Returns atom name, global resnr and residue name of atom atnr_global */
86 extern void
87 gmx_mtop_atominfo_global(const gmx_mtop_t *mtop,int atnr_global,
88 char **atomname,int *resnr,char **resname);
91 /* Abstract type for atom loop over all atoms */
92 typedef struct gmx_mtop_atomloop_all *gmx_mtop_atomloop_all_t;
94 /* Initialize an atom loop over all atoms in the system.
95 * The order of the atoms will be as in the state struct.
96 * Only use this when you really need to loop over all atoms,
97 * i.e. when you use groups which might differ per molecule,
98 * otherwise use gmx_mtop_atomloop_block.
100 extern gmx_mtop_atomloop_all_t
101 gmx_mtop_atomloop_all_init(const gmx_mtop_t *mtop);
103 /* Loop to the next atom.
104 * When not at the end:
105 * returns TRUE and at_global,
106 * writes the global atom number in *at_global
107 * and sets the pointer atom to the t_atom struct of that atom.
108 * When at the end, destroys aloop and returns FALSE.
109 * Use as:
110 * gmx_mtop_atomloop_all_t aloop;
111 * aloop = gmx_mtop_atomloop_all_init(mtop)
112 * while (gmx_mtop_atomloop_all_next(aloop,&at_global,&atom)) {
113 * ...
116 extern bool
117 gmx_mtop_atomloop_all_next(gmx_mtop_atomloop_all_t aloop,
118 int *at_global,t_atom **atom);
120 /* Return the atomname, the residue number and residue name
121 * of the current atom in the loop.
123 extern void
124 gmx_mtop_atomloop_all_names(gmx_mtop_atomloop_all_t aloop,
125 char **atomname,int *resnr,char **resname);
127 /* Return the a pointer to the moltype struct of the current atom
128 * in the loop and the atom number in the molecule.
130 extern void
131 gmx_mtop_atomloop_all_moltype(gmx_mtop_atomloop_all_t aloop,
132 gmx_moltype_t **moltype,int *at_mol);
135 /* Abstract type for atom loop over atoms in all molecule blocks */
136 typedef struct gmx_mtop_atomloop_block *gmx_mtop_atomloop_block_t;
138 /* Initialize an atom loop over atoms in all molecule blocks the system.
140 extern gmx_mtop_atomloop_block_t
141 gmx_mtop_atomloop_block_init(const gmx_mtop_t *mtop);
143 /* Loop to the next atom.
144 * When not at the end:
145 * returns TRUE
146 * sets the pointer atom to the t_atom struct of that atom
147 * and return the number of molecules corresponding to this atom.
148 * When at the end, destroys aloop and returns FALSE.
149 * Use as:
150 * gmx_mtop_atomloop_block_t aloop;
151 * aloop = gmx_mtop_atomloop_block_init(mtop)
152 * while (gmx_mtop_atomloop_block_next(aloop,&atom,&nmol)) {
153 * ...
156 extern bool
157 gmx_mtop_atomloop_block_next(gmx_mtop_atomloop_block_t aloop,
158 t_atom **atom,int *nmol);
161 /* Abstract type for ilist loop over all ilists */
162 typedef struct gmx_mtop_ilistloop *gmx_mtop_ilistloop_t;
164 /* Initialize an ilist loop over all molecule types in the system. */
165 extern gmx_mtop_ilistloop_t
166 gmx_mtop_ilistloop_init(const gmx_mtop_t *mtop);
169 /* Loop to the next molecule,
170 * When not at the end:
171 * returns TRUE and a pointer to the next array ilist_mol[F_NRE],
172 * writes the number of molecules for this ilist in *nmol.
173 * When at the end, destroys iloop and returns FALSE.
175 extern bool
176 gmx_mtop_ilistloop_next(gmx_mtop_ilistloop_t iloop,
177 t_ilist **ilist_mol,int *nmol);
180 /* Abstract type for ilist loop over all ilists of all molecules */
181 typedef struct gmx_mtop_ilistloop_all *gmx_mtop_ilistloop_all_t;
183 /* Initialize an ilist loop over all molecule types in the system.
184 * Only use this when you really need to loop over all molecules,
185 * i.e. when you use groups which might differ per molecule,
186 * otherwise use gmx_mtop_ilistloop.
188 extern gmx_mtop_ilistloop_all_t
189 gmx_mtop_ilistloop_all_init(const gmx_mtop_t *mtop);
191 /* Loop to the next molecule,
192 * When not at the end:
193 * returns TRUE and a pointer to the next array ilist_mol[F_NRE],
194 * writes the atom offset which should be added to iatoms in atnr_offset.
195 * When at the end, destroys iloop and returns FALSE.
197 extern bool
198 gmx_mtop_ilistloop_all_next(gmx_mtop_ilistloop_all_t iloop,
199 t_ilist **ilist_mol,int *atnr_offset);
202 /* Returns the total number of interactions in the system of type ftype */
203 extern int
204 gmx_mtop_ftype_count(const gmx_mtop_t *mtop,int ftype);
207 /* Returns a charge group index for the whole system */
208 extern t_block
209 gmx_mtop_global_cgs(const gmx_mtop_t *mtop);
212 /* Returns a single t_atoms struct for the whole system */
213 extern t_atoms
214 gmx_mtop_global_atoms(const gmx_mtop_t *mtop);
217 /* Make all charge groups the size of one atom.
218 * When bKeepSingleMolCG==TRUE keep charge groups for molecules
219 * that consist of a single charge group.
221 extern void
222 gmx_mtop_make_atomic_charge_groups(gmx_mtop_t *mtop,bool bKeepSingleMolCG);
225 /* Generate a 'local' topology for the whole system.
226 * When ir!=NULL the free energy interactions will be sorted to the end.
228 extern gmx_localtop_t *
229 gmx_mtop_generate_local_top(const gmx_mtop_t *mtop,const t_inputrec *ir);
232 /* Converts a gmx_mtop_t struct to t_topology.
233 * All memory relating only to mtop will be freed.
235 extern t_topology
236 gmx_mtop_t_to_t_topology(gmx_mtop_t *mtop);
238 #ifdef __cplusplus
240 #endif