From 04645acecd7b5859f1355fef46c5f65fb068c171 Mon Sep 17 00:00:00 2001 From: Pascal Merz Date: Wed, 5 Sep 2018 18:16:03 -0600 Subject: [PATCH] Added trivial const qualifiers Const qualifiers were added to function arguments. No changes were made inside function bodies, except for adding const qualifiers to convenience references within functions. These changes help the development of a MD state object, as they reflect more clearly where write access to data is _really_ needed. Refs #2616 Change-Id: I779b4dfed2fbd0ad129e226c9b535ed97a8bb01f --- src/gromacs/domdec/domdec.h | 2 +- src/gromacs/domdec/domdec_topology.cpp | 2 +- src/gromacs/imd/imd.cpp | 28 ++++++------ src/gromacs/imd/imd.h | 16 +++---- src/gromacs/listed-forces/disre.cpp | 6 +-- src/gromacs/listed-forces/disre.h | 2 +- src/gromacs/listed-forces/orires.cpp | 4 +- src/gromacs/listed-forces/orires.h | 2 +- src/gromacs/mdlib/calcvir.cpp | 8 ++-- src/gromacs/mdlib/calcvir.h | 8 ++-- src/gromacs/mdlib/compute_io.cpp | 2 +- src/gromacs/mdlib/compute_io.h | 4 +- src/gromacs/mdlib/coupling.cpp | 78 +++++++++++++++++----------------- src/gromacs/mdlib/expanded.cpp | 20 +++++---- src/gromacs/mdlib/expanded.h | 11 ++--- src/gromacs/mdlib/groupcoord.cpp | 22 +++++----- src/gromacs/mdlib/groupcoord.h | 2 +- src/gromacs/mdlib/sim_util.cpp | 30 ++++++------- src/gromacs/mdlib/sim_util.h | 18 ++++---- src/gromacs/mdlib/stat.cpp | 8 ++-- src/gromacs/mdlib/tgroup.cpp | 12 +++--- src/gromacs/mdlib/tgroup.h | 12 +++--- src/gromacs/mdlib/update.cpp | 51 +++++++++++----------- src/gromacs/mdlib/update.h | 71 +++++++++++++++++-------------- src/gromacs/mdlib/vcm.cpp | 2 +- src/gromacs/mdlib/vcm.h | 2 +- 26 files changed, 216 insertions(+), 207 deletions(-) diff --git a/src/gromacs/domdec/domdec.h b/src/gromacs/domdec/domdec.h index 78529bebd1..ad8edec3cf 100644 --- a/src/gromacs/domdec/domdec.h +++ b/src/gromacs/domdec/domdec.h @@ -422,7 +422,7 @@ gmx_localtop_t *dd_init_local_top(const gmx_mtop_t *top_global); /*! \brief Construct local state */ void dd_init_local_state(struct gmx_domdec_t *dd, - t_state *state_global, t_state *local_state); + const t_state *state_global, t_state *local_state); /*! \brief Generate a list of links between charge groups that are linked by bonded interactions */ t_blocka *make_charge_group_links(const gmx_mtop_t *mtop, gmx_domdec_t *dd, diff --git a/src/gromacs/domdec/domdec_topology.cpp b/src/gromacs/domdec/domdec_topology.cpp index 322b53c337..76fa2786db 100644 --- a/src/gromacs/domdec/domdec_topology.cpp +++ b/src/gromacs/domdec/domdec_topology.cpp @@ -2228,7 +2228,7 @@ gmx_localtop_t *dd_init_local_top(const gmx_mtop_t *top_global) } void dd_init_local_state(gmx_domdec_t *dd, - t_state *state_global, t_state *state_local) + const t_state *state_global, t_state *state_local) { int buf[NITEM_DD_INIT_LOCAL_STATE]; diff --git a/src/gromacs/imd/imd.cpp b/src/gromacs/imd/imd.cpp index 21ee74a6de..8c2af328dd 100644 --- a/src/gromacs/imd/imd.cpp +++ b/src/gromacs/imd/imd.cpp @@ -401,8 +401,8 @@ static int imd_recv_mdcomm(IMDSocket *socket, int32_t nforces, int32_t *forcendx #endif /* GROMACS specific functions for the IMD implementation */ -void write_IMDgroup_to_file(gmx_bool bIMD, t_inputrec *ir, t_state *state, - gmx_mtop_t *sys, int nfile, const t_filenm fnm[]) +void write_IMDgroup_to_file(gmx_bool bIMD, t_inputrec *ir, const t_state *state, + const gmx_mtop_t *sys, int nfile, const t_filenm fnm[]) { t_atoms IMDatoms; @@ -416,9 +416,9 @@ void write_IMDgroup_to_file(gmx_bool bIMD, t_inputrec *ir, t_state *state, } -void dd_make_local_IMD_atoms(gmx_bool bIMD, gmx_domdec_t *dd, t_IMD *imd) +void dd_make_local_IMD_atoms(gmx_bool bIMD, const gmx_domdec_t *dd, t_IMD *imd) { - gmx_ga2la_t *ga2la; + const gmx_ga2la_t *ga2la; t_gmx_IMD_setup *IMDsetup; if (bIMD) @@ -1044,7 +1044,7 @@ void IMD_finalize(gmx_bool bIMD, t_IMD *imd) #ifdef GMX_IMD /*! \brief Creates the molecule start-end position array of molecules in the IMD group. */ -static void init_imd_prepare_mols_in_imdgroup(t_gmx_IMD_setup *IMDsetup, gmx_mtop_t *top_global) +static void init_imd_prepare_mols_in_imdgroup(t_gmx_IMD_setup *IMDsetup, const gmx_mtop_t *top_global) { int i, ii; t_block lmols; @@ -1094,7 +1094,7 @@ static void init_imd_prepare_mols_in_imdgroup(t_gmx_IMD_setup *IMDsetup, gmx_mto /*! \brief Copied and modified from groupcoord.c shift_positions_group(). */ static void shift_positions( - matrix box, + const matrix box, rvec x[], /* The positions [0..nr] */ const ivec is, /* The shift [0..nr] */ int nr) /* The number of positions */ @@ -1132,7 +1132,7 @@ static void shift_positions( /*! \brief Removes shifts of molecules diffused outside of the box. */ -static void imd_remove_molshifts(t_gmx_IMD_setup *IMDsetup, matrix box) +static void imd_remove_molshifts(t_gmx_IMD_setup *IMDsetup, const matrix box) { int i, ii, molsize; ivec largest, smallest, shift; @@ -1225,7 +1225,7 @@ static void imd_remove_molshifts(t_gmx_IMD_setup *IMDsetup, matrix box) /*! \brief Initialize arrays used to assemble the positions from the other nodes. */ -static void init_imd_prepare_for_x_assembly(const t_commrec *cr, rvec x[], t_gmx_IMD_setup *IMDsetup) +static void init_imd_prepare_for_x_assembly(const t_commrec *cr, const rvec x[], t_gmx_IMD_setup *IMDsetup) { int i, ii; @@ -1285,10 +1285,10 @@ static void imd_check_integrator_parallel(t_inputrec *ir, const t_commrec *cr) void init_IMD(t_inputrec *ir, const t_commrec *cr, const gmx_multisim_t *ms, - gmx_mtop_t *top_global, + const gmx_mtop_t *top_global, FILE *fplog, int defnstimd, - rvec x[], + const rvec x[], int nfile, const t_filenm fnm[], const gmx_output_env_t *oenv, @@ -1478,8 +1478,8 @@ gmx_bool do_IMD(gmx_bool bIMD, int64_t step, const t_commrec *cr, gmx_bool bNS, - matrix box, - rvec x[], + const matrix box, + const rvec x[], t_inputrec *ir, double t, gmx_wallcycle *wcycle) @@ -1559,7 +1559,7 @@ gmx_bool do_IMD(gmx_bool bIMD, } -void IMD_fill_energy_record(gmx_bool bIMD, t_IMD *imd, gmx_enerdata_t *enerd, +void IMD_fill_energy_record(gmx_bool bIMD, t_IMD *imd, const gmx_enerdata_t *enerd, int64_t step, gmx_bool bHaveNewEnergies) { IMDEnergyBlock *ene; @@ -1628,7 +1628,7 @@ void IMD_send_positions(t_IMD *imd) void IMD_prep_energies_send_positions(gmx_bool bIMD, gmx_bool bIMDstep, - t_IMD *imd, gmx_enerdata_t *enerd, + t_IMD *imd, const gmx_enerdata_t *enerd, int64_t step, gmx_bool bHaveNewEnergies, gmx_wallcycle *wcycle) { diff --git a/src/gromacs/imd/imd.h b/src/gromacs/imd/imd.h index 0ac8e1325b..70fc97f1a2 100644 --- a/src/gromacs/imd/imd.h +++ b/src/gromacs/imd/imd.h @@ -102,8 +102,8 @@ static const char IMDstr[] = "IMD:"; /**< Tag output from the IMD module with t * \param nfile Number of files. * \param fnm Filename struct. */ -void write_IMDgroup_to_file(gmx_bool bIMD, t_inputrec *ir, t_state *state, - gmx_mtop_t *sys, int nfile, const t_filenm fnm[]); +void write_IMDgroup_to_file(gmx_bool bIMD, t_inputrec *ir, const t_state *state, + const gmx_mtop_t *sys, int nfile, const t_filenm fnm[]); /*! \brief Make a selection of the home atoms for the IMD group. @@ -119,7 +119,7 @@ void write_IMDgroup_to_file(gmx_bool bIMD, t_inputrec *ir, t_state *state, * \param dd Structure containing domain decomposition data. * \param imd The IMD group of atoms. */ -void dd_make_local_IMD_atoms(gmx_bool bIMD, gmx_domdec_t *dd, t_IMD *imd); +void dd_make_local_IMD_atoms(gmx_bool bIMD, const gmx_domdec_t *dd, t_IMD *imd); /*! \brief Initializes (or disables) IMD. @@ -141,8 +141,8 @@ void dd_make_local_IMD_atoms(gmx_bool bIMD, gmx_domdec_t *dd, t_IMD *imd); */ void init_IMD(t_inputrec *ir, const t_commrec *cr, const gmx_multisim_t *ms, - gmx_mtop_t *top_global, - FILE *fplog, int defnstimd, rvec x[], + const gmx_mtop_t *top_global, + FILE *fplog, int defnstimd, const rvec x[], int nfile, const t_filenm fnm[], const gmx_output_env_t *oenv, const MdrunOptions &mdrunOptions); @@ -165,7 +165,7 @@ void init_IMD(t_inputrec *ir, const t_commrec *cr, */ gmx_bool do_IMD(gmx_bool bIMD, int64_t step, const t_commrec *cr, gmx_bool bNS, - matrix box, rvec x[], t_inputrec *ir, double t, + const matrix box, const rvec x[], t_inputrec *ir, double t, gmx_wallcycle *wcycle); @@ -202,7 +202,7 @@ void IMD_apply_forces(gmx_bool bIMD, t_IMD *imd, * \param bHaveNewEnergies Only copy energies if we have done global summing of them before. * */ -void IMD_fill_energy_record(gmx_bool bIMD, t_IMD *imd, gmx_enerdata_t *enerd, +void IMD_fill_energy_record(gmx_bool bIMD, t_IMD *imd, const gmx_enerdata_t *enerd, int64_t step, gmx_bool bHaveNewEnergies); @@ -225,7 +225,7 @@ void IMD_send_positions(t_IMD *imd); * */ void IMD_prep_energies_send_positions(gmx_bool bIMD, gmx_bool bIMDstep, - t_IMD *imd, gmx_enerdata_t *enerd, + t_IMD *imd, const gmx_enerdata_t *enerd, int64_t step, gmx_bool bHaveNewEnergies, gmx_wallcycle *wcycle); diff --git a/src/gromacs/listed-forces/disre.cpp b/src/gromacs/listed-forces/disre.cpp index 49eb068444..8d6bcb85c3 100644 --- a/src/gromacs/listed-forces/disre.cpp +++ b/src/gromacs/listed-forces/disre.cpp @@ -621,10 +621,10 @@ real ta_disres(int nfa, const t_iatom forceatoms[], const t_iparams ip[], return vtot; } -void update_disres_history(t_fcdata *fcd, history_t *hist) +void update_disres_history(const t_fcdata *fcd, history_t *hist) { - t_disresdata *dd; - int pair; + const t_disresdata *dd; + int pair; dd = &(fcd->disres); if (dd->dr_tau != 0) diff --git a/src/gromacs/listed-forces/disre.h b/src/gromacs/listed-forces/disre.h index bc95d13d0c..d2d82a06e6 100644 --- a/src/gromacs/listed-forces/disre.h +++ b/src/gromacs/listed-forces/disre.h @@ -86,6 +86,6 @@ void calc_disres_R_6(const t_commrec *cr, t_ifunc ta_disres; //! Copies the new time averages that have been calculated in calc_disres_R_6. -void update_disres_history(t_fcdata *fcd, history_t *hist); +void update_disres_history(const t_fcdata *fcd, history_t *hist); #endif diff --git a/src/gromacs/listed-forces/orires.cpp b/src/gromacs/listed-forces/orires.cpp index 1723464e65..b7f9cfd04d 100644 --- a/src/gromacs/listed-forces/orires.cpp +++ b/src/gromacs/listed-forces/orires.cpp @@ -738,9 +738,9 @@ real orires(int nfa, const t_iatom forceatoms[], const t_iparams ip[], /* Approx. 80*nfa/3 flops */ } -void update_orires_history(t_fcdata *fcd, history_t *hist) +void update_orires_history(const t_fcdata *fcd, history_t *hist) { - t_oriresdata *od = &(fcd->orires); + const t_oriresdata *od = &(fcd->orires); if (od->edt != 0) { diff --git a/src/gromacs/listed-forces/orires.h b/src/gromacs/listed-forces/orires.h index 0491c9b59a..75d29c3800 100644 --- a/src/gromacs/listed-forces/orires.h +++ b/src/gromacs/listed-forces/orires.h @@ -99,6 +99,6 @@ void print_orires_log(FILE *log, t_oriresdata *od); t_ifunc orires; //! Copies the new time averages that have been calculated in calc_orires_dev. -void update_orires_history(t_fcdata *fcd, history_t *hist); +void update_orires_history(const t_fcdata *fcd, history_t *hist); #endif diff --git a/src/gromacs/mdlib/calcvir.cpp b/src/gromacs/mdlib/calcvir.cpp index 525f15d857..795591ea39 100644 --- a/src/gromacs/mdlib/calcvir.cpp +++ b/src/gromacs/mdlib/calcvir.cpp @@ -102,8 +102,8 @@ static void calc_x_times_f(int nxf, const rvec x[], const rvec f[], } } -void calc_vir(int nxf, rvec x[], rvec f[], tensor vir, - bool bScrewPBC, matrix box) +void calc_vir(int nxf, const rvec x[], const rvec f[], tensor vir, + bool bScrewPBC, const matrix box) { matrix x_times_f; @@ -210,8 +210,8 @@ static void lo_fcv(int i0, int i1, upd_vir(vir[ZZ], dvzx, dvzy, dvzz); } -void f_calc_vir(int i0, int i1, rvec x[], rvec f[], tensor vir, - t_graph *g, matrix box) +void f_calc_vir(int i0, int i1, const rvec x[], const rvec f[], tensor vir, + const t_graph *g, const matrix box) { int start, end; diff --git a/src/gromacs/mdlib/calcvir.h b/src/gromacs/mdlib/calcvir.h index 896b1347fb..c3db0b56c0 100644 --- a/src/gromacs/mdlib/calcvir.h +++ b/src/gromacs/mdlib/calcvir.h @@ -40,12 +40,12 @@ struct t_graph; struct t_pbc; -void calc_vir(int nxf, rvec x[], rvec f[], tensor vir, - bool bScrewPBC, matrix box); +void calc_vir(int nxf, const rvec x[], const rvec f[], tensor vir, + bool bScrewPBC, const matrix box); /* Calculate virial for nxf atoms, and add it to vir */ -void f_calc_vir(int i0, int i1, rvec x[], rvec f[], tensor vir, - t_graph *g, rvec shift_vec[]); +void f_calc_vir(int i0, int i1, const rvec x[], const rvec f[], tensor vir, + const t_graph *g, const rvec shift_vec[]); /* Calculate virial taking periodicity into account */ #endif diff --git a/src/gromacs/mdlib/compute_io.cpp b/src/gromacs/mdlib/compute_io.cpp index 36cad80422..ec5b613b24 100644 --- a/src/gromacs/mdlib/compute_io.cpp +++ b/src/gromacs/mdlib/compute_io.cpp @@ -58,7 +58,7 @@ static int div_nsteps(int nsteps, int nst) } } -double compute_io(t_inputrec *ir, int natoms, gmx_groups_t *groups, +double compute_io(const t_inputrec *ir, int natoms, const gmx_groups_t *groups, int nrener, int nrepl) { diff --git a/src/gromacs/mdlib/compute_io.h b/src/gromacs/mdlib/compute_io.h index a697238853..5d96ef1f7c 100644 --- a/src/gromacs/mdlib/compute_io.h +++ b/src/gromacs/mdlib/compute_io.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2011,2014,2015, by the GROMACS development team, led by + * Copyright (c) 2011,2014,2015,2018, 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. @@ -45,7 +45,7 @@ struct t_inputrec; extern "C" { #endif -double compute_io(t_inputrec *ir, int natoms, gmx_groups_t *groups, +double compute_io(const t_inputrec *ir, int natoms, const gmx_groups_t *groups, int nrener, int nrepl); /* Return total output to be written from this simulation. */ diff --git a/src/gromacs/mdlib/coupling.cpp b/src/gromacs/mdlib/coupling.cpp index 27304afeed..190053851e 100644 --- a/src/gromacs/mdlib/coupling.cpp +++ b/src/gromacs/mdlib/coupling.cpp @@ -102,8 +102,8 @@ static const double* sy_const[] = { };*/ /* these integration routines are only referenced inside this file */ -static void NHC_trotter(t_grpopts *opts, int nvar, gmx_ekindata_t *ekind, real dtfull, - double xi[], double vxi[], double scalefac[], real *veta, t_extmass *MassQ, gmx_bool bEkinAveVel) +static void NHC_trotter(const t_grpopts *opts, int nvar, const gmx_ekindata_t *ekind, real dtfull, + double xi[], double vxi[], double scalefac[], real *veta, const t_extmass *MassQ, gmx_bool bEkinAveVel) { /* general routine for both barostat and thermostat nose hoover chains */ @@ -237,8 +237,8 @@ static void NHC_trotter(t_grpopts *opts, int nvar, gmx_ekindata_t *ekind, real d sfree(GQ); } -static void boxv_trotter(t_inputrec *ir, real *veta, real dt, tensor box, - gmx_ekindata_t *ekind, tensor vir, real pcorr, t_extmass *MassQ) +static void boxv_trotter(const t_inputrec *ir, real *veta, real dt, const tensor box, + const gmx_ekindata_t *ekind, const tensor vir, real pcorr, const t_extmass *MassQ) { real pscal; @@ -294,7 +294,7 @@ static void boxv_trotter(t_inputrec *ir, real *veta, real dt, tensor box, * */ -real calc_pres(int ePBC, int nwall, matrix box, tensor ekin, tensor vir, +real calc_pres(int ePBC, int nwall, const matrix box, const tensor ekin, const tensor vir, tensor pres) { int n, m; @@ -364,7 +364,7 @@ static void calcParrinelloRahmanInvMass(const t_inputrec *ir, const matrix box, void parrinellorahman_pcoupl(FILE *fplog, int64_t step, const t_inputrec *ir, real dt, const tensor pres, - tensor box, tensor box_rel, tensor boxv, + const tensor box, tensor box_rel, tensor boxv, tensor M, matrix mu, gmx_bool bFirstStep) { /* This doesn't do any coordinate updating. It just @@ -778,7 +778,7 @@ void berendsen_tcoupl(const t_inputrec *ir, const gmx_ekindata_t *ekind, real dt } } -void andersen_tcoupl(t_inputrec *ir, int64_t step, +void andersen_tcoupl(const t_inputrec *ir, int64_t step, const t_commrec *cr, const t_mdatoms *md, t_state *state, real rate, const gmx_bool *randomize, const real *boltzfac) { const int *gatindex = (DOMAINDECOMP(cr) ? cr->dd->globalAtomIndices.data() : nullptr); @@ -833,8 +833,8 @@ void andersen_tcoupl(t_inputrec *ir, int64_t step, } -void nosehoover_tcoupl(t_grpopts *opts, gmx_ekindata_t *ekind, real dt, - double xi[], double vxi[], t_extmass *MassQ) +void nosehoover_tcoupl(const t_grpopts *opts, const gmx_ekindata_t *ekind, real dt, + double xi[], double vxi[], const t_extmass *MassQ) { int i; real reft, oldvxi; @@ -850,21 +850,21 @@ void nosehoover_tcoupl(t_grpopts *opts, gmx_ekindata_t *ekind, real dt, } } -void trotter_update(t_inputrec *ir, int64_t step, gmx_ekindata_t *ekind, - gmx_enerdata_t *enerd, t_state *state, - tensor vir, t_mdatoms *md, - t_extmass *MassQ, int **trotter_seqlist, int trotter_seqno) +void trotter_update(const t_inputrec *ir, int64_t step, gmx_ekindata_t *ekind, + const gmx_enerdata_t *enerd, t_state *state, + const tensor vir, const t_mdatoms *md, + const t_extmass *MassQ, const int * const *trotter_seqlist, int trotter_seqno) { - int n, i, d, ngtc, gc = 0, t; - t_grp_tcstat *tcstat; - t_grpopts *opts; - int64_t step_eff; - real dt; - double *scalefac, dtc; - int *trotter_seq; - rvec sumv = {0, 0, 0}; - gmx_bool bCouple; + int n, i, d, ngtc, gc = 0, t; + t_grp_tcstat *tcstat; + const t_grpopts *opts; + int64_t step_eff; + real dt; + double *scalefac, dtc; + const int *trotter_seq; + rvec sumv = {0, 0, 0}; + gmx_bool bCouple; if (trotter_seqno <= ettTSEQ2) { @@ -970,11 +970,11 @@ void trotter_update(t_inputrec *ir, int64_t step, gmx_ekindata_t *ekind, } -extern void init_npt_masses(t_inputrec *ir, t_state *state, t_extmass *MassQ, gmx_bool bInit) +extern void init_npt_masses(const t_inputrec *ir, t_state *state, t_extmass *MassQ, gmx_bool bInit) { - int n, i, j, d, ngtc, nh; - t_grpopts *opts; - real reft, kT, ndj, nd; + int n, i, j, d, ngtc, nh; + const t_grpopts *opts; + real reft, kT, ndj, nd; opts = &(ir->opts); /* just for ease of referencing */ ngtc = ir->opts.ngtc; @@ -1065,12 +1065,12 @@ extern void init_npt_masses(t_inputrec *ir, t_state *state, t_extmass *MassQ, gm } } -int **init_npt_vars(t_inputrec *ir, t_state *state, t_extmass *MassQ, gmx_bool bTrotter) +int **init_npt_vars(const t_inputrec *ir, t_state *state, t_extmass *MassQ, gmx_bool bTrotter) { - int i, j, nnhpres, nh; - t_grpopts *opts; - real bmass, qmass, reft, kT; - int **trotter_seq; + int i, j, nnhpres, nh; + const t_grpopts *opts; + real bmass, qmass, reft, kT; + int **trotter_seq; opts = &(ir->opts); /* just for ease of referencing */ nnhpres = state->nnhpres; @@ -1430,9 +1430,9 @@ real NPT_energy(const t_inputrec *ir, const t_state *state, const t_extmass *Mas } -static real vrescale_sumnoises(real nn, - gmx::ThreeFry2x64<> *rng, - gmx::NormalDistribution *normalDist) +static real vrescale_sumnoises(real nn, + gmx::ThreeFry2x64<> *rng, + gmx::NormalDistribution *normalDist) { /* * Returns the sum of nn independent gaussian noises squared @@ -1507,13 +1507,13 @@ static real vrescale_resamplekin(real kk, real sigma, real ndeg, real taut, return ekin_new; } -void vrescale_tcoupl(t_inputrec *ir, int64_t step, +void vrescale_tcoupl(const t_inputrec *ir, int64_t step, gmx_ekindata_t *ekind, real dt, double therm_integral[]) { - t_grpopts *opts; - int i; - real Ek, Ek_ref1, Ek_ref, Ek_new; + const t_grpopts *opts; + int i; + real Ek, Ek_ref1, Ek_ref, Ek_new; opts = &ir->opts; @@ -1562,7 +1562,7 @@ void vrescale_tcoupl(t_inputrec *ir, int64_t step, } } -void rescale_velocities(gmx_ekindata_t *ekind, t_mdatoms *mdatoms, +void rescale_velocities(const gmx_ekindata_t *ekind, const t_mdatoms *mdatoms, int start, int end, rvec v[]) { t_grp_acc *gstat; diff --git a/src/gromacs/mdlib/expanded.cpp b/src/gromacs/mdlib/expanded.cpp index 88686630fe..7e70646bd5 100644 --- a/src/gromacs/mdlib/expanded.cpp +++ b/src/gromacs/mdlib/expanded.cpp @@ -70,7 +70,7 @@ #include "gromacs/utility/gmxmpi.h" #include "gromacs/utility/smalloc.h" -static void init_df_history_weights(df_history_t *dfhist, t_expanded *expand, int nlim) +static void init_df_history_weights(df_history_t *dfhist, const t_expanded *expand, int nlim) { int i; dfhist->wl_delta = expand->init_wl_delta; @@ -83,7 +83,7 @@ static void init_df_history_weights(df_history_t *dfhist, t_expanded *expand, in /* Eventually should contain all the functions needed to initialize expanded ensemble before the md loop starts */ -void init_expanded_ensemble(gmx_bool bStateFromCP, t_inputrec *ir, df_history_t *dfhist) +void init_expanded_ensemble(gmx_bool bStateFromCP, const t_inputrec *ir, df_history_t *dfhist) { if (!bStateFromCP) { @@ -91,7 +91,7 @@ void init_expanded_ensemble(gmx_bool bStateFromCP, t_inputrec *ir, df_history_t } } -static void GenerateGibbsProbabilities(real *ene, double *p_k, double *pks, int minfep, int maxfep) +static void GenerateGibbsProbabilities(const real *ene, double *p_k, double *pks, int minfep, int maxfep) { int i; @@ -226,7 +226,7 @@ static gmx_bool CheckHistogramRatios(int nhisto, const real *histo, real ratio) return bIfFlat; } -static gmx_bool CheckIfDoneEquilibrating(int nlim, t_expanded *expand, df_history_t *dfhist, int64_t step) +static gmx_bool CheckIfDoneEquilibrating(int nlim, const t_expanded *expand, const df_history_t *dfhist, int64_t step) { int i, totalsamples; @@ -335,7 +335,7 @@ static gmx_bool CheckIfDoneEquilibrating(int nlim, t_expanded *expand, df_histor } static gmx_bool UpdateWeights(int nlim, t_expanded *expand, df_history_t *dfhist, - int fep_state, real *scaled_lamee, real *weighted_lamee, int64_t step) + int fep_state, const real *scaled_lamee, const real *weighted_lamee, int64_t step) { gmx_bool bSufficientSamples; int i; @@ -700,7 +700,8 @@ static gmx_bool UpdateWeights(int nlim, t_expanded *expand, df_history_t *dfhist return FALSE; } -static int ChooseNewLambda(int nlim, t_expanded *expand, df_history_t *dfhist, int fep_state, real *weighted_lamee, double *p_k, +static int ChooseNewLambda(int nlim, const t_expanded *expand, df_history_t *dfhist, int fep_state, + const real *weighted_lamee, double *p_k, int64_t seed, int64_t step) { /* Choose new lambda value, and update transition matrix */ @@ -990,7 +991,8 @@ static int ChooseNewLambda(int nlim, t_expanded *expand, df_history_t *dfhist, i } /* print out the weights to the log, along with current state */ -void PrintFreeEnergyInfoToFile(FILE *outfile, t_lambda *fep, t_expanded *expand, t_simtemp *simtemp, df_history_t *dfhist, +void PrintFreeEnergyInfoToFile(FILE *outfile, const t_lambda *fep, const t_expanded *expand, + const t_simtemp *simtemp, const df_history_t *dfhist, int fep_state, int frequency, int64_t step) { int nlim, i, ifep, jfep; @@ -1157,10 +1159,10 @@ void PrintFreeEnergyInfoToFile(FILE *outfile, t_lambda *fep, t_expanded *expand, } } -int ExpandedEnsembleDynamics(FILE *log, t_inputrec *ir, gmx_enerdata_t *enerd, +int ExpandedEnsembleDynamics(FILE *log, const t_inputrec *ir, const gmx_enerdata_t *enerd, t_state *state, t_extmass *MassQ, int fep_state, df_history_t *dfhist, int64_t step, - rvec *v, t_mdatoms *mdatoms) + rvec *v, const t_mdatoms *mdatoms) /* Note that the state variable is only needed for simulated tempering, not Hamiltonian expanded ensemble. May be able to remove it after integrator refactoring. */ { diff --git a/src/gromacs/mdlib/expanded.h b/src/gromacs/mdlib/expanded.h index 80abb31344..48a63de024 100644 --- a/src/gromacs/mdlib/expanded.h +++ b/src/gromacs/mdlib/expanded.h @@ -50,16 +50,17 @@ struct t_mdatoms; struct t_simtemp; class t_state; -void init_npt_masses(t_inputrec *ir, t_state *state, t_extmass *MassQ, gmx_bool bInit); +void init_npt_masses(const t_inputrec *ir, t_state *state, t_extmass *MassQ, gmx_bool bInit); -void init_expanded_ensemble(gmx_bool bStateFromCP, t_inputrec *ir, df_history_t *dfhist); +void init_expanded_ensemble(gmx_bool bStateFromCP, const t_inputrec *ir, df_history_t *dfhist); -int ExpandedEnsembleDynamics(FILE *log, t_inputrec *ir, gmx_enerdata_t *enerd, +int ExpandedEnsembleDynamics(FILE *log, const t_inputrec *ir, const gmx_enerdata_t *enerd, t_state *state, t_extmass *MassQ, int fep_state, df_history_t *dfhist, int64_t step, - rvec *v, t_mdatoms *mdatoms); + rvec *v, const t_mdatoms *mdatoms); -void PrintFreeEnergyInfoToFile(FILE *outfile, t_lambda *fep, t_expanded *expand, t_simtemp *simtemp, df_history_t *dfhist, +void PrintFreeEnergyInfoToFile(FILE *outfile, const t_lambda *fep, const t_expanded *expand, + const t_simtemp *simtemp, const df_history_t *dfhist, int fep_state, int frequency, int64_t step); #endif diff --git a/src/gromacs/mdlib/groupcoord.cpp b/src/gromacs/mdlib/groupcoord.cpp index e2b3039954..9e4ec821b0 100644 --- a/src/gromacs/mdlib/groupcoord.cpp +++ b/src/gromacs/mdlib/groupcoord.cpp @@ -101,12 +101,12 @@ dd_make_local_group_indices(const gmx_ga2la_t *ga2la, static void get_shifts_group( - int npbcdim, - matrix box, - rvec *xcoll, /* IN: Collective set of positions [0..nr] */ - int nr, /* IN: Total number of atoms in the group */ - rvec *xcoll_old, /* IN: Positions from the last time step [0...nr] */ - ivec *shifts) /* OUT: Shifts for xcoll */ + int npbcdim, + const matrix box, + rvec *xcoll, /* IN: Collective set of positions [0..nr] */ + int nr, /* IN: Total number of atoms in the group */ + rvec *xcoll_old, /* IN: Positions from the last time step [0...nr] */ + ivec *shifts) /* OUT: Shifts for xcoll */ { int i, m, d; rvec dx; @@ -151,10 +151,10 @@ static void get_shifts_group( static void shift_positions_group( - matrix box, - rvec x[], /* The positions [0..nr] */ - ivec *is, /* The shifts [0..nr] */ - int nr) /* The number of positions and shifts */ + const matrix box, + rvec x[], /* The positions [0..nr] */ + ivec *is, /* The shifts [0..nr] */ + int nr) /* The number of positions and shifts */ { int i, tx, ty, tz; @@ -205,7 +205,7 @@ extern void communicate_group_positions( const int *coll_ind, /* Collective index */ rvec *xcoll_old, /* (optional) Positions from the last time step, used to make group whole */ - matrix box) /* (optional) The box */ + const matrix box) /* (optional) The box */ { int i; diff --git a/src/gromacs/mdlib/groupcoord.h b/src/gromacs/mdlib/groupcoord.h index 775f26b24a..9d2443c76e 100644 --- a/src/gromacs/mdlib/groupcoord.h +++ b/src/gromacs/mdlib/groupcoord.h @@ -127,7 +127,7 @@ extern void communicate_group_positions(const t_commrec *cr, rvec *xcoll, ivec * ivec *extra_shifts, gmx_bool bNS, const rvec *x_loc, int nr, int nr_loc, const int *anrs_loc, const int *coll_ind, rvec *xcoll_old, - matrix box); + const matrix box); /*! \brief Calculates the center of the positions x locally. * diff --git a/src/gromacs/mdlib/sim_util.cpp b/src/gromacs/mdlib/sim_util.cpp index 3b2137bfd9..03913bf416 100644 --- a/src/gromacs/mdlib/sim_util.cpp +++ b/src/gromacs/mdlib/sim_util.cpp @@ -126,7 +126,7 @@ static const bool c_disableAlternatingWait = (getenv("GMX_DISABLE_ALTERNATING_GP void print_time(FILE *out, gmx_walltime_accounting_t walltime_accounting, int64_t step, - t_inputrec *ir, + const t_inputrec *ir, const t_commrec *cr) { time_t finish; @@ -247,8 +247,8 @@ static void pme_gpu_reduce_outputs(gmx_wallcycle_t wcycle, wallcycle_stop(wcycle, ewcPME_GPU_F_REDUCTION); } -static void calc_virial(int start, int homenr, rvec x[], rvec f[], - tensor vir_part, t_graph *graph, matrix box, +static void calc_virial(int start, int homenr, const rvec x[], const rvec f[], + tensor vir_part, const t_graph *graph, const matrix box, t_nrnb *nrnb, const t_forcerec *fr, int ePBC) { /* The short-range virial from surrounding boxes */ @@ -269,11 +269,11 @@ static void calc_virial(int start, int homenr, rvec x[], rvec f[], static void pull_potential_wrapper(const t_commrec *cr, const t_inputrec *ir, - matrix box, gmx::ArrayRef x, + const matrix box, gmx::ArrayRef x, gmx::ForceWithVirial *force, const t_mdatoms *mdatoms, gmx_enerdata_t *enerd, - real *lambda, + const real *lambda, double t, gmx_wallcycle_t wcycle) { @@ -364,14 +364,14 @@ static void post_process_forces(const t_commrec *cr, t_nrnb *nrnb, gmx_wallcycle_t wcycle, const gmx_localtop_t *top, - matrix box, - rvec x[], + const matrix box, + const rvec x[], rvec f[], gmx::ForceWithVirial *forceWithVirial, tensor vir_force, const t_mdatoms *mdatoms, - t_graph *graph, - t_forcerec *fr, + const t_graph *graph, + const t_forcerec *fr, const gmx_vsite_t *vsite, int flags) { @@ -415,8 +415,8 @@ static void post_process_forces(const t_commrec *cr, } } -static void do_nb_verlet(t_forcerec *fr, - interaction_const_t *ic, +static void do_nb_verlet(const t_forcerec *fr, + const interaction_const_t *ic, gmx_enerdata_t *enerd, int flags, int ilocality, int clearF, @@ -2165,7 +2165,7 @@ void do_force(FILE *fplog, void do_constrain_first(FILE *fplog, gmx::Constraints *constr, - t_inputrec *ir, t_mdatoms *md, + const t_inputrec *ir, const t_mdatoms *md, t_state *state) { int i, m, start, end; @@ -2508,8 +2508,8 @@ void calc_enervirdiff(FILE *fplog, int eDispCorr, t_forcerec *fr) } } -void calc_dispcorr(t_inputrec *ir, t_forcerec *fr, - matrix box, real lambda, tensor pres, tensor virial, +void calc_dispcorr(const t_inputrec *ir, const t_forcerec *fr, + const matrix box, real lambda, tensor pres, tensor virial, real *prescorr, real *enercorr, real *dvdlcorr) { gmx_bool bCorrAll, bCorrPres; @@ -2700,7 +2700,7 @@ void finish_run(FILE *fplog, const gmx::MDLogger &mdlog, const t_commrec *cr, t_nrnb nrnb[], gmx_wallcycle_t wcycle, gmx_walltime_accounting_t walltime_accounting, nonbonded_verlet_t *nbv, - gmx_pme_t *pme, + const gmx_pme_t *pme, gmx_bool bWriteStat) { t_nrnb *nrnb_tot = nullptr; diff --git a/src/gromacs/mdlib/sim_util.h b/src/gromacs/mdlib/sim_util.h index 86628be6f8..6d17a966fc 100644 --- a/src/gromacs/mdlib/sim_util.h +++ b/src/gromacs/mdlib/sim_util.h @@ -84,16 +84,16 @@ void put_atoms_in_box_omp(int ePBC, const matrix box, gmx::ArrayRef x /* ROUTINES from stat.c */ -gmx_global_stat_t global_stat_init(t_inputrec *ir); +gmx_global_stat_t global_stat_init(const t_inputrec *ir); void global_stat_destroy(gmx_global_stat_t gs); -void global_stat(gmx_global_stat_t gs, +void global_stat(const gmx_global_stat *gs, const t_commrec *cr, gmx_enerdata_t *enerd, tensor fvir, tensor svir, rvec mu_tot, - t_inputrec *inputrec, + const t_inputrec *inputrec, gmx_ekindata_t *ekind, - gmx::Constraints *constr, t_vcm *vcm, + const gmx::Constraints *constr, t_vcm *vcm, int nsig, real *sig, int *totalNumberOfBondedInteractions, gmx_bool bSumEkinhOld, int flags); @@ -105,7 +105,7 @@ bool do_per_step(int64_t step, int64_t nstep); /* ROUTINES from sim_util.c */ void print_time(FILE *out, gmx_walltime_accounting_t walltime_accounting, - int64_t step, t_inputrec *ir, const t_commrec *cr); + int64_t step, const t_inputrec *ir, const t_commrec *cr); /*! \brief Print date, time, MPI rank and a description of this point * in time. @@ -127,19 +127,19 @@ void finish_run(FILE *log, const gmx::MDLogger &mdlog, const t_commrec *cr, t_nrnb nrnb[], gmx_wallcycle_t wcycle, gmx_walltime_accounting_t walltime_accounting, nonbonded_verlet_t *nbv, - gmx_pme_t *pme, + const gmx_pme_t *pme, gmx_bool bWriteStat); void calc_enervirdiff(FILE *fplog, int eDispCorr, t_forcerec *fr); -void calc_dispcorr(t_inputrec *ir, t_forcerec *fr, - matrix box, real lambda, tensor pres, tensor virial, +void calc_dispcorr(const t_inputrec *ir, const t_forcerec *fr, + const matrix box, real lambda, tensor pres, tensor virial, real *prescorr, real *enercorr, real *dvdlcorr); void initialize_lambdas(FILE *fplog, t_inputrec *ir, int *fep_state, gmx::ArrayRef lambda, double *lam0); void do_constrain_first(FILE *log, gmx::Constraints *constr, - t_inputrec *inputrec, t_mdatoms *md, + const t_inputrec *inputrec, const t_mdatoms *md, t_state *state); void init_md(FILE *fplog, diff --git a/src/gromacs/mdlib/stat.cpp b/src/gromacs/mdlib/stat.cpp index c24ef03006..ba9a135ecf 100644 --- a/src/gromacs/mdlib/stat.cpp +++ b/src/gromacs/mdlib/stat.cpp @@ -68,7 +68,7 @@ typedef struct gmx_global_stat int *itc1; } t_gmx_global_stat; -gmx_global_stat_t global_stat_init(t_inputrec *ir) +gmx_global_stat_t global_stat_init(const t_inputrec *ir) { gmx_global_stat_t gs; @@ -135,11 +135,11 @@ static int filter_enerdterm(const real *afrom, gmx_bool bToBuffer, real *ato, return to; } -void global_stat(gmx_global_stat_t gs, +void global_stat(const gmx_global_stat *gs, const t_commrec *cr, gmx_enerdata_t *enerd, tensor fvir, tensor svir, rvec mu_tot, - t_inputrec *inputrec, - gmx_ekindata_t *ekind, gmx::Constraints *constr, + const t_inputrec *inputrec, + gmx_ekindata_t *ekind, const gmx::Constraints *constr, t_vcm *vcm, int nsig, real *sig, int *totalNumberOfBondedInteractions, diff --git a/src/gromacs/mdlib/tgroup.cpp b/src/gromacs/mdlib/tgroup.cpp index 5eeac139a3..e52e74c137 100644 --- a/src/gromacs/mdlib/tgroup.cpp +++ b/src/gromacs/mdlib/tgroup.cpp @@ -69,9 +69,9 @@ static void init_grptcstat(int ngtc, t_grp_tcstat tcstat[]) } } -static void init_grpstat(gmx_mtop_t *mtop, int ngacc, t_grp_acc gstat[]) +static void init_grpstat(const gmx_mtop_t *mtop, int ngacc, t_grp_acc gstat[]) { - gmx_groups_t *groups; + const gmx_groups_t *groups; gmx_mtop_atomloop_all_t aloop; int i, grp; const t_atom *atom; @@ -95,7 +95,7 @@ static void init_grpstat(gmx_mtop_t *mtop, int ngacc, t_grp_acc gstat[]) } } -void init_ekindata(FILE gmx_unused *log, gmx_mtop_t *mtop, t_grpopts *opts, +void init_ekindata(FILE gmx_unused *log, const gmx_mtop_t *mtop, const t_grpopts *opts, gmx_ekindata_t *ekind) { int i; @@ -155,7 +155,7 @@ void init_ekindata(FILE gmx_unused *log, gmx_mtop_t *mtop, t_grpopts *opts, init_grpstat(mtop, opts->ngacc, ekind->grpstat); } -void accumulate_u(t_commrec *cr, t_grpopts *opts, gmx_ekindata_t *ekind) +void accumulate_u(const t_commrec *cr, const t_grpopts *opts, gmx_ekindata_t *ekind) { /* This routine will only be called when it's necessary */ t_bin *rb; @@ -177,7 +177,7 @@ void accumulate_u(t_commrec *cr, t_grpopts *opts, gmx_ekindata_t *ekind) } void update_ekindata(int start, int homenr, gmx_ekindata_t *ekind, - t_grpopts *opts, rvec v[], t_mdatoms *md, real lambda) + const t_grpopts *opts, const rvec v[], const t_mdatoms *md, real lambda) { int d, g, n; real mv; @@ -220,7 +220,7 @@ void update_ekindata(int start, int homenr, gmx_ekindata_t *ekind, } } -real sum_ekin(t_grpopts *opts, gmx_ekindata_t *ekind, real *dekindlambda, +real sum_ekin(const t_grpopts *opts, gmx_ekindata_t *ekind, real *dekindlambda, gmx_bool bEkinAveVel, gmx_bool bScaleEkin) { int i, j, m, ngtc; diff --git a/src/gromacs/mdlib/tgroup.h b/src/gromacs/mdlib/tgroup.h index 02505615ec..3530fe6f81 100644 --- a/src/gromacs/mdlib/tgroup.h +++ b/src/gromacs/mdlib/tgroup.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by + * Copyright (c) 2013,2014,2015,2018, 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. @@ -49,29 +49,29 @@ struct t_commrec; struct t_grpopts; struct t_mdatoms; -void init_ekindata(FILE *log, gmx_mtop_t *mtop, - t_grpopts *opts, +void init_ekindata(FILE *log, const gmx_mtop_t *mtop, + const t_grpopts *opts, gmx_ekindata_t *ekind); /* Allocate memory and set the grpnr array. */ void done_ekindata(gmx_ekindata_t *ekind); /* Free the memory */ -void accumulate_u(t_commrec *cr, t_grpopts *opts, +void accumulate_u(const t_commrec *cr, const t_grpopts *opts, gmx_ekindata_t *ekind); /* Communicate subsystem - group velocities and subsystem ekin respectively * and sum them up. Return them in grps. */ -real sum_ekin(t_grpopts *opts, gmx_ekindata_t *ekind, real *dekindlambda, +real sum_ekin(const t_grpopts *opts, gmx_ekindata_t *ekind, real *dekindlambda, gmx_bool bEkinFullStep, gmx_bool bScaleEkin); /* Sum the group ekins into total ekin and calc temp per group, * return total temperature. */ void update_ekindata(int start, int homenr, gmx_ekindata_t *ekind, - t_grpopts *opts, rvec v[], t_mdatoms *md, real lambda); + const t_grpopts *opts, const rvec v[], const t_mdatoms *md, real lambda); /* Do the update of group velocities (if bNEMD) and * (partial) group ekin. */ diff --git a/src/gromacs/mdlib/update.cpp b/src/gromacs/mdlib/update.cpp index 5578853df9..1f1d3b9576 100644 --- a/src/gromacs/mdlib/update.cpp +++ b/src/gromacs/mdlib/update.cpp @@ -672,7 +672,7 @@ static void do_update_md(int start, } static void do_update_vv_vel(int start, int nrend, real dt, - rvec accel[], ivec nFreeze[], const real invmass[], + const rvec accel[], const ivec nFreeze[], const real invmass[], const unsigned short ptype[], const unsigned short cFREEZE[], const unsigned short cACC[], rvec v[], const rvec f[], gmx_bool bExtended, real veta, real alpha) @@ -719,9 +719,9 @@ static void do_update_vv_vel(int start, int nrend, real dt, } /* do_update_vv_vel */ static void do_update_vv_pos(int start, int nrend, real dt, - ivec nFreeze[], + const ivec nFreeze[], const unsigned short ptype[], const unsigned short cFREEZE[], - const rvec x[], rvec xprime[], rvec v[], + const rvec x[], rvec xprime[], const rvec v[], gmx_bool bExtended, real veta) { int gf = 0; @@ -901,7 +901,7 @@ template static void doSDUpdateGeneral(gmx_stochd_t *sd, int start, int nrend, real dt, - rvec accel[], ivec nFreeze[], + const rvec accel[], const ivec nFreeze[], const real invmass[], const unsigned short ptype[], const unsigned short cFREEZE[], const unsigned short cACC[], const unsigned short cTC[], @@ -994,7 +994,7 @@ doSDUpdateGeneral(gmx_stochd_t *sd, } static void do_update_bd(int start, int nrend, real dt, - ivec nFreeze[], + const ivec nFreeze[], const real invmass[], const unsigned short ptype[], const unsigned short cFREEZE[], const unsigned short cTC[], const rvec x[], rvec xprime[], rvec v[], @@ -1059,7 +1059,7 @@ static void do_update_bd(int start, int nrend, real dt, } } -static void calc_ke_part_normal(rvec v[], t_grpopts *opts, t_mdatoms *md, +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; @@ -1175,8 +1175,8 @@ static void calc_ke_part_normal(rvec v[], t_grpopts *opts, t_mdatoms *md, inc_nrnb(nrnb, eNR_EKIN, md->homenr); } -static void calc_ke_part_visc(matrix box, rvec x[], rvec v[], - t_grpopts *opts, t_mdatoms *md, +static void calc_ke_part_visc(const matrix box, const rvec x[], const rvec v[], + const t_grpopts *opts, const t_mdatoms *md, gmx_ekindata_t *ekind, t_nrnb *nrnb, gmx_bool bEkinAveVel) { @@ -1248,7 +1248,7 @@ static void calc_ke_part_visc(matrix box, rvec x[], rvec v[], inc_nrnb(nrnb, eNR_EKIN, homenr); } -void calc_ke_part(t_state *state, t_grpopts *opts, t_mdatoms *md, +void calc_ke_part(const t_state *state, const t_grpopts *opts, const t_mdatoms *md, gmx_ekindata_t *ekind, t_nrnb *nrnb, gmx_bool bEkinAveVel) { if (ekind->cosacc.cos_accel == 0) @@ -1274,7 +1274,7 @@ extern void init_ekinstate(ekinstate_t *ekinstate, const t_inputrec *ir) ekinstate->mvcos = 0; } -void update_ekinstate(ekinstate_t *ekinstate, gmx_ekindata_t *ekind) +void update_ekinstate(ekinstate_t *ekinstate, const gmx_ekindata_t *ekind) { int i; @@ -1346,11 +1346,11 @@ void restore_ekinstate_from_state(const t_commrec *cr, } void update_tcouple(int64_t step, - t_inputrec *inputrec, + const t_inputrec *inputrec, t_state *state, gmx_ekindata_t *ekind, - t_extmass *MassQ, - t_mdatoms *md) + const t_extmass *MassQ, + const t_mdatoms *md) { bool doTemperatureCoupling = false; @@ -1537,7 +1537,7 @@ void update_sd_second_half(int64_t step, real *dvdlambda, /* the contribution to be added to the bonded interactions */ const t_inputrec *inputrec, /* input record and box stuff */ - t_mdatoms *md, + const t_mdatoms *md, t_state *state, const t_commrec *cr, t_nrnb *nrnb, @@ -1608,13 +1608,13 @@ update_sd_second_half(int64_t step, } void finish_update(const t_inputrec *inputrec, /* input record and box stuff */ - t_mdatoms *md, + const t_mdatoms *md, t_state *state, - t_graph *graph, + const t_graph *graph, t_nrnb *nrnb, gmx_wallcycle_t wcycle, gmx_update_t *upd, - gmx::Constraints *constr) + const gmx::Constraints *constr) { int homenr = md->homenr; @@ -1792,17 +1792,17 @@ void update_pcouple_after_coordinates(FILE *fplog, } void update_coords(int64_t step, - t_inputrec *inputrec, /* input record and box stuff */ - t_mdatoms *md, + const t_inputrec *inputrec, /* input record and box stuff */ + const t_mdatoms *md, t_state *state, gmx::PaddedArrayRef f, /* forces on home particles */ - t_fcdata *fcd, - gmx_ekindata_t *ekind, - matrix M, + const t_fcdata *fcd, + const gmx_ekindata_t *ekind, + const matrix M, gmx_update_t *upd, int UpdatePart, const t_commrec *cr, /* these shouldn't be here -- need to think about it */ - gmx::Constraints *constr) + const gmx::Constraints *constr) { gmx_bool bDoConstr = (nullptr != constr); @@ -1937,8 +1937,9 @@ void update_coords(int64_t step, } -extern gmx_bool update_randomize_velocities(t_inputrec *ir, int64_t step, const t_commrec *cr, - t_mdatoms *md, t_state *state, gmx_update_t *upd, gmx::Constraints *constr) +extern gmx_bool update_randomize_velocities(const t_inputrec *ir, int64_t step, const t_commrec *cr, + const t_mdatoms *md, t_state *state, const gmx_update_t *upd, + const gmx::Constraints *constr) { real rate = (ir->delta_t)/ir->opts.tau_t[0]; diff --git a/src/gromacs/mdlib/update.h b/src/gromacs/mdlib/update.h index bf83237c17..1785fb115b 100644 --- a/src/gromacs/mdlib/update.h +++ b/src/gromacs/mdlib/update.h @@ -86,11 +86,11 @@ void set_deform_reference_box(gmx_update_t *upd, int64_t step, matrix box); void update_tcouple(int64_t step, - t_inputrec *inputrec, + const t_inputrec *inputrec, t_state *state, gmx_ekindata_t *ekind, - t_extmass *MassQ, - t_mdatoms *md + const t_extmass *MassQ, + const t_mdatoms *md ); /* Update Parrinello-Rahman, to be called before the coordinate update */ @@ -119,22 +119,24 @@ void update_pcouple_after_coordinates(FILE *fplog, t_nrnb *nrnb, gmx_update_t *upd); -void update_coords(int64_t step, - t_inputrec *inputrec, /* input record and box stuff */ - t_mdatoms *md, - t_state *state, - gmx::PaddedArrayRef f, /* forces on home particles */ - t_fcdata *fcd, - gmx_ekindata_t *ekind, - matrix M, - gmx_update_t *upd, - int bUpdatePart, - const t_commrec *cr, /* these shouldn't be here -- need to think about it */ - gmx::Constraints *constr); +void update_coords(int64_t step, + const t_inputrec *inputrec, /* input record and box stuff */ + const t_mdatoms *md, + t_state *state, + gmx::PaddedArrayRef f, /* forces on home particles */ + const t_fcdata *fcd, + const gmx_ekindata_t *ekind, + const matrix M, + gmx_update_t *upd, + int bUpdatePart, + const t_commrec *cr, /* these shouldn't be here -- need to think about it */ + const gmx::Constraints *constr); /* Return TRUE if OK, FALSE in case of Shake Error */ -extern gmx_bool update_randomize_velocities(t_inputrec *ir, int64_t step, const t_commrec *cr, t_mdatoms *md, t_state *state, gmx_update_t *upd, gmx::Constraints *constr); +extern gmx_bool update_randomize_velocities(const t_inputrec *ir, int64_t step, const t_commrec *cr, + const t_mdatoms *md, t_state *state, const gmx_update_t *upd, + const gmx::Constraints *constr); void constrain_velocities(int64_t step, real *dvdlambda, /* the contribution to be added to the bonded interactions */ @@ -160,7 +162,7 @@ void constrain_coordinates(int64_t step, void update_sd_second_half(int64_t step, real *dvdlambda, /* the contribution to be added to the bonded interactions */ const t_inputrec *inputrec, /* input record and box stuff */ - t_mdatoms *md, + const t_mdatoms *md, t_state *state, const t_commrec *cr, t_nrnb *nrnb, @@ -171,17 +173,17 @@ void update_sd_second_half(int64_t step, bool do_ene); void finish_update(const t_inputrec *inputrec, - t_mdatoms *md, + const t_mdatoms *md, t_state *state, - t_graph *graph, + const t_graph *graph, t_nrnb *nrnb, gmx_wallcycle_t wcycle, gmx_update_t *upd, - gmx::Constraints *constr); + const gmx::Constraints *constr); /* Return TRUE if OK, FALSE in case of Shake Error */ -void calc_ke_part(t_state *state, t_grpopts *opts, t_mdatoms *md, +void calc_ke_part(const t_state *state, const t_grpopts *opts, const t_mdatoms *md, gmx_ekindata_t *ekind, t_nrnb *nrnb, gmx_bool bEkinAveVel); /* * Compute the partial kinetic energy for home particles; @@ -204,7 +206,7 @@ void init_ekinstate(ekinstate_t *ekinstate, const t_inputrec *ir); void -update_ekinstate(ekinstate_t *ekinstate, gmx_ekindata_t *ekind); +update_ekinstate(ekinstate_t *ekinstate, const gmx_ekindata_t *ekind); /*! \brief Restores data from \p ekinstate to \p ekind, then broadcasts it to the rest of the simulation */ @@ -215,40 +217,42 @@ restore_ekinstate_from_state(const t_commrec *cr, void berendsen_tcoupl(const t_inputrec *ir, const gmx_ekindata_t *ekind, real dt, std::vector &therm_integral); //NOLINT(google-runtime-references) -void andersen_tcoupl(t_inputrec *ir, int64_t step, +void andersen_tcoupl(const t_inputrec *ir, int64_t step, const t_commrec *cr, const t_mdatoms *md, t_state *state, real rate, const gmx_bool *randomize, const real *boltzfac); -void nosehoover_tcoupl(t_grpopts *opts, gmx_ekindata_t *ekind, real dt, - double xi[], double vxi[], t_extmass *MassQ); +void nosehoover_tcoupl(const t_grpopts *opts, const gmx_ekindata_t *ekind, real dt, + double xi[], double vxi[], const t_extmass *MassQ); -void trotter_update(t_inputrec *ir, int64_t step, gmx_ekindata_t *ekind, - gmx_enerdata_t *enerd, t_state *state, tensor vir, t_mdatoms *md, - t_extmass *MassQ, int **trotter_seqlist, int trotter_seqno); +void trotter_update(const t_inputrec *ir, int64_t step, gmx_ekindata_t *ekind, + const gmx_enerdata_t *enerd, t_state *state, const tensor vir, const t_mdatoms *md, + const t_extmass *MassQ, const int * const *trotter_seqlist, int trotter_seqno); -int **init_npt_vars(t_inputrec *ir, t_state *state, t_extmass *Mass, gmx_bool bTrotter); +int **init_npt_vars(const t_inputrec *ir, t_state *state, t_extmass *Mass, gmx_bool bTrotter); real NPT_energy(const t_inputrec *ir, const t_state *state, const t_extmass *MassQ); /* computes all the pressure/tempertature control energy terms to get a conserved energy */ +// TODO: This doesn't seem to be used or implemented anywhere void NBaroT_trotter(t_grpopts *opts, real dt, double xi[], double vxi[], real *veta, t_extmass *MassQ); -void vrescale_tcoupl(t_inputrec *ir, int64_t step, +void vrescale_tcoupl(const t_inputrec *ir, int64_t step, gmx_ekindata_t *ekind, real dt, double therm_integral[]); /* Compute temperature scaling. For V-rescale it is done in update. */ -void rescale_velocities(gmx_ekindata_t *ekind, t_mdatoms *mdatoms, +void rescale_velocities(const gmx_ekindata_t *ekind, const t_mdatoms *mdatoms, int start, int end, rvec v[]); /* Rescale the velocities with the scaling factor in ekind */ +// TODO: This is the only function in update.h altering the inputrec void update_annealing_target_temp(t_inputrec *ir, real t, gmx_update_t *upd); /* Set reference temp for simulated annealing at time t*/ real calc_temp(real ekin, real nrdf); /* Calculate the temperature */ -real calc_pres(int ePBC, int nwall, matrix box, tensor ekin, tensor vir, +real calc_pres(int ePBC, int nwall, const matrix box, const tensor ekin, const tensor vir, tensor pres); /* Calculate the pressure tensor, returns the scalar pressure. * The unit of pressure is bar. @@ -256,7 +260,7 @@ real calc_pres(int ePBC, int nwall, matrix box, tensor ekin, tensor vir, void parrinellorahman_pcoupl(FILE *fplog, int64_t step, const t_inputrec *ir, real dt, const tensor pres, - tensor box, tensor box_rel, tensor boxv, + const tensor box, tensor box_rel, tensor boxv, tensor M, matrix mu, gmx_bool bFirstStep); @@ -272,6 +276,7 @@ void berendsen_pscale(const t_inputrec *ir, const matrix mu, rvec x[], const unsigned short cFREEZE[], t_nrnb *nrnb); +// TODO: This doesn't seem to be used or implemented anywhere void correct_ekin(FILE *log, int start, int end, rvec v[], rvec vcm, real mass[], real tmass, tensor ekin); /* Correct ekin for vcm */ diff --git a/src/gromacs/mdlib/vcm.cpp b/src/gromacs/mdlib/vcm.cpp index cedee94fab..d7a56714be 100644 --- a/src/gromacs/mdlib/vcm.cpp +++ b/src/gromacs/mdlib/vcm.cpp @@ -54,7 +54,7 @@ #include "gromacs/utility/gmxomp.h" #include "gromacs/utility/smalloc.h" -t_vcm *init_vcm(FILE *fp, gmx_groups_t *groups, const t_inputrec *ir) +t_vcm *init_vcm(FILE *fp, const gmx_groups_t *groups, const t_inputrec *ir) { t_vcm *vcm; int g; diff --git a/src/gromacs/mdlib/vcm.h b/src/gromacs/mdlib/vcm.h index 2599027ff4..716cf07f70 100644 --- a/src/gromacs/mdlib/vcm.h +++ b/src/gromacs/mdlib/vcm.h @@ -76,7 +76,7 @@ typedef struct { t_vcm_thread *thread_vcm; /* Temporary data per thread and group */ } t_vcm; -t_vcm *init_vcm(FILE *fp, gmx_groups_t *groups, const t_inputrec *ir); +t_vcm *init_vcm(FILE *fp, const gmx_groups_t *groups, const t_inputrec *ir); /* Do a per group center of mass things */ void calc_vcm_grp(int start, int homenr, t_mdatoms *md, -- 2.11.4.GIT