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>
Wed, 13 Nov 2019 12:10:46 +0000 (13:10 +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

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 bdaf94ce3a2f4a345c32dc11f8867a23bbfac908..03c3ccb1e002db56e23d135cd44eb173f48f9690 100644 (file)
@@ -173,7 +173,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{};
@@ -1211,7 +1211,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))
@@ -1443,7 +1443,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)  ############# */