Partial commit of the project to remove all static variables.
[gromacs.git] / include / random.h
blob5e8a1beef416c966a10c0a3d8982622abbf7e7c6
1 /*
2 * $Id$
3 *
4 * This source code is part of
5 *
6 * G R O M A C S
7 *
8 * GROningen MAchine for Chemical Simulations
9 *
10 * VERSION 3.1
11 * Copyright (c) 1991-2001, University of Groningen, The Netherlands
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * If you want to redistribute modifications, please consider that
18 * scientific software is very special. Version control is crucial -
19 * bugs must be traceable. We will be happy to consider code for
20 * inclusion in the official distribution, but derived work must not
21 * be called official GROMACS. Details are found in the README & COPYING
22 * files - if they are missing, get the official version at www.gromacs.org.
24 * To help us fund GROMACS development, we humbly ask that you cite
25 * the papers on the package - you can find them in the top README file.
27 * For more info, check our website at http://www.gromacs.org
29 * And Hey:
30 * Getting the Right Output Means no Artefacts in Calculating Stuff
33 #ifndef _random_h
34 #define _random_h
36 #ifdef HAVE_CONFIG_H
37 #include <config.h>
38 #endif
40 #include <typedefs.h>
43 typedef struct t_gaussdata *t_Gaussdata;
44 /* Abstract data type for the internal state of
45 * a gaussian random number generator
48 t_Gaussdata init_gauss(int seed);
49 /* Initialize (and warm up) a gaussian random number generator
50 * by copying the seed. The routine returns a handle to the
51 * new generator.
54 real
55 gauss(t_Gaussdata data);
56 /* Return a new gaussian random number with expectation value
57 * 0.0 and standard deviation 1.0. This routine is NOT thread-safe
58 * for performance reasons - you will either have to do the locking
59 * yourself, or better: initialize one generator per thread.
62 void
63 finish_gauss(t_Gaussdata data);
64 /* Release all the resources used for the generator */
69 extern int make_seed(void);
70 /* Make a random seed: (time+getpid) % 1000000 */
72 extern real rando(int *seed);
73 /* Generate a random number 0 <= r < 1. seed is the (address of) the
74 * random seed variable.
77 extern void grp_maxwell(t_block *grp,real tempi[],int nrdf[],int seed,
78 t_atoms *atoms,rvec v[]);
79 /* Generate for each group in grp a temperature.
80 * When seed = -1, set the seed to make_seed.
83 extern void maxwell_speed(real tempi,int nrdf,int seed,
84 t_atoms *atoms, rvec v[]);
85 /* Generate velocites according to a maxwellian distribution */
87 extern real calc_cm(FILE *log,int natoms,real mass[],rvec x[],rvec v[],
88 rvec xcm,rvec vcm,rvec acm,matrix L);
89 /* Calculate the c.o.m. position, velocity, acceleration and the
90 * moment of Inertia. Returns the total mass.
93 extern void stop_cm(FILE *log,int natoms,real mass[],rvec x[],rvec v[]);
95 #endif /* _random_h */