fprintf(fp,
"\n%s converged to machine precision in %s steps,\n"
"but did not reach the requested Fmax < %g.\n",
- alg, gmx_step_str(count, buf), ftol);
+ alg,
+ gmx_step_str(count, buf),
+ ftol);
}
else
{
- fprintf(fp, "\n%s did not converge to Fmax < %g in %s steps.\n", alg, ftol,
- gmx_step_str(count, buf));
+ fprintf(fp, "\n%s did not converge to Fmax < %g in %s steps.\n", alg, ftol, gmx_step_str(count, buf));
}
#if GMX_DOUBLE
{
GMX_ASSERT(shellfc != nullptr, "With NM we always support shells");
- *shellfc =
- init_shell_flexcon(stdout, top_global, constr ? constr->numFlexibleConstraints() : 0,
- ir->nstcalcenergy, DOMAINDECOMP(cr), thisRankHasDuty(cr, DUTY_PME));
+ *shellfc = init_shell_flexcon(stdout,
+ top_global,
+ constr ? constr->numFlexibleConstraints() : 0,
+ ir->nstcalcenergy,
+ DOMAINDECOMP(cr),
+ thisRankHasDuty(cr, DUTY_PME));
}
else
{
dd_init_local_state(cr->dd, state_global, &ems->s);
/* Distribute the charge groups over the nodes from the master node */
- dd_partition_system(fplog, mdlog, ir->init_step, cr, TRUE, 1, state_global, *top_global, ir,
- imdSession, pull_work, &ems->s, &ems->f, mdAtoms, top, fr, vsite,
- constr, nrnb, nullptr, FALSE);
+ dd_partition_system(fplog,
+ mdlog,
+ ir->init_step,
+ cr,
+ TRUE,
+ 1,
+ state_global,
+ *top_global,
+ ir,
+ imdSession,
+ pull_work,
+ &ems->s,
+ &ems->f,
+ mdAtoms,
+ top,
+ fr,
+ vsite,
+ constr,
+ nrnb,
+ nullptr,
+ FALSE);
dd_store_state(cr->dd, &ems->s);
}
else
ems->s = *state_global;
state_change_natoms(&ems->s, ems->s.natoms);
- mdAlgorithmsSetupAtomData(cr, ir, *top_global, top, fr, &ems->f, mdAtoms, constr, vsite,
- shellfc ? *shellfc : nullptr);
+ mdAlgorithmsSetupAtomData(
+ cr, ir, *top_global, top, fr, &ems->f, mdAtoms, constr, vsite, shellfc ? *shellfc : nullptr);
}
update_mdatoms(mdAtoms->mdatoms(), ems->s.lambda[efptMASS]);
// TODO how should this cross-module support dependency be managed?
if (ir->eConstrAlg == econtSHAKE && gmx_mtop_ftype_count(top_global, F_CONSTR) > 0)
{
- gmx_fatal(FARGS, "Can not do energy minimization with %s, use %s\n",
- econstr_names[econtSHAKE], econstr_names[econtLINCS]);
+ gmx_fatal(FARGS,
+ "Can not do energy minimization with %s, use %s\n",
+ econstr_names[econtSHAKE],
+ econstr_names[econtLINCS]);
}
if (!ir->bContinuation)
bool computeEnergy = true;
bool computeVirial = false;
dvdl_constr = 0;
- constr->apply(needsLogging, computeEnergy, -1, 0, 1.0, ems->s.x.arrayRefWithPadding(),
- ems->s.x.arrayRefWithPadding(), ArrayRef<RVec>(), ems->s.box,
- ems->s.lambda[efptFEP], &dvdl_constr, gmx::ArrayRefWithPadding<RVec>(),
- computeVirial, nullptr, gmx::ConstraintVariable::Positions);
+ constr->apply(needsLogging,
+ computeEnergy,
+ -1,
+ 0,
+ 1.0,
+ ems->s.x.arrayRefWithPadding(),
+ ems->s.x.arrayRefWithPadding(),
+ ArrayRef<RVec>(),
+ ems->s.box,
+ ems->s.lambda[efptFEP],
+ &dvdl_constr,
+ gmx::ArrayRefWithPadding<RVec>(),
+ computeVirial,
+ nullptr,
+ gmx::ConstraintVariable::Positions);
}
}
}
gmx::WriteCheckpointDataHolder checkpointDataHolder;
- mdoutf_write_to_trajectory_files(fplog, cr, outf, mdof_flags, top_global->natoms, step,
- static_cast<double>(step), &state->s, state_global,
- observablesHistory, state->f.view().force(), &checkpointDataHolder);
+ mdoutf_write_to_trajectory_files(fplog,
+ cr,
+ outf,
+ mdof_flags,
+ top_global->natoms,
+ step,
+ static_cast<double>(step),
+ &state->s,
+ state_global,
+ observablesHistory,
+ state->f.view().force(),
+ &checkpointDataHolder);
if (confout != nullptr)
{
if (!bX)
{
auto globalXRef = MASTER(cr) ? state_global->x : gmx::ArrayRef<gmx::RVec>();
- dd_collect_vec(cr->dd, state->s.ddp_count, state->s.ddp_count_cg_gl, state->s.cg_gl,
- state->s.x, globalXRef);
+ dd_collect_vec(
+ cr->dd, state->s.ddp_count, state->s.ddp_count_cg_gl, state->s.cg_gl, state->s.x, globalXRef);
}
}
else
do_pbc_mtop(ir->pbcType, state->s.box, top_global, state_global->x.rvec_array());
}
- write_sto_conf_mtop(confout, *top_global->name, top_global,
- state_global->x.rvec_array(), nullptr, ir->pbcType, state->s.box);
+ write_sto_conf_mtop(confout,
+ *top_global->name,
+ top_global,
+ state_global->x.rvec_array(),
+ nullptr,
+ ir->pbcType,
+ state->s.box);
}
}
}
if (constr)
{
dvdl_constr = 0;
- validStep = constr->apply(
- TRUE, TRUE, count, 0, 1.0, s1->x.arrayRefWithPadding(), s2->x.arrayRefWithPadding(),
- ArrayRef<RVec>(), s2->box, s2->lambda[efptBONDED], &dvdl_constr,
- gmx::ArrayRefWithPadding<RVec>(), false, nullptr, gmx::ConstraintVariable::Positions);
+ validStep = constr->apply(TRUE,
+ TRUE,
+ count,
+ 0,
+ 1.0,
+ s1->x.arrayRefWithPadding(),
+ s2->x.arrayRefWithPadding(),
+ ArrayRef<RVec>(),
+ s2->box,
+ s2->lambda[efptBONDED],
+ &dvdl_constr,
+ gmx::ArrayRefWithPadding<RVec>(),
+ false,
+ nullptr,
+ gmx::ConstraintVariable::Positions);
if (cr->nnodes > 1)
{
gmx_fatal(FARGS,
"The coordinates could not be constrained. Minimizer '%s' can not handle "
"constraint failures, use minimizer '%s' before using '%s'.",
- EI(ir->eI), EI(eiSteep), EI(ir->eI));
+ EI(ir->eI),
+ EI(eiSteep),
+ EI(ir->eI));
}
}
gmx_wallcycle_t wcycle)
{
/* Repartition the domain decomposition */
- dd_partition_system(fplog, mdlog, step, cr, FALSE, 1, nullptr, *top_global, ir, imdSession, pull_work,
- &ems->s, &ems->f, mdAtoms, top, fr, vsite, constr, nrnb, wcycle, FALSE);
+ dd_partition_system(fplog,
+ mdlog,
+ step,
+ cr,
+ FALSE,
+ 1,
+ nullptr,
+ *top_global,
+ ir,
+ imdSession,
+ pull_work,
+ &ems->s,
+ &ems->f,
+ mdAtoms,
+ top,
+ fr,
+ vsite,
+ constr,
+ nrnb,
+ wcycle,
+ FALSE);
dd_store_state(cr->dd, &ems->s);
}
if (DOMAINDECOMP(cr) && bNS)
{
/* Repartition the domain decomposition */
- em_dd_partition_system(fplog, mdlog, count, cr, top_global, inputrec, imdSession, pull_work,
- ems, top, mdAtoms, fr, vsite, constr, nrnb, wcycle);
+ em_dd_partition_system(
+ fplog, mdlog, count, cr, top_global, inputrec, imdSession, pull_work, ems, top, mdAtoms, fr, vsite, constr, nrnb, wcycle);
}
/* Calc force & energy on new trial position */
/* do_force always puts the charge groups in the box and shifts again
* We do not unshift, so molecules are always whole in congrad.c
*/
- do_force(fplog, cr, ms, inputrec, nullptr, nullptr, imdSession, pull_work, count, nrnb, wcycle,
- top, ems->s.box, ems->s.x.arrayRefWithPadding(), &ems->s.hist, &ems->f.view(), force_vir,
- mdAtoms->mdatoms(), enerd, ems->s.lambda, fr, runScheduleWork, vsite, mu_tot, t, nullptr,
+ do_force(fplog,
+ cr,
+ ms,
+ inputrec,
+ nullptr,
+ nullptr,
+ imdSession,
+ pull_work,
+ count,
+ nrnb,
+ wcycle,
+ top,
+ ems->s.box,
+ ems->s.x.arrayRefWithPadding(),
+ &ems->s.hist,
+ &ems->f.view(),
+ force_vir,
+ mdAtoms->mdatoms(),
+ enerd,
+ ems->s.lambda,
+ fr,
+ runScheduleWork,
+ vsite,
+ mu_tot,
+ t,
+ nullptr,
GMX_FORCE_STATECHANGED | GMX_FORCE_ALLFORCES | GMX_FORCE_VIRIAL | GMX_FORCE_ENERGY
| (bNS ? GMX_FORCE_NS : 0),
DDBalanceRegionHandler(cr));
{
wallcycle_start(wcycle, ewcMoveE);
- global_stat(gstat, cr, enerd, force_vir, shake_vir, inputrec, nullptr, nullptr, nullptr, 1,
- &terminate, nullptr, FALSE, CGLO_ENERGY | CGLO_PRESSURE | CGLO_CONSTRAINT);
+ global_stat(gstat,
+ cr,
+ enerd,
+ force_vir,
+ shake_vir,
+ inputrec,
+ nullptr,
+ nullptr,
+ nullptr,
+ 1,
+ &terminate,
+ nullptr,
+ FALSE,
+ CGLO_ENERGY | CGLO_PRESSURE | CGLO_CONSTRAINT);
wallcycle_stop(wcycle, ewcMoveE);
}
bool computeVirial = true;
dvdl_constr = 0;
auto f = ems->f.view().forceWithPadding();
- constr->apply(needsLogging, computeEnergy, count, 0, 1.0, ems->s.x.arrayRefWithPadding(), f,
- f.unpaddedArrayRef(), ems->s.box, ems->s.lambda[efptBONDED], &dvdl_constr,
- gmx::ArrayRefWithPadding<RVec>(), computeVirial, shake_vir,
+ constr->apply(needsLogging,
+ computeEnergy,
+ count,
+ 0,
+ 1.0,
+ ems->s.x.arrayRefWithPadding(),
+ f,
+ f.unpaddedArrayRef(),
+ ems->s.box,
+ ems->s.lambda[efptBONDED],
+ &dvdl_constr,
+ gmx::ArrayRefWithPadding<RVec>(),
+ computeVirial,
+ shake_vir,
gmx::ConstraintVariable::ForceDispl);
enerd->term[F_DVDL_CONSTR] += dvdl_constr;
m_add(force_vir, shake_vir, vir);
em_state_t* s_c = &s3;
/* Init em and store the local state in s_min */
- init_em(fplog, mdlog, CG, cr, inputrec, imdSession, pull_work, state_global, top_global, s_min,
- &top, nrnb, fr, mdAtoms, &gstat, vsite, constr, nullptr);
+ init_em(fplog,
+ mdlog,
+ CG,
+ cr,
+ inputrec,
+ imdSession,
+ pull_work,
+ state_global,
+ top_global,
+ s_min,
+ &top,
+ nrnb,
+ fr,
+ mdAtoms,
+ &gstat,
+ vsite,
+ constr,
+ nullptr);
const bool simulationsShareState = false;
- gmx_mdoutf* outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider,
- mdModulesNotifier, inputrec, top_global, nullptr, wcycle,
- StartingBehavior::NewSimulation, simulationsShareState, ms);
- gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, inputrec, pull_work,
- nullptr, false, StartingBehavior::NewSimulation,
- simulationsShareState, mdModulesNotifier);
+ gmx_mdoutf* outf = init_mdoutf(fplog,
+ nfile,
+ fnm,
+ mdrunOptions,
+ cr,
+ outputProvider,
+ mdModulesNotifier,
+ inputrec,
+ top_global,
+ nullptr,
+ wcycle,
+ StartingBehavior::NewSimulation,
+ simulationsShareState,
+ ms);
+ gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf),
+ top_global,
+ inputrec,
+ pull_work,
+ nullptr,
+ false,
+ StartingBehavior::NewSimulation,
+ simulationsShareState,
+ mdModulesNotifier);
/* Print to log file */
print_em_start(fplog, cr, walltime_accounting, wcycle, CG);
{
/* Copy stuff to the energy bin for easy printing etc. */
matrix nullBox = {};
- energyOutput.addDataAtEnergyStep(false, false, static_cast<double>(step), mdatoms->tmass,
- enerd, nullptr, nullptr, nullBox, PTCouplingArrays(), 0,
- nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
+ energyOutput.addDataAtEnergyStep(false,
+ false,
+ static_cast<double>(step),
+ mdatoms->tmass,
+ enerd,
+ nullptr,
+ nullptr,
+ nullBox,
+ PTCouplingArrays(),
+ 0,
+ nullptr,
+ nullptr,
+ vir,
+ pres,
+ nullptr,
+ mu_tot,
+ constr);
EnergyOutput::printHeader(fplog, step, step);
- energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), TRUE, FALSE, FALSE, fplog, step,
- step, fr->fcdata.get(), nullptr);
+ energyOutput.printStepToEnergyFile(
+ mdoutf_get_fp_ene(outf), TRUE, FALSE, FALSE, fplog, step, step, fr->fcdata.get(), nullptr);
}
/* Estimate/guess the initial stepsize */
do_x = do_per_step(step, inputrec->nstxout);
do_f = do_per_step(step, inputrec->nstfout);
- write_em_traj(fplog, cr, outf, do_x, do_f, nullptr, top_global, inputrec, step, s_min,
- state_global, observablesHistory);
+ write_em_traj(
+ fplog, cr, outf, do_x, do_f, nullptr, top_global, inputrec, step, s_min, state_global, observablesHistory);
/* Take a step downhill.
* In theory, we should minimize the function along this direction.
if (DOMAINDECOMP(cr) && s_min->s.ddp_count < cr->dd->ddp_count)
{
- em_dd_partition_system(fplog, mdlog, step, cr, top_global, inputrec, imdSession,
- pull_work, s_min, &top, mdAtoms, fr, vsite, constr, nrnb, wcycle);
+ em_dd_partition_system(fplog,
+ mdlog,
+ step,
+ cr,
+ top_global,
+ inputrec,
+ imdSession,
+ pull_work,
+ s_min,
+ &top,
+ mdAtoms,
+ fr,
+ vsite,
+ constr,
+ nrnb,
+ wcycle);
}
/* Take a trial step (new coords in s_c) */
- do_em_step(cr, inputrec, mdatoms, s_min, c, s_min->s.cg_p.constArrayRefWithPadding(), s_c,
- constr, -1);
+ do_em_step(cr, inputrec, mdatoms, s_min, c, s_min->s.cg_p.constArrayRefWithPadding(), s_c, constr, -1);
neval++;
/* Calculate energy for the trial step */
if (DOMAINDECOMP(cr) && s_min->s.ddp_count != cr->dd->ddp_count)
{
/* Reload the old state */
- em_dd_partition_system(fplog, mdlog, -1, cr, top_global, inputrec, imdSession, pull_work,
- s_min, &top, mdAtoms, fr, vsite, constr, nrnb, wcycle);
+ em_dd_partition_system(fplog,
+ mdlog,
+ -1,
+ cr,
+ top_global,
+ inputrec,
+ imdSession,
+ pull_work,
+ s_min,
+ &top,
+ mdAtoms,
+ fr,
+ vsite,
+ constr,
+ nrnb,
+ wcycle);
}
/* Take a trial step to this new point - new coords in s_b */
- do_em_step(cr, inputrec, mdatoms, s_min, b,
- s_min->s.cg_p.constArrayRefWithPadding(), s_b, constr, -1);
+ do_em_step(cr, inputrec, mdatoms, s_min, b, s_min->s.cg_p.constArrayRefWithPadding(), s_b, constr, -1);
neval++;
/* Calculate energy for the trial step */
if (debug)
{
- fprintf(debug, "CGE: EpotA %f EpotB %f EpotC %f gpb %f\n", s_a->epot, s_b->epot,
- s_c->epot, gpb);
+ fprintf(debug, "CGE: EpotA %f EpotB %f EpotC %f gpb %f\n", s_a->epot, s_b->epot, s_c->epot, gpb);
}
epot_repl = s_b->epot;
{
if (debug)
{
- fprintf(debug, "CGE: C (%f) is lower than A (%f), moving C to B\n", s_c->epot,
- s_a->epot);
+ fprintf(debug, "CGE: C (%f) is lower than A (%f), moving C to B\n", s_c->epot, s_a->epot);
}
swap_em_state(&s_b, &s_c);
gpb = gpc;
{
if (debug)
{
- fprintf(debug, "CGE: A (%f) is lower than C (%f), moving A to B\n", s_a->epot,
- s_c->epot);
+ fprintf(debug, "CGE: A (%f) is lower than C (%f), moving A to B\n", s_a->epot, s_c->epot);
}
swap_em_state(&s_b, &s_a);
gpb = gpa;
if (mdrunOptions.verbose)
{
double sqrtNumAtoms = sqrt(static_cast<double>(state_global->natoms));
- fprintf(stderr, "\rStep %d, Epot=%12.6e, Fnorm=%9.3e, Fmax=%9.3e (atom %d)\n", step,
- s_min->epot, s_min->fnorm / sqrtNumAtoms, s_min->fmax, s_min->a_fmax + 1);
+ fprintf(stderr,
+ "\rStep %d, Epot=%12.6e, Fnorm=%9.3e, Fmax=%9.3e (atom %d)\n",
+ step,
+ s_min->epot,
+ s_min->fnorm / sqrtNumAtoms,
+ s_min->fmax,
+ s_min->a_fmax + 1);
fflush(stderr);
}
/* Store the new (lower) energies */
matrix nullBox = {};
- energyOutput.addDataAtEnergyStep(false, false, static_cast<double>(step), mdatoms->tmass,
- enerd, nullptr, nullptr, nullBox, PTCouplingArrays(), 0,
- nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
+ energyOutput.addDataAtEnergyStep(false,
+ false,
+ static_cast<double>(step),
+ mdatoms->tmass,
+ enerd,
+ nullptr,
+ nullptr,
+ nullBox,
+ PTCouplingArrays(),
+ 0,
+ nullptr,
+ nullptr,
+ vir,
+ pres,
+ nullptr,
+ mu_tot,
+ constr);
do_log = do_per_step(step, inputrec->nstlog);
do_ene = do_per_step(step, inputrec->nstenergy);
{
EnergyOutput::printHeader(fplog, step, step);
}
- energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), do_ene, FALSE, FALSE,
- do_log ? fplog : nullptr, step, step,
- fr->fcdata.get(), nullptr);
+ energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf),
+ do_ene,
+ FALSE,
+ FALSE,
+ do_log ? fplog : nullptr,
+ step,
+ step,
+ fr->fcdata.get(),
+ nullptr);
}
/* Send energies and positions to the IMD client if bIMD is TRUE. */
if (!do_ene || !do_log)
{
/* Write final energy file entries */
- energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), !do_ene, FALSE, FALSE,
- !do_log ? fplog : nullptr, step, step,
- fr->fcdata.get(), nullptr);
+ energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf),
+ !do_ene,
+ FALSE,
+ FALSE,
+ !do_log ? fplog : nullptr,
+ step,
+ step,
+ fr->fcdata.get(),
+ nullptr);
}
}
do_x = !do_per_step(step, inputrec->nstxout);
do_f = (inputrec->nstfout > 0 && !do_per_step(step, inputrec->nstfout));
- write_em_traj(fplog, cr, outf, do_x, do_f, ftp2fn(efSTO, nfile, fnm), top_global, inputrec,
- step, s_min, state_global, observablesHistory);
+ write_em_traj(
+ fplog, cr, outf, do_x, do_f, ftp2fn(efSTO, nfile, fnm), top_global, inputrec, step, s_min, state_global, observablesHistory);
if (MASTER(cr))
neval = 0;
/* Init em */
- init_em(fplog, mdlog, LBFGS, cr, inputrec, imdSession, pull_work, state_global, top_global,
- &ems, &top, nrnb, fr, mdAtoms, &gstat, vsite, constr, nullptr);
+ init_em(fplog,
+ mdlog,
+ LBFGS,
+ cr,
+ inputrec,
+ imdSession,
+ pull_work,
+ state_global,
+ top_global,
+ &ems,
+ &top,
+ nrnb,
+ fr,
+ mdAtoms,
+ &gstat,
+ vsite,
+ constr,
+ nullptr);
const bool simulationsShareState = false;
- gmx_mdoutf* outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider,
- mdModulesNotifier, inputrec, top_global, nullptr, wcycle,
- StartingBehavior::NewSimulation, simulationsShareState, ms);
- gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, inputrec, pull_work,
- nullptr, false, StartingBehavior::NewSimulation,
- simulationsShareState, mdModulesNotifier);
+ gmx_mdoutf* outf = init_mdoutf(fplog,
+ nfile,
+ fnm,
+ mdrunOptions,
+ cr,
+ outputProvider,
+ mdModulesNotifier,
+ inputrec,
+ top_global,
+ nullptr,
+ wcycle,
+ StartingBehavior::NewSimulation,
+ simulationsShareState,
+ ms);
+ gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf),
+ top_global,
+ inputrec,
+ pull_work,
+ nullptr,
+ false,
+ StartingBehavior::NewSimulation,
+ simulationsShareState,
+ mdModulesNotifier);
start = 0;
end = mdatoms->homenr;
{
/* Copy stuff to the energy bin for easy printing etc. */
matrix nullBox = {};
- energyOutput.addDataAtEnergyStep(false, false, static_cast<double>(step), mdatoms->tmass,
- enerd, nullptr, nullptr, nullBox, PTCouplingArrays(), 0,
- nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
+ energyOutput.addDataAtEnergyStep(false,
+ false,
+ static_cast<double>(step),
+ mdatoms->tmass,
+ enerd,
+ nullptr,
+ nullptr,
+ nullBox,
+ PTCouplingArrays(),
+ 0,
+ nullptr,
+ nullptr,
+ vir,
+ pres,
+ nullptr,
+ mu_tot,
+ constr);
EnergyOutput::printHeader(fplog, step, step);
- energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), TRUE, FALSE, FALSE, fplog, step,
- step, fr->fcdata.get(), nullptr);
+ energyOutput.printStepToEnergyFile(
+ mdoutf_get_fp_ene(outf), TRUE, FALSE, FALSE, fplog, step, step, fr->fcdata.get(), nullptr);
}
/* Set the initial step.
}
gmx::WriteCheckpointDataHolder checkpointDataHolder;
- mdoutf_write_to_trajectory_files(fplog, cr, outf, mdof_flags, top_global->natoms, step,
- static_cast<real>(step), &ems.s, state_global, observablesHistory,
- ems.f.view().force(), &checkpointDataHolder);
+ mdoutf_write_to_trajectory_files(fplog,
+ cr,
+ outf,
+ mdof_flags,
+ top_global->natoms,
+ step,
+ static_cast<real>(step),
+ &ems.s,
+ state_global,
+ observablesHistory,
+ ems.f.view().force(),
+ &checkpointDataHolder);
/* Do the linesearching in the direction dx[point][0..(n-1)] */
if (mdrunOptions.verbose)
{
double sqrtNumAtoms = sqrt(static_cast<double>(state_global->natoms));
- fprintf(stderr, "\rStep %d, Epot=%12.6e, Fnorm=%9.3e, Fmax=%9.3e (atom %d)\n", step,
- ems.epot, ems.fnorm / sqrtNumAtoms, ems.fmax, ems.a_fmax + 1);
+ fprintf(stderr,
+ "\rStep %d, Epot=%12.6e, Fnorm=%9.3e, Fmax=%9.3e (atom %d)\n",
+ step,
+ ems.epot,
+ ems.fnorm / sqrtNumAtoms,
+ ems.fmax,
+ ems.a_fmax + 1);
fflush(stderr);
}
/* Store the new (lower) energies */
matrix nullBox = {};
- energyOutput.addDataAtEnergyStep(false, false, static_cast<double>(step), mdatoms->tmass,
- enerd, nullptr, nullptr, nullBox, PTCouplingArrays(), 0,
- nullptr, nullptr, vir, pres, nullptr, mu_tot, constr);
+ energyOutput.addDataAtEnergyStep(false,
+ false,
+ static_cast<double>(step),
+ mdatoms->tmass,
+ enerd,
+ nullptr,
+ nullptr,
+ nullBox,
+ PTCouplingArrays(),
+ 0,
+ nullptr,
+ nullptr,
+ vir,
+ pres,
+ nullptr,
+ mu_tot,
+ constr);
do_log = do_per_step(step, inputrec->nstlog);
do_ene = do_per_step(step, inputrec->nstenergy);
{
EnergyOutput::printHeader(fplog, step, step);
}
- energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), do_ene, FALSE, FALSE,
- do_log ? fplog : nullptr, step, step,
- fr->fcdata.get(), nullptr);
+ energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf),
+ do_ene,
+ FALSE,
+ FALSE,
+ do_log ? fplog : nullptr,
+ step,
+ step,
+ fr->fcdata.get(),
+ nullptr);
}
/* Send x and E to IMD client, if bIMD is TRUE. */
}
if (!do_ene || !do_log) /* Write final energy file entries */
{
- energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), !do_ene, FALSE, FALSE,
- !do_log ? fplog : nullptr, step, step, fr->fcdata.get(),
+ energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf),
+ !do_ene,
+ FALSE,
+ FALSE,
+ !do_log ? fplog : nullptr,
+ step,
+ step,
+ fr->fcdata.get(),
nullptr);
}
*/
do_x = !do_per_step(step, inputrec->nstxout);
do_f = !do_per_step(step, inputrec->nstfout);
- write_em_traj(fplog, cr, outf, do_x, do_f, ftp2fn(efSTO, nfile, fnm), top_global, inputrec,
- step, &ems, state_global, observablesHistory);
+ write_em_traj(
+ fplog, cr, outf, do_x, do_f, ftp2fn(efSTO, nfile, fnm), top_global, inputrec, step, &ems, state_global, observablesHistory);
if (MASTER(cr))
{
em_state_t* s_try = &s1;
/* Init em and store the local state in s_try */
- init_em(fplog, mdlog, SD, cr, inputrec, imdSession, pull_work, state_global, top_global, s_try,
- &top, nrnb, fr, mdAtoms, &gstat, vsite, constr, nullptr);
+ init_em(fplog,
+ mdlog,
+ SD,
+ cr,
+ inputrec,
+ imdSession,
+ pull_work,
+ state_global,
+ top_global,
+ s_try,
+ &top,
+ nrnb,
+ fr,
+ mdAtoms,
+ &gstat,
+ vsite,
+ constr,
+ nullptr);
const bool simulationsShareState = false;
- gmx_mdoutf* outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider,
- mdModulesNotifier, inputrec, top_global, nullptr, wcycle,
- StartingBehavior::NewSimulation, simulationsShareState, ms);
- gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf), top_global, inputrec, pull_work,
- nullptr, false, StartingBehavior::NewSimulation,
- simulationsShareState, mdModulesNotifier);
+ gmx_mdoutf* outf = init_mdoutf(fplog,
+ nfile,
+ fnm,
+ mdrunOptions,
+ cr,
+ outputProvider,
+ mdModulesNotifier,
+ inputrec,
+ top_global,
+ nullptr,
+ wcycle,
+ StartingBehavior::NewSimulation,
+ simulationsShareState,
+ ms);
+ gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf),
+ top_global,
+ inputrec,
+ pull_work,
+ nullptr,
+ false,
+ StartingBehavior::NewSimulation,
+ simulationsShareState,
+ mdModulesNotifier);
/* Print to log file */
print_em_start(fplog, cr, walltime_accounting, wcycle, SD);
bool validStep = true;
if (count > 0)
{
- validStep = do_em_step(cr, inputrec, mdatoms, s_min, stepsize,
- s_min->f.view().forceWithPadding(), s_try, constr, count);
+ validStep = do_em_step(
+ cr, inputrec, mdatoms, s_min, stepsize, s_min->f.view().forceWithPadding(), s_try, constr, count);
}
if (validStep)
{
if (mdrunOptions.verbose)
{
- fprintf(stderr, "Step=%5d, Dmax= %6.1e nm, Epot= %12.5e Fmax= %11.5e, atom= %d%c",
- count, ustep, s_try->epot, s_try->fmax, s_try->a_fmax + 1,
+ fprintf(stderr,
+ "Step=%5d, Dmax= %6.1e nm, Epot= %12.5e Fmax= %11.5e, atom= %d%c",
+ count,
+ ustep,
+ s_try->epot,
+ s_try->fmax,
+ s_try->a_fmax + 1,
((count == 0) || (s_try->epot < s_min->epot)) ? '\n' : '\r');
fflush(stderr);
}
{
/* Store the new (lower) energies */
matrix nullBox = {};
- energyOutput.addDataAtEnergyStep(false, false, static_cast<double>(count),
- mdatoms->tmass, enerd, nullptr, nullptr, nullBox,
- PTCouplingArrays(), 0, nullptr, nullptr, vir, pres,
- nullptr, mu_tot, constr);
+ energyOutput.addDataAtEnergyStep(false,
+ false,
+ static_cast<double>(count),
+ mdatoms->tmass,
+ enerd,
+ nullptr,
+ nullptr,
+ nullBox,
+ PTCouplingArrays(),
+ 0,
+ nullptr,
+ nullptr,
+ vir,
+ pres,
+ nullptr,
+ mu_tot,
+ constr);
imdSession->fillEnergyRecord(count, TRUE);
const bool do_dr = do_per_step(steps_accepted, inputrec->nstdisreout);
const bool do_or = do_per_step(steps_accepted, inputrec->nstorireout);
- energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf), TRUE, do_dr, do_or,
- fplog, count, count, fr->fcdata.get(), nullptr);
+ energyOutput.printStepToEnergyFile(
+ mdoutf_get_fp_ene(outf), TRUE, do_dr, do_or, fplog, count, count, fr->fcdata.get(), nullptr);
fflush(fplog);
}
}
/* Write to trn, if necessary */
do_x = do_per_step(steps_accepted, inputrec->nstxout);
do_f = do_per_step(steps_accepted, inputrec->nstfout);
- write_em_traj(fplog, cr, outf, do_x, do_f, nullptr, top_global, inputrec, count, s_min,
- state_global, observablesHistory);
+ write_em_traj(
+ fplog, cr, outf, do_x, do_f, nullptr, top_global, inputrec, count, s_min, state_global, observablesHistory);
}
else
{
if (DOMAINDECOMP(cr) && s_min->s.ddp_count != cr->dd->ddp_count)
{
/* Reload the old state */
- em_dd_partition_system(fplog, mdlog, count, cr, top_global, inputrec, imdSession,
- pull_work, s_min, &top, mdAtoms, fr, vsite, constr, nrnb, wcycle);
+ em_dd_partition_system(fplog,
+ mdlog,
+ count,
+ cr,
+ top_global,
+ inputrec,
+ imdSession,
+ pull_work,
+ s_min,
+ &top,
+ mdAtoms,
+ fr,
+ vsite,
+ constr,
+ nrnb,
+ wcycle);
}
}
}
/* Send IMD energies and positions, if bIMD is TRUE. */
- if (imdSession->run(count, TRUE, MASTER(cr) ? state_global->box : nullptr,
- MASTER(cr) ? state_global->x.rvec_array() : nullptr, 0)
+ if (imdSession->run(count,
+ TRUE,
+ MASTER(cr) ? state_global->box : nullptr,
+ MASTER(cr) ? state_global->x.rvec_array() : nullptr,
+ 0)
&& MASTER(cr))
{
imdSession->sendPositionsAndEnergies();
{
fprintf(stderr, "\nwriting lowest energy coordinates.\n");
}
- write_em_traj(fplog, cr, outf, TRUE, inputrec->nstfout != 0, ftp2fn(efSTO, nfile, fnm),
- top_global, inputrec, count, s_min, state_global, observablesHistory);
+ write_em_traj(fplog,
+ cr,
+ outf,
+ TRUE,
+ inputrec->nstfout != 0,
+ ftp2fn(efSTO, nfile, fnm),
+ top_global,
+ inputrec,
+ count,
+ s_min,
+ state_global,
+ observablesHistory);
if (MASTER(cr))
{
em_state_t state_work{};
/* Init em and store the local state in state_minimum */
- init_em(fplog, mdlog, NM, cr, inputrec, imdSession, pull_work, state_global, top_global,
- &state_work, &top, nrnb, fr, mdAtoms, &gstat, vsite, constr, &shellfc);
+ init_em(fplog,
+ mdlog,
+ NM,
+ cr,
+ inputrec,
+ imdSession,
+ pull_work,
+ state_global,
+ top_global,
+ &state_work,
+ &top,
+ nrnb,
+ fr,
+ mdAtoms,
+ &gstat,
+ vsite,
+ constr,
+ &shellfc);
const bool simulationsShareState = false;
- gmx_mdoutf* outf = init_mdoutf(fplog, nfile, fnm, mdrunOptions, cr, outputProvider,
- mdModulesNotifier, inputrec, top_global, nullptr, wcycle,
- StartingBehavior::NewSimulation, simulationsShareState, ms);
+ gmx_mdoutf* outf = init_mdoutf(fplog,
+ nfile,
+ fnm,
+ mdrunOptions,
+ cr,
+ outputProvider,
+ mdModulesNotifier,
+ inputrec,
+ top_global,
+ nullptr,
+ wcycle,
+ StartingBehavior::NewSimulation,
+ simulationsShareState,
+ ms);
std::vector<int> atom_index = get_atom_index(top_global);
std::vector<gmx::RVec> fneg(atom_index.size(), { 0, 0, 0 });
if (bIsMaster)
{
- fprintf(stderr, "starting normal mode calculation '%s'\n%" PRId64 " steps.\n\n",
- *(top_global->name), inputrec->nsteps);
+ fprintf(stderr,
+ "starting normal mode calculation '%s'\n%" PRId64 " steps.\n\n",
+ *(top_global->name),
+ inputrec->nsteps);
}
nnodes = cr->nnodes;
if (shellfc)
{
/* Now is the time to relax the shells */
- relax_shell_flexcon(fplog, cr, ms, mdrunOptions.verbose, nullptr, step, inputrec,
- imdSession, pull_work, bNS, force_flags, &top, constr, enerd,
- state_work.s.natoms, state_work.s.x.arrayRefWithPadding(),
- state_work.s.v.arrayRefWithPadding(), state_work.s.box,
- state_work.s.lambda, &state_work.s.hist, &state_work.f.view(),
- vir, mdatoms, nrnb, wcycle, shellfc, fr, runScheduleWork, t,
- mu_tot, vsite, DDBalanceRegionHandler(nullptr));
+ relax_shell_flexcon(fplog,
+ cr,
+ ms,
+ mdrunOptions.verbose,
+ nullptr,
+ step,
+ inputrec,
+ imdSession,
+ pull_work,
+ bNS,
+ force_flags,
+ &top,
+ constr,
+ enerd,
+ state_work.s.natoms,
+ state_work.s.x.arrayRefWithPadding(),
+ state_work.s.v.arrayRefWithPadding(),
+ state_work.s.box,
+ state_work.s.lambda,
+ &state_work.s.hist,
+ &state_work.f.view(),
+ vir,
+ mdatoms,
+ nrnb,
+ wcycle,
+ shellfc,
+ fr,
+ runScheduleWork,
+ t,
+ mu_tot,
+ vsite,
+ DDBalanceRegionHandler(nullptr));
bNS = false;
step++;
}
if (dx == 0)
{
- std::copy(state_work_f.begin(), state_work_f.begin() + atom_index.size(),
- fneg.begin());
+ std::copy(state_work_f.begin(), state_work_f.begin() + atom_index.size(), fneg.begin());
}
}
{
#if GMX_MPI
# define mpi_type GMX_MPI_REAL
- MPI_Send(dfdx[0], atom_index.size() * DIM, mpi_type, MASTER(cr), cr->nodeid,
- cr->mpi_comm_mygroup);
+ MPI_Send(dfdx[0], atom_index.size() * DIM, mpi_type, MASTER(cr), cr->nodeid, cr->mpi_comm_mygroup);
#endif
}
else
{
#if GMX_MPI
MPI_Status stat;
- MPI_Recv(dfdx[0], atom_index.size() * DIM, mpi_type, node, node,
- cr->mpi_comm_mygroup, &stat);
+ MPI_Recv(dfdx[0], atom_index.size() * DIM, mpi_type, node, node, cr->mpi_comm_mygroup, &stat);
# undef mpi_type
#endif
}
/* write progress */
if (bIsMaster && mdrunOptions.verbose)
{
- fprintf(stderr, "\rFinished step %d out of %td",
- std::min<int>(atom + nnodes, atom_index.size()), ssize(atom_index));
+ fprintf(stderr,
+ "\rFinished step %d out of %td",
+ std::min<int>(atom + nnodes, atom_index.size()),
+ ssize(atom_index));
fflush(stderr);
}
}