add_subdirectory(fft)
add_subdirectory(linearalgebra)
add_subdirectory(math)
+add_subdirectory(random)
add_subdirectory(onlinehelp)
add_subdirectory(options)
add_subdirectory(timing)
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "vec.h"
#include "macros.h"
#include "index.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "pbc.h"
#include "rmpbc.h"
#include "xvgr.h"
#include "gromacs/statistics/statistics.h"
#include "gstat.h"
#include "index.h"
-#include "random.h"
+#include "gromacs/random/random.h"
#include "names.h"
#include "physics.h"
#include "calcmu.h"
#include "gmx_fatal.h"
#include "vec.h"
#include "physics.h"
-#include "random.h"
#include "gmx_ana.h"
#include "macros.h"
#include "gromacs/fileio/trxio.h"
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "txtdump.h"
#include <math.h>
#include "macros.h"
-#include "random.h"
+#include "gromacs/random/random.h"
#include "gromacs/fileio/futil.h"
#include "atomprop.h"
#include "names.h"
rvec offset_x;
int trial;
double **rpos;
+ gmx_rng_t rng;
+ rng = gmx_rng_init(seed);
set_pbc(&pbc, ePBC, box);
/* read number of atoms of insert molecules */
switch (enum_rot)
{
case en_rotXYZ:
- alfa = 2*M_PI *rando(&seed);
- beta = 2*M_PI *rando(&seed);
- gamma = 2*M_PI *rando(&seed);
+ alfa = 2*M_PI * gmx_rng_uniform_real(rng);
+ beta = 2*M_PI * gmx_rng_uniform_real(rng);
+ gamma = 2*M_PI * gmx_rng_uniform_real(rng);
break;
case en_rotZ:
alfa = beta = 0.;
- gamma = 2*M_PI*rando(&seed);
+ gamma = 2*M_PI * gmx_rng_uniform_real(rng);
break;
case en_rotNone:
alfa = beta = gamma = 0.;
if (posfn == NULL)
{
/* insert at random positions */
- offset_x[XX] = box[XX][XX]*rando(&seed);
- offset_x[YY] = box[YY][YY]*rando(&seed);
- offset_x[ZZ] = box[ZZ][ZZ]*rando(&seed);
+ offset_x[XX] = box[XX][XX] * gmx_rng_uniform_real(rng);
+ offset_x[YY] = box[YY][YY] * gmx_rng_uniform_real(rng);
+ offset_x[ZZ] = box[ZZ][ZZ] * gmx_rng_uniform_real(rng);
gen_box(0, atoms_insrt.nr, x_n, box_insrt, offset_x, TRUE);
if (!in_box(&pbc, x_n[0]) || !in_box(&pbc, x_n[atoms_insrt.nr-1]))
{
else
{
/* Insert at positions taken from option -ip file */
- offset_x[XX] = rpos[XX][mol] + deltaR[XX]*(2*rando(&seed)-1);
- offset_x[YY] = rpos[YY][mol] + deltaR[YY]*(2*rando(&seed)-1);
- offset_x[ZZ] = rpos[ZZ][mol] + deltaR[ZZ]*(2*rando(&seed)-1);
+ offset_x[XX] = rpos[XX][mol] + deltaR[XX]*(2 * gmx_rng_uniform_real(rng)-1);
+ offset_x[YY] = rpos[YY][mol] + deltaR[YY]*(2 * gmx_rng_uniform_real(rng)-1);
+ offset_x[ZZ] = rpos[ZZ][mol] + deltaR[ZZ]*(2 * gmx_rng_uniform_real(rng)-1);
for (i = 0; i < atoms_insrt.nr; i++)
{
rvec_inc(x_n[i], offset_x);
fprintf(stderr, " success (now %d atoms)!\n", atoms->nr);
}
}
+ gmx_rng_destroy(rng);
srenew(atoms->resinfo, atoms->nres);
srenew(atoms->atomname, atoms->nr);
srenew(atoms->atom, atoms->nr);
#include "gromacs/fileio/confio.h"
#include "gromacs/commandline/pargs.h"
#include "vec.h"
-#include "random.h"
+#include "gromacs/random/random.h"
#include "gromacs/math/3dview.h"
#include "txtdump.h"
#include "readinp.h"
#include "gromacs/fileio/trxio.h"
static void rand_rot(int natoms, rvec x[], rvec v[], vec4 xrot[], vec4 vrot[],
- int *seed, rvec max_rot)
+ gmx_rng_t rng, rvec max_rot)
{
mat4 mt1, mt2, mr[DIM], mtemp1, mtemp2, mtemp3, mxtot, mvtot;
rvec xcm;
translate(-xcm[XX], -xcm[YY], -xcm[ZZ], mt1); /* move c.o.ma to origin */
for (m = 0; (m < DIM); m++)
{
- phi = M_PI*max_rot[m]*(2*rando(seed) - 1)/180;
+ phi = M_PI*max_rot[m]*(2*gmx_rng_uniform_real(rng) - 1)/180;
rotate(m, phi, mr[m]);
}
translate(xcm[XX], xcm[YY], xcm[ZZ], mt2);
t_trxstatus *status;
gmx_bool bTRX;
output_env_t oenv;
+ gmx_rng_t rng;
t_filenm fnm[] = {
{ efSTX, "-f", "conf", ffREAD },
return 0;
}
- if (bRandom && (seed == 0))
+ if (seed == 0)
{
- seed = make_seed();
+ rng = gmx_rng_init(gmx_rng_make_seed());
+ }
+ else
+ {
+ rng = gmx_rng_init(seed);
}
bTRX = ftp2bSet(efTRX, NFILE, fnm);
/* Random rotation on input coords */
if (bRandom)
{
- rand_rot(natoms, xx, v, xrot, vrot, &seed, max_rot);
+ rand_rot(natoms, xx, v, xrot, vrot, rng, max_rot);
}
for (l = 0; (l < natoms); l++)
if (bShuffle)
{
- randwater(0, atoms->nr/nmolat, nmolat, x, v, &seed);
+ randwater(0, atoms->nr/nmolat, nmolat, x, v, rng);
}
else if (bSort)
{
{
mkcompact(0, atoms->nr/nmolat, nmolat, x, v, nblock, box);
}
+ gmx_rng_destroy(rng);
write_sto_conf(opt2fn("-o", NFILE, fnm), title, atoms, x, v, ePBC, box);
#include "gromacs/fileio/tpxio.h"
#include "mdrun.h"
#include "main.h"
-#include "random.h"
+#include "gromacs/random/random.h"
#include "index.h"
#include "mtop_util.h"
#include "gmx_ana.h"
rvec x[], t_pbc *pbc,
int sign, int q, const char *ionname,
t_atoms *atoms,
- real rmin, int *seed)
+ real rmin, gmx_rng_t rng)
{
int i, ei, nw;
real rmin2;
do
{
- ei = nw*rando(seed);
+ ei = nw*gmx_rng_uniform_real(rng);
maxrand--;
}
while (bSet[ei] && (maxrand > 0));
gmx_bool *bSet;
int i, nw, nwa, nsa, nsalt, iqtot;
output_env_t oenv;
+ gmx_rng_t rng;
t_filenm fnm[] = {
{ efTPX, NULL, NULL, ffREAD },
{ efNDX, NULL, NULL, ffOPTRD },
set_pbc(&pbc, ePBC, box);
+ if (seed == 0)
+ {
+ rng = gmx_rng_init(gmx_rng_make_seed());
+ }
+ else
+ {
+ rng = gmx_rng_init(seed);
+ }
/* Now loop over the ions that have to be placed */
while (p_num-- > 0)
{
insert_ion(nsa, &nw, bSet, repl, index, x, &pbc,
- 1, p_q, p_name, &atoms, rmin, &seed);
+ 1, p_q, p_name, &atoms, rmin, rng);
}
while (n_num-- > 0)
{
insert_ion(nsa, &nw, bSet, repl, index, x, &pbc,
- -1, n_q, n_name, &atoms, rmin, &seed);
+ -1, n_q, n_name, &atoms, rmin, rng);
}
+ gmx_rng_destroy(rng);
fprintf(stderr, "\n");
if (nw)
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/fileio/trxio.h"
#include "txtdump.h"
#include "physics.h"
-#include "random.h"
+#include "gromacs/random/random.h"
#include "eigio.h"
#include "gmx_ana.h"
real rfac, invfr, rhalf, jr;
int * eigvalnr;
output_env_t oenv;
-
+ gmx_rng_t rng;
unsigned long jran;
const unsigned long im = 0xffff;
const unsigned long ia = 1093;
if (seed == -1)
{
- seed = make_seed();
+ seed = (int)gmx_rng_make_seed();
+ rng = gmx_rng_init(seed);
+ }
+ else
+ {
+ rng = gmx_rng_init(seed);
}
fprintf(stderr, "Using seed %d and a temperature of %g K\n", seed, temp);
snew(xout1, natoms);
snew(xout2, atoms->nr);
out = open_trx(ftp2fn(efTRO, NFILE, fnm), "w");
- jran = (unsigned long)((real)im*rando(&seed));
+ jran = (unsigned long)((real)im*gmx_rng_uniform_real(rng));
+ gmx_rng_destroy(rng);
for (s = 0; s < nstruct; s++)
{
for (i = 0; i < natoms; i++)
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gromacs/fileio/trxio.h"
#include "txtdump.h"
#include "physics.h"
-#include "random.h"
#include "eigio.h"
#include "gmx_ana.h"
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "calcgrid.h"
#include "checkpoint.h"
#include "gmx_ana.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "physics.h"
#include "mdatoms.h"
#include "coulomb.h"
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "copyrite.h"
#include "gromacs/fileio/tpxio.h"
#include "names.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "gmx_ana.h"
#include "macros.h"
* \name Using umbrella pull code since gromacs 4.x
*/
/*!\{*/
- int npullcrds; //!< nr of pull coordinates in tpr file
- int pull_geometry; //!< such as distance, direction
- ivec pull_dim; //!< pull dimension with geometry distance
- int pull_ndim; //!< nr of pull_dim != 0
- gmx_bool bPrintRef; //!< Coordinates of reference groups written to pullx.xvg ?
- real *k; //!< force constants in tpr file
- real *init_dist; //!< reference displacements
- real *umbInitDist; //!< reference displacement in umbrella direction
+ int npullcrds; //!< nr of pull coordinates in tpr file
+ int pull_geometry; //!< such as distance, direction
+ ivec pull_dim; //!< pull dimension with geometry distance
+ int pull_ndim; //!< nr of pull_dim != 0
+ gmx_bool bPrintRef; //!< Coordinates of reference groups written to pullx.xvg ?
+ real *k; //!< force constants in tpr file
+ real *init_dist; //!< reference displacements
+ real *umbInitDist; //!< reference displacement in umbrella direction
/*!\}*/
/*!
* \name Using PDO files common until gromacs 3.x
#include "smalloc.h"
#include "string2.h"
#include "typedefs.h"
-#include "random.h"
#include "bondf.h"
#include "gromacs/fileio/futil.h"
#include "gmx_fatal.h"
#include <ctype.h>
#include <string.h>
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "smalloc.h"
#include "sysstuff.h"
#include "vec.h"
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#endif
#include "typedefs.h"
-#include "random.h"
+#include "gromacs/random/random.h"
#include "smalloc.h"
#include "vec.h"
#include "sortwater.h"
static matrix BOX;
static ivec NBOX;
-void randwater(int astart, int nwater, int nwatom, rvec x[], rvec v[], int *seed)
+void randwater(int astart, int nwater, int nwatom, rvec x[], rvec v[],
+ gmx_rng_t rng)
{
int i, j, wi, wj, *tab;
rvec buf;
}
for (j = 0; (j < 23*nwater); j++)
{
- wi = (int) (nwater*rando(seed)) % nwater;
+ wi = (int) (nwater*gmx_rng_uniform_real(rng)) % nwater;
do
{
- wj = (int) (nwater*rando(seed)) % nwater;
+ wj = (int) (nwater*gmx_rng_uniform_real(rng)) % nwater;
}
while (wi == wj);
wi = astart+wi*nwatom;
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2010, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#define _sortwater_h
#include "typedefs.h"
+#include "gromacs/random/random.h"
#ifdef __cplusplus
extern "C" {
#endif
void randwater(int astart, int nwater, int nwatom,
- rvec x[], rvec v[], int *seed);
+ rvec x[], rvec v[], gmx_rng_t rng);
/* Randomize the order of nwater molecules of length nwatom, the
* first atom of which is at astart.
* If v is not NULL it will be shuffled along
#include "txtdump.h"
#include "vec.h"
#include "network.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "checkpoint.h"
#include "main.h"
#include "string2.h"
/* This file is completely threadsafe - keep it that way! */
#include "gromacs/legacyheaders/macros.h"
-#include "gromacs/legacyheaders/random.h"
+#include "gromacs/random/random.h"
#include "gromacs/legacyheaders/smalloc.h"
#include "gromacs/legacyheaders/string2.h"
#include "gromacs/legacyheaders/vec.h"
static void pukeit(const char *db, const char *defstring, char *retstring,
int retsize, int *cqnum)
{
- FILE *fp;
- char **help;
- int i, nhlp;
- int seed;
+ FILE *fp;
+ char **help;
+ int i, nhlp;
+ gmx_rng_t rng;
if (be_cool() && ((fp = low_libopen(db, FALSE)) != NULL))
{
nhlp = fget_lines(fp, &help);
/* for libraries we can use the low-level close routines */
ffclose(fp);
- seed = time(NULL);
- *cqnum = static_cast<int>(nhlp*rando(&seed));
+ rng = gmx_rng_init(gmx_rng_make_seed());
+ *cqnum = static_cast<int>(nhlp*gmx_rng_uniform_real(rng));
+ gmx_rng_destroy(rng);
if (strlen(help[*cqnum]) >= STRLEN)
{
help[*cqnum][STRLEN-1] = '\0';
+++ /dev/null
-/*
- * This file is part of the GROMACS molecular simulation package.
- *
- * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012, by the GROMACS development team, led by
- * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
- * and including many others, as listed in the AUTHORS file in the
- * top-level source directory and at http://www.gromacs.org.
- *
- * GROMACS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * GROMACS is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with GROMACS; if not, see
- * http://www.gnu.org/licenses, or write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * If you want to redistribute modifications to GROMACS, please
- * consider that scientific software is very special. Version
- * control is crucial - bugs must be traceable. We will be happy to
- * consider code for inclusion in the official distribution, but
- * derived work must not be called official GROMACS. Details are found
- * in the README & COPYING files - if they are missing, get the
- * official version at http://www.gromacs.org.
- *
- * To help us fund GROMACS development, we humbly ask that you cite
- * the research papers on the package. Check out http://www.gromacs.org.
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <time.h>
-#ifdef GMX_NATIVE_WINDOWS
-#include <process.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include "sysstuff.h"
-#include "typedefs.h"
-#include "random.h"
-
-int make_seed(void)
-{
-#ifdef GMX_NATIVE_WINDOWS
- return (int)_getpid();
-#else
- return (int)getpid();
-#endif
-}
-
-real rando(int *ig)
-/* generate a random number. */
-{
- int irand;
-
- int m = 100000000;
- real rm = 100000000.0; /* same number as m, but real format */
- int m1 = 10000;
- int mult = 31415821;
-
- real r;
- int irandh, irandl, multh, multl;
-
- irand = abs(*ig) % m;
-
- /* multiply irand by mult, but take into account that overflow
- * must be discarded, and do not generate an error.
- */
- irandh = irand / m1;
- irandl = irand % m1;
- multh = mult / m1;
- multl = mult % m1;
- irand = ((irandh*multl+irandl*multh) % m1) * m1 + irandl*multl;
- irand = (irand + 1) % m;
-
- /* convert irand to a real random number between 0 and 1. */
- r = (irand / 10);
- r = r * 10 / rm;
- if ((r <= 0) || (r > 1))
- {
- r = 0.0;
- }
- *ig = irand;
-
- return r;
-}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#endif
#include <math.h>
+#include "gromacs/random/random.h"
#include "sysstuff.h"
#include "smalloc.h"
#include "physics.h"
#include "typedefs.h"
#include "vec.h"
-#include "gmx_random.h"
-#include "random.h"
+#include "gen_maxwell_velocities.h"
#include "mtop_util.h"
static void low_mspeed(real tempi,
}
}
-void maxwell_speed(real tempi, int seed, gmx_mtop_t *mtop, rvec v[])
+void maxwell_speed(real tempi, unsigned int seed, gmx_mtop_t *mtop, rvec v[])
{
atom_id *dummy;
int i;
gmx_rng_t rng;
- if (seed == -1)
+ if (seed == 0)
{
- seed = make_seed();
+ seed = gmx_rng_make_seed();
fprintf(stderr, "Using random seed %d for generating velocities\n", seed);
}
gmx_rng_destroy(rng);
}
-real calc_cm(int natoms, real mass[], rvec x[], rvec v[],
- rvec xcm, rvec vcm, rvec acm, matrix L)
+static real calc_cm(int natoms, real mass[], rvec x[], rvec v[],
+ rvec xcm, rvec vcm, rvec acm, matrix L)
{
rvec dx, a0;
real tm, m0;
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* the research papers on the package. Check out http://www.gromacs.org.
*/
-#ifndef _random_h
-#define _random_h
+#ifndef GMX_MAXWELL_VELOCITIES
+#define GMX_MAXWELL_VELOCITIES
#include "typedefs.h"
extern "C" {
#endif
-int make_seed(void);
-/* Make a random seed: (time+getpid) % 1000000 */
-
-real rando(int *seed);
-/* Generate a random number 0 <= r < 1. seed is the (address of) the
- * random seed variable.
+/*! \brief
+ * Generate Maxwellian velocities.
+ *
+ * \param[in] tempi Temperature to generate around
+ * \param[in] seed Random number generator seed
+ * \param[in] mtop Molecular Topology
+ * \param[out] v Velocities
*/
-
-void maxwell_speed(real tempi, int seed,
+void maxwell_speed(real tempi, unsigned int seed,
gmx_mtop_t *mtop, rvec v[]);
-/* Generate velocites according to a maxwellian distribution */
-real calc_cm(int natoms, real mass[], rvec x[], rvec v[],
- rvec xcm, rvec vcm, rvec acm, matrix L);
-/* Calculate the c.o.m. position, velocity, acceleration and the
- * moment of Inertia. Returns the total mass.
+/*! \brief
+ * Remove the center of mass motion in a set of coordinates.
+ *
+ * \param[out] log File for printing debug information
+ * \param[in] natoms Number of atoms
+ * \param[in] mass Atomic masses
+ * \param[in] x Coordinates
+ * \param[out] v Velocities
*/
-
void stop_cm(FILE *log, int natoms, real mass[], rvec x[], rvec v[]);
#ifdef __cplusplus
}
#endif
-#endif /* _random_h */
+#endif
#include "symtab.h"
#include "names.h"
#include "grompp-impl.h"
-#include "random.h"
+#include "gromacs/random/random.h"
+#include "gromacs/gmxpreprocess/gen_maxwell_velocities.h"
#include "vec.h"
#include "gromacs/fileio/futil.h"
#include "gromacs/commandline/pargs.h"
#include "splitter.h"
-#include "sortwater.h"
+#include "gromacs/gmxana/sortwater.h"
#include "convparm.h"
#include "gmx_fatal.h"
#include "warninp.h"
real *mass;
gmx_mtop_atomloop_all_t aloop;
t_atom *atom;
+ unsigned int useed;
snew(mass, state->natoms);
aloop = gmx_mtop_atomloop_all_init(sys);
mass[i] = atom->m;
}
+ useed = opts->seed;
if (opts->seed == -1)
{
- opts->seed = make_seed();
- fprintf(stderr, "Setting gen_seed to %d\n", opts->seed);
+ useed = (int)gmx_rng_make_seed();
+ fprintf(stderr, "Setting gen_seed to %u\n", useed);
}
- maxwell_speed(opts->tempi, opts->seed, sys, state->v);
+ maxwell_speed(opts->tempi, useed, sys, state->v);
stop_cm(stdout, state->natoms, mass, state->x, state->v);
sfree(mass);
gmx_bool bVerbose = FALSE;
warninp_t wi;
char warn_buf[STRLEN];
+ unsigned int useed;
t_filenm fnm[] = {
{ efMDP, NULL, NULL, ffREAD },
if (ir->ld_seed == -1)
{
- ir->ld_seed = make_seed();
+ ir->ld_seed = (int)gmx_rng_make_seed();
fprintf(stderr, "Setting the LD random seed to %d\n", ir->ld_seed);
}
if (ir->expandedvals->lmc_seed == -1)
{
- ir->expandedvals->lmc_seed = make_seed();
+ ir->expandedvals->lmc_seed = (int)gmx_rng_make_seed();
fprintf(stderr, "Setting the lambda MC random seed to %d\n", ir->expandedvals->lmc_seed);
}
#include "gromacs/fileio/confio.h"
#include "physics.h"
#include "vec.h"
-#include "random.h"
#include "gromacs/math/3dview.h"
#include "txtdump.h"
#include "readinp.h"
#include "physics.h"
#include "gromacs/commandline/pargs.h"
#include "vec.h"
-#include "random.h"
#include "gromacs/math/3dview.h"
#include "txtdump.h"
#include "readinp.h"
#include "mshift.h"
#include "tgroup.h"
#include "network.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "vec.h"
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "gmx_fatal.h"
#include "txtdump.h"
#include "nrnb.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "update.h"
#include "mdrun.h"
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2006,2007,2008,2009,2010,2011,2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2006,2007,2008,2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "vec.h"
#include "pbc.h"
#include "chargegroup.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "gromacs/gmxlib/topsort.h"
#include "mtop_util.h"
#include "mshift.h"
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "calcmu.h"
#include "constr.h"
#include "xvgr.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "domdec.h"
#include "partdec.h"
#include "macros.h"
#include "mdrun.h"
#include "names.h"
#include "calcgrid.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "update.h"
#include "mdebin.h"
#include "main.h"
#include "force.h"
#include "macros.h"
-#include "random.h"
+#include "gromacs/random/random.h"
#include "names.h"
#include "gmx_fatal.h"
#include "txtdump.h"
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "ns.h"
#include "partdec.h"
#include "splitter.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "mtop_util.h"
#include "mvdata.h"
#include "vec.h"
#include "constr.h"
#include "xvgr.h"
#include "copyrite.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "domdec.h"
#include "partdec.h"
#include "genborn.h"
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "chargegroup.h"
#include "force.h"
#include "macros.h"
-#include "random.h"
#include "names.h"
#include "gmx_fatal.h"
#include "txtdump.h"
#include "typedefs.h"
#include "update.h"
-#include "random.h"
#include "constr.h"
#include "vec.h"
#include "tgroup.h"
#include "mdrun.h"
#include "domdec.h"
#include "partdec.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "physics.h"
#include "xvgr.h"
#include "mdatoms.h"
#include "vec.h"
#include "main.h"
#include "update.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "mshift.h"
#include "tgroup.h"
#include "force.h"
--- /dev/null
+#
+# This file is part of the GROMACS molecular simulation package.
+#
+# Copyright (c) 2014, by the GROMACS development team, led by
+# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+# and including many others, as listed in the AUTHORS file in the
+# top-level source directory and at http://www.gromacs.org.
+#
+# GROMACS is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; either version 2.1
+# of the License, or (at your option) any later version.
+#
+# GROMACS is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with GROMACS; if not, see
+# http://www.gnu.org/licenses, or write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# If you want to redistribute modifications to GROMACS, please
+# consider that scientific software is very special. Version
+# control is crucial - bugs must be traceable. We will be happy to
+# consider code for inclusion in the official distribution, but
+# derived work must not be called official GROMACS. Details are found
+# in the README & COPYING files - if they are missing, get the
+# official version at http://www.gromacs.org.
+#
+# To help us fund GROMACS development, we humbly ask that you cite
+# the research papers on the package. Check out http://www.gromacs.org.
+
+file(GLOB RANDOM_SOURCES *.c)
+set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${RANDOM_SOURCES} PARENT_SCOPE)
#include <config.h>
#endif
-#include "gmx_random.h"
+#include "random.h"
#include <stdio.h>
#include <stdlib.h>
#endif
#include "gromacs/math/utilities.h"
-#include "gmx_random_gausstable.h"
+#include "random_gausstable.h"
#define RNG_N 624
#define RNG_M 397
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2008, The GROMACS development team.
- * Copyright (c) 2010, by the GROMACS development team, led by
+ * Copyright (c) 2010,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2004, by the GROMACS development team, led by
+ * Copyright (c) 2004,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include <set>
#include <vector>
-#include "gromacs/legacyheaders/gmx_random.h"
+#include "gromacs/random/random.h"
#include "gromacs/legacyheaders/pbc.h"
#include "gromacs/legacyheaders/smalloc.h"
#include "gromacs/legacyheaders/vec.h"
#include "typedefs.h"
#include "smalloc.h"
#include "vec.h"
-#include "gmx_random.h"
+#include "gromacs/random/random.h"
#include "statistics.h"
static void horizontal()
#include "gromacs/commandline/pargs.h"
#include "vec.h"
#include "mtop_util.h"
-#include "random.h"
+#include "gromacs/random/random.h"
#include "checkpoint.h"
#include "gromacs/fileio/tpxio.h"
#include "gromacs/fileio/trnio.h"
if (EI_SD(ir->eI) || ir->eI == eiBD)
{
fprintf(stderr, "\nChanging ld-seed from %d ", ir->ld_seed);
- ir->ld_seed = make_seed();
+ ir->ld_seed = (int)gmx_rng_make_seed();
fprintf(stderr, "to %d\n\n", ir->ld_seed);
}
#include "gromacs/legacyheaders/atomprop.h"
#include "gromacs/legacyheaders/copyrite.h"
-#include "gromacs/legacyheaders/gmx_random.h"
+#include "gromacs/random/random.h"
#include "gromacs/legacyheaders/pbc.h"
#include "gromacs/legacyheaders/vec.h"
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2011,2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include <math.h>
#include "repl_ex.h"
#include "network.h"
-#include "random.h"
+#include "gromacs/random/random.h"
#include "smalloc.h"
#include "physics.h"
#include "copyrite.h"
typedef struct gmx_repl_ex
{
- int repl;
- int nrepl;
- real temp;
- int type;
- real **q;
- gmx_bool bNPT;
- real *pres;
- int *ind;
- int *allswaps;
- int nst;
- int nex;
- int seed;
- int nattempt[2];
- real *prob_sum;
- int **nmoves;
- int *nexchange;
+ int repl;
+ int nrepl;
+ real temp;
+ int type;
+ real **q;
+ gmx_bool bNPT;
+ real *pres;
+ int *ind;
+ int *allswaps;
+ int nst;
+ int nex;
+ int seed;
+ int nattempt[2];
+ real *prob_sum;
+ int **nmoves;
+ int *nexchange;
+ gmx_rng_t rng;
/* these are helper arrays for replica exchange; allocated here so they
don't have to be allocated each time */
{
if (MASTERSIM(ms))
{
- re->seed = make_seed();
+ re->seed = (int)gmx_rng_make_seed();
}
else
{
}
fprintf(fplog, "\nReplica exchange interval: %d\n", re->nst);
fprintf(fplog, "\nReplica random seed: %d\n", re->seed);
+ re->rng = gmx_rng_init(re->seed);
re->nattempt[0] = 0;
re->nattempt[1] = 0;
gmx_bool bEpot = FALSE;
gmx_bool bDLambda = FALSE;
gmx_bool bVol = FALSE;
+ gmx_rng_t rng;
bMultiEx = (re->nex > 1); /* multiple exchanges at each state */
fprintf(fplog, "Replica exchange at step " "%"GMX_PRId64 " time %g\n", step, time);
probability of occurring (log p > -100) and only operate on those switches */
/* find out which state it is from, and what label that state currently has. Likely
more work that useful. */
- i0 = (int)(re->nrepl*rando(&(re->seed)));
- i1 = (int)(re->nrepl*rando(&(re->seed)));
+ i0 = (int)(re->nrepl*gmx_rng_uniform_real(re->rng));
+ i1 = (int)(re->nrepl*gmx_rng_uniform_real(re->rng));
if (i0 == i1)
{
i--;
prob[0] = exp(-delta);
}
/* roll a number to determine if accepted */
- bEx[0] = (rando(&(re->seed)) < prob[0]);
+ bEx[0] = (gmx_rng_uniform_real(re->rng) < prob[0]);
}
re->prob_sum[0] += prob[0];
prob[i] = exp(-delta);
}
/* roll a number to determine if accepted */
- bEx[i] = (rando(&(re->seed)) < prob[i]);
+ bEx[i] = (gmx_rng_uniform_real(re->rng) < prob[i]);
}
re->prob_sum[i] += prob[i];