Allow using COM of previous step as PBC reference
[alexxy/gromacs.git] / src / gromacs / mdrun / md.cpp
index c430b2cf91fd74f3df7af5dc50baadaa67474eb8..78195bc80eb03a30fc2fa2e006cd4b09296c9c13 100644 (file)
@@ -361,6 +361,20 @@ void gmx::Integrator::do_md()
                  */
                 observablesHistory->energyHistory = {};
             }
+            if (ir->pull && ir->pull->bSetPbcRefToPrevStepCOM)
+            {
+                /* Copy the pull group COM of the previous step from the checkpoint state to the pull state */
+                setPrevStepPullComFromState(ir->pull_work, state);
+            }
+        }
+        else if (ir->pull && ir->pull->bSetPbcRefToPrevStepCOM)
+        {
+            allocStatePrevStepPullCom(state, ir->pull_work);
+            t_pbc pbc;
+            set_pbc(&pbc, ir->ePBC, state->box);
+            initPullComFromPrevStep(cr, ir->pull_work, mdatoms, &pbc, as_rvec_array(state->x.data()));
+            updatePrevStepCom(ir->pull_work);
+            setStatePrevStepPullCom(ir->pull_work, state);
         }
         if (observablesHistory->energyHistory == nullptr)
         {
@@ -1145,6 +1159,12 @@ void gmx::Integrator::do_md()
                       state, graph,
                       nrnb, wcycle, upd, constr);
 
+        if (MASTER(cr) && ir->bPull && ir->pull->bSetPbcRefToPrevStepCOM)
+        {
+            updatePrevStepCom(ir->pull_work);
+            setStatePrevStepPullCom(ir->pull_work, state);
+        }
+
         if (ir->eI == eiVVAK)
         {
             /* erase F_EKIN and F_TEMP here? */