#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/smalloc.h"
-static void low_mspeed(real tempi,
- gmx_mtop_t *mtop, rvec v[], gmx::ThreeFry2x64<> * rng)
+static void low_mspeed(real tempi, gmx_mtop_t* mtop, rvec v[], gmx::ThreeFry2x64<>* rng)
{
- int nrdf;
- real boltz;
- real ekin, temp;
- gmx::TabulatedNormalDistribution<real> normalDist;
+ int nrdf;
+ real boltz;
+ real ekin, temp;
+ gmx::TabulatedNormalDistribution<real> normalDist;
- boltz = BOLTZ*tempi;
+ boltz = BOLTZ * tempi;
ekin = 0.0;
nrdf = 0;
for (const AtomProxy atomP : AtomRange(*mtop))
{
- const t_atom &local = atomP.atom();
+ const t_atom& local = atomP.atom();
int i = atomP.globalAtomNumber();
real mass = local.m;
if (mass > 0)
{
rng->restart(i, 0);
- real sd = std::sqrt(boltz/mass);
+ real sd = std::sqrt(boltz / mass);
for (int m = 0; (m < DIM); m++)
{
- v[i][m] = sd*normalDist(*rng);
- ekin += 0.5*mass*v[i][m]*v[i][m];
+ v[i][m] = sd * normalDist(*rng);
+ ekin += 0.5 * mass * v[i][m] * v[i][m];
}
nrdf += DIM;
}
}
- temp = (2.0*ekin)/(nrdf*BOLTZ);
+ temp = (2.0 * ekin) / (nrdf * BOLTZ);
if (temp > 0)
{
- real scal = std::sqrt(tempi/temp);
+ real scal = std::sqrt(tempi / temp);
for (int i = 0; (i < mtop->natoms); i++)
{
for (int m = 0; (m < DIM); m++)
}
}
}
- fprintf(stderr, "Velocities were taken from a Maxwell distribution at %g K\n",
- tempi);
+ fprintf(stderr, "Velocities were taken from a Maxwell distribution at %g K\n", tempi);
if (debug)
{
fprintf(debug,
}
}
-void maxwell_speed(real tempi, unsigned int seed, gmx_mtop_t *mtop, rvec v[])
+void maxwell_speed(real tempi, unsigned int seed, gmx_mtop_t* mtop, rvec v[])
{
if (seed == 0)
seed = static_cast<int>(gmx::makeRandomSeed());
fprintf(stderr, "Using random seed %u for generating velocities\n", seed);
}
- gmx::ThreeFry2x64<> rng(seed, gmx::RandomDomain::MaxwellVelocities);
+ gmx::ThreeFry2x64<> rng(seed, gmx::RandomDomain::MaxwellVelocities);
low_mspeed(tempi, mtop, v, &rng);
}
-static real calc_cm(int natoms, const real mass[], rvec x[], rvec v[],
- rvec xcm, rvec vcm, rvec acm, matrix L)
+static real calc_cm(int natoms, const real mass[], rvec x[], rvec v[], rvec xcm, rvec vcm, rvec acm, matrix L)
{
rvec dx, a0;
real tm, m0;
tm = 0.0;
for (i = 0; (i < natoms); i++)
{
- m0 = mass[i];
+ m0 = mass[i];
tm += m0;
cprod(x[i], v[i], a0);
for (m = 0; (m < DIM); m++)
{
- xcm[m] += m0*x[i][m]; /* c.o.m. position */
- vcm[m] += m0*v[i][m]; /* c.o.m. velocity */
- acm[m] += m0*a0[m]; /* rotational velocity around c.o.m. */
+ xcm[m] += m0 * x[i][m]; /* c.o.m. position */
+ vcm[m] += m0 * v[i][m]; /* c.o.m. velocity */
+ acm[m] += m0 * a0[m]; /* rotational velocity around c.o.m. */
}
}
cprod(xcm, vcm, a0);
{
xcm[m] /= tm;
vcm[m] /= tm;
- acm[m] -= a0[m]/tm;
+ acm[m] -= a0[m] / tm;
}
-#define PVEC(str, v) fprintf(log, \
- "%s[X]: %10.5e %s[Y]: %10.5e %s[Z]: %10.5e\n", \
- str, (v)[0], str, (v)[1], str, (v)[2])
+#define PVEC(str, v) \
+ fprintf(log, "%s[X]: %10.5e %s[Y]: %10.5e %s[Z]: %10.5e\n", str, (v)[0], str, (v)[1], str, (v)[2])
#ifdef DEBUG
PVEC("xcm", xcm);
PVEC("acm", acm);
m0 = mass[i];
for (m = 0; (m < DIM); m++)
{
- dx[m] = x[i][m]-xcm[m];
+ dx[m] = x[i][m] - xcm[m];
}
- L[XX][XX] += dx[XX]*dx[XX]*m0;
- L[XX][YY] += dx[XX]*dx[YY]*m0;
- L[XX][ZZ] += dx[XX]*dx[ZZ]*m0;
- L[YY][YY] += dx[YY]*dx[YY]*m0;
- L[YY][ZZ] += dx[YY]*dx[ZZ]*m0;
- L[ZZ][ZZ] += dx[ZZ]*dx[ZZ]*m0;
+ L[XX][XX] += dx[XX] * dx[XX] * m0;
+ L[XX][YY] += dx[XX] * dx[YY] * m0;
+ L[XX][ZZ] += dx[XX] * dx[ZZ] * m0;
+ L[YY][YY] += dx[YY] * dx[YY] * m0;
+ L[YY][ZZ] += dx[YY] * dx[ZZ] * m0;
+ L[ZZ][ZZ] += dx[ZZ] * dx[ZZ] * m0;
}
#ifdef DEBUG
PVEC("L-x", L[XX]);
return tm;
}
-void stop_cm(FILE gmx_unused *log, int natoms, real mass[], rvec x[], rvec v[])
+void stop_cm(FILE gmx_unused* log, int natoms, real mass[], rvec x[], rvec v[])
{
rvec xcm, vcm, acm;
tensor L;