Require -ei for essential dynamics
authorBerk Hess <hess@kth.se>
Tue, 22 Oct 2019 09:33:20 +0000 (11:33 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Tue, 22 Oct 2019 15:32:10 +0000 (17:32 +0200)
Essential dynamics sampling was switching on by either the -ei
option or by ED information being present in the checkpoint file.
As this complicates initialization and we should not choose
algorithms based on a checkpoint, it is now only switched on
by the -ei option (but an mdp option is we actually want).

Change-Id: I6e0873a38ee42779d09f66ed7e55c6d1b8bf25da

src/gromacs/mdrun/md.cpp
src/gromacs/mdrun/runner.cpp

index d62fafa24942a93cbd728dfc2ba36a30af28a7f7..a01c2decad3f8954d9a921106f5ddcbc17a4829a 100644 (file)
@@ -237,7 +237,7 @@ void gmx::LegacySimulator::do_md()
     SimulationGroups                  *groups = &top_global->groups;
 
     std::unique_ptr<EssentialDynamics> ed = nullptr;
-    if (opt2bSet("-ei", nfile, fnm) || observablesHistory->edsamHistory != nullptr)
+    if (opt2bSet("-ei", nfile, fnm))
     {
         /* Initialize essential dynamics sampling */
         ed = init_edsam(mdlog,
@@ -248,6 +248,13 @@ void gmx::LegacySimulator::do_md()
                         oenv,
                         startingBehavior);
     }
+    else if (observablesHistory->edsamHistory)
+    {
+        gmx_fatal(FARGS,
+                  "The checkpoint is from a run with essential dynamics sampling, "
+                  "but the current run did not specify the -ei option. "
+                  "Either specify the -ei option to mdrun, or do not use this checkpoint file.");
+    }
 
     initialize_lambdas(fplog, *ir, MASTER(cr), &state_global->fep_state, state_global->lambda, lam0);
     Update     upd(ir, deform);
index a49f5372d5f3b9beea1e74b13c9ba3ed9a127e5c..ee79084fb40d3f6ae53b4fbf6a471a6e2451b64f 100644 (file)
@@ -685,8 +685,10 @@ int Mdrunner::mdrunner()
        cr doesn't reflect the final parallel state right now */
     gmx_mtop_t                      mtop;
 
-    bool doMembed = opt2bSet("-membed", filenames.size(), filenames.data());
-    bool doRerun  = mdrunOptions.rerun;
+    /* TODO: inputrec should tell us whether we use an algorithm, not a file option */
+    const bool doEssentialDynamics = opt2bSet("-ei", filenames.size(), filenames.data());
+    const bool doMembed            = opt2bSet("-membed", filenames.size(), filenames.data());
+    const bool doRerun             = mdrunOptions.rerun;
 
     // Handle task-assignment related user options.
     EmulateGpuNonbonded emulateGpuNonbonded = (getenv("GMX_EMULATE_GPU") != nullptr ?
@@ -1504,14 +1506,10 @@ int Mdrunner::mdrunner()
                                    startingBehavior);
         }
 
-        /* Let makeConstraints know whether we have essential dynamics constraints.
-         * TODO: inputrec should tell us whether we use an algorithm, not a file option or the checkpoint
-         */
-        bool doEssentialDynamics = (opt2fn_null("-ei", filenames.size(), filenames.data()) != nullptr
-                                    || observablesHistory.edsamHistory);
-        auto constr              = makeConstraints(mtop, *inputrec, pull_work, doEssentialDynamics,
-                                                   fplog, *mdAtoms->mdatoms(),
-                                                   cr, ms, &nrnb, wcycle, fr->bMolPBC);
+        /* Let makeConstraints know whether we have essential dynamics constraints. */
+        auto constr = makeConstraints(mtop, *inputrec, pull_work, doEssentialDynamics,
+                                      fplog, *mdAtoms->mdatoms(),
+                                      cr, ms, &nrnb, wcycle, fr->bMolPBC);
 
         /* Energy terms and groups */
         gmx_enerdata_t enerd(mtop.groups.groups[SimulationAtomGroupType::EnergyOutput].size(), inputrec->fepvals->n_lambda);