#include "gromacs/ewald/pme.h"
#include "gromacs/fileio/confio.h"
#include "gromacs/fileio/mtxio.h"
-#include "gromacs/gmxlib/md_logging.h"
#include "gromacs/gmxlib/network.h"
#include "gromacs/gmxlib/nrnb.h"
#include "gromacs/imd/imd.h"
#include "gromacs/mdlib/mdatoms.h"
#include "gromacs/mdlib/mdebin.h"
#include "gromacs/mdlib/mdrun.h"
+#include "gromacs/mdlib/mdsetup.h"
#include "gromacs/mdlib/ns.h"
#include "gromacs/mdlib/shellfc.h"
#include "gromacs/mdlib/sim_util.h"
#include "gromacs/timing/wallcycle.h"
#include "gromacs/timing/walltime_accounting.h"
#include "gromacs/topology/mtop_util.h"
+#include "gromacs/topology/topology.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/fatalerror.h"
+#include "gromacs/utility/logger.h"
#include "gromacs/utility/smalloc.h"
//! Utility structure for manipulating states during EM
t_nrnb *nrnb, rvec mu_tot,
t_forcerec *fr, gmx_enerdata_t **enerd,
t_graph **graph, t_mdatoms *mdatoms, gmx_global_stat_t *gstat,
- gmx_vsite_t *vsite, gmx_constr_t constr,
+ gmx_vsite_t *vsite, gmx_constr_t constr, gmx_shellfc_t **shellfc,
int nfile, const t_filenm fnm[],
gmx_mdoutf_t *outf, t_mdebin **mdebin,
int imdport, unsigned long gmx_unused Flags,
init_IMD(ir, cr, top_global, fplog, 1, state_global->x,
nfile, fnm, NULL, imdport, Flags);
+ if (ir->eI == eiNM)
+ {
+ GMX_ASSERT(shellfc != NULL, "With NM we always support shells");
+
+ *shellfc = init_shell_flexcon(stdout,
+ top_global,
+ n_flexible_constraints(constr),
+ ir->nstcalcenergy,
+ DOMAINDECOMP(cr));
+ }
+ else
+ {
+ GMX_ASSERT(EI_ENERGY_MINIMIZATION(ir->eI), "This else currently only handles energy minimizers, consider if your algorithm needs shell/flexible-constraint support");
+
+ /* With energy minimization, shells and flexible constraints are
+ * automatically minimized when treated like normal DOFS.
+ */
+ if (shellfc != NULL)
+ {
+ *shellfc = NULL;
+ }
+ }
+
if (DOMAINDECOMP(cr))
{
*top = dd_init_local_top(top_global);
}
copy_mat(state_global->box, ems->s.box);
- *top = gmx_mtop_generate_local_top(top_global, ir->efep != efepNO);
- setup_bonded_threading(fr, &(*top)->idef);
+ snew(*top, 1);
+ mdAlgorithmsSetupAtomData(cr, ir, top_global, *top, fr,
+ graph, mdatoms,
+ vsite, shellfc ? *shellfc : NULL);
- if (ir->ePBC != epbcNONE && !fr->bMolPBC)
- {
- *graph = mk_graph(fplog, &((*top)->idef), 0, top_global->natoms, FALSE, FALSE);
- }
- else
- {
- *graph = NULL;
- }
-
- atoms2md(top_global, ir, 0, NULL, top_global->natoms, mdatoms);
update_mdatoms(mdatoms, state_global->lambda[efptFEP]);
if (vsite)
{
t_state *s1, *s2;
- int i;
int start, end;
- rvec *x1, *x2;
real dvdl_constr;
int nthreads gmx_unused;
s2->natoms = s1->natoms;
copy_mat(s1->box, s2->box);
/* Copy free energy state */
- for (i = 0; i < efptNR; i++)
+ for (int i = 0; i < efptNR; i++)
{
s2->lambda[i] = s1->lambda[i];
}
start = 0;
end = md->homenr;
- x1 = s1->x;
- x2 = s2->x;
-
// cppcheck-suppress unreadVariable
nthreads = gmx_omp_nthreads_get(emntUpdate);
#pragma omp parallel num_threads(nthreads)
{
- int gf, i, m;
+ rvec *x1 = s1->x;
+ rvec *x2 = s2->x;
- gf = 0;
+ int gf = 0;
#pragma omp for schedule(static) nowait
- for (i = start; i < end; i++)
+ for (int i = start; i < end; i++)
{
try
{
{
gf = md->cFREEZE[i];
}
- for (m = 0; m < DIM; m++)
+ for (int m = 0; m < DIM; m++)
{
if (ir->opts.nFreeze[gf][m])
{
if (s2->flags & (1<<estCGP))
{
/* Copy the CG p vector */
- x1 = s1->cg_p;
- x2 = s2->cg_p;
+ rvec *p1 = s1->cg_p;
+ rvec *p2 = s2->cg_p;
#pragma omp for schedule(static) nowait
- for (i = start; i < end; i++)
+ for (int i = start; i < end; i++)
{
// Trivial OpenMP block that does not throw
- copy_rvec(x1[i], x2[i]);
+ copy_rvec(p1[i], p2[i]);
}
}
}
s2->ncg_gl = s1->ncg_gl;
#pragma omp for schedule(static) nowait
- for (i = 0; i < s2->ncg_gl; i++)
+ for (int i = 0; i < s2->ncg_gl; i++)
{
s2->cg_gl[i] = s1->cg_gl[i];
}
{
/*! \brief Do conjugate gradients minimization
- \copydoc integrator_t (FILE *fplog, t_commrec *cr,
+ \copydoc integrator_t(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
int nfile, const t_filenm fnm[],
const gmx_output_env_t *oenv, gmx_bool bVerbose,
int nstglobalcomm,
unsigned long Flags,
gmx_walltime_accounting_t walltime_accounting)
*/
-double do_cg(FILE *fplog, t_commrec *cr,
+double do_cg(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlog,
int nfile, const t_filenm fnm[],
const gmx_output_env_t gmx_unused *oenv, gmx_bool bVerbose,
int gmx_unused nstglobalcomm,
/* Init em and store the local state in s_min */
init_em(fplog, CG, cr, inputrec,
state_global, top_global, s_min, &top, &f,
- nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat, vsite, constr,
+ nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat,
+ vsite, constr, NULL,
nfile, fnm, &outf, &mdebin, imdport, Flags, wcycle);
/* Print to log file */
/*! \brief Do L-BFGS conjugate gradients minimization
- \copydoc integrator_t (FILE *fplog, t_commrec *cr,
- int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int nstglobalcomm,
- gmx_vsite_t *vsite, gmx_constr_t constr,
- int stepout,
- t_inputrec *inputrec,
- gmx_mtop_t *top_global, t_fcdata *fcd,
- t_state *state_global,
- t_mdatoms *mdatoms,
- t_nrnb *nrnb, gmx_wallcycle_t wcycle,
- gmx_edsam_t ed,
- t_forcerec *fr,
- int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
- real cpt_period, real max_hours,
- int imdport,
- unsigned long Flags,
- gmx_walltime_accounting_t walltime_accounting)
+ \copydoc integrator_t(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
+ int nfile, const t_filenm fnm[],
+ const gmx_output_env_t *oenv, gmx_bool bVerbose,
+ int nstglobalcomm,
+ gmx_vsite_t *vsite, gmx_constr_t constr,
+ int stepout,
+ t_inputrec *inputrec,
+ gmx_mtop_t *top_global, t_fcdata *fcd,
+ t_state *state_global,
+ t_mdatoms *mdatoms,
+ t_nrnb *nrnb, gmx_wallcycle_t wcycle,
+ gmx_edsam_t ed,
+ t_forcerec *fr,
+ int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
+ real cpt_period, real max_hours,
+ int imdport,
+ unsigned long Flags,
+ gmx_walltime_accounting_t walltime_accounting)
*/
-double do_lbfgs(FILE *fplog, t_commrec *cr,
+double do_lbfgs(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlog,
int nfile, const t_filenm fnm[],
const gmx_output_env_t gmx_unused *oenv, gmx_bool bVerbose,
int gmx_unused nstglobalcomm,
/* Init em */
init_em(fplog, LBFGS, cr, inputrec,
state_global, top_global, &ems, &top, &f,
- nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat, vsite, constr,
+ nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat,
+ vsite, constr, NULL,
nfile, fnm, &outf, &mdebin, imdport, Flags, wcycle);
/* Do_lbfgs is not completely updated like do_steep and do_cg,
* so we free some memory again.
} /* That's all folks */
/*! \brief Do steepest descents minimization
- \copydoc integrator_t (FILE *fplog, t_commrec *cr,
- int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int nstglobalcomm,
- gmx_vsite_t *vsite, gmx_constr_t constr,
- int stepout,
- t_inputrec *inputrec,
- gmx_mtop_t *top_global, t_fcdata *fcd,
- t_state *state_global,
- t_mdatoms *mdatoms,
- t_nrnb *nrnb, gmx_wallcycle_t wcycle,
- gmx_edsam_t ed,
- t_forcerec *fr,
- int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
- real cpt_period, real max_hours,
- int imdport,
- unsigned long Flags,
- gmx_walltime_accounting_t walltime_accounting)
+ \copydoc integrator_t(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
+ int nfile, const t_filenm fnm[],
+ const gmx_output_env_t *oenv, gmx_bool bVerbose,
+ int nstglobalcomm,
+ gmx_vsite_t *vsite, gmx_constr_t constr,
+ int stepout,
+ t_inputrec *inputrec,
+ gmx_mtop_t *top_global, t_fcdata *fcd,
+ t_state *state_global,
+ t_mdatoms *mdatoms,
+ t_nrnb *nrnb, gmx_wallcycle_t wcycle,
+ gmx_edsam_t ed,
+ t_forcerec *fr,
+ int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
+ real cpt_period, real max_hours,
+ int imdport,
+ unsigned long Flags,
+ gmx_walltime_accounting_t walltime_accounting)
*/
-double do_steep(FILE *fplog, t_commrec *cr,
+double do_steep(FILE *fplog, t_commrec *cr, const gmx::MDLogger gmx_unused &mdlog,
int nfile, const t_filenm fnm[],
const gmx_output_env_t gmx_unused *oenv, gmx_bool bVerbose,
int gmx_unused nstglobalcomm,
/* Init em and store the local state in s_try */
init_em(fplog, SD, cr, inputrec,
state_global, top_global, s_try, &top, &f,
- nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat, vsite, constr,
+ nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat,
+ vsite, constr, NULL,
nfile, fnm, &outf, &mdebin, imdport, Flags, wcycle);
/* Print to log file */
} /* That's all folks */
/*! \brief Do normal modes analysis
- \copydoc integrator_t (FILE *fplog, t_commrec *cr,
- int nfile, const t_filenm fnm[],
- const gmx_output_env_t *oenv, gmx_bool bVerbose,
- int nstglobalcomm,
- gmx_vsite_t *vsite, gmx_constr_t constr,
- int stepout,
- t_inputrec *inputrec,
- gmx_mtop_t *top_global, t_fcdata *fcd,
- t_state *state_global,
- t_mdatoms *mdatoms,
- t_nrnb *nrnb, gmx_wallcycle_t wcycle,
- gmx_edsam_t ed,
- t_forcerec *fr,
- int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
- real cpt_period, real max_hours,
- int imdport,
- unsigned long Flags,
- gmx_walltime_accounting_t walltime_accounting)
+ \copydoc integrator_t(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
+ int nfile, const t_filenm fnm[],
+ const gmx_output_env_t *oenv, gmx_bool bVerbose,
+ int nstglobalcomm,
+ gmx_vsite_t *vsite, gmx_constr_t constr,
+ int stepout,
+ t_inputrec *inputrec,
+ gmx_mtop_t *top_global, t_fcdata *fcd,
+ t_state *state_global,
+ t_mdatoms *mdatoms,
+ t_nrnb *nrnb, gmx_wallcycle_t wcycle,
+ gmx_edsam_t ed,
+ t_forcerec *fr,
+ int repl_ex_nst, int repl_ex_nex, int repl_ex_seed,
+ real cpt_period, real max_hours,
+ int imdport,
+ unsigned long Flags,
+ gmx_walltime_accounting_t walltime_accounting)
*/
-double do_nm(FILE *fplog, t_commrec *cr,
+double do_nm(FILE *fplog, t_commrec *cr, const gmx::MDLogger &mdlog,
int nfile, const t_filenm fnm[],
const gmx_output_env_t gmx_unused *oenv, gmx_bool bVerbose,
int gmx_unused nstglobalcomm,
state_work = init_em_state();
+ gmx_shellfc_t *shellfc;
+
/* Init em and store the local state in state_minimum */
init_em(fplog, NM, cr, inputrec,
state_global, top_global, state_work, &top,
&f,
- nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat, vsite, constr,
+ nrnb, mu_tot, fr, &enerd, &graph, mdatoms, &gstat,
+ vsite, constr, &shellfc,
nfile, fnm, &outf, NULL, imdport, Flags, wcycle);
- gmx_shellfc_t *shellfc = init_shell_flexcon(stdout,
- top_global,
- n_flexible_constraints(constr),
- inputrec->nstcalcenergy,
- DOMAINDECOMP(cr));
-
- if (shellfc)
- {
- make_local_shells(cr, mdatoms, shellfc);
- }
std::vector<size_t> atom_index = get_atom_index(top_global);
snew(fneg, atom_index.size());
snew(dfdx, atom_index.size());
*/
if (EEL_FULL(fr->eeltype) || fr->rlist == 0.0)
{
- md_print_info(cr, fplog, "Non-cutoff electrostatics used, forcing full Hessian format.\n");
+ GMX_LOG(mdlog.warning).appendText("Non-cutoff electrostatics used, forcing full Hessian format.");
bSparse = FALSE;
}
else if (atom_index.size() < 1000)
{
- md_print_info(cr, fplog, "Small system size (N=%d), using full Hessian format.\n", atom_index.size());
+ GMX_LOG(mdlog.warning).appendTextFormatted("Small system size (N=%d), using full Hessian format.",
+ atom_index.size());
bSparse = FALSE;
}
else
{
- md_print_info(cr, fplog, "Using compressed symmetric sparse Hessian format.\n");
+ GMX_LOG(mdlog.warning).appendText("Using compressed symmetric sparse Hessian format.");
bSparse = TRUE;
}
/* if forces are not small, warn user */
get_state_f_norm_max(cr, &(inputrec->opts), mdatoms, state_work);
- md_print_info(cr, fplog, "Maximum force:%12.5e\n", state_work->fmax);
+ GMX_LOG(mdlog.warning).appendTextFormatted("Maximum force:%12.5e", state_work->fmax);
if (state_work->fmax > 1.0e-3)
{
- md_print_info(cr, fplog,
- "The force is probably not small enough to "
- "ensure that you are at a minimum.\n"
- "Be aware that negative eigenvalues may occur\n"
- "when the resulting matrix is diagonalized.\n\n");
+ GMX_LOG(mdlog.warning).appendText(
+ "The force is probably not small enough to "
+ "ensure that you are at a minimum.\n"
+ "Be aware that negative eigenvalues may occur\n"
+ "when the resulting matrix is diagonalized.");
}
/***********************************************************