*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, 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.
int i, j, mi, mj;
double Ekin, Efac, reft, kT, nd;
double dt;
- t_grp_tcstat *tcstat;
double *ivxi, *ixi;
double *GQ;
gmx_bool bBarostat;
else
{
iQinv = gmx::arrayRefFromArray(&MassQ->Qinv[i*nh], nh);
- tcstat = &ekind->tcstat[i];
+ const t_grp_tcstat *tcstat = &ekind->tcstat[i];
nd = opts->nrdf[i];
reft = std::max<real>(0, opts->ref_t[i]);
if (bEkinAveVel)
inc_nrnb(nrnb, eNR_PCOUPL, nr_atoms);
}
-void berendsen_tcoupl(const t_inputrec *ir, const gmx_ekindata_t *ekind, real dt,
+void berendsen_tcoupl(const t_inputrec *ir, gmx_ekindata_t *ekind, real dt,
std::vector<double> &therm_integral)
{
const t_grpopts *opts = &ir->opts;
void rescale_velocities(const gmx_ekindata_t *ekind, const t_mdatoms *mdatoms,
int start, int end, rvec v[])
{
- t_grp_acc *gstat;
- t_grp_tcstat *tcstat;
unsigned short *cACC, *cTC;
int ga, gt, n, d;
real lg;
rvec vrel;
- tcstat = ekind->tcstat;
cTC = mdatoms->cTC;
+ gmx::ArrayRef<const t_grp_tcstat> tcstat = ekind->tcstat;
+
if (ekind->bNEMD)
{
- gstat = ekind->grpstat;
+ gmx::ArrayRef<const t_grp_acc> gstat = ekind->grpstat;
cACC = mdatoms->cACC;
ga = 0;
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, 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/utility/futil.h"
#include "gromacs/utility/smalloc.h"
-static void init_grptcstat(int ngtc, t_grp_tcstat tcstat[])
-{
- int i;
-
- for (i = 0; (i < ngtc); i++)
- {
- tcstat[i].T = 0;
- clear_mat(tcstat[i].ekinh);
- clear_mat(tcstat[i].ekinh_old);
- clear_mat(tcstat[i].ekinf);
- }
-}
-
static void init_grpstat(const gmx_mtop_t *mtop, int ngacc, t_grp_acc gstat[])
{
gmx_mtop_atomloop_all_t aloop;
ekind->bNEMD = (opts->ngacc > 1 || norm2(opts->acc[0]) > 0);
ekind->ngtc = opts->ngtc;
- snew(ekind->tcstat, opts->ngtc);
- init_grptcstat(opts->ngtc, ekind->tcstat);
+ ekind->tcstat.resize(opts->ngtc);
/* Set Berendsen tcoupl lambda's to 1,
* so runs without Berendsen coupling are not affected.
*/
ekind->tcstat[i].ekinscalef_nhc = 1.0;
}
- nthread = gmx_omp_nthreads_get(emntUpdate);
-
+ nthread = gmx_omp_nthreads_get(emntUpdate);
+ ekind->nthreads = nthread;
snew(ekind->ekin_work_alloc, nthread);
snew(ekind->ekin_work, nthread);
snew(ekind->dekindl_work, nthread);
}
ekind->ngacc = opts->ngacc;
- snew(ekind->grpstat, opts->ngacc);
- init_grpstat(mtop, opts->ngacc, ekind->grpstat);
+ ekind->grpstat.resize(opts->ngacc);
+ init_grpstat(mtop, opts->ngacc, ekind->grpstat.data());
}
void accumulate_u(const t_commrec *cr, const t_grpopts *opts, gmx_ekindata_t *ekind)
template<NumTempScaleValues numTempScaleValues,
ApplyParrinelloRahmanVScaling applyPRVScaling>
static void
-updateMDLeapfrogSimple(int start,
- int nrend,
- real dt,
- real dtPressureCouple,
- const rvec * gmx_restrict invMassPerDim,
- const t_grp_tcstat * tcstat,
- const unsigned short * cTC,
- const rvec pRVScaleMatrixDiagonal,
- const rvec * gmx_restrict x,
- rvec * gmx_restrict xprime,
- rvec * gmx_restrict v,
- const rvec * gmx_restrict f)
+updateMDLeapfrogSimple(int start,
+ int nrend,
+ real dt,
+ real dtPressureCouple,
+ const rvec * gmx_restrict invMassPerDim,
+ gmx::ArrayRef<const t_grp_tcstat> tcstat,
+ const unsigned short * cTC,
+ const rvec pRVScaleMatrixDiagonal,
+ const rvec * gmx_restrict x,
+ rvec * gmx_restrict xprime,
+ rvec * gmx_restrict v,
+ const rvec * gmx_restrict f)
{
real lambdaGroup;
* \param[in] f Forces
*/
static void
-updateMDLeapfrogSimpleSimd(int start,
- int nrend,
- real dt,
- const real * gmx_restrict invMass,
- const t_grp_tcstat * tcstat,
- const rvec * gmx_restrict x,
- rvec * gmx_restrict xprime,
- rvec * gmx_restrict v,
- const rvec * gmx_restrict f)
+updateMDLeapfrogSimpleSimd(int start,
+ int nrend,
+ real dt,
+ const real * gmx_restrict invMass,
+ gmx::ArrayRef<const t_grp_tcstat> tcstat,
+ const rvec * gmx_restrict x,
+ rvec * gmx_restrict xprime,
+ rvec * gmx_restrict v,
+ const rvec * gmx_restrict f)
{
SimdReal timestep(dt);
SimdReal lambdaSystem(tcstat[0].lambda);
* Holian et al. Phys Rev E 52(3) : 2338, 1995
*/
- const unsigned short * cTC = md->cTC;
- const t_grp_tcstat * tcstat = ekind->tcstat;
+ gmx::ArrayRef<const t_grp_tcstat> tcstat = ekind->tcstat;
+ gmx::ArrayRef<const t_grp_acc> grpstat = ekind->grpstat;
+ const unsigned short * cTC = md->cTC;
+ const unsigned short * cACC = md->cACC;
+ const rvec * accel = ir->opts.acc;
- const unsigned short * cACC = md->cACC;
- const rvec * accel = ir->opts.acc;
- const t_grp_acc * grpstat = ekind->grpstat;
-
- const rvec * gmx_restrict invMassPerDim = md->invMassPerDim;
+ const rvec * gmx_restrict invMassPerDim = md->invMassPerDim;
/* Initialize group values, changed later when multiple groups are used */
int ga = 0;
bool haveSingleTempScaleValue = (!doTempCouple || ekind->ngtc == 1);
/* Extract some pointers needed by all cases */
- const unsigned short *cTC = md->cTC;
- const t_grp_tcstat *tcstat = ekind->tcstat;
- const rvec *invMassPerDim = md->invMassPerDim;
+ const unsigned short *cTC = md->cTC;
+ gmx::ArrayRef<const t_grp_tcstat> tcstat = ekind->tcstat;
+ const rvec *invMassPerDim = md->invMassPerDim;
if (doParrinelloRahman)
{
static void calc_ke_part_normal(const rvec v[], const t_grpopts *opts, const t_mdatoms *md,
gmx_ekindata_t *ekind, t_nrnb *nrnb, gmx_bool bEkinAveVel)
{
- int g;
- t_grp_tcstat *tcstat = ekind->tcstat;
- t_grp_acc *grpstat = ekind->grpstat;
- int nthread, thread;
+ int g;
+ gmx::ArrayRef<t_grp_tcstat> tcstat = ekind->tcstat;
+ gmx::ArrayRef<t_grp_acc> grpstat = ekind->grpstat;
+ int nthread, thread;
/* three main: VV with AveVel, vv with AveEkin, leap with AveEkin. Leap with AveVel is also
an option, but not supported now.
gmx_ekindata_t *ekind,
t_nrnb *nrnb, gmx_bool bEkinAveVel)
{
- int start = 0, homenr = md->homenr;
- int g, d, n, m, gt = 0;
- rvec v_corrt;
- real hm;
- t_grp_tcstat *tcstat = ekind->tcstat;
- t_cos_acc *cosacc = &(ekind->cosacc);
- real dekindl;
- real fac, cosz;
- double mvcos;
+ int start = 0, homenr = md->homenr;
+ int g, d, n, m, gt = 0;
+ rvec v_corrt;
+ real hm;
+ gmx::ArrayRef<t_grp_tcstat> tcstat = ekind->tcstat;
+ t_cos_acc *cosacc = &(ekind->cosacc);
+ real dekindl;
+ real fac, cosz;
+ double mvcos;
for (g = 0; g < opts->ngtc; g++)
{
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, 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.
restore_ekinstate_from_state(const t_commrec *cr,
gmx_ekindata_t *ekind, const ekinstate_t *ekinstate);
-void berendsen_tcoupl(const t_inputrec *ir, const gmx_ekindata_t *ekind, real dt,
+void berendsen_tcoupl(const t_inputrec *ir, gmx_ekindata_t *ekind, real dt,
std::vector<double> &therm_integral); //NOLINT(google-runtime-references)
void andersen_tcoupl(const t_inputrec *ir, int64_t step,
gmx_update_t *upd = nullptr;
t_graph *graph = nullptr;
gmx_groups_t *groups;
- gmx_ekindata_t *ekind;
gmx_shellfc_t *shellfc;
gmx_bool bSumEkinhOld, bDoReplEx, bExchanged, bNeedRepartition;
gmx_bool bTemp, bPres, bTrotter;
enerd);
/* Kinetic energy data */
- snew(ekind, 1);
+ std::unique_ptr<gmx_ekindata_t> eKinData = compat::make_unique<gmx_ekindata_t>();
+ gmx_ekindata_t *ekind = eKinData.get();
init_ekindata(fplog, top_global, &(ir->opts), ekind);
/* Copy the cos acceleration to the groups struct */
ekind->cosacc.cos_accel = ir->cos_accel;
gmx_global_stat_t gstat;
t_graph *graph = nullptr;
gmx_groups_t *groups;
- gmx_ekindata_t *ekind;
gmx_shellfc_t *shellfc;
double cycles;
enerd);
/* Kinetic energy data */
- snew(ekind, 1);
+ std::unique_ptr<gmx_ekindata_t> eKinData = compat::make_unique<gmx_ekindata_t>();
+ gmx_ekindata_t *ekind = eKinData.get();
init_ekindata(fplog, top_global, &(ir->opts), ekind);
/* Copy the cos acceleration to the groups struct */
ekind->cosacc.cos_accel = ir->cos_accel;
gmx_global_stat_t gstat;
t_graph *graph = nullptr;
gmx_groups_t *groups;
- gmx_ekindata_t *ekind;
gmx_shellfc_t *shellfc;
double cycles;
enerd);
/* Kinetic energy data */
- snew(ekind, 1);
+ std::unique_ptr<gmx_ekindata_t> eKinData = compat::make_unique<gmx_ekindata_t>();
+ gmx_ekindata_t *ekind = eKinData.get();
init_ekindata(fplog, top_global, &(ir->opts), ekind);
/* Copy the cos acceleration to the groups struct */
ekind->cosacc.cos_accel = ir->cos_accel;
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 2019, 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.
+ */
+/*! \internal \file
+ * \brief
+ * Implements classes from group.h.
+ *
+ * \author Kevin Boyd <kevin.boyd@uconn.edu>
+ * \ingroup module_mdtypes
+ */
+#include "gmxpre.h"
+
+#include "group.h"
+
+gmx_ekindata_t::~gmx_ekindata_t()
+{
+ for (int i = 0; i < nthreads; i++)
+ {
+ sfree(ekin_work_alloc[i]);
+ }
+ sfree(ekin_work_alloc);
+ sfree(ekin_work);
+ sfree(dekindl_work);
+}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015,2018, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2018,2019, 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.
#ifndef GMX_MDTYPES_GROUP_H
#define GMX_MDTYPES_GROUP_H
+#include <vector>
+
#include "gromacs/math/vectypes.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
+#include "gromacs/utility/smalloc.h"
-typedef struct {
- real Th; /* Temperature at half step */
- real T; /* Temperature at full step */
- tensor ekinh; /* Kinetic energy at half step */
- tensor ekinh_old; /* Kinetic energy at old half step */
- tensor ekinf; /* Kinetic energy at full step */
- real lambda; /* Berendsen coupling lambda */
- double ekinscalef_nhc; /* Scaling factor for NHC- full step */
- double ekinscaleh_nhc; /* Scaling factor for NHC- half step */
- double vscale_nhc; /* Scaling factor for NHC- velocity */
-} t_grp_tcstat;
+struct t_grp_tcstat{
+ real Th = 0; /* Temperature at half step */
+ real T = 0; /* Temperature at full step */
+ tensor ekinh = {{0}}; /* Kinetic energy at half step */
+ tensor ekinh_old = {{0}}; /* Kinetic energy at old half step */
+ tensor ekinf = {{0}}; /* Kinetic energy at full step */
+ real lambda = 0; /* Berendsen coupling lambda */
+ double ekinscalef_nhc = 0; /* Scaling factor for NHC- full step */
+ double ekinscaleh_nhc = 0; /* Scaling factor for NHC- half step */
+ double vscale_nhc = 0; /* Scaling factor for NHC- velocity */
+};
-typedef struct {
+struct t_grp_acc {
int nat; /* Number of atoms in this group */
rvec u; /* Mean velocities of home particles */
rvec uold; /* Previous mean velocities of home particles */
double mA; /* Mass for topology A */
double mB; /* Mass for topology B */
-} t_grp_acc;
+};
-typedef struct {
+struct t_cos_acc{
real cos_accel; /* The acceleration for the cosine profile */
real mvcos; /* The cos momenta of home particles */
real vcos; /* The velocity of the cosine profile */
-} t_cos_acc;
+};
+
+struct gmx_ekindata_t {
+ gmx_bool bNEMD;
+ int ngtc; /* The number of T-coupling groups */
+ int nthreads; /* For size of ekin_work */
+ std::vector<t_grp_tcstat> tcstat; /* T-coupling data */
+ tensor **ekin_work_alloc; /* Allocated locations for *_work members */
+ tensor **ekin_work; /* Work arrays for tcstat per thread */
+ real **dekindl_work; /* Work location for dekindl per thread */
+ int ngacc; /* The number of acceleration groups */
+ std::vector<t_grp_acc> grpstat; /* Acceleration data */
+ tensor ekin; /* overall kinetic energy */
+ tensor ekinh; /* overall 1/2 step kinetic energy */
+ real dekindl; /* dEkin/dlambda at half step */
+ real dekindl_old; /* dEkin/dlambda at old half step */
+ t_cos_acc cosacc; /* Cosine acceleration data */
-typedef struct gmx_ekindata_t {
- gmx_bool bNEMD;
- int ngtc; /* The number of T-coupling groups */
- t_grp_tcstat *tcstat; /* T-coupling data */
- tensor **ekin_work_alloc; /* Allocated locations for *_work members */
- tensor **ekin_work; /* Work arrays for tcstat per thread */
- real **dekindl_work; /* Work location for dekindl per thread */
- int ngacc; /* The number of acceleration groups */
- t_grp_acc *grpstat; /* Acceleration data */
- tensor ekin; /* overall kinetic energy */
- tensor ekinh; /* overall 1/2 step kinetic energy */
- real dekindl; /* dEkin/dlambda at half step */
- real dekindl_old; /* dEkin/dlambda at old half step */
- t_cos_acc cosacc; /* Cosine acceleration data */
-} gmx_ekindata_t;
+ ~gmx_ekindata_t();
+};
#define GID(igid, jgid, gnr) (((igid) < (jgid)) ? ((igid)*(gnr)+(jgid)) : ((jgid)*(gnr)+(igid)))