Use same matrix for Parrinello-Rahman and Berendsen coordinates scaling
authorArtem Zhmurov <zhmurov@gmail.com>
Tue, 12 Nov 2019 17:33:37 +0000 (18:33 +0100)
committerPaul Bauer <paul.bauer.q@gmail.com>
Mon, 25 Nov 2019 15:46:26 +0000 (16:46 +0100)
Currently, Parrinello-Rahman uses the matrix created in the md.cpp,
whereas it is created when needed internally for the Berendsen.
This commit renames the matrix and make use of it in both barostats.

Change-Id: I66e010a1ed7efbc93c8a2240ccb7b9e174fd7e45
(cherry picked from commit abab855fdceee437c33010ebbe544afe1f88db87)

src/gromacs/mdlib/update.cpp
src/gromacs/mdlib/update.h
src/gromacs/mdrun/md.cpp

index 503fa4d20e3841ac0e64180df221c4024a68813b..eeff24cf943a8bd21f58d2affa9b5cdafd9e6caa 100644 (file)
@@ -1664,7 +1664,7 @@ void update_pcouple_after_coordinates(FILE*             fplog,
                                       const matrix      pressure,
                                       const matrix      forceVirial,
                                       const matrix      constraintVirial,
-                                      const matrix      parrinellorahmanMu,
+                                      matrix            pressureCouplingMu,
                                       t_state*          state,
                                       t_nrnb*           nrnb,
                                       Update*           upd)
@@ -1683,12 +1683,11 @@ void update_pcouple_after_coordinates(FILE*             fplog,
         case (epcBERENDSEN):
             if (do_per_step(step, inputrec->nstpcouple))
             {
-                real   dtpc = inputrec->nstpcouple * dt;
-                matrix mu;
+                real dtpc = inputrec->nstpcouple * dt;
                 berendsen_pcoupl(fplog, step, inputrec, dtpc, pressure, state->box, forceVirial,
-                                 constraintVirial, mu, &state->baros_integral);
-                berendsen_pscale(inputrec, mu, state->box, state->box_rel, start, homenr,
-                                 state->x.rvec_array(), md->cFREEZE, nrnb);
+                                 constraintVirial, pressureCouplingMu, &state->baros_integral);
+                berendsen_pscale(inputrec, pressureCouplingMu, state->box, state->box_rel, start,
+                                 homenr, state->x.rvec_array(), md->cFREEZE, nrnb);
             }
             break;
         case (epcPARRINELLORAHMAN):
@@ -1712,7 +1711,7 @@ void update_pcouple_after_coordinates(FILE*             fplog,
                 auto x = state->x.rvec_array();
                 for (int n = start; n < start + homenr; n++)
                 {
-                    tmvmul_ur0(parrinellorahmanMu, x[n], x[n]);
+                    tmvmul_ur0(pressureCouplingMu, x[n], x[n]);
                 }
             }
             break;
index c5f2522f44061edcd66955d9e0f1cd72d4f7fc7d..8239a97b87b1484a7aab2f53178432b93c87380b 100644 (file)
@@ -131,7 +131,7 @@ void update_pcouple_after_coordinates(FILE*             fplog,
                                       const matrix      pressure,
                                       const matrix      forceVirial,
                                       const matrix      constraintVirial,
-                                      const matrix      parrinellorahmanMu,
+                                      matrix            pressureCouplingMu,
                                       t_state*          state,
                                       t_nrnb*           nrnb,
                                       gmx::Update*      upd);
index e054d2c9d44c8d0d2bd4adbb911a1a3c21c13f82..da1278b19ed5f0e5ffe4f35ad618912ef14c0999 100644 (file)
@@ -172,7 +172,7 @@ void gmx::LegacySimulator::do_md()
            pres = { { 0 } };
     int                         i, m;
     rvec                        mu_tot;
-    matrix                      parrinellorahmanMu, M;
+    matrix                      pressureCouplingMu, M;
     gmx_repl_ex_t               repl_ex = nullptr;
     gmx_localtop_t              top;
     PaddedHostVector<gmx::RVec> f{};
@@ -1209,7 +1209,7 @@ void gmx::LegacySimulator::do_md()
         else
         {
             update_tcouple(step, ir, state, ekind, &MassQ, mdatoms);
-            update_pcouple_before_coordinates(fplog, step, ir, state, parrinellorahmanMu, M, bInitStep);
+            update_pcouple_before_coordinates(fplog, step, ir, state, pressureCouplingMu, M, bInitStep);
         }
 
         if (EI_VV(ir->eI))
@@ -1441,7 +1441,7 @@ void gmx::LegacySimulator::do_md()
         }
 
         update_pcouple_after_coordinates(fplog, step, ir, mdatoms, pres, force_vir, shake_vir,
-                                         parrinellorahmanMu, state, nrnb, &upd);
+                                         pressureCouplingMu, state, nrnb, &upd);
 
         /* ################# END UPDATE STEP 2 ################# */
         /* #### We now have r(t+dt) and v(t+dt/2)  ############# */