hillclimber 0.1.6__cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (475) hide show
  1. hillclimber/__init__.py +41 -0
  2. hillclimber/actions.py +53 -0
  3. hillclimber/analysis.py +590 -0
  4. hillclimber/biases.py +293 -0
  5. hillclimber/calc.py +22 -0
  6. hillclimber/cvs.py +1070 -0
  7. hillclimber/interfaces.py +133 -0
  8. hillclimber/metadynamics.py +416 -0
  9. hillclimber/nodes.py +6 -0
  10. hillclimber/opes.py +359 -0
  11. hillclimber/pycv.py +362 -0
  12. hillclimber/selectors.py +230 -0
  13. hillclimber/virtual_atoms.py +341 -0
  14. hillclimber-0.1.6.dist-info/METADATA +325 -0
  15. hillclimber-0.1.6.dist-info/RECORD +475 -0
  16. hillclimber-0.1.6.dist-info/WHEEL +6 -0
  17. hillclimber-0.1.6.dist-info/entry_points.txt +8 -0
  18. hillclimber-0.1.6.dist-info/licenses/LICENSE +165 -0
  19. hillclimber-0.1.6.dist-info/sboms/auditwheel.cdx.json +1 -0
  20. hillclimber.libs/libgomp-a49a47f9.so.1.0.0 +0 -0
  21. plumed/__init__.py +104 -0
  22. plumed/_lib/bin/plumed +0 -0
  23. plumed/_lib/bin/plumed-config +9 -0
  24. plumed/_lib/bin/plumed-patch +9 -0
  25. plumed/_lib/include/plumed/adjmat/AdjacencyMatrixBase.h +659 -0
  26. plumed/_lib/include/plumed/adjmat/ContactMatrix.h +59 -0
  27. plumed/_lib/include/plumed/asmjit/arch.h +228 -0
  28. plumed/_lib/include/plumed/asmjit/arm.h +43 -0
  29. plumed/_lib/include/plumed/asmjit/asmjit.h +69 -0
  30. plumed/_lib/include/plumed/asmjit/asmjit_apibegin.h +143 -0
  31. plumed/_lib/include/plumed/asmjit/asmjit_apiend.h +93 -0
  32. plumed/_lib/include/plumed/asmjit/asmjit_build.h +971 -0
  33. plumed/_lib/include/plumed/asmjit/assembler.h +183 -0
  34. plumed/_lib/include/plumed/asmjit/base.h +56 -0
  35. plumed/_lib/include/plumed/asmjit/codebuilder.h +944 -0
  36. plumed/_lib/include/plumed/asmjit/codecompiler.h +767 -0
  37. plumed/_lib/include/plumed/asmjit/codeemitter.h +528 -0
  38. plumed/_lib/include/plumed/asmjit/codeholder.h +777 -0
  39. plumed/_lib/include/plumed/asmjit/constpool.h +286 -0
  40. plumed/_lib/include/plumed/asmjit/cpuinfo.h +402 -0
  41. plumed/_lib/include/plumed/asmjit/func.h +1327 -0
  42. plumed/_lib/include/plumed/asmjit/globals.h +370 -0
  43. plumed/_lib/include/plumed/asmjit/inst.h +137 -0
  44. plumed/_lib/include/plumed/asmjit/logging.h +317 -0
  45. plumed/_lib/include/plumed/asmjit/misc_p.h +103 -0
  46. plumed/_lib/include/plumed/asmjit/moved_string.h +318 -0
  47. plumed/_lib/include/plumed/asmjit/operand.h +1599 -0
  48. plumed/_lib/include/plumed/asmjit/osutils.h +207 -0
  49. plumed/_lib/include/plumed/asmjit/regalloc_p.h +597 -0
  50. plumed/_lib/include/plumed/asmjit/runtime.h +227 -0
  51. plumed/_lib/include/plumed/asmjit/simdtypes.h +1104 -0
  52. plumed/_lib/include/plumed/asmjit/utils.h +1387 -0
  53. plumed/_lib/include/plumed/asmjit/vmem.h +183 -0
  54. plumed/_lib/include/plumed/asmjit/x86.h +45 -0
  55. plumed/_lib/include/plumed/asmjit/x86assembler.h +125 -0
  56. plumed/_lib/include/plumed/asmjit/x86builder.h +117 -0
  57. plumed/_lib/include/plumed/asmjit/x86compiler.h +322 -0
  58. plumed/_lib/include/plumed/asmjit/x86emitter.h +5149 -0
  59. plumed/_lib/include/plumed/asmjit/x86globals.h +535 -0
  60. plumed/_lib/include/plumed/asmjit/x86inst.h +2547 -0
  61. plumed/_lib/include/plumed/asmjit/x86instimpl_p.h +74 -0
  62. plumed/_lib/include/plumed/asmjit/x86internal_p.h +108 -0
  63. plumed/_lib/include/plumed/asmjit/x86logging_p.h +92 -0
  64. plumed/_lib/include/plumed/asmjit/x86misc.h +417 -0
  65. plumed/_lib/include/plumed/asmjit/x86operand.h +1133 -0
  66. plumed/_lib/include/plumed/asmjit/x86regalloc_p.h +734 -0
  67. plumed/_lib/include/plumed/asmjit/zone.h +1157 -0
  68. plumed/_lib/include/plumed/bias/Bias.h +82 -0
  69. plumed/_lib/include/plumed/bias/ReweightBase.h +58 -0
  70. plumed/_lib/include/plumed/blas/blas.h +253 -0
  71. plumed/_lib/include/plumed/blas/def_external.h +61 -0
  72. plumed/_lib/include/plumed/blas/def_internal.h +97 -0
  73. plumed/_lib/include/plumed/blas/real.h +49 -0
  74. plumed/_lib/include/plumed/cltools/CLTool.h +32 -0
  75. plumed/_lib/include/plumed/clusters/ClusteringBase.h +70 -0
  76. plumed/_lib/include/plumed/colvar/Colvar.h +32 -0
  77. plumed/_lib/include/plumed/colvar/ColvarInput.h +68 -0
  78. plumed/_lib/include/plumed/colvar/ColvarShortcut.h +81 -0
  79. plumed/_lib/include/plumed/colvar/CoordinationBase.h +52 -0
  80. plumed/_lib/include/plumed/colvar/MultiColvarTemplate.h +333 -0
  81. plumed/_lib/include/plumed/colvar/PathMSDBase.h +101 -0
  82. plumed/_lib/include/plumed/colvar/RMSDVector.h +78 -0
  83. plumed/_lib/include/plumed/config/Config.h +118 -0
  84. plumed/_lib/include/plumed/config/version.h +9 -0
  85. plumed/_lib/include/plumed/contour/ContourFindingObject.h +87 -0
  86. plumed/_lib/include/plumed/contour/DistanceFromContourBase.h +82 -0
  87. plumed/_lib/include/plumed/contour/FindContour.h +67 -0
  88. plumed/_lib/include/plumed/core/Action.h +540 -0
  89. plumed/_lib/include/plumed/core/ActionAnyorder.h +48 -0
  90. plumed/_lib/include/plumed/core/ActionAtomistic.h +343 -0
  91. plumed/_lib/include/plumed/core/ActionForInterface.h +99 -0
  92. plumed/_lib/include/plumed/core/ActionPilot.h +57 -0
  93. plumed/_lib/include/plumed/core/ActionRegister.h +124 -0
  94. plumed/_lib/include/plumed/core/ActionSet.h +163 -0
  95. plumed/_lib/include/plumed/core/ActionSetup.h +48 -0
  96. plumed/_lib/include/plumed/core/ActionShortcut.h +73 -0
  97. plumed/_lib/include/plumed/core/ActionToGetData.h +59 -0
  98. plumed/_lib/include/plumed/core/ActionToPutData.h +101 -0
  99. plumed/_lib/include/plumed/core/ActionWithArguments.h +140 -0
  100. plumed/_lib/include/plumed/core/ActionWithMatrix.h +87 -0
  101. plumed/_lib/include/plumed/core/ActionWithValue.h +258 -0
  102. plumed/_lib/include/plumed/core/ActionWithVector.h +94 -0
  103. plumed/_lib/include/plumed/core/ActionWithVirtualAtom.h +123 -0
  104. plumed/_lib/include/plumed/core/CLTool.h +177 -0
  105. plumed/_lib/include/plumed/core/CLToolMain.h +102 -0
  106. plumed/_lib/include/plumed/core/CLToolRegister.h +108 -0
  107. plumed/_lib/include/plumed/core/Colvar.h +115 -0
  108. plumed/_lib/include/plumed/core/DataPassingObject.h +94 -0
  109. plumed/_lib/include/plumed/core/DataPassingTools.h +54 -0
  110. plumed/_lib/include/plumed/core/DomainDecomposition.h +120 -0
  111. plumed/_lib/include/plumed/core/ExchangePatterns.h +47 -0
  112. plumed/_lib/include/plumed/core/FlexibleBin.h +63 -0
  113. plumed/_lib/include/plumed/core/GREX.h +61 -0
  114. plumed/_lib/include/plumed/core/GenericMolInfo.h +89 -0
  115. plumed/_lib/include/plumed/core/Group.h +41 -0
  116. plumed/_lib/include/plumed/core/ModuleMap.h +30 -0
  117. plumed/_lib/include/plumed/core/ParallelTaskManager.h +1023 -0
  118. plumed/_lib/include/plumed/core/PbcAction.h +61 -0
  119. plumed/_lib/include/plumed/core/PlumedMain.h +632 -0
  120. plumed/_lib/include/plumed/core/PlumedMainInitializer.h +118 -0
  121. plumed/_lib/include/plumed/core/RegisterBase.h +340 -0
  122. plumed/_lib/include/plumed/core/TargetDist.h +48 -0
  123. plumed/_lib/include/plumed/core/Value.h +547 -0
  124. plumed/_lib/include/plumed/core/WithCmd.h +93 -0
  125. plumed/_lib/include/plumed/dimred/SMACOF.h +55 -0
  126. plumed/_lib/include/plumed/drr/DRR.h +383 -0
  127. plumed/_lib/include/plumed/drr/colvar_UIestimator.h +777 -0
  128. plumed/_lib/include/plumed/fisst/legendre_rule_fast.h +44 -0
  129. plumed/_lib/include/plumed/function/Custom.h +54 -0
  130. plumed/_lib/include/plumed/function/Function.h +85 -0
  131. plumed/_lib/include/plumed/function/FunctionOfMatrix.h +368 -0
  132. plumed/_lib/include/plumed/function/FunctionOfScalar.h +135 -0
  133. plumed/_lib/include/plumed/function/FunctionOfVector.h +296 -0
  134. plumed/_lib/include/plumed/function/FunctionSetup.h +180 -0
  135. plumed/_lib/include/plumed/function/FunctionShortcut.h +130 -0
  136. plumed/_lib/include/plumed/function/FunctionWithSingleArgument.h +165 -0
  137. plumed/_lib/include/plumed/gridtools/ActionWithGrid.h +43 -0
  138. plumed/_lib/include/plumed/gridtools/EvaluateGridFunction.h +99 -0
  139. plumed/_lib/include/plumed/gridtools/FunctionOfGrid.h +295 -0
  140. plumed/_lib/include/plumed/gridtools/GridCoordinatesObject.h +179 -0
  141. plumed/_lib/include/plumed/gridtools/GridSearch.h +135 -0
  142. plumed/_lib/include/plumed/gridtools/Interpolator.h +45 -0
  143. plumed/_lib/include/plumed/gridtools/KDE.h +455 -0
  144. plumed/_lib/include/plumed/gridtools/RDF.h +40 -0
  145. plumed/_lib/include/plumed/gridtools/SumOfKernels.h +219 -0
  146. plumed/_lib/include/plumed/isdb/MetainferenceBase.h +398 -0
  147. plumed/_lib/include/plumed/lapack/def_external.h +207 -0
  148. plumed/_lib/include/plumed/lapack/def_internal.h +388 -0
  149. plumed/_lib/include/plumed/lapack/lapack.h +899 -0
  150. plumed/_lib/include/plumed/lapack/lapack_limits.h +79 -0
  151. plumed/_lib/include/plumed/lapack/real.h +50 -0
  152. plumed/_lib/include/plumed/lepton/CompiledExpression.h +164 -0
  153. plumed/_lib/include/plumed/lepton/CustomFunction.h +143 -0
  154. plumed/_lib/include/plumed/lepton/Exception.h +93 -0
  155. plumed/_lib/include/plumed/lepton/ExpressionProgram.h +137 -0
  156. plumed/_lib/include/plumed/lepton/ExpressionTreeNode.h +145 -0
  157. plumed/_lib/include/plumed/lepton/Lepton.h +85 -0
  158. plumed/_lib/include/plumed/lepton/MSVC_erfc.h +123 -0
  159. plumed/_lib/include/plumed/lepton/Operation.h +1302 -0
  160. plumed/_lib/include/plumed/lepton/ParsedExpression.h +165 -0
  161. plumed/_lib/include/plumed/lepton/Parser.h +111 -0
  162. plumed/_lib/include/plumed/lepton/windowsIncludes.h +73 -0
  163. plumed/_lib/include/plumed/mapping/Path.h +44 -0
  164. plumed/_lib/include/plumed/mapping/PathProjectionCalculator.h +57 -0
  165. plumed/_lib/include/plumed/matrixtools/MatrixOperationBase.h +54 -0
  166. plumed/_lib/include/plumed/matrixtools/MatrixTimesMatrix.h +309 -0
  167. plumed/_lib/include/plumed/matrixtools/MatrixTimesVectorBase.h +365 -0
  168. plumed/_lib/include/plumed/matrixtools/OuterProduct.h +238 -0
  169. plumed/_lib/include/plumed/maze/Core.h +65 -0
  170. plumed/_lib/include/plumed/maze/Loss.h +86 -0
  171. plumed/_lib/include/plumed/maze/Member.h +66 -0
  172. plumed/_lib/include/plumed/maze/Memetic.h +799 -0
  173. plumed/_lib/include/plumed/maze/Optimizer.h +357 -0
  174. plumed/_lib/include/plumed/maze/Random_MT.h +156 -0
  175. plumed/_lib/include/plumed/maze/Tools.h +183 -0
  176. plumed/_lib/include/plumed/metatomic/vesin.h +188 -0
  177. plumed/_lib/include/plumed/molfile/Gromacs.h +2013 -0
  178. plumed/_lib/include/plumed/molfile/endianswap.h +217 -0
  179. plumed/_lib/include/plumed/molfile/fastio.h +683 -0
  180. plumed/_lib/include/plumed/molfile/largefiles.h +78 -0
  181. plumed/_lib/include/plumed/molfile/libmolfile_plugin.h +77 -0
  182. plumed/_lib/include/plumed/molfile/molfile_plugin.h +1034 -0
  183. plumed/_lib/include/plumed/molfile/periodic_table.h +248 -0
  184. plumed/_lib/include/plumed/molfile/readpdb.h +447 -0
  185. plumed/_lib/include/plumed/molfile/vmdplugin.h +236 -0
  186. plumed/_lib/include/plumed/multicolvar/MultiColvarShortcuts.h +45 -0
  187. plumed/_lib/include/plumed/opes/ExpansionCVs.h +79 -0
  188. plumed/_lib/include/plumed/sasa/Sasa.h +32 -0
  189. plumed/_lib/include/plumed/secondarystructure/SecondaryStructureBase.h +372 -0
  190. plumed/_lib/include/plumed/setup/ActionSetup.h +25 -0
  191. plumed/_lib/include/plumed/small_vector/small_vector.h +6114 -0
  192. plumed/_lib/include/plumed/symfunc/CoordinationNumbers.h +41 -0
  193. plumed/_lib/include/plumed/tools/Angle.h +52 -0
  194. plumed/_lib/include/plumed/tools/AtomDistribution.h +138 -0
  195. plumed/_lib/include/plumed/tools/AtomNumber.h +152 -0
  196. plumed/_lib/include/plumed/tools/BiasRepresentation.h +106 -0
  197. plumed/_lib/include/plumed/tools/BitmaskEnum.h +167 -0
  198. plumed/_lib/include/plumed/tools/Brent1DRootSearch.h +159 -0
  199. plumed/_lib/include/plumed/tools/CheckInRange.h +44 -0
  200. plumed/_lib/include/plumed/tools/Citations.h +74 -0
  201. plumed/_lib/include/plumed/tools/ColvarOutput.h +118 -0
  202. plumed/_lib/include/plumed/tools/Communicator.h +316 -0
  203. plumed/_lib/include/plumed/tools/ConjugateGradient.h +80 -0
  204. plumed/_lib/include/plumed/tools/DLLoader.h +79 -0
  205. plumed/_lib/include/plumed/tools/ERMSD.h +73 -0
  206. plumed/_lib/include/plumed/tools/Exception.h +406 -0
  207. plumed/_lib/include/plumed/tools/File.h +28 -0
  208. plumed/_lib/include/plumed/tools/FileBase.h +153 -0
  209. plumed/_lib/include/plumed/tools/FileTools.h +37 -0
  210. plumed/_lib/include/plumed/tools/ForwardDecl.h +54 -0
  211. plumed/_lib/include/plumed/tools/Grid.h +638 -0
  212. plumed/_lib/include/plumed/tools/HistogramBead.h +136 -0
  213. plumed/_lib/include/plumed/tools/IFile.h +117 -0
  214. plumed/_lib/include/plumed/tools/KernelFunctions.h +113 -0
  215. plumed/_lib/include/plumed/tools/Keywords.h +380 -0
  216. plumed/_lib/include/plumed/tools/LatticeReduction.h +66 -0
  217. plumed/_lib/include/plumed/tools/LeptonCall.h +64 -0
  218. plumed/_lib/include/plumed/tools/LinkCells.h +126 -0
  219. plumed/_lib/include/plumed/tools/Log.h +41 -0
  220. plumed/_lib/include/plumed/tools/LoopUnroller.h +163 -0
  221. plumed/_lib/include/plumed/tools/Matrix.h +721 -0
  222. plumed/_lib/include/plumed/tools/MatrixSquareBracketsAccess.h +138 -0
  223. plumed/_lib/include/plumed/tools/MergeVectorTools.h +153 -0
  224. plumed/_lib/include/plumed/tools/Minimise1DBrent.h +244 -0
  225. plumed/_lib/include/plumed/tools/MinimiseBase.h +120 -0
  226. plumed/_lib/include/plumed/tools/MolDataClass.h +51 -0
  227. plumed/_lib/include/plumed/tools/NeighborList.h +112 -0
  228. plumed/_lib/include/plumed/tools/OFile.h +286 -0
  229. plumed/_lib/include/plumed/tools/OpenACC.h +180 -0
  230. plumed/_lib/include/plumed/tools/OpenMP.h +75 -0
  231. plumed/_lib/include/plumed/tools/PDB.h +154 -0
  232. plumed/_lib/include/plumed/tools/Pbc.h +139 -0
  233. plumed/_lib/include/plumed/tools/PlumedHandle.h +105 -0
  234. plumed/_lib/include/plumed/tools/RMSD.h +493 -0
  235. plumed/_lib/include/plumed/tools/Random.h +80 -0
  236. plumed/_lib/include/plumed/tools/RootFindingBase.h +79 -0
  237. plumed/_lib/include/plumed/tools/Stopwatch.h +475 -0
  238. plumed/_lib/include/plumed/tools/Subprocess.h +142 -0
  239. plumed/_lib/include/plumed/tools/SwitchingFunction.h +208 -0
  240. plumed/_lib/include/plumed/tools/Tensor.h +724 -0
  241. plumed/_lib/include/plumed/tools/TokenizedLine.h +123 -0
  242. plumed/_lib/include/plumed/tools/Tools.h +638 -0
  243. plumed/_lib/include/plumed/tools/Torsion.h +55 -0
  244. plumed/_lib/include/plumed/tools/TrajectoryParser.h +118 -0
  245. plumed/_lib/include/plumed/tools/Tree.h +61 -0
  246. plumed/_lib/include/plumed/tools/TypesafePtr.h +463 -0
  247. plumed/_lib/include/plumed/tools/Units.h +167 -0
  248. plumed/_lib/include/plumed/tools/Vector.h +433 -0
  249. plumed/_lib/include/plumed/tools/View.h +296 -0
  250. plumed/_lib/include/plumed/tools/View2D.h +100 -0
  251. plumed/_lib/include/plumed/tools/h36.h +39 -0
  252. plumed/_lib/include/plumed/vatom/ActionWithVirtualAtom.h +32 -0
  253. plumed/_lib/include/plumed/ves/BasisFunctions.h +380 -0
  254. plumed/_lib/include/plumed/ves/CoeffsBase.h +310 -0
  255. plumed/_lib/include/plumed/ves/CoeffsMatrix.h +220 -0
  256. plumed/_lib/include/plumed/ves/CoeffsVector.h +251 -0
  257. plumed/_lib/include/plumed/ves/FermiSwitchingFunction.h +74 -0
  258. plumed/_lib/include/plumed/ves/GridIntegrationWeights.h +50 -0
  259. plumed/_lib/include/plumed/ves/GridLinearInterpolation.h +81 -0
  260. plumed/_lib/include/plumed/ves/GridProjWeights.h +61 -0
  261. plumed/_lib/include/plumed/ves/LinearBasisSetExpansion.h +303 -0
  262. plumed/_lib/include/plumed/ves/Optimizer.h +444 -0
  263. plumed/_lib/include/plumed/ves/TargetDistModifer.h +53 -0
  264. plumed/_lib/include/plumed/ves/TargetDistribution.h +266 -0
  265. plumed/_lib/include/plumed/ves/VesBias.h +545 -0
  266. plumed/_lib/include/plumed/ves/VesTools.h +142 -0
  267. plumed/_lib/include/plumed/ves/WaveletGrid.h +75 -0
  268. plumed/_lib/include/plumed/volumes/ActionVolume.h +268 -0
  269. plumed/_lib/include/plumed/volumes/VolumeShortcut.h +147 -0
  270. plumed/_lib/include/plumed/wrapper/Plumed.h +5025 -0
  271. plumed/_lib/include/plumed/xdrfile/xdrfile.h +663 -0
  272. plumed/_lib/include/plumed/xdrfile/xdrfile_trr.h +89 -0
  273. plumed/_lib/include/plumed/xdrfile/xdrfile_xtc.h +90 -0
  274. plumed/_lib/lib/PythonCVInterface.so +0 -0
  275. plumed/_lib/lib/libplumed.a +0 -0
  276. plumed/_lib/lib/libplumed.so +0 -0
  277. plumed/_lib/lib/libplumedKernel.so +0 -0
  278. plumed/_lib/lib/libplumedWrapper.a +0 -0
  279. plumed/_lib/lib/pkgconfig/plumed.pc +13 -0
  280. plumed/_lib/lib/pkgconfig/plumedInternals.pc +13 -0
  281. plumed/_lib/lib/pkgconfig/plumedWrapper.pc +13 -0
  282. plumed/_lib/lib/plumed/fortran/plumed.f90 +879 -0
  283. plumed/_lib/lib/plumed/fortran/plumed_f08.f90 +2625 -0
  284. plumed/_lib/lib/plumed/modulefile +69 -0
  285. plumed/_lib/lib/plumed/patches/gromacs-2022.5.config +43 -0
  286. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt +543 -0
  287. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt.preplumed +540 -0
  288. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.cpp +1628 -0
  289. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1590 -0
  290. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.h +103 -0
  291. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.h.preplumed +99 -0
  292. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/sim_util.cpp +2527 -0
  293. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2513 -0
  294. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
  295. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
  296. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.h +408 -0
  297. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +394 -0
  298. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/md.cpp +2348 -0
  299. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/md.cpp.preplumed +2091 -0
  300. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/minimize.cpp +3573 -0
  301. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3495 -0
  302. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.cpp +1506 -0
  303. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1402 -0
  304. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
  305. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
  306. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/rerun.cpp +997 -0
  307. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/rerun.cpp.preplumed +906 -0
  308. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/runner.cpp +2780 -0
  309. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/runner.cpp.preplumed +2738 -0
  310. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
  311. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
  312. plumed/_lib/lib/plumed/patches/gromacs-2023.5.config +43 -0
  313. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/CMakeLists.txt +549 -0
  314. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/CMakeLists.txt.preplumed +546 -0
  315. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.cpp +1632 -0
  316. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1594 -0
  317. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.h +104 -0
  318. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.h.preplumed +100 -0
  319. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/sim_util.cpp +2624 -0
  320. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2610 -0
  321. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
  322. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
  323. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.h +409 -0
  324. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +395 -0
  325. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/md.cpp +2419 -0
  326. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/md.cpp.preplumed +2164 -0
  327. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/minimize.cpp +3546 -0
  328. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3468 -0
  329. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.cpp +1513 -0
  330. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1409 -0
  331. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
  332. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
  333. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/rerun.cpp +991 -0
  334. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/rerun.cpp.preplumed +900 -0
  335. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/runner.cpp +2895 -0
  336. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/runner.cpp.preplumed +2849 -0
  337. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
  338. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
  339. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/decidegpuusage.cpp +886 -0
  340. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed +880 -0
  341. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h +347 -0
  342. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed +345 -0
  343. plumed/_lib/lib/plumed/patches/gromacs-2024.3.config +43 -0
  344. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/CMakeLists.txt +575 -0
  345. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/CMakeLists.txt.preplumed +572 -0
  346. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.cpp +1632 -0
  347. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1594 -0
  348. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.h +104 -0
  349. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.h.preplumed +100 -0
  350. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/sim_util.cpp +2564 -0
  351. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2550 -0
  352. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
  353. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
  354. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.h +410 -0
  355. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +396 -0
  356. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/md.cpp +2435 -0
  357. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/md.cpp.preplumed +2187 -0
  358. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/minimize.cpp +3592 -0
  359. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3514 -0
  360. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.cpp +1513 -0
  361. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1409 -0
  362. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
  363. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
  364. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/rerun.cpp +958 -0
  365. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/rerun.cpp.preplumed +929 -0
  366. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/runner.cpp +2987 -0
  367. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/runner.cpp.preplumed +2941 -0
  368. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
  369. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
  370. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/decidegpuusage.cpp +904 -0
  371. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed +898 -0
  372. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h +353 -0
  373. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed +351 -0
  374. plumed/_lib/lib/plumed/patches/gromacs-2025.0.config +39 -0
  375. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/cmake/gmxManagePlumed.cmake +82 -0
  376. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/cmake/gmxManagePlumed.cmake.preplumed +82 -0
  377. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedMDModule.cpp +162 -0
  378. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedMDModule.cpp.preplumed +154 -0
  379. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.cpp +107 -0
  380. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.cpp.preplumed +99 -0
  381. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.h +120 -0
  382. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.h.preplumed +111 -0
  383. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.cpp +215 -0
  384. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.cpp.preplumed +197 -0
  385. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.h +87 -0
  386. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.h.preplumed +86 -0
  387. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrun/runner.cpp +2971 -0
  388. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrun/runner.cpp.preplumed +2970 -0
  389. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrunutility/mdmodulesnotifiers.h +430 -0
  390. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrunutility/mdmodulesnotifiers.h.preplumed +429 -0
  391. plumed/_lib/lib/plumed/patches/namd-2.12.config +30 -0
  392. plumed/_lib/lib/plumed/patches/namd-2.12.diff +267 -0
  393. plumed/_lib/lib/plumed/patches/namd-2.13.config +30 -0
  394. plumed/_lib/lib/plumed/patches/namd-2.13.diff +267 -0
  395. plumed/_lib/lib/plumed/patches/namd-2.14.config +30 -0
  396. plumed/_lib/lib/plumed/patches/namd-2.14.diff +268 -0
  397. plumed/_lib/lib/plumed/patches/patch.sh +500 -0
  398. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.config +25 -0
  399. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/forces.f90 +368 -0
  400. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/forces.f90.preplumed +366 -0
  401. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_forces.f90 +71 -0
  402. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_forces.f90.preplumed +24 -0
  403. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_initialization.f90 +62 -0
  404. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  405. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/pwscf.f90 +189 -0
  406. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/pwscf.f90.preplumed +185 -0
  407. plumed/_lib/lib/plumed/patches/qespresso-6.2.config +26 -0
  408. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/forces.f90 +422 -0
  409. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/forces.f90.preplumed +420 -0
  410. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90 +70 -0
  411. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
  412. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_initialization.f90 +62 -0
  413. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  414. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/run_pwscf.f90 +233 -0
  415. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/run_pwscf.f90.preplumed +230 -0
  416. plumed/_lib/lib/plumed/patches/qespresso-7.0.config +28 -0
  417. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/Modules/Makefile +175 -0
  418. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/Modules/Makefile.preplumed +171 -0
  419. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/forces.f90 +486 -0
  420. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/forces.f90.preplumed +484 -0
  421. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90 +74 -0
  422. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
  423. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_initialization.f90 +64 -0
  424. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  425. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/run_pwscf.f90 +532 -0
  426. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/run_pwscf.f90.preplumed +518 -0
  427. plumed/_lib/lib/plumed/patches/qespresso-7.2.config +28 -0
  428. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/Modules/Makefile +249 -0
  429. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/Modules/Makefile.preplumed +244 -0
  430. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/forces.f90 +532 -0
  431. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/forces.f90.preplumed +535 -0
  432. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_ext_forces.f90 +74 -0
  433. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
  434. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_initialization.f90 +64 -0
  435. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  436. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/run_pwscf.f90 +569 -0
  437. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/run_pwscf.f90.preplumed +560 -0
  438. plumed/_lib/lib/plumed/plumed-config +9 -0
  439. plumed/_lib/lib/plumed/plumed-mklib +9 -0
  440. plumed/_lib/lib/plumed/plumed-newcv +9 -0
  441. plumed/_lib/lib/plumed/plumed-partial_tempering +9 -0
  442. plumed/_lib/lib/plumed/plumed-patch +9 -0
  443. plumed/_lib/lib/plumed/plumed-runtime +0 -0
  444. plumed/_lib/lib/plumed/plumed-selector +9 -0
  445. plumed/_lib/lib/plumed/plumed-vim2html +9 -0
  446. plumed/_lib/lib/plumed/scripts/config.sh +126 -0
  447. plumed/_lib/lib/plumed/scripts/mklib.sh +175 -0
  448. plumed/_lib/lib/plumed/scripts/newcv.sh +26 -0
  449. plumed/_lib/lib/plumed/scripts/partial_tempering.sh +319 -0
  450. plumed/_lib/lib/plumed/scripts/patch.sh +4 -0
  451. plumed/_lib/lib/plumed/scripts/selector.sh +234 -0
  452. plumed/_lib/lib/plumed/scripts/vim2html.sh +190 -0
  453. plumed/_lib/lib/plumed/src/colvar/Template.cpp +116 -0
  454. plumed/_lib/lib/plumed/src/config/compile_options.sh +3 -0
  455. plumed/_lib/lib/plumed/src/config/config.txt +179 -0
  456. plumed/_lib/lib/plumed/src/lib/Plumed.cmake +8 -0
  457. plumed/_lib/lib/plumed/src/lib/Plumed.cmake.runtime +5 -0
  458. plumed/_lib/lib/plumed/src/lib/Plumed.cmake.shared +5 -0
  459. plumed/_lib/lib/plumed/src/lib/Plumed.cmake.static +5 -0
  460. plumed/_lib/lib/plumed/src/lib/Plumed.inc +8 -0
  461. plumed/_lib/lib/plumed/src/lib/Plumed.inc.runtime +5 -0
  462. plumed/_lib/lib/plumed/src/lib/Plumed.inc.shared +5 -0
  463. plumed/_lib/lib/plumed/src/lib/Plumed.inc.static +5 -0
  464. plumed/_lib/lib/plumed/vim/scripts.vim +6 -0
  465. plumed/_plumed_core.cpython-311-aarch64-linux-gnu.so +0 -0
  466. plumed/_plumed_core.cpython-312-aarch64-linux-gnu.so +0 -0
  467. plumed/_plumed_core.cpython-313-aarch64-linux-gnu.so +0 -0
  468. plumed/_plumed_core.cpython-314-aarch64-linux-gnu.so +0 -0
  469. plumed/_plumed_core.cpython-314t-aarch64-linux-gnu.so +0 -0
  470. plumedCommunications.cpython-311-aarch64-linux-gnu.so +0 -0
  471. plumedCommunications.cpython-312-aarch64-linux-gnu.so +0 -0
  472. plumedCommunications.cpython-313-aarch64-linux-gnu.so +0 -0
  473. plumedCommunications.cpython-314-aarch64-linux-gnu.so +0 -0
  474. plumedCommunications.cpython-314t-aarch64-linux-gnu.so +0 -0
  475. plumedCommunications.pyi +431 -0
@@ -0,0 +1,2348 @@
1
+ /*
2
+ * This file is part of the GROMACS molecular simulation package.
3
+ *
4
+ * Copyright 1991- The GROMACS Authors
5
+ * and the project initiators Erik Lindahl, Berk Hess and David van der Spoel.
6
+ * Consult the AUTHORS/COPYING files and https://www.gromacs.org for details.
7
+ *
8
+ * GROMACS is free software; you can redistribute it and/or
9
+ * modify it under the terms of the GNU Lesser General Public License
10
+ * as published by the Free Software Foundation; either version 2.1
11
+ * of the License, or (at your option) any later version.
12
+ *
13
+ * GROMACS is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ * Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU Lesser General Public
19
+ * License along with GROMACS; if not, see
20
+ * https://www.gnu.org/licenses, or write to the Free Software Foundation,
21
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
+ *
23
+ * If you want to redistribute modifications to GROMACS, please
24
+ * consider that scientific software is very special. Version
25
+ * control is crucial - bugs must be traceable. We will be happy to
26
+ * consider code for inclusion in the official distribution, but
27
+ * derived work must not be called official GROMACS. Details are found
28
+ * in the README & COPYING files - if they are missing, get the
29
+ * official version at https://www.gromacs.org.
30
+ *
31
+ * To help us fund GROMACS development, we humbly ask that you cite
32
+ * the research papers on the package. Check out https://www.gromacs.org.
33
+ */
34
+ /*! \internal \file
35
+ *
36
+ * \brief Implements the integrator for normal molecular dynamics simulations
37
+ *
38
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
39
+ * \ingroup module_mdrun
40
+ */
41
+ #include "gmxpre.h"
42
+
43
+ #include <cinttypes>
44
+ #include <cmath>
45
+ #include <cstdio>
46
+ #include <cstdlib>
47
+
48
+ #include <algorithm>
49
+ #include <memory>
50
+ #include <numeric>
51
+
52
+ #include "gromacs/applied_forces/awh/awh.h"
53
+ #include "gromacs/applied_forces/awh/read_params.h"
54
+ #include "gromacs/commandline/filenm.h"
55
+ #include "gromacs/domdec/collect.h"
56
+ #include "gromacs/domdec/dlbtiming.h"
57
+ #include "gromacs/domdec/domdec.h"
58
+ #include "gromacs/domdec/domdec_network.h"
59
+ #include "gromacs/domdec/domdec_struct.h"
60
+ #include "gromacs/domdec/gpuhaloexchange.h"
61
+ #include "gromacs/domdec/localtopologychecker.h"
62
+ #include "gromacs/domdec/mdsetup.h"
63
+ #include "gromacs/domdec/partition.h"
64
+ #include "gromacs/essentialdynamics/edsam.h"
65
+ #include "gromacs/ewald/pme_load_balancing.h"
66
+ #include "gromacs/ewald/pme_pp.h"
67
+ #include "gromacs/fileio/trxio.h"
68
+ #include "gromacs/gmxlib/network.h"
69
+ #include "gromacs/gmxlib/nrnb.h"
70
+ #include "gromacs/gpu_utils/device_stream_manager.h"
71
+ #include "gromacs/gpu_utils/gpu_utils.h"
72
+ #include "gromacs/math/units.h"
73
+ #include "gromacs/imd/imd.h"
74
+ #include "gromacs/listed_forces/listed_forces.h"
75
+ #include "gromacs/math/functions.h"
76
+ #include "gromacs/math/invertmatrix.h"
77
+ #include "gromacs/math/vec.h"
78
+ #include "gromacs/math/vectypes.h"
79
+ #include "gromacs/mdlib/checkpointhandler.h"
80
+ #include "gromacs/mdlib/compute_io.h"
81
+ #include "gromacs/mdlib/constr.h"
82
+ #include "gromacs/mdlib/coupling.h"
83
+ #include "gromacs/mdlib/ebin.h"
84
+ #include "gromacs/mdlib/enerdata_utils.h"
85
+ #include "gromacs/mdlib/energyoutput.h"
86
+ #include "gromacs/mdlib/expanded.h"
87
+ #include "gromacs/mdlib/force.h"
88
+ #include "gromacs/mdlib/force_flags.h"
89
+ #include "gromacs/mdlib/forcerec.h"
90
+ #include "gromacs/mdlib/freeenergyparameters.h"
91
+ #include "gromacs/mdlib/md_support.h"
92
+ #include "gromacs/mdlib/mdatoms.h"
93
+ #include "gromacs/mdlib/mdoutf.h"
94
+ #include "gromacs/mdlib/membed.h"
95
+ #include "gromacs/mdlib/resethandler.h"
96
+ #include "gromacs/mdlib/sighandler.h"
97
+ #include "gromacs/mdlib/simulationsignal.h"
98
+ #include "gromacs/mdlib/stat.h"
99
+ #include "gromacs/mdlib/stophandler.h"
100
+ #include "gromacs/mdlib/tgroup.h"
101
+ #include "gromacs/mdlib/trajectory_writing.h"
102
+ #include "gromacs/mdlib/update.h"
103
+ #include "gromacs/mdlib/update_constrain_gpu.h"
104
+ #include "gromacs/mdlib/update_vv.h"
105
+ #include "gromacs/mdlib/vcm.h"
106
+ #include "gromacs/mdlib/vsite.h"
107
+ #include "gromacs/mdrunutility/freeenergy.h"
108
+ #include "gromacs/mdrunutility/handlerestart.h"
109
+ #include "gromacs/mdrunutility/multisim.h"
110
+ #include "gromacs/mdrunutility/printtime.h"
111
+ #include "gromacs/mdtypes/awh_history.h"
112
+ #include "gromacs/mdtypes/awh_params.h"
113
+ #include "gromacs/mdtypes/commrec.h"
114
+ #include "gromacs/mdtypes/df_history.h"
115
+ #include "gromacs/mdtypes/energyhistory.h"
116
+ #include "gromacs/mdtypes/fcdata.h"
117
+ #include "gromacs/mdtypes/forcebuffers.h"
118
+ #include "gromacs/mdtypes/forcerec.h"
119
+ #include "gromacs/mdtypes/group.h"
120
+ #include "gromacs/mdtypes/inputrec.h"
121
+ #include "gromacs/mdtypes/interaction_const.h"
122
+ #include "gromacs/mdtypes/md_enums.h"
123
+ #include "gromacs/mdtypes/mdatom.h"
124
+ #include "gromacs/mdtypes/mdrunoptions.h"
125
+ #include "gromacs/mdtypes/multipletimestepping.h"
126
+ #include "gromacs/mdtypes/observableshistory.h"
127
+ #include "gromacs/mdtypes/observablesreducer.h"
128
+ #include "gromacs/mdtypes/pullhistory.h"
129
+ #include "gromacs/mdtypes/simulation_workload.h"
130
+ #include "gromacs/mdtypes/state.h"
131
+ #include "gromacs/mdtypes/state_propagator_data_gpu.h"
132
+ #include "gromacs/modularsimulator/energydata.h"
133
+ #include "gromacs/nbnxm/gpu_data_mgmt.h"
134
+ #include "gromacs/nbnxm/nbnxm.h"
135
+ #include "gromacs/pbcutil/pbc.h"
136
+ #include "gromacs/pulling/output.h"
137
+ #include "gromacs/pulling/pull.h"
138
+ #include "gromacs/swap/swapcoords.h"
139
+ #include "gromacs/timing/wallcycle.h"
140
+ #include "gromacs/timing/walltime_accounting.h"
141
+ #include "gromacs/topology/atoms.h"
142
+ #include "gromacs/topology/idef.h"
143
+ #include "gromacs/topology/mtop_util.h"
144
+ #include "gromacs/topology/topology.h"
145
+ #include "gromacs/trajectory/trajectoryframe.h"
146
+ #include "gromacs/utility/basedefinitions.h"
147
+ #include "gromacs/utility/cstringutil.h"
148
+ #include "gromacs/utility/fatalerror.h"
149
+ #include "gromacs/utility/logger.h"
150
+ #include "gromacs/utility/real.h"
151
+ #include "gromacs/utility/smalloc.h"
152
+
153
+ #include "legacysimulator.h"
154
+ #include "replicaexchange.h"
155
+ #include "shellfc.h"
156
+
157
+ /* PLUMED */
158
+ #include "../../../Plumed.h"
159
+ extern int plumedswitch;
160
+ extern plumed plumedmain;
161
+ /* END PLUMED */
162
+
163
+ /* PLUMED HREX */
164
+ extern int plumed_hrex;
165
+ /* END PLUMED HREX */
166
+
167
+ using gmx::SimulationSignaller;
168
+
169
+ void gmx::LegacySimulator::do_md()
170
+ {
171
+ // TODO Historically, the EM and MD "integrators" used different
172
+ // names for the t_inputrec *parameter, but these must have the
173
+ // same name, now that it's a member of a struct. We use this ir
174
+ // alias to avoid a large ripple of nearly useless changes.
175
+ // t_inputrec is being replaced by IMdpOptionsProvider, so this
176
+ // will go away eventually.
177
+ const t_inputrec* ir = inputrec;
178
+
179
+ double t, t0 = ir->init_t;
180
+ gmx_bool bGStatEveryStep, bGStat, bCalcVir, bCalcEnerStep, bCalcEner;
181
+ gmx_bool bNS = FALSE, bNStList, bStopCM, bFirstStep, bInitStep, bLastStep = FALSE;
182
+ gmx_bool bDoExpanded = FALSE;
183
+ gmx_bool do_ene, do_log, do_verbose;
184
+ gmx_bool bMasterState;
185
+ unsigned int force_flags;
186
+ tensor force_vir = { { 0 } }, shake_vir = { { 0 } }, total_vir = { { 0 } }, pres = { { 0 } };
187
+ int i, m;
188
+ rvec mu_tot;
189
+ matrix pressureCouplingMu, M;
190
+ gmx_repl_ex_t repl_ex = nullptr;
191
+ gmx_global_stat_t gstat;
192
+ gmx_shellfc_t* shellfc;
193
+ gmx_bool bSumEkinhOld, bDoReplEx, bDoReplExPrev, bExchanged, bNeedRepartition;
194
+ gmx_bool bTrotter;
195
+ real dvdl_constr;
196
+ std::vector<RVec> cbuf;
197
+ matrix lastbox;
198
+ int lamnew = 0;
199
+ /* for FEP */
200
+ double cycles;
201
+ real saved_conserved_quantity = 0;
202
+ real last_ekin = 0;
203
+ t_extmass MassQ;
204
+ char sbuf[STEPSTRSIZE], sbuf2[STEPSTRSIZE];
205
+
206
+ /* PME load balancing data for GPU kernels */
207
+ gmx_bool bPMETune = FALSE;
208
+ gmx_bool bPMETunePrinting = FALSE;
209
+
210
+ bool bInteractiveMDstep = false;
211
+
212
+ SimulationSignals signals;
213
+ /* PLUMED */
214
+ int plumedNeedsEnergy=0;
215
+ int plumedWantsToStop=0;
216
+ matrix plumed_vir;
217
+ real lambdaForce=0;
218
+ real realFepState=0;
219
+ /* END PLUMED */
220
+
221
+ // Most global communnication stages don't propagate mdrun
222
+ // signals, and will use this object to achieve that.
223
+ SimulationSignaller nullSignaller(nullptr, nullptr, nullptr, false, false);
224
+
225
+ if (!mdrunOptions.writeConfout)
226
+ {
227
+ // This is on by default, and the main known use case for
228
+ // turning it off is for convenience in benchmarking, which is
229
+ // something that should not show up in the general user
230
+ // interface.
231
+ GMX_LOG(mdlog.info)
232
+ .asParagraph()
233
+ .appendText(
234
+ "The -noconfout functionality is deprecated, and may be removed in a "
235
+ "future version.");
236
+ }
237
+
238
+ /* md-vv uses averaged full step velocities for T-control
239
+ md-vv-avek uses averaged half step velocities for T-control (but full step ekin for P control)
240
+ md uses averaged half step kinetic energies to determine temperature unless defined otherwise by GMX_EKIN_AVE_VEL; */
241
+ bTrotter = (EI_VV(ir->eI)
242
+ && (inputrecNptTrotter(ir) || inputrecNphTrotter(ir) || inputrecNvtTrotter(ir)));
243
+
244
+ const bool bRerunMD = false;
245
+
246
+ int nstglobalcomm = computeGlobalCommunicationPeriod(mdlog, ir, cr);
247
+ bGStatEveryStep = (nstglobalcomm == 1);
248
+
249
+ const SimulationGroups* groups = &top_global.groups;
250
+
251
+ std::unique_ptr<EssentialDynamics> ed = nullptr;
252
+ if (opt2bSet("-ei", nfile, fnm))
253
+ {
254
+ /* Initialize essential dynamics sampling */
255
+ ed = init_edsam(mdlog,
256
+ opt2fn_null("-ei", nfile, fnm),
257
+ opt2fn("-eo", nfile, fnm),
258
+ top_global,
259
+ *ir,
260
+ cr,
261
+ constr,
262
+ state_global,
263
+ observablesHistory,
264
+ oenv,
265
+ startingBehavior);
266
+ }
267
+ else if (observablesHistory->edsamHistory)
268
+ {
269
+ gmx_fatal(FARGS,
270
+ "The checkpoint is from a run with essential dynamics sampling, "
271
+ "but the current run did not specify the -ei option. "
272
+ "Either specify the -ei option to mdrun, or do not use this checkpoint file.");
273
+ }
274
+
275
+ int* fep_state = MASTER(cr) ? &state_global->fep_state : nullptr;
276
+ gmx::ArrayRef<real> lambda = MASTER(cr) ? state_global->lambda : gmx::ArrayRef<real>();
277
+ initialize_lambdas(fplog,
278
+ ir->efep,
279
+ ir->bSimTemp,
280
+ *ir->fepvals,
281
+ ir->simtempvals->temperatures,
282
+ gmx::arrayRefFromArray(ir->opts.ref_t, ir->opts.ngtc),
283
+ MASTER(cr),
284
+ fep_state,
285
+ lambda);
286
+ Update upd(*ir, deform);
287
+ bool doSimulatedAnnealing = false;
288
+ {
289
+ // TODO: Avoid changing inputrec (#3854)
290
+ // Simulated annealing updates the reference temperature.
291
+ auto* nonConstInputrec = const_cast<t_inputrec*>(inputrec);
292
+ doSimulatedAnnealing = initSimulatedAnnealing(nonConstInputrec, &upd);
293
+ }
294
+ const bool useReplicaExchange = (replExParams.exchangeInterval > 0);
295
+
296
+ t_fcdata& fcdata = *fr->fcdata;
297
+
298
+ bool simulationsShareState = false;
299
+ int nstSignalComm = nstglobalcomm;
300
+ {
301
+ // TODO This implementation of ensemble orientation restraints is nasty because
302
+ // a user can't just do multi-sim with single-sim orientation restraints.
303
+ bool usingEnsembleRestraints = (fcdata.disres->nsystems > 1) || ((ms != nullptr) && fcdata.orires);
304
+ bool awhUsesMultiSim = (ir->bDoAwh && ir->awhParams->shareBiasMultisim() && (ms != nullptr));
305
+
306
+ // Replica exchange, ensemble restraints and AWH need all
307
+ // simulations to remain synchronized, so they need
308
+ // checkpoints and stop conditions to act on the same step, so
309
+ // the propagation of such signals must take place between
310
+ // simulations, not just within simulations.
311
+ // TODO: Make algorithm initializers set these flags.
312
+ simulationsShareState = useReplicaExchange || usingEnsembleRestraints || awhUsesMultiSim || (plumedswitch && ms); // PLUMED hack, if we have multiple sim and plumed we usually want them to be in sync
313
+
314
+ if (simulationsShareState)
315
+ {
316
+ // Inter-simulation signal communication does not need to happen
317
+ // often, so we use a minimum of 200 steps to reduce overhead.
318
+ const int c_minimumInterSimulationSignallingInterval = 200;
319
+ nstSignalComm = ((c_minimumInterSimulationSignallingInterval + nstglobalcomm - 1) / nstglobalcomm)
320
+ * nstglobalcomm;
321
+ }
322
+ }
323
+
324
+ if (startingBehavior != StartingBehavior::RestartWithAppending)
325
+ {
326
+ pleaseCiteCouplingAlgorithms(fplog, *ir);
327
+ }
328
+ gmx_mdoutf* outf = init_mdoutf(fplog,
329
+ nfile,
330
+ fnm,
331
+ mdrunOptions,
332
+ cr,
333
+ outputProvider,
334
+ mdModulesNotifiers,
335
+ ir,
336
+ top_global,
337
+ oenv,
338
+ wcycle,
339
+ startingBehavior,
340
+ simulationsShareState,
341
+ ms);
342
+ gmx::EnergyOutput energyOutput(mdoutf_get_fp_ene(outf),
343
+ top_global,
344
+ *ir,
345
+ pull_work,
346
+ mdoutf_get_fp_dhdl(outf),
347
+ false,
348
+ startingBehavior,
349
+ simulationsShareState,
350
+ mdModulesNotifiers);
351
+
352
+ gstat = global_stat_init(ir);
353
+
354
+ const auto& simulationWork = runScheduleWork->simulationWork;
355
+ const bool useGpuForPme = simulationWork.useGpuPme;
356
+ const bool useGpuForNonbonded = simulationWork.useGpuNonbonded;
357
+ const bool useGpuForUpdate = simulationWork.useGpuUpdate;
358
+
359
+ /* Check for polarizable models and flexible constraints */
360
+ shellfc = init_shell_flexcon(fplog,
361
+ top_global,
362
+ constr ? constr->numFlexibleConstraints() : 0,
363
+ ir->nstcalcenergy,
364
+ haveDDAtomOrdering(*cr),
365
+ useGpuForPme);
366
+
367
+ {
368
+ double io = compute_io(ir, top_global.natoms, *groups, energyOutput.numEnergyTerms(), 1);
369
+ if ((io > 2000) && MASTER(cr))
370
+ {
371
+ fprintf(stderr, "\nWARNING: This run will generate roughly %.0f Mb of data\n\n", io);
372
+ }
373
+ }
374
+
375
+ ObservablesReducer observablesReducer = observablesReducerBuilder->build();
376
+
377
+ ForceBuffers f(simulationWork.useMts,
378
+ (simulationWork.useGpuFBufferOps || useGpuForUpdate) ? PinningPolicy::PinnedIfSupported
379
+ : PinningPolicy::CannotBePinned);
380
+ const t_mdatoms* md = mdAtoms->mdatoms();
381
+ if (haveDDAtomOrdering(*cr))
382
+ {
383
+ // Local state only becomes valid now.
384
+ dd_init_local_state(*cr->dd, state_global, state);
385
+
386
+ /* Distribute the charge groups over the nodes from the master node */
387
+ dd_partition_system(fplog,
388
+ mdlog,
389
+ ir->init_step,
390
+ cr,
391
+ TRUE,
392
+ 1,
393
+ state_global,
394
+ top_global,
395
+ *ir,
396
+ imdSession,
397
+ pull_work,
398
+ state,
399
+ &f,
400
+ mdAtoms,
401
+ top,
402
+ fr,
403
+ vsite,
404
+ constr,
405
+ nrnb,
406
+ nullptr,
407
+ FALSE);
408
+ upd.updateAfterPartition(state->natoms,
409
+ md->cFREEZE ? gmx::arrayRefFromArray(md->cFREEZE, md->nr)
410
+ : gmx::ArrayRef<const unsigned short>(),
411
+ md->cTC ? gmx::arrayRefFromArray(md->cTC, md->nr)
412
+ : gmx::ArrayRef<const unsigned short>(),
413
+ md->cACC ? gmx::arrayRefFromArray(md->cACC, md->nr)
414
+ : gmx::ArrayRef<const unsigned short>());
415
+ fr->longRangeNonbondeds->updateAfterPartition(*md);
416
+ }
417
+ else
418
+ {
419
+ state_change_natoms(state_global, state_global->natoms);
420
+
421
+ /* Generate and initialize new topology */
422
+ mdAlgorithmsSetupAtomData(cr, *ir, top_global, top, fr, &f, mdAtoms, constr, vsite, shellfc);
423
+
424
+ upd.updateAfterPartition(state->natoms,
425
+ md->cFREEZE ? gmx::arrayRefFromArray(md->cFREEZE, md->nr)
426
+ : gmx::ArrayRef<const unsigned short>(),
427
+ md->cTC ? gmx::arrayRefFromArray(md->cTC, md->nr)
428
+ : gmx::ArrayRef<const unsigned short>(),
429
+ md->cACC ? gmx::arrayRefFromArray(md->cACC, md->nr)
430
+ : gmx::ArrayRef<const unsigned short>());
431
+ fr->longRangeNonbondeds->updateAfterPartition(*md);
432
+ }
433
+
434
+ std::unique_ptr<UpdateConstrainGpu> integrator;
435
+
436
+ StatePropagatorDataGpu* stateGpu = fr->stateGpu;
437
+
438
+ // TODO: the assertions below should be handled by UpdateConstraintsBuilder.
439
+ if (useGpuForUpdate)
440
+ {
441
+ GMX_RELEASE_ASSERT(!haveDDAtomOrdering(*cr) || ddUsesUpdateGroups(*cr->dd)
442
+ || constr == nullptr || constr->numConstraintsTotal() == 0,
443
+ "Constraints in domain decomposition are only supported with update "
444
+ "groups if using GPU update.\n");
445
+ GMX_RELEASE_ASSERT(ir->eConstrAlg != ConstraintAlgorithm::Shake || constr == nullptr
446
+ || constr->numConstraintsTotal() == 0,
447
+ "SHAKE is not supported with GPU update.");
448
+ GMX_RELEASE_ASSERT(useGpuForPme || (useGpuForNonbonded && simulationWork.useGpuXBufferOps),
449
+ "Either PME or short-ranged non-bonded interaction tasks must run on "
450
+ "the GPU to use GPU update.\n");
451
+ GMX_RELEASE_ASSERT(ir->eI == IntegrationAlgorithm::MD,
452
+ "Only the md integrator is supported with the GPU update.\n");
453
+ GMX_RELEASE_ASSERT(
454
+ ir->etc != TemperatureCoupling::NoseHoover,
455
+ "Nose-Hoover temperature coupling is not supported with the GPU update.\n");
456
+ GMX_RELEASE_ASSERT(
457
+ ir->epc == PressureCoupling::No || ir->epc == PressureCoupling::ParrinelloRahman
458
+ || ir->epc == PressureCoupling::Berendsen || ir->epc == PressureCoupling::CRescale,
459
+ "Only Parrinello-Rahman, Berendsen, and C-rescale pressure coupling are supported "
460
+ "with the GPU update.\n");
461
+ GMX_RELEASE_ASSERT(!md->haveVsites,
462
+ "Virtual sites are not supported with the GPU update.\n");
463
+ GMX_RELEASE_ASSERT(ed == nullptr,
464
+ "Essential dynamics is not supported with the GPU update.\n");
465
+ GMX_RELEASE_ASSERT(!ir->bPull || !pull_have_constraint(*ir->pull),
466
+ "Constraints pulling is not supported with the GPU update.\n");
467
+ GMX_RELEASE_ASSERT(fcdata.orires == nullptr,
468
+ "Orientation restraints are not supported with the GPU update.\n");
469
+ GMX_RELEASE_ASSERT(
470
+ ir->efep == FreeEnergyPerturbationType::No
471
+ || (!haveFepPerturbedMasses(top_global) && !havePerturbedConstraints(top_global)),
472
+ "Free energy perturbation of masses and constraints are not supported with the GPU "
473
+ "update.");
474
+
475
+ if (constr != nullptr && constr->numConstraintsTotal() > 0)
476
+ {
477
+ GMX_LOG(mdlog.info)
478
+ .asParagraph()
479
+ .appendText("Updating coordinates and applying constraints on the GPU.");
480
+ }
481
+ else
482
+ {
483
+ GMX_LOG(mdlog.info).asParagraph().appendText("Updating coordinates on the GPU.");
484
+ }
485
+ GMX_RELEASE_ASSERT(fr->deviceStreamManager != nullptr,
486
+ "Device stream manager should be initialized in order to use GPU "
487
+ "update-constraints.");
488
+ GMX_RELEASE_ASSERT(
489
+ fr->deviceStreamManager->streamIsValid(gmx::DeviceStreamType::UpdateAndConstraints),
490
+ "Update stream should be initialized in order to use GPU "
491
+ "update-constraints.");
492
+ integrator = std::make_unique<UpdateConstrainGpu>(
493
+ *ir,
494
+ top_global,
495
+ ekind->ngtc,
496
+ fr->deviceStreamManager->context(),
497
+ fr->deviceStreamManager->stream(gmx::DeviceStreamType::UpdateAndConstraints),
498
+ wcycle);
499
+
500
+ stateGpu->setXUpdatedOnDeviceEvent(integrator->xUpdatedOnDeviceEvent());
501
+
502
+ integrator->setPbc(PbcType::Xyz, state->box);
503
+ }
504
+
505
+ if (useGpuForPme || simulationWork.useGpuXBufferOps || useGpuForUpdate)
506
+ {
507
+ changePinningPolicy(&state->x, PinningPolicy::PinnedIfSupported);
508
+ }
509
+ if (useGpuForUpdate)
510
+ {
511
+ changePinningPolicy(&state->v, PinningPolicy::PinnedIfSupported);
512
+ }
513
+
514
+ // NOTE: The global state is no longer used at this point.
515
+ // But state_global is still used as temporary storage space for writing
516
+ // the global state to file and potentially for replica exchange.
517
+ // (Global topology should persist.)
518
+
519
+ update_mdatoms(mdAtoms->mdatoms(), state->lambda[FreeEnergyPerturbationCouplingType::Mass]);
520
+
521
+ if (ir->bExpanded)
522
+ {
523
+ /* Check nstexpanded here, because the grompp check was broken */
524
+ if (ir->expandedvals->nstexpanded % ir->nstcalcenergy != 0)
525
+ {
526
+ gmx_fatal(FARGS,
527
+ "With expanded ensemble, nstexpanded should be a multiple of nstcalcenergy");
528
+ }
529
+ init_expanded_ensemble(startingBehavior != StartingBehavior::NewSimulation, ir, state->dfhist);
530
+ }
531
+
532
+ if (MASTER(cr))
533
+ {
534
+ EnergyData::initializeEnergyHistory(startingBehavior, observablesHistory, &energyOutput);
535
+ }
536
+
537
+ preparePrevStepPullCom(ir,
538
+ pull_work,
539
+ gmx::arrayRefFromArray(md->massT, md->nr),
540
+ state,
541
+ state_global,
542
+ cr,
543
+ startingBehavior != StartingBehavior::NewSimulation);
544
+
545
+ // TODO: Remove this by converting AWH into a ForceProvider
546
+ auto awh = prepareAwhModule(fplog,
547
+ *ir,
548
+ state_global,
549
+ cr,
550
+ ms,
551
+ startingBehavior != StartingBehavior::NewSimulation,
552
+ shellfc != nullptr,
553
+ opt2fn("-awh", nfile, fnm),
554
+ pull_work);
555
+
556
+ if (useReplicaExchange && MASTER(cr))
557
+ {
558
+ repl_ex = init_replica_exchange(fplog, ms, top_global.natoms, ir, replExParams);
559
+ }
560
+ /* PME tuning is only supported in the Verlet scheme, with PME for
561
+ * Coulomb. It is not supported with only LJ PME.
562
+ * Disable PME tuning with GPU PME decomposition */
563
+ bPMETune = (mdrunOptions.tunePme && EEL_PME(fr->ic->eeltype) && !mdrunOptions.reproducible
564
+ && ir->cutoff_scheme != CutoffScheme::Group && !simulationWork.useGpuPmeDecomposition);
565
+
566
+ pme_load_balancing_t* pme_loadbal = nullptr;
567
+ if (bPMETune)
568
+ {
569
+ pme_loadbal_init(
570
+ &pme_loadbal, cr, mdlog, *ir, state->box, *fr->ic, *fr->nbv, fr->pmedata, fr->nbv->useGpu());
571
+ }
572
+
573
+ if (!ir->bContinuation)
574
+ {
575
+ if (state->flags & enumValueToBitMask(StateEntry::V))
576
+ {
577
+ auto v = makeArrayRef(state->v);
578
+ /* Set the velocities of vsites, shells and frozen atoms to zero */
579
+ for (i = 0; i < md->homenr; i++)
580
+ {
581
+ if (md->ptype[i] == ParticleType::Shell)
582
+ {
583
+ clear_rvec(v[i]);
584
+ }
585
+ else if (md->cFREEZE)
586
+ {
587
+ for (m = 0; m < DIM; m++)
588
+ {
589
+ if (ir->opts.nFreeze[md->cFREEZE[i]][m])
590
+ {
591
+ v[i][m] = 0;
592
+ }
593
+ }
594
+ }
595
+ }
596
+ }
597
+
598
+ if (constr)
599
+ {
600
+ /* Constrain the initial coordinates and velocities */
601
+ do_constrain_first(fplog,
602
+ constr,
603
+ ir,
604
+ md->nr,
605
+ md->homenr,
606
+ state->x.arrayRefWithPadding(),
607
+ state->v.arrayRefWithPadding(),
608
+ state->box,
609
+ state->lambda[FreeEnergyPerturbationCouplingType::Bonded]);
610
+ }
611
+ }
612
+
613
+ const int nstfep = computeFepPeriod(*ir, replExParams);
614
+
615
+ /* Be REALLY careful about what flags you set here. You CANNOT assume
616
+ * this is the first step, since we might be restarting from a checkpoint,
617
+ * and in that case we should not do any modifications to the state.
618
+ */
619
+ bStopCM = (ir->comm_mode != ComRemovalAlgorithm::No && !ir->bContinuation);
620
+
621
+ // When restarting from a checkpoint, it can be appropriate to
622
+ // initialize ekind from quantities in the checkpoint. Otherwise,
623
+ // compute_globals must initialize ekind before the simulation
624
+ // starts/restarts. However, only the master rank knows what was
625
+ // found in the checkpoint file, so we have to communicate in
626
+ // order to coordinate the restart.
627
+ //
628
+ // TODO Consider removing this communication if/when checkpoint
629
+ // reading directly follows .tpr reading, because all ranks can
630
+ // agree on hasReadEkinState at that time.
631
+ bool hasReadEkinState = MASTER(cr) ? state_global->ekinstate.hasReadEkinState : false;
632
+ if (PAR(cr))
633
+ {
634
+ gmx_bcast(sizeof(hasReadEkinState), &hasReadEkinState, cr->mpi_comm_mygroup);
635
+ }
636
+ if (hasReadEkinState)
637
+ {
638
+ restore_ekinstate_from_state(cr, ekind, MASTER(cr) ? &state_global->ekinstate : nullptr);
639
+ }
640
+
641
+ unsigned int cglo_flags =
642
+ (CGLO_TEMPERATURE | CGLO_GSTAT | (EI_VV(ir->eI) ? CGLO_PRESSURE : 0)
643
+ | (EI_VV(ir->eI) ? CGLO_CONSTRAINT : 0) | (hasReadEkinState ? CGLO_READEKIN : 0));
644
+
645
+ bSumEkinhOld = FALSE;
646
+
647
+ t_vcm vcm(top_global.groups, *ir);
648
+ reportComRemovalInfo(fplog, vcm);
649
+
650
+ int64_t step = ir->init_step;
651
+ int64_t step_rel = 0;
652
+
653
+ /* To minimize communication, compute_globals computes the COM velocity
654
+ * and the kinetic energy for the velocities without COM motion removed.
655
+ * Thus to get the kinetic energy without the COM contribution, we need
656
+ * to call compute_globals twice.
657
+ */
658
+ for (int cgloIteration = 0; cgloIteration < (bStopCM ? 2 : 1); cgloIteration++)
659
+ {
660
+ unsigned int cglo_flags_iteration = cglo_flags;
661
+ if (bStopCM && cgloIteration == 0)
662
+ {
663
+ cglo_flags_iteration |= CGLO_STOPCM;
664
+ cglo_flags_iteration &= ~CGLO_TEMPERATURE;
665
+ }
666
+ compute_globals(gstat,
667
+ cr,
668
+ ir,
669
+ fr,
670
+ ekind,
671
+ makeConstArrayRef(state->x),
672
+ makeConstArrayRef(state->v),
673
+ state->box,
674
+ md,
675
+ nrnb,
676
+ &vcm,
677
+ nullptr,
678
+ enerd,
679
+ force_vir,
680
+ shake_vir,
681
+ total_vir,
682
+ pres,
683
+ &nullSignaller,
684
+ state->box,
685
+ &bSumEkinhOld,
686
+ cglo_flags_iteration,
687
+ step,
688
+ &observablesReducer);
689
+ // Clean up after pre-step use of compute_globals()
690
+ observablesReducer.markAsReadyToReduce();
691
+
692
+ if (cglo_flags_iteration & CGLO_STOPCM)
693
+ {
694
+ /* At initialization, do not pass x with acceleration-correction mode
695
+ * to avoid (incorrect) correction of the initial coordinates.
696
+ */
697
+ auto x = (vcm.mode == ComRemovalAlgorithm::LinearAccelerationCorrection)
698
+ ? ArrayRef<RVec>()
699
+ : makeArrayRef(state->x);
700
+ process_and_stopcm_grp(fplog, &vcm, *md, x, makeArrayRef(state->v));
701
+ inc_nrnb(nrnb, eNR_STOPCM, md->homenr);
702
+ }
703
+ }
704
+ if (ir->eI == IntegrationAlgorithm::VVAK)
705
+ {
706
+ /* a second call to get the half step temperature initialized as well */
707
+ /* we do the same call as above, but turn the pressure off -- internally to
708
+ compute_globals, this is recognized as a velocity verlet half-step
709
+ kinetic energy calculation. This minimized excess variables, but
710
+ perhaps loses some logic?*/
711
+
712
+ compute_globals(gstat,
713
+ cr,
714
+ ir,
715
+ fr,
716
+ ekind,
717
+ makeConstArrayRef(state->x),
718
+ makeConstArrayRef(state->v),
719
+ state->box,
720
+ md,
721
+ nrnb,
722
+ &vcm,
723
+ nullptr,
724
+ enerd,
725
+ force_vir,
726
+ shake_vir,
727
+ total_vir,
728
+ pres,
729
+ &nullSignaller,
730
+ state->box,
731
+ &bSumEkinhOld,
732
+ cglo_flags & ~CGLO_PRESSURE,
733
+ step,
734
+ &observablesReducer);
735
+ // Clean up after pre-step use of compute_globals()
736
+ observablesReducer.markAsReadyToReduce();
737
+ }
738
+
739
+ /* Calculate the initial half step temperature, and save the ekinh_old */
740
+ if (startingBehavior == StartingBehavior::NewSimulation)
741
+ {
742
+ for (i = 0; (i < ir->opts.ngtc); i++)
743
+ {
744
+ copy_mat(ekind->tcstat[i].ekinh, ekind->tcstat[i].ekinh_old);
745
+ }
746
+ }
747
+
748
+ /* need to make an initiation call to get the Trotter variables set, as well as other constants
749
+ for non-trotter temperature control */
750
+ auto trotter_seq = init_npt_vars(ir, state, &MassQ, bTrotter);
751
+
752
+ if (MASTER(cr))
753
+ {
754
+ if (!ir->bContinuation)
755
+ {
756
+ if (constr && ir->eConstrAlg == ConstraintAlgorithm::Lincs)
757
+ {
758
+ fprintf(fplog,
759
+ "RMS relative constraint deviation after constraining: %.2e\n",
760
+ constr->rmsd());
761
+ }
762
+ if (EI_STATE_VELOCITY(ir->eI))
763
+ {
764
+ real temp = enerd->term[F_TEMP];
765
+ if (ir->eI != IntegrationAlgorithm::VV)
766
+ {
767
+ /* Result of Ekin averaged over velocities of -half
768
+ * and +half step, while we only have -half step here.
769
+ */
770
+ temp *= 2;
771
+ }
772
+ fprintf(fplog, "Initial temperature: %g K\n", temp);
773
+ }
774
+ }
775
+
776
+ char tbuf[20];
777
+ fprintf(stderr, "starting mdrun '%s'\n", *(top_global.name));
778
+ if (ir->nsteps >= 0)
779
+ {
780
+ sprintf(tbuf, "%8.1f", (ir->init_step + ir->nsteps) * ir->delta_t);
781
+ }
782
+ else
783
+ {
784
+ sprintf(tbuf, "%s", "infinite");
785
+ }
786
+ if (ir->init_step > 0)
787
+ {
788
+ fprintf(stderr,
789
+ "%s steps, %s ps (continuing from step %s, %8.1f ps).\n",
790
+ gmx_step_str(ir->init_step + ir->nsteps, sbuf),
791
+ tbuf,
792
+ gmx_step_str(ir->init_step, sbuf2),
793
+ ir->init_step * ir->delta_t);
794
+ }
795
+ else
796
+ {
797
+ fprintf(stderr, "%s steps, %s ps.\n", gmx_step_str(ir->nsteps, sbuf), tbuf);
798
+ }
799
+ fprintf(fplog, "\n");
800
+ }
801
+
802
+ /* PLUMED */
803
+ if(plumedswitch){
804
+ /* detect plumed API version */
805
+ int pversion=0;
806
+ plumed_cmd(plumedmain,"getApiVersion",&pversion);
807
+ /* setting kbT is only implemented with api>1) */
808
+ real kbT=ir->opts.ref_t[0]*gmx::c_boltz;
809
+ if(pversion>1) plumed_cmd(plumedmain,"setKbT",&kbT);
810
+ if(pversion>2){
811
+ int res=1;
812
+ if( (startingBehavior != StartingBehavior::NewSimulation) ) plumed_cmd(plumedmain,"setRestart",&res);
813
+ }
814
+
815
+ if(isMultiSim(ms)) {
816
+ if(MASTER(cr)) plumed_cmd(plumedmain,"GREX setMPIIntercomm",&ms->mastersComm_);
817
+ if(PAR(cr)){
818
+ if(haveDDAtomOrdering(*cr)) {
819
+ plumed_cmd(plumedmain,"GREX setMPIIntracomm",&cr->dd->mpi_comm_all);
820
+ }else{
821
+ plumed_cmd(plumedmain,"GREX setMPIIntracomm",&cr->mpi_comm_mysim);
822
+ }
823
+ }
824
+ plumed_cmd(plumedmain,"GREX init",nullptr);
825
+ }
826
+ if(PAR(cr)){
827
+ if(haveDDAtomOrdering(*cr)) {
828
+ plumed_cmd(plumedmain,"setMPIComm",&cr->dd->mpi_comm_all);
829
+ }
830
+ }
831
+ plumed_cmd(plumedmain,"setNatoms",top_global.natoms);
832
+ plumed_cmd(plumedmain,"setMDEngine","gromacs");
833
+ plumed_cmd(plumedmain,"setLog",fplog);
834
+ real real_delta_t=ir->delta_t;
835
+ plumed_cmd(plumedmain,"setTimestep",&real_delta_t);
836
+ plumed_cmd(plumedmain,"init",nullptr);
837
+
838
+ if(haveDDAtomOrdering(*cr)) {
839
+ int nat_home = dd_numHomeAtoms(*cr->dd);
840
+ plumed_cmd(plumedmain,"setAtomsNlocal",&nat_home);
841
+ plumed_cmd(plumedmain,"setAtomsGatindex",cr->dd->globalAtomIndices.data());
842
+ }
843
+ realFepState = state->fep_state;
844
+ plumed_cmd(plumedmain, "setExtraCV lambda", &realFepState);
845
+ plumed_cmd(plumedmain, "setExtraCVForce lambda", &lambdaForce);
846
+ }
847
+ /* END PLUMED */
848
+
849
+ walltime_accounting_start_time(walltime_accounting);
850
+ wallcycle_start(wcycle, WallCycleCounter::Run);
851
+ print_start(fplog, cr, walltime_accounting, "mdrun");
852
+
853
+ /***********************************************************
854
+ *
855
+ * Loop over MD steps
856
+ *
857
+ ************************************************************/
858
+
859
+ bFirstStep = TRUE;
860
+ /* Skip the first Nose-Hoover integration when we get the state from tpx */
861
+ bInitStep = startingBehavior == StartingBehavior::NewSimulation || EI_VV(ir->eI);
862
+ bSumEkinhOld = FALSE;
863
+ bExchanged = FALSE;
864
+ bNeedRepartition = FALSE;
865
+ bDoReplEx = FALSE;
866
+
867
+ auto stopHandler = stopHandlerBuilder->getStopHandlerMD(
868
+ compat::not_null<SimulationSignal*>(&signals[eglsSTOPCOND]),
869
+ simulationsShareState,
870
+ MASTER(cr),
871
+ ir->nstlist,
872
+ mdrunOptions.reproducible,
873
+ nstSignalComm,
874
+ mdrunOptions.maximumHoursToRun,
875
+ ir->nstlist == 0,
876
+ fplog,
877
+ step,
878
+ bNS,
879
+ walltime_accounting);
880
+
881
+ real checkpointPeriod = mdrunOptions.checkpointOptions.period;
882
+ if (ir->bExpanded)
883
+ {
884
+ GMX_LOG(mdlog.info)
885
+ .asParagraph()
886
+ .appendText(
887
+ "Expanded ensemble with the legacy simulator does not always "
888
+ "checkpoint correctly, so checkpointing is disabled. You will "
889
+ "not be able to do a checkpoint restart of this simulation. "
890
+ "If you use the modular simulator (e.g. by choosing md-vv integrator) "
891
+ "then checkpointing is enabled. See "
892
+ "https://gitlab.com/gromacs/gromacs/-/issues/4629 for details.");
893
+ // Use a negative period to disable checkpointing.
894
+ checkpointPeriod = -1;
895
+ }
896
+ auto checkpointHandler = std::make_unique<CheckpointHandler>(
897
+ compat::make_not_null<SimulationSignal*>(&signals[eglsCHKPT]),
898
+ simulationsShareState,
899
+ ir->nstlist == 0,
900
+ MASTER(cr),
901
+ mdrunOptions.writeConfout,
902
+ checkpointPeriod);
903
+
904
+ const bool resetCountersIsLocal = true;
905
+ auto resetHandler = std::make_unique<ResetHandler>(
906
+ compat::make_not_null<SimulationSignal*>(&signals[eglsRESETCOUNTERS]),
907
+ !resetCountersIsLocal,
908
+ ir->nsteps,
909
+ MASTER(cr),
910
+ mdrunOptions.timingOptions.resetHalfway,
911
+ mdrunOptions.maximumHoursToRun,
912
+ mdlog,
913
+ wcycle,
914
+ walltime_accounting);
915
+
916
+ const DDBalanceRegionHandler ddBalanceRegionHandler(cr);
917
+
918
+ if (MASTER(cr) && isMultiSim(ms) && !useReplicaExchange)
919
+ {
920
+ logInitialMultisimStatus(ms, cr, mdlog, simulationsShareState, ir->nsteps, ir->init_step);
921
+ }
922
+
923
+ /* and stop now if we should */
924
+ bLastStep = (bLastStep || (ir->nsteps >= 0 && step_rel > ir->nsteps));
925
+ while (!bLastStep)
926
+ {
927
+
928
+ /* Determine if this is a neighbor search step */
929
+ bNStList = (ir->nstlist > 0 && step % ir->nstlist == 0);
930
+
931
+ if (bPMETune && bNStList)
932
+ {
933
+ // This has to be here because PME load balancing is called so early.
934
+ // TODO: Move to after all booleans are defined.
935
+ if (useGpuForUpdate && !bFirstStep)
936
+ {
937
+ stateGpu->copyCoordinatesFromGpu(state->x, AtomLocality::Local);
938
+ stateGpu->waitCoordinatesReadyOnHost(AtomLocality::Local);
939
+ }
940
+ /* PME grid + cut-off optimization with GPUs or PME nodes */
941
+ pme_loadbal_do(pme_loadbal,
942
+ cr,
943
+ (mdrunOptions.verbose && MASTER(cr)) ? stderr : nullptr,
944
+ fplog,
945
+ mdlog,
946
+ *ir,
947
+ fr,
948
+ state->box,
949
+ state->x,
950
+ wcycle,
951
+ step,
952
+ step_rel,
953
+ &bPMETunePrinting,
954
+ simulationWork.useGpuPmePpCommunication);
955
+ }
956
+
957
+ wallcycle_start(wcycle, WallCycleCounter::Step);
958
+
959
+ bLastStep = (step_rel == ir->nsteps);
960
+ t = t0 + step * ir->delta_t;
961
+
962
+ // TODO Refactor this, so that nstfep does not need a default value of zero
963
+ if (ir->efep != FreeEnergyPerturbationType::No || ir->bSimTemp)
964
+ {
965
+ /* find and set the current lambdas */
966
+ state->lambda = currentLambdas(step, *(ir->fepvals), state->fep_state);
967
+
968
+ bDoExpanded = (do_per_step(step, ir->expandedvals->nstexpanded) && (ir->bExpanded)
969
+ && (!bFirstStep));
970
+ }
971
+
972
+ bDoReplExPrev = bDoReplEx;
973
+ bDoReplEx = (useReplicaExchange && (step > 0) && !bLastStep
974
+ && do_per_step(step, replExParams.exchangeInterval));
975
+
976
+ if (doSimulatedAnnealing)
977
+ {
978
+ // TODO: Avoid changing inputrec (#3854)
979
+ // Simulated annealing updates the reference temperature.
980
+ auto* nonConstInputrec = const_cast<t_inputrec*>(inputrec);
981
+ update_annealing_target_temp(nonConstInputrec, t, &upd);
982
+ }
983
+
984
+ /* Stop Center of Mass motion */
985
+ bStopCM = (ir->comm_mode != ComRemovalAlgorithm::No && do_per_step(step, ir->nstcomm));
986
+
987
+ /* Determine whether or not to do Neighbour Searching */
988
+ bNS = (bFirstStep || bNStList || bExchanged || bNeedRepartition);
989
+
990
+ /* Note that the stopHandler will cause termination at nstglobalcomm
991
+ * steps. Since this concides with nstcalcenergy, nsttcouple and/or
992
+ * nstpcouple steps, we have computed the half-step kinetic energy
993
+ * of the previous step and can always output energies at the last step.
994
+ */
995
+ bLastStep = bLastStep || stopHandler->stoppingAfterCurrentStep(bNS);
996
+
997
+ /* do_log triggers energy and virial calculation. Because this leads
998
+ * to different code paths, forces can be different. Thus for exact
999
+ * continuation we should avoid extra log output.
1000
+ * Note that the || bLastStep can result in non-exact continuation
1001
+ * beyond the last step. But we don't consider that to be an issue.
1002
+ */
1003
+ do_log = (do_per_step(step, ir->nstlog)
1004
+ || (bFirstStep && startingBehavior == StartingBehavior::NewSimulation) || bLastStep);
1005
+ do_verbose = mdrunOptions.verbose
1006
+ && (step % mdrunOptions.verboseStepPrintInterval == 0 || bFirstStep || bLastStep);
1007
+
1008
+ // On search steps, when doing the update on the GPU, copy
1009
+ // the coordinates and velocities to the host unless they are
1010
+ // already there (ie on the first step and after replica
1011
+ // exchange).
1012
+ if (useGpuForUpdate && bNS && !bFirstStep && !bExchanged)
1013
+ {
1014
+ stateGpu->copyVelocitiesFromGpu(state->v, AtomLocality::Local);
1015
+ stateGpu->copyCoordinatesFromGpu(state->x, AtomLocality::Local);
1016
+ stateGpu->waitVelocitiesReadyOnHost(AtomLocality::Local);
1017
+ stateGpu->waitCoordinatesReadyOnHost(AtomLocality::Local);
1018
+ }
1019
+
1020
+ // We only need to calculate virtual velocities if we are writing them in the current step
1021
+ const bool needVirtualVelocitiesThisStep =
1022
+ (vsite != nullptr)
1023
+ && (do_per_step(step, ir->nstvout) || checkpointHandler->isCheckpointingStep());
1024
+
1025
+ if (vsite != nullptr)
1026
+ {
1027
+ // Virtual sites need to be updated before domain decomposition and forces are calculated
1028
+ wallcycle_start(wcycle, WallCycleCounter::VsiteConstr);
1029
+ // md-vv calculates virtual velocities once it has full-step real velocities
1030
+ vsite->construct(state->x,
1031
+ state->v,
1032
+ state->box,
1033
+ (!EI_VV(inputrec->eI) && needVirtualVelocitiesThisStep)
1034
+ ? VSiteOperation::PositionsAndVelocities
1035
+ : VSiteOperation::Positions);
1036
+ wallcycle_stop(wcycle, WallCycleCounter::VsiteConstr);
1037
+ }
1038
+
1039
+ if (bNS && !(bFirstStep && ir->bContinuation))
1040
+ {
1041
+ bMasterState = FALSE;
1042
+ /* Correct the new box if it is too skewed */
1043
+ if (inputrecDynamicBox(ir))
1044
+ {
1045
+ if (correct_box(fplog, step, state->box))
1046
+ {
1047
+ bMasterState = TRUE;
1048
+ }
1049
+ }
1050
+ // If update is offloaded, and the box was changed either
1051
+ // above or in a replica exchange on the previous step,
1052
+ // the GPU Update object should be informed
1053
+ if (useGpuForUpdate && (bMasterState || bExchanged))
1054
+ {
1055
+ integrator->setPbc(PbcType::Xyz, state->box);
1056
+ }
1057
+ if (haveDDAtomOrdering(*cr) && bMasterState)
1058
+ {
1059
+ dd_collect_state(cr->dd, state, state_global);
1060
+ }
1061
+
1062
+ if (haveDDAtomOrdering(*cr))
1063
+ {
1064
+ /* Repartition the domain decomposition */
1065
+ dd_partition_system(fplog,
1066
+ mdlog,
1067
+ step,
1068
+ cr,
1069
+ bMasterState,
1070
+ nstglobalcomm,
1071
+ state_global,
1072
+ top_global,
1073
+ *ir,
1074
+ imdSession,
1075
+ pull_work,
1076
+ state,
1077
+ &f,
1078
+ mdAtoms,
1079
+ top,
1080
+ fr,
1081
+ vsite,
1082
+ constr,
1083
+ nrnb,
1084
+ wcycle,
1085
+ do_verbose && !bPMETunePrinting);
1086
+ upd.updateAfterPartition(state->natoms,
1087
+ md->cFREEZE ? gmx::arrayRefFromArray(md->cFREEZE, md->nr)
1088
+ : gmx::ArrayRef<const unsigned short>(),
1089
+ md->cTC ? gmx::arrayRefFromArray(md->cTC, md->nr)
1090
+ : gmx::ArrayRef<const unsigned short>(),
1091
+ md->cACC ? gmx::arrayRefFromArray(md->cACC, md->nr)
1092
+ : gmx::ArrayRef<const unsigned short>());
1093
+ fr->longRangeNonbondeds->updateAfterPartition(*md);
1094
+ /* PLUMED */
1095
+ if(plumedswitch){
1096
+ int nat_home = dd_numHomeAtoms(*cr->dd);
1097
+ plumed_cmd(plumedmain,"setAtomsNlocal",&nat_home);
1098
+ plumed_cmd(plumedmain,"setAtomsGatindex",cr->dd->globalAtomIndices.data());
1099
+ }
1100
+ /* END PLUMED */
1101
+ }
1102
+ }
1103
+
1104
+ // Allocate or re-size GPU halo exchange object, if necessary
1105
+ if (bNS && simulationWork.havePpDomainDecomposition && simulationWork.useGpuHaloExchange)
1106
+ {
1107
+ GMX_RELEASE_ASSERT(fr->deviceStreamManager != nullptr,
1108
+ "GPU device manager has to be initialized to use GPU "
1109
+ "version of halo exchange.");
1110
+ constructGpuHaloExchange(*cr, *fr->deviceStreamManager, wcycle);
1111
+ }
1112
+
1113
+ if (MASTER(cr) && do_log)
1114
+ {
1115
+ gmx::EnergyOutput::printHeader(
1116
+ fplog, step, t); /* can we improve the information printed here? */
1117
+ }
1118
+
1119
+ if (ir->efep != FreeEnergyPerturbationType::No)
1120
+ {
1121
+ update_mdatoms(mdAtoms->mdatoms(), state->lambda[FreeEnergyPerturbationCouplingType::Mass]);
1122
+ }
1123
+
1124
+ if (bExchanged)
1125
+ {
1126
+ /* We need the kinetic energy at minus the half step for determining
1127
+ * the full step kinetic energy and possibly for T-coupling.*/
1128
+ /* This may not be quite working correctly yet . . . . */
1129
+ int cglo_flags = CGLO_GSTAT | CGLO_TEMPERATURE;
1130
+ compute_globals(gstat,
1131
+ cr,
1132
+ ir,
1133
+ fr,
1134
+ ekind,
1135
+ makeConstArrayRef(state->x),
1136
+ makeConstArrayRef(state->v),
1137
+ state->box,
1138
+ md,
1139
+ nrnb,
1140
+ &vcm,
1141
+ wcycle,
1142
+ enerd,
1143
+ nullptr,
1144
+ nullptr,
1145
+ nullptr,
1146
+ nullptr,
1147
+ &nullSignaller,
1148
+ state->box,
1149
+ &bSumEkinhOld,
1150
+ cglo_flags,
1151
+ step,
1152
+ &observablesReducer);
1153
+ }
1154
+ clear_mat(force_vir);
1155
+
1156
+ /* PLUMED HREX */
1157
+ gmx_bool bHREX = bDoReplEx && plumed_hrex;
1158
+
1159
+ if (plumedswitch && bHREX) {
1160
+ // gmx_enerdata_t *hrex_enerd;
1161
+ int nlambda = enerd->foreignLambdaTerms.numLambdas();
1162
+ gmx_enerdata_t hrex_enerd(enerd->grpp.nener, nlambda == 0 ? 0 : nlambda - 1);
1163
+ int repl = -1;
1164
+ int nrepl = -1;
1165
+ if (MASTER(cr)){
1166
+ repl = replica_exchange_get_repl(repl_ex);
1167
+ nrepl = replica_exchange_get_nrepl(repl_ex);
1168
+ }
1169
+
1170
+ if (haveDDAtomOrdering(*cr)) {
1171
+ dd_collect_state(cr->dd,state,state_global);
1172
+ } else {
1173
+ copy_state_serial(state, state_global);
1174
+ }
1175
+
1176
+ if(MASTER(cr)){
1177
+ if(repl%2==step/replExParams.exchangeInterval%2){
1178
+ if(repl-1>=0) exchange_state(ms,repl-1,state_global);
1179
+ }else{
1180
+ if(repl+1<nrepl) exchange_state(ms,repl+1,state_global);
1181
+ }
1182
+ }
1183
+ if (!haveDDAtomOrdering(*cr)) {
1184
+ copy_state_serial(state_global, state);
1185
+ }
1186
+ if (haveDDAtomOrdering(*cr)) {
1187
+ dd_partition_system(fplog,
1188
+ mdlog,
1189
+ step,
1190
+ cr,
1191
+ TRUE,
1192
+ 1,
1193
+ state_global,
1194
+ top_global,
1195
+ *ir,
1196
+ imdSession,
1197
+ pull_work,
1198
+ state,
1199
+ &f,
1200
+ mdAtoms,
1201
+ top,
1202
+ fr,
1203
+ vsite,
1204
+ constr,
1205
+ nrnb,
1206
+ wcycle,
1207
+ do_verbose && !bPMETunePrinting);
1208
+ }
1209
+ do_force(fplog,
1210
+ cr,
1211
+ ms,
1212
+ *ir,
1213
+ awh.get(),
1214
+ enforcedRotation,
1215
+ imdSession,
1216
+ pull_work,
1217
+ step,
1218
+ nrnb,
1219
+ wcycle,
1220
+ top,
1221
+ state->box,
1222
+ state->x.arrayRefWithPadding(),
1223
+ &state->hist,
1224
+ &f.view(),
1225
+ force_vir,
1226
+ md,
1227
+ &hrex_enerd,
1228
+ state->lambda,
1229
+ fr,
1230
+ runScheduleWork,
1231
+ vsite,
1232
+ mu_tot,
1233
+ t,
1234
+ ed ? ed->getLegacyED() : nullptr,
1235
+ fr->longRangeNonbondeds.get(),
1236
+ GMX_FORCE_STATECHANGED |
1237
+ GMX_FORCE_DYNAMICBOX |
1238
+ GMX_FORCE_ALLFORCES |
1239
+ GMX_FORCE_VIRIAL |
1240
+ GMX_FORCE_ENERGY |
1241
+ GMX_FORCE_DHDL |
1242
+ GMX_FORCE_NS,
1243
+ ddBalanceRegionHandler);
1244
+
1245
+ plumed_cmd(plumedmain,"GREX cacheLocalUSwap",&(&hrex_enerd)->term[F_EPOT]);
1246
+
1247
+ /* exchange back */
1248
+ if (haveDDAtomOrdering(*cr)) {
1249
+ dd_collect_state(cr->dd,state,state_global);
1250
+ } else {
1251
+ copy_state_serial(state, state_global);
1252
+ }
1253
+
1254
+ if(MASTER(cr)){
1255
+ if(repl%2==step/replExParams.exchangeInterval%2){
1256
+ if(repl-1>=0) exchange_state(ms,repl-1,state_global);
1257
+ }else{
1258
+ if(repl+1<nrepl) exchange_state(ms,repl+1,state_global);
1259
+ }
1260
+ }
1261
+
1262
+ if (!haveDDAtomOrdering(*cr)) {
1263
+ copy_state_serial(state_global, state);
1264
+ }
1265
+ if (haveDDAtomOrdering(*cr)) {
1266
+ dd_partition_system(fplog,
1267
+ mdlog,
1268
+ step,
1269
+ cr,
1270
+ TRUE,
1271
+ 1,
1272
+ state_global,
1273
+ top_global,
1274
+ *ir,
1275
+ imdSession,
1276
+ pull_work,
1277
+ state,
1278
+ &f,
1279
+ mdAtoms,
1280
+ top,
1281
+ fr,
1282
+ vsite,
1283
+ constr,
1284
+ nrnb,
1285
+ wcycle,
1286
+ do_verbose && !bPMETunePrinting);
1287
+ int nat_home = dd_numHomeAtoms(*cr->dd);
1288
+ plumed_cmd(plumedmain,"setAtomsNlocal",&nat_home);
1289
+ plumed_cmd(plumedmain,"setAtomsGatindex",cr->dd->globalAtomIndices.data());
1290
+ }
1291
+ bNS=true;
1292
+ }
1293
+ /* END PLUMED HREX */
1294
+
1295
+ checkpointHandler->decideIfCheckpointingThisStep(bNS||bDoReplExPrev, bFirstStep, bLastStep);
1296
+
1297
+ /* Determine the energy and pressure:
1298
+ * at nstcalcenergy steps and at energy output steps (set below).
1299
+ */
1300
+ if (EI_VV(ir->eI) && (!bInitStep))
1301
+ {
1302
+ bCalcEnerStep = do_per_step(step, ir->nstcalcenergy);
1303
+ bCalcVir = bCalcEnerStep
1304
+ || (ir->epc != PressureCoupling::No
1305
+ && (do_per_step(step, ir->nstpcouple) || do_per_step(step - 1, ir->nstpcouple)));
1306
+ }
1307
+ else
1308
+ {
1309
+ bCalcEnerStep = do_per_step(step, ir->nstcalcenergy);
1310
+ bCalcVir = bCalcEnerStep
1311
+ || (ir->epc != PressureCoupling::No && do_per_step(step, ir->nstpcouple));
1312
+ }
1313
+ bCalcEner = bCalcEnerStep;
1314
+
1315
+ do_ene = (do_per_step(step, ir->nstenergy) || bLastStep);
1316
+
1317
+ if (do_ene || do_log || bDoReplEx)
1318
+ {
1319
+ bCalcVir = TRUE;
1320
+ bCalcEner = TRUE;
1321
+ }
1322
+
1323
+ // bCalcEner is only here for when the last step is not a mulitple of nstfep
1324
+ const bool computeDHDL = ((ir->efep != FreeEnergyPerturbationType::No || ir->bSimTemp)
1325
+ && (do_per_step(step, nstfep) || bCalcEner));
1326
+
1327
+ /* Do we need global communication ? */
1328
+ bGStat = (bCalcVir || bCalcEner || bStopCM || do_per_step(step, nstglobalcomm)
1329
+ || (EI_VV(ir->eI) && inputrecNvtTrotter(ir) && do_per_step(step - 1, nstglobalcomm)));
1330
+
1331
+ force_flags = (GMX_FORCE_STATECHANGED | ((inputrecDynamicBox(ir)) ? GMX_FORCE_DYNAMICBOX : 0)
1332
+ | GMX_FORCE_ALLFORCES | (bCalcVir ? GMX_FORCE_VIRIAL : 0)
1333
+ | (bCalcEner ? GMX_FORCE_ENERGY : 0) | (computeDHDL ? GMX_FORCE_DHDL : 0));
1334
+ if (simulationWork.useMts && !do_per_step(step, ir->nstfout))
1335
+ {
1336
+ // TODO: merge this with stepWork.useOnlyMtsCombinedForceBuffer
1337
+ force_flags |= GMX_FORCE_DO_NOT_NEED_NORMAL_FORCE;
1338
+ }
1339
+
1340
+ if (shellfc)
1341
+ {
1342
+ /* Now is the time to relax the shells */
1343
+ relax_shell_flexcon(fplog,
1344
+ cr,
1345
+ ms,
1346
+ mdrunOptions.verbose,
1347
+ enforcedRotation,
1348
+ step,
1349
+ ir,
1350
+ imdSession,
1351
+ pull_work,
1352
+ bNS,
1353
+ force_flags,
1354
+ top,
1355
+ constr,
1356
+ enerd,
1357
+ state->natoms,
1358
+ state->x.arrayRefWithPadding(),
1359
+ state->v.arrayRefWithPadding(),
1360
+ state->box,
1361
+ state->lambda,
1362
+ &state->hist,
1363
+ &f.view(),
1364
+ force_vir,
1365
+ *md,
1366
+ fr->longRangeNonbondeds.get(),
1367
+ nrnb,
1368
+ wcycle,
1369
+ shellfc,
1370
+ fr,
1371
+ runScheduleWork,
1372
+ t,
1373
+ mu_tot,
1374
+ vsite,
1375
+ ddBalanceRegionHandler);
1376
+ }
1377
+ else
1378
+ {
1379
+ /* The AWH history need to be saved _before_ doing force calculations where the AWH bias
1380
+ is updated (or the AWH update will be performed twice for one step when continuing).
1381
+ It would be best to call this update function from do_md_trajectory_writing but that
1382
+ would occur after do_force. One would have to divide the update_awh function into one
1383
+ function applying the AWH force and one doing the AWH bias update. The update AWH
1384
+ bias function could then be called after do_md_trajectory_writing (then containing
1385
+ update_awh_history). The checkpointing will in the future probably moved to the start
1386
+ of the md loop which will rid of this issue. */
1387
+ if (awh && checkpointHandler->isCheckpointingStep() && MASTER(cr))
1388
+ {
1389
+ awh->updateHistory(state_global->awhHistory.get());
1390
+ }
1391
+
1392
+ /* The coordinates (x) are shifted (to get whole molecules)
1393
+ * in do_force.
1394
+ * This is parallellized as well, and does communication too.
1395
+ * Check comments in sim_util.c
1396
+ */
1397
+
1398
+ /* PLUMED */
1399
+ plumedNeedsEnergy=0;
1400
+ if(plumedswitch){
1401
+ int pversion=0;
1402
+ plumed_cmd(plumedmain,"getApiVersion",&pversion);
1403
+ long int lstep=step; plumed_cmd(plumedmain,"setStepLong",&lstep);
1404
+ plumed_cmd(plumedmain,"setPositions",&state->x[0][0]);
1405
+ plumed_cmd(plumedmain,"setMasses",&md->massT[0]);
1406
+ plumed_cmd(plumedmain,"setCharges",&md->chargeA[0]);
1407
+ plumed_cmd(plumedmain,"setBox",&state->box[0][0]);
1408
+ plumed_cmd(plumedmain,"prepareCalc",nullptr);
1409
+ plumed_cmd(plumedmain,"setStopFlag",&plumedWantsToStop);
1410
+ int checkp=0; if(checkpointHandler->isCheckpointingStep()) checkp=1;
1411
+ if(pversion>3) plumed_cmd(plumedmain,"doCheckPoint",&checkp);
1412
+ plumed_cmd(plumedmain,"setForces",&f.view().force()[0][0]);
1413
+ plumed_cmd(plumedmain,"isEnergyNeeded",&plumedNeedsEnergy);
1414
+ if(plumedNeedsEnergy) force_flags |= GMX_FORCE_ENERGY | GMX_FORCE_VIRIAL;
1415
+ clear_mat(plumed_vir);
1416
+ plumed_cmd(plumedmain,"setVirial",&plumed_vir[0][0]);
1417
+ }
1418
+ /* END PLUMED */
1419
+ do_force(fplog,
1420
+ cr,
1421
+ ms,
1422
+ *ir,
1423
+ awh.get(),
1424
+ enforcedRotation,
1425
+ imdSession,
1426
+ pull_work,
1427
+ step,
1428
+ nrnb,
1429
+ wcycle,
1430
+ top,
1431
+ state->box,
1432
+ state->x.arrayRefWithPadding(),
1433
+ &state->hist,
1434
+ &f.view(),
1435
+ force_vir,
1436
+ md,
1437
+ enerd,
1438
+ state->lambda,
1439
+ fr,
1440
+ runScheduleWork,
1441
+ vsite,
1442
+ mu_tot,
1443
+ t,
1444
+ ed ? ed->getLegacyED() : nullptr,
1445
+ fr->longRangeNonbondeds.get(),
1446
+ (bNS ? GMX_FORCE_NS : 0) | force_flags,
1447
+ ddBalanceRegionHandler);
1448
+ /* PLUMED */
1449
+ if(plumedswitch){
1450
+ if(plumedNeedsEnergy){
1451
+ msmul(force_vir,2.0,plumed_vir);
1452
+ plumed_cmd(plumedmain,"setEnergy",&enerd->term[F_EPOT]);
1453
+ plumed_cmd(plumedmain,"performCalc",nullptr);
1454
+ msmul(plumed_vir,0.5,force_vir);
1455
+ } else {
1456
+ msmul(plumed_vir,0.5,plumed_vir);
1457
+ m_add(force_vir,plumed_vir,force_vir);
1458
+ }
1459
+ if(bDoReplEx) plumed_cmd(plumedmain,"GREX savePositions",nullptr);
1460
+ if(plumedWantsToStop) bLastStep = true;
1461
+ if(bHREX) plumed_cmd(plumedmain,"GREX cacheLocalUNow",&enerd->term[F_EPOT]);
1462
+ }
1463
+ /* END PLUMED */
1464
+ }
1465
+
1466
+ // VV integrators do not need the following velocity half step
1467
+ // if it is the first step after starting from a checkpoint.
1468
+ // That is, the half step is needed on all other steps, and
1469
+ // also the first step when starting from a .tpr file.
1470
+ if (EI_VV(ir->eI))
1471
+ {
1472
+ integrateVVFirstStep(step,
1473
+ bFirstStep,
1474
+ bInitStep,
1475
+ startingBehavior,
1476
+ nstglobalcomm,
1477
+ ir,
1478
+ fr,
1479
+ cr,
1480
+ state,
1481
+ mdAtoms->mdatoms(),
1482
+ &fcdata,
1483
+ &MassQ,
1484
+ &vcm,
1485
+ enerd,
1486
+ &observablesReducer,
1487
+ ekind,
1488
+ gstat,
1489
+ &last_ekin,
1490
+ bCalcVir,
1491
+ total_vir,
1492
+ shake_vir,
1493
+ force_vir,
1494
+ pres,
1495
+ M,
1496
+ do_log,
1497
+ do_ene,
1498
+ bCalcEner,
1499
+ bGStat,
1500
+ bStopCM,
1501
+ bTrotter,
1502
+ bExchanged,
1503
+ &bSumEkinhOld,
1504
+ &saved_conserved_quantity,
1505
+ &f,
1506
+ &upd,
1507
+ constr,
1508
+ &nullSignaller,
1509
+ trotter_seq,
1510
+ nrnb,
1511
+ fplog,
1512
+ wcycle);
1513
+ if (vsite != nullptr && needVirtualVelocitiesThisStep)
1514
+ {
1515
+ // Positions were calculated earlier
1516
+ wallcycle_start(wcycle, WallCycleCounter::VsiteConstr);
1517
+ vsite->construct(state->x, state->v, state->box, VSiteOperation::Velocities);
1518
+ wallcycle_stop(wcycle, WallCycleCounter::VsiteConstr);
1519
+ }
1520
+ }
1521
+
1522
+ /* ######## END FIRST UPDATE STEP ############## */
1523
+ /* ######## If doing VV, we now have v(dt) ###### */
1524
+ if (bDoExpanded)
1525
+ {
1526
+ /* perform extended ensemble sampling in lambda - we don't
1527
+ actually move to the new state before outputting
1528
+ statistics, but if performing simulated tempering, we
1529
+ do update the velocities and the tau_t. */
1530
+ // TODO: Avoid changing inputrec (#3854)
1531
+ // Simulated tempering updates the reference temperature.
1532
+ // Expanded ensemble without simulated tempering does not change the inputrec.
1533
+ auto* nonConstInputrec = const_cast<t_inputrec*>(inputrec);
1534
+ lamnew = ExpandedEnsembleDynamics(fplog,
1535
+ nonConstInputrec,
1536
+ enerd,
1537
+ state,
1538
+ &MassQ,
1539
+ state->fep_state,
1540
+ state->dfhist,
1541
+ step,
1542
+ state->v.rvec_array(),
1543
+ &realFepState,
1544
+ md->homenr,
1545
+ md->cTC ? gmx::arrayRefFromArray(md->cTC, md->nr)
1546
+ : gmx::ArrayRef<const unsigned short>());
1547
+ /* history is maintained in state->dfhist, but state_global is what is sent to trajectory and log output */
1548
+ if (MASTER(cr))
1549
+ {
1550
+ copy_df_history(state_global->dfhist, state->dfhist);
1551
+ }
1552
+ }
1553
+
1554
+ // Copy coordinate from the GPU for the output/checkpointing if the update is offloaded and
1555
+ // coordinates have not already been copied for i) search or ii) CPU force tasks.
1556
+ if (useGpuForUpdate && !bNS && !runScheduleWork->domainWork.haveCpuLocalForceWork
1557
+ && (do_per_step(step, ir->nstxout) || do_per_step(step, ir->nstxout_compressed)
1558
+ || checkpointHandler->isCheckpointingStep()))
1559
+ {
1560
+ stateGpu->copyCoordinatesFromGpu(state->x, AtomLocality::Local);
1561
+ stateGpu->waitCoordinatesReadyOnHost(AtomLocality::Local);
1562
+ }
1563
+ // Copy velocities if needed for the output/checkpointing.
1564
+ // NOTE: Copy on the search steps is done at the beginning of the step.
1565
+ if (useGpuForUpdate && !bNS
1566
+ && (do_per_step(step, ir->nstvout) || checkpointHandler->isCheckpointingStep()))
1567
+ {
1568
+ stateGpu->copyVelocitiesFromGpu(state->v, AtomLocality::Local);
1569
+ stateGpu->waitVelocitiesReadyOnHost(AtomLocality::Local);
1570
+ }
1571
+ // Copy forces for the output if the forces were reduced on the GPU (not the case on virial steps)
1572
+ // and update is offloaded hence forces are kept on the GPU for update and have not been
1573
+ // already transferred in do_force().
1574
+ // TODO: There should be an improved, explicit mechanism that ensures this copy is only executed
1575
+ // when the forces are ready on the GPU -- the same synchronizer should be used as the one
1576
+ // prior to GPU update.
1577
+ // TODO: When the output flags will be included in step workload, this copy can be combined with the
1578
+ // copy call in do_force(...).
1579
+ // NOTE: The forces should not be copied here if the vsites are present, since they were modified
1580
+ // on host after the D2H copy in do_force(...).
1581
+ if (runScheduleWork->stepWork.useGpuFBufferOps && (simulationWork.useGpuUpdate && !vsite)
1582
+ && do_per_step(step, ir->nstfout))
1583
+ {
1584
+ stateGpu->copyForcesFromGpu(f.view().force(), AtomLocality::Local);
1585
+ stateGpu->waitForcesReadyOnHost(AtomLocality::Local);
1586
+ }
1587
+ /* Now we have the energies and forces corresponding to the
1588
+ * coordinates at time t. We must output all of this before
1589
+ * the update.
1590
+ */
1591
+ const EkindataState ekindataState = bGStat ? (bSumEkinhOld ? EkindataState::UsedNeedToReduce
1592
+ : EkindataState::UsedDoNotNeedToReduce)
1593
+ : EkindataState::NotUsed;
1594
+ do_md_trajectory_writing(fplog,
1595
+ cr,
1596
+ nfile,
1597
+ fnm,
1598
+ step,
1599
+ step_rel,
1600
+ t,
1601
+ ir,
1602
+ state,
1603
+ state_global,
1604
+ observablesHistory,
1605
+ top_global,
1606
+ fr,
1607
+ outf,
1608
+ energyOutput,
1609
+ ekind,
1610
+ f.view().force(),
1611
+ checkpointHandler->isCheckpointingStep(),
1612
+ bRerunMD,
1613
+ bLastStep,
1614
+ mdrunOptions.writeConfout,
1615
+ ekindataState);
1616
+ /* Check if IMD step and do IMD communication, if bIMD is TRUE. */
1617
+ bInteractiveMDstep = imdSession->run(step, bNS, state->box, state->x, t);
1618
+
1619
+ /* kludge -- virial is lost with restart for MTTK NPT control. Must reload (saved earlier). */
1620
+ if (startingBehavior != StartingBehavior::NewSimulation && bFirstStep
1621
+ && (inputrecNptTrotter(ir) || inputrecNphTrotter(ir)))
1622
+ {
1623
+ copy_mat(state->svir_prev, shake_vir);
1624
+ copy_mat(state->fvir_prev, force_vir);
1625
+ }
1626
+
1627
+ stopHandler->setSignal();
1628
+ resetHandler->setSignal(walltime_accounting);
1629
+
1630
+ if (bGStat || !PAR(cr))
1631
+ {
1632
+ /* In parallel we only have to check for checkpointing in steps
1633
+ * where we do global communication,
1634
+ * otherwise the other nodes don't know.
1635
+ */
1636
+ checkpointHandler->setSignal(walltime_accounting);
1637
+ }
1638
+
1639
+ /* ######### START SECOND UPDATE STEP ################# */
1640
+
1641
+ /* at the start of step, randomize or scale the velocities ((if vv. Restriction of Andersen
1642
+ controlled in preprocessing */
1643
+
1644
+ if (ETC_ANDERSEN(ir->etc)) /* keep this outside of update_tcouple because of the extra info required to pass */
1645
+ {
1646
+ gmx_bool bIfRandomize;
1647
+ bIfRandomize = update_randomize_velocities(ir,
1648
+ step,
1649
+ cr,
1650
+ md->homenr,
1651
+ md->cTC ? gmx::arrayRefFromArray(md->cTC, md->nr)
1652
+ : gmx::ArrayRef<const unsigned short>(),
1653
+ gmx::arrayRefFromArray(md->invmass, md->nr),
1654
+ state->v,
1655
+ &upd,
1656
+ constr);
1657
+ /* if we have constraints, we have to remove the kinetic energy parallel to the bonds */
1658
+ if (constr && bIfRandomize)
1659
+ {
1660
+ constrain_velocities(constr, do_log, do_ene, step, state, nullptr, false, nullptr);
1661
+ }
1662
+ }
1663
+ /* Box is changed in update() when we do pressure coupling,
1664
+ * but we should still use the old box for energy corrections and when
1665
+ * writing it to the energy file, so it matches the trajectory files for
1666
+ * the same timestep above. Make a copy in a separate array.
1667
+ */
1668
+ copy_mat(state->box, lastbox);
1669
+
1670
+ dvdl_constr = 0;
1671
+
1672
+ if (!useGpuForUpdate)
1673
+ {
1674
+ wallcycle_start(wcycle, WallCycleCounter::Update);
1675
+ }
1676
+ /* UPDATE PRESSURE VARIABLES IN TROTTER FORMULATION WITH CONSTRAINTS */
1677
+ if (bTrotter)
1678
+ {
1679
+ trotter_update(ir,
1680
+ step,
1681
+ ekind,
1682
+ enerd,
1683
+ state,
1684
+ total_vir,
1685
+ md->homenr,
1686
+ md->cTC ? gmx::arrayRefFromArray(md->cTC, md->nr)
1687
+ : gmx::ArrayRef<const unsigned short>(),
1688
+ gmx::arrayRefFromArray(md->invmass, md->nr),
1689
+ &MassQ,
1690
+ trotter_seq,
1691
+ TrotterSequence::Three);
1692
+ /* We can only do Berendsen coupling after we have summed
1693
+ * the kinetic energy or virial. Since the happens
1694
+ * in global_state after update, we should only do it at
1695
+ * step % nstlist = 1 with bGStatEveryStep=FALSE.
1696
+ */
1697
+ }
1698
+ else
1699
+ {
1700
+ update_tcouple(step,
1701
+ ir,
1702
+ state,
1703
+ ekind,
1704
+ &MassQ,
1705
+ md->homenr,
1706
+ md->cTC ? gmx::arrayRefFromArray(md->cTC, md->nr)
1707
+ : gmx::ArrayRef<const unsigned short>());
1708
+ update_pcouple_before_coordinates(fplog, step, ir, state, pressureCouplingMu, M, bInitStep);
1709
+ }
1710
+
1711
+ /* With leap-frog type integrators we compute the kinetic energy
1712
+ * at a whole time step as the average of the half-time step kinetic
1713
+ * energies of two subsequent steps. Therefore we need to compute the
1714
+ * half step kinetic energy also if we need energies at the next step.
1715
+ */
1716
+ const bool needHalfStepKineticEnergy =
1717
+ (!EI_VV(ir->eI) && (do_per_step(step + 1, nstglobalcomm) || step_rel + 1 == ir->nsteps));
1718
+
1719
+ // Parrinello-Rahman requires the pressure to be availible before the update to compute
1720
+ // the velocity scaling matrix. Hence, it runs one step after the nstpcouple step.
1721
+ const bool doParrinelloRahman = (ir->epc == PressureCoupling::ParrinelloRahman
1722
+ && do_per_step(step + ir->nstpcouple - 1, ir->nstpcouple));
1723
+
1724
+ if (EI_VV(ir->eI))
1725
+ {
1726
+ GMX_ASSERT(!useGpuForUpdate, "GPU update is not supported with VVAK integrator.");
1727
+
1728
+ integrateVVSecondStep(step,
1729
+ ir,
1730
+ fr,
1731
+ cr,
1732
+ state,
1733
+ mdAtoms->mdatoms(),
1734
+ &fcdata,
1735
+ &MassQ,
1736
+ &vcm,
1737
+ pull_work,
1738
+ enerd,
1739
+ &observablesReducer,
1740
+ ekind,
1741
+ gstat,
1742
+ &dvdl_constr,
1743
+ bCalcVir,
1744
+ total_vir,
1745
+ shake_vir,
1746
+ force_vir,
1747
+ pres,
1748
+ M,
1749
+ lastbox,
1750
+ do_log,
1751
+ do_ene,
1752
+ bGStat,
1753
+ &bSumEkinhOld,
1754
+ &f,
1755
+ &cbuf,
1756
+ &upd,
1757
+ constr,
1758
+ &nullSignaller,
1759
+ trotter_seq,
1760
+ nrnb,
1761
+ wcycle);
1762
+ }
1763
+ else
1764
+ {
1765
+ if (useGpuForUpdate)
1766
+ {
1767
+ // On search steps, update handles to device vectors
1768
+ // TODO: this condition has redundant / unnecessary clauses
1769
+ if (bNS && (bFirstStep || haveDDAtomOrdering(*cr) || bExchanged))
1770
+ {
1771
+ integrator->set(stateGpu->getCoordinates(),
1772
+ stateGpu->getVelocities(),
1773
+ stateGpu->getForces(),
1774
+ top->idef,
1775
+ *md);
1776
+
1777
+ // Copy data to the GPU after buffers might have been reinitialized
1778
+ /* The velocity copy is redundant if we had Center-of-Mass motion removed on
1779
+ * the previous step. We don't check that now. */
1780
+ stateGpu->copyVelocitiesToGpu(state->v, AtomLocality::Local);
1781
+ }
1782
+
1783
+ // Copy x to the GPU unless we have already transferred in do_force().
1784
+ // We transfer in do_force() if a GPU force task requires x (PME or x buffer ops).
1785
+ if (!(runScheduleWork->stepWork.haveGpuPmeOnThisRank
1786
+ || runScheduleWork->stepWork.useGpuXBufferOps))
1787
+ {
1788
+ stateGpu->copyCoordinatesToGpu(state->x, AtomLocality::Local);
1789
+ // Coordinates are later used by the integrator running in the same stream.
1790
+ stateGpu->consumeCoordinatesCopiedToDeviceEvent(AtomLocality::Local);
1791
+ }
1792
+
1793
+ if ((simulationWork.useGpuPme && simulationWork.useCpuPmePpCommunication)
1794
+ || (!runScheduleWork->stepWork.useGpuFBufferOps))
1795
+ {
1796
+ // The PME forces were recieved to the host, and reduced on the CPU with the
1797
+ // rest of the forces computed on the GPU, so the final forces have to be copied
1798
+ // back to the GPU. Or the buffer ops were not offloaded this step, so the
1799
+ // forces are on the host and have to be copied
1800
+ stateGpu->copyForcesToGpu(f.view().force(), AtomLocality::Local);
1801
+ }
1802
+ const bool doTemperatureScaling =
1803
+ (ir->etc != TemperatureCoupling::No
1804
+ && do_per_step(step + ir->nsttcouple - 1, ir->nsttcouple));
1805
+
1806
+ // This applies Leap-Frog, LINCS and SETTLE in succession
1807
+ integrator->integrate(stateGpu->getLocalForcesReadyOnDeviceEvent(
1808
+ runScheduleWork->stepWork, runScheduleWork->simulationWork),
1809
+ ir->delta_t,
1810
+ true,
1811
+ bCalcVir,
1812
+ shake_vir,
1813
+ doTemperatureScaling,
1814
+ ekind->tcstat,
1815
+ doParrinelloRahman,
1816
+ ir->nstpcouple * ir->delta_t,
1817
+ M);
1818
+ }
1819
+ else
1820
+ {
1821
+ /* With multiple time stepping we need to do an additional normal
1822
+ * update step to obtain the virial, as the actual MTS integration
1823
+ * using an acceleration where the slow forces are multiplied by mtsFactor.
1824
+ * Using that acceleration would result in a virial with the slow
1825
+ * force contribution would be a factor mtsFactor too large.
1826
+ */
1827
+ if (simulationWork.useMts && bCalcVir && constr != nullptr)
1828
+ {
1829
+ upd.update_for_constraint_virial(*ir,
1830
+ md->homenr,
1831
+ md->havePartiallyFrozenAtoms,
1832
+ gmx::arrayRefFromArray(md->invmass, md->nr),
1833
+ gmx::arrayRefFromArray(md->invMassPerDim, md->nr),
1834
+ *state,
1835
+ f.view().forceWithPadding(),
1836
+ *ekind);
1837
+
1838
+ constrain_coordinates(constr,
1839
+ do_log,
1840
+ do_ene,
1841
+ step,
1842
+ state,
1843
+ upd.xp()->arrayRefWithPadding(),
1844
+ &dvdl_constr,
1845
+ bCalcVir,
1846
+ shake_vir);
1847
+ }
1848
+
1849
+ ArrayRefWithPadding<const RVec> forceCombined =
1850
+ (simulationWork.useMts && step % ir->mtsLevels[1].stepFactor == 0)
1851
+ ? f.view().forceMtsCombinedWithPadding()
1852
+ : f.view().forceWithPadding();
1853
+ upd.update_coords(*ir,
1854
+ step,
1855
+ md->homenr,
1856
+ md->havePartiallyFrozenAtoms,
1857
+ gmx::arrayRefFromArray(md->ptype, md->nr),
1858
+ gmx::arrayRefFromArray(md->invmass, md->nr),
1859
+ gmx::arrayRefFromArray(md->invMassPerDim, md->nr),
1860
+ state,
1861
+ forceCombined,
1862
+ &fcdata,
1863
+ ekind,
1864
+ M,
1865
+ etrtPOSITION,
1866
+ cr,
1867
+ constr != nullptr);
1868
+
1869
+ wallcycle_stop(wcycle, WallCycleCounter::Update);
1870
+
1871
+ constrain_coordinates(constr,
1872
+ do_log,
1873
+ do_ene,
1874
+ step,
1875
+ state,
1876
+ upd.xp()->arrayRefWithPadding(),
1877
+ &dvdl_constr,
1878
+ bCalcVir && !simulationWork.useMts,
1879
+ shake_vir);
1880
+
1881
+ upd.update_sd_second_half(*ir,
1882
+ step,
1883
+ &dvdl_constr,
1884
+ md->homenr,
1885
+ gmx::arrayRefFromArray(md->ptype, md->nr),
1886
+ gmx::arrayRefFromArray(md->invmass, md->nr),
1887
+ state,
1888
+ cr,
1889
+ nrnb,
1890
+ wcycle,
1891
+ constr,
1892
+ do_log,
1893
+ do_ene);
1894
+ upd.finish_update(
1895
+ *ir, md->havePartiallyFrozenAtoms, md->homenr, state, wcycle, constr != nullptr);
1896
+ }
1897
+
1898
+ if (ir->bPull && ir->pull->bSetPbcRefToPrevStepCOM)
1899
+ {
1900
+ updatePrevStepPullCom(pull_work, state->pull_com_prev_step);
1901
+ }
1902
+
1903
+ enerd->term[F_DVDL_CONSTR] += dvdl_constr;
1904
+ }
1905
+
1906
+ /* ############## IF NOT VV, Calculate globals HERE ############ */
1907
+ /* With Leap-Frog we can skip compute_globals at
1908
+ * non-communication steps, but we need to calculate
1909
+ * the kinetic energy one step before communication.
1910
+ */
1911
+ {
1912
+ // Organize to do inter-simulation signalling on steps if
1913
+ // and when algorithms require it.
1914
+ const bool doInterSimSignal = (simulationsShareState && do_per_step(step, nstSignalComm));
1915
+
1916
+ if (useGpuForUpdate)
1917
+ {
1918
+ const bool coordinatesRequiredForStopCM =
1919
+ bStopCM && (bGStat || needHalfStepKineticEnergy || doInterSimSignal)
1920
+ && !EI_VV(ir->eI);
1921
+
1922
+ // Copy coordinates when needed to stop the CM motion or for replica exchange
1923
+ if (coordinatesRequiredForStopCM || bDoReplEx)
1924
+ {
1925
+ stateGpu->copyCoordinatesFromGpu(state->x, AtomLocality::Local);
1926
+ stateGpu->waitCoordinatesReadyOnHost(AtomLocality::Local);
1927
+ }
1928
+
1929
+ // Copy velocities back to the host if:
1930
+ // - Globals are computed this step (includes the energy output steps).
1931
+ // - Temperature is needed for the next step.
1932
+ // - This is a replica exchange step (even though we will only need
1933
+ // the velocities if an exchange succeeds)
1934
+ if (bGStat || needHalfStepKineticEnergy || bDoReplEx)
1935
+ {
1936
+ stateGpu->copyVelocitiesFromGpu(state->v, AtomLocality::Local);
1937
+ stateGpu->waitVelocitiesReadyOnHost(AtomLocality::Local);
1938
+ }
1939
+ }
1940
+
1941
+ if (bGStat || needHalfStepKineticEnergy || doInterSimSignal)
1942
+ {
1943
+ // Since we're already communicating at this step, we
1944
+ // can propagate intra-simulation signals. Note that
1945
+ // check_nstglobalcomm has the responsibility for
1946
+ // choosing the value of nstglobalcomm that is one way
1947
+ // bGStat becomes true, so we can't get into a
1948
+ // situation where e.g. checkpointing can't be
1949
+ // signalled.
1950
+ bool doIntraSimSignal = true;
1951
+ SimulationSignaller signaller(&signals, cr, ms, doInterSimSignal, doIntraSimSignal);
1952
+
1953
+ compute_globals(gstat,
1954
+ cr,
1955
+ ir,
1956
+ fr,
1957
+ ekind,
1958
+ makeConstArrayRef(state->x),
1959
+ makeConstArrayRef(state->v),
1960
+ state->box,
1961
+ md,
1962
+ nrnb,
1963
+ &vcm,
1964
+ wcycle,
1965
+ enerd,
1966
+ force_vir,
1967
+ shake_vir,
1968
+ total_vir,
1969
+ pres,
1970
+ &signaller,
1971
+ lastbox,
1972
+ &bSumEkinhOld,
1973
+ (bGStat ? CGLO_GSTAT : 0) | (!EI_VV(ir->eI) && bCalcEner ? CGLO_ENERGY : 0)
1974
+ | (!EI_VV(ir->eI) && bStopCM ? CGLO_STOPCM : 0)
1975
+ | (!EI_VV(ir->eI) ? CGLO_TEMPERATURE : 0)
1976
+ | (!EI_VV(ir->eI) ? CGLO_PRESSURE : 0) | CGLO_CONSTRAINT,
1977
+ step,
1978
+ &observablesReducer);
1979
+ if (!EI_VV(ir->eI) && bStopCM)
1980
+ {
1981
+ process_and_stopcm_grp(
1982
+ fplog, &vcm, *md, makeArrayRef(state->x), makeArrayRef(state->v));
1983
+ inc_nrnb(nrnb, eNR_STOPCM, md->homenr);
1984
+
1985
+ // TODO: The special case of removing CM motion should be dealt more gracefully
1986
+ if (useGpuForUpdate)
1987
+ {
1988
+ // Issue #3988, #4106.
1989
+ stateGpu->resetCoordinatesCopiedToDeviceEvent(AtomLocality::Local);
1990
+ stateGpu->copyCoordinatesToGpu(state->x, AtomLocality::Local);
1991
+ // Here we block until the H2D copy completes because event sync with the
1992
+ // force kernels that use the coordinates on the next steps is not implemented
1993
+ // (not because of a race on state->x being modified on the CPU while H2D is in progress).
1994
+ stateGpu->waitCoordinatesCopiedToDevice(AtomLocality::Local);
1995
+ // If the COM removal changed the velocities on the CPU, this has to be accounted for.
1996
+ if (vcm.mode != ComRemovalAlgorithm::No)
1997
+ {
1998
+ stateGpu->copyVelocitiesToGpu(state->v, AtomLocality::Local);
1999
+ }
2000
+ }
2001
+ }
2002
+ }
2003
+ }
2004
+
2005
+ /* ############# END CALC EKIN AND PRESSURE ################# */
2006
+
2007
+ /* Note: this is OK, but there are some numerical precision issues with using the convergence of
2008
+ the virial that should probably be addressed eventually. state->veta has better properies,
2009
+ but what we actually need entering the new cycle is the new shake_vir value. Ideally, we could
2010
+ generate the new shake_vir, but test the veta value for convergence. This will take some thought. */
2011
+
2012
+ if (ir->efep != FreeEnergyPerturbationType::No && !EI_VV(ir->eI))
2013
+ {
2014
+ /* Sum up the foreign energy and dK/dl terms for md and sd.
2015
+ Currently done every step so that dH/dl is correct in the .edr */
2016
+ accumulateKineticLambdaComponents(enerd, state->lambda, *ir->fepvals);
2017
+ }
2018
+
2019
+ bool scaleCoordinates = !useGpuForUpdate || bDoReplEx;
2020
+ update_pcouple_after_coordinates(fplog,
2021
+ step,
2022
+ ir,
2023
+ md->homenr,
2024
+ md->cFREEZE ? gmx::arrayRefFromArray(md->cFREEZE, md->nr)
2025
+ : gmx::ArrayRef<const unsigned short>(),
2026
+ pres,
2027
+ force_vir,
2028
+ shake_vir,
2029
+ pressureCouplingMu,
2030
+ state,
2031
+ nrnb,
2032
+ upd.deform(),
2033
+ scaleCoordinates);
2034
+
2035
+ const bool doBerendsenPressureCoupling = (inputrec->epc == PressureCoupling::Berendsen
2036
+ && do_per_step(step, inputrec->nstpcouple));
2037
+ const bool doCRescalePressureCoupling = (inputrec->epc == PressureCoupling::CRescale
2038
+ && do_per_step(step, inputrec->nstpcouple));
2039
+ if (useGpuForUpdate
2040
+ && (doBerendsenPressureCoupling || doCRescalePressureCoupling || doParrinelloRahman))
2041
+ {
2042
+ integrator->scaleCoordinates(pressureCouplingMu);
2043
+ if (doCRescalePressureCoupling)
2044
+ {
2045
+ matrix pressureCouplingInvMu;
2046
+ gmx::invertBoxMatrix(pressureCouplingMu, pressureCouplingInvMu);
2047
+ integrator->scaleVelocities(pressureCouplingInvMu);
2048
+ }
2049
+ integrator->setPbc(PbcType::Xyz, state->box);
2050
+ }
2051
+
2052
+ /* ################# END UPDATE STEP 2 ################# */
2053
+ /* #### We now have r(t+dt) and v(t+dt/2) ############# */
2054
+
2055
+ /* The coordinates (x) were unshifted in update */
2056
+ if (!bGStat)
2057
+ {
2058
+ /* We will not sum ekinh_old,
2059
+ * so signal that we still have to do it.
2060
+ */
2061
+ bSumEkinhOld = TRUE;
2062
+ }
2063
+
2064
+ if (bCalcEner)
2065
+ {
2066
+ /* ######### BEGIN PREPARING EDR OUTPUT ########### */
2067
+
2068
+ /* use the directly determined last velocity, not actually the averaged half steps */
2069
+ if (bTrotter && ir->eI == IntegrationAlgorithm::VV)
2070
+ {
2071
+ enerd->term[F_EKIN] = last_ekin;
2072
+ }
2073
+ enerd->term[F_ETOT] = enerd->term[F_EPOT] + enerd->term[F_EKIN];
2074
+
2075
+ if (integratorHasConservedEnergyQuantity(ir))
2076
+ {
2077
+ if (EI_VV(ir->eI))
2078
+ {
2079
+ enerd->term[F_ECONSERVED] = enerd->term[F_ETOT] + saved_conserved_quantity;
2080
+ }
2081
+ else
2082
+ {
2083
+ enerd->term[F_ECONSERVED] = enerd->term[F_ETOT] + NPT_energy(ir, state, &MassQ);
2084
+ }
2085
+ }
2086
+ /* ######### END PREPARING EDR OUTPUT ########### */
2087
+ }
2088
+
2089
+ /* Output stuff */
2090
+ if (MASTER(cr))
2091
+ {
2092
+ if (fplog && do_log && bDoExpanded)
2093
+ {
2094
+ /* only needed if doing expanded ensemble */
2095
+ PrintFreeEnergyInfoToFile(fplog,
2096
+ ir->fepvals.get(),
2097
+ ir->expandedvals.get(),
2098
+ ir->bSimTemp ? ir->simtempvals.get() : nullptr,
2099
+ state_global->dfhist,
2100
+ state->fep_state,
2101
+ ir->nstlog,
2102
+ step);
2103
+ }
2104
+ if (bCalcEner)
2105
+ {
2106
+ const bool outputDHDL = (computeDHDL && do_per_step(step, ir->fepvals->nstdhdl));
2107
+
2108
+ energyOutput.addDataAtEnergyStep(outputDHDL,
2109
+ bCalcEnerStep,
2110
+ t,
2111
+ md->tmass,
2112
+ enerd,
2113
+ ir->fepvals.get(),
2114
+ lastbox,
2115
+ PTCouplingArrays{ state->boxv,
2116
+ state->nosehoover_xi,
2117
+ state->nosehoover_vxi,
2118
+ state->nhpres_xi,
2119
+ state->nhpres_vxi },
2120
+ state->fep_state,
2121
+ total_vir,
2122
+ pres,
2123
+ ekind,
2124
+ mu_tot,
2125
+ constr);
2126
+ }
2127
+ else
2128
+ {
2129
+ energyOutput.recordNonEnergyStep();
2130
+ }
2131
+
2132
+ gmx_bool do_dr = do_per_step(step, ir->nstdisreout);
2133
+ gmx_bool do_or = do_per_step(step, ir->nstorireout);
2134
+
2135
+ if (doSimulatedAnnealing)
2136
+ {
2137
+ gmx::EnergyOutput::printAnnealingTemperatures(
2138
+ do_log ? fplog : nullptr, groups, &(ir->opts));
2139
+ }
2140
+ if (do_log || do_ene || do_dr || do_or)
2141
+ {
2142
+ energyOutput.printStepToEnergyFile(mdoutf_get_fp_ene(outf),
2143
+ do_ene,
2144
+ do_dr,
2145
+ do_or,
2146
+ do_log ? fplog : nullptr,
2147
+ step,
2148
+ t,
2149
+ fr->fcdata.get(),
2150
+ awh.get());
2151
+ }
2152
+ if (do_log && ((ir->bDoAwh && awh->hasFepLambdaDimension()) || ir->fepvals->delta_lambda != 0))
2153
+ {
2154
+ const bool isInitialOutput = false;
2155
+ printLambdaStateToLog(fplog, state->lambda, isInitialOutput);
2156
+ }
2157
+
2158
+ if (ir->bPull)
2159
+ {
2160
+ pull_print_output(pull_work, step, t);
2161
+ }
2162
+
2163
+ if (do_per_step(step, ir->nstlog))
2164
+ {
2165
+ if (fflush(fplog) != 0)
2166
+ {
2167
+ gmx_fatal(FARGS, "Cannot flush logfile - maybe you are out of disk space?");
2168
+ }
2169
+ }
2170
+ }
2171
+ if (bDoExpanded)
2172
+ {
2173
+ /* Have to do this part _after_ outputting the logfile and the edr file */
2174
+ /* Gets written into the state at the beginning of next loop*/
2175
+ state->fep_state = lamnew;
2176
+ if(plumedswitch)
2177
+ {
2178
+ realFepState = state->fep_state;
2179
+ }
2180
+ }
2181
+ else if (ir->bDoAwh && awh->needForeignEnergyDifferences(step))
2182
+ {
2183
+ state->fep_state = awh->fepLambdaState();
2184
+ }
2185
+ /* Print the remaining wall clock time for the run */
2186
+ if (isMasterSimMasterRank(ms, MASTER(cr)) && (do_verbose || gmx_got_usr_signal()) && !bPMETunePrinting)
2187
+ {
2188
+ if (shellfc)
2189
+ {
2190
+ fprintf(stderr, "\n");
2191
+ }
2192
+ print_time(stderr, walltime_accounting, step, ir, cr);
2193
+ }
2194
+
2195
+ /* Ion/water position swapping.
2196
+ * Not done in last step since trajectory writing happens before this call
2197
+ * in the MD loop and exchanges would be lost anyway. */
2198
+ bNeedRepartition = FALSE;
2199
+ if ((ir->eSwapCoords != SwapType::No) && (step > 0) && !bLastStep
2200
+ && do_per_step(step, ir->swap->nstswap))
2201
+ {
2202
+ bNeedRepartition = do_swapcoords(cr,
2203
+ step,
2204
+ t,
2205
+ ir,
2206
+ swap,
2207
+ wcycle,
2208
+ as_rvec_array(state->x.data()),
2209
+ state->box,
2210
+ MASTER(cr) && mdrunOptions.verbose,
2211
+ bRerunMD);
2212
+
2213
+ if (bNeedRepartition && haveDDAtomOrdering(*cr))
2214
+ {
2215
+ dd_collect_state(cr->dd, state, state_global);
2216
+ }
2217
+ }
2218
+
2219
+ /* Replica exchange */
2220
+ bExchanged = FALSE;
2221
+ if (bDoReplEx)
2222
+ {
2223
+ bExchanged = replica_exchange(fplog, cr, ms, repl_ex, state_global, enerd, state, step, t);
2224
+ }
2225
+
2226
+ if ((bExchanged || bNeedRepartition) && haveDDAtomOrdering(*cr))
2227
+ {
2228
+ dd_partition_system(fplog,
2229
+ mdlog,
2230
+ step,
2231
+ cr,
2232
+ TRUE,
2233
+ 1,
2234
+ state_global,
2235
+ top_global,
2236
+ *ir,
2237
+ imdSession,
2238
+ pull_work,
2239
+ state,
2240
+ &f,
2241
+ mdAtoms,
2242
+ top,
2243
+ fr,
2244
+ vsite,
2245
+ constr,
2246
+ nrnb,
2247
+ wcycle,
2248
+ FALSE);
2249
+ upd.updateAfterPartition(state->natoms,
2250
+ md->cFREEZE ? gmx::arrayRefFromArray(md->cFREEZE, md->nr)
2251
+ : gmx::ArrayRef<const unsigned short>(),
2252
+ md->cTC ? gmx::arrayRefFromArray(md->cTC, md->nr)
2253
+ : gmx::ArrayRef<const unsigned short>(),
2254
+ md->cACC ? gmx::arrayRefFromArray(md->cACC, md->nr)
2255
+ : gmx::ArrayRef<const unsigned short>());
2256
+ fr->longRangeNonbondeds->updateAfterPartition(*md);
2257
+ }
2258
+
2259
+ bFirstStep = FALSE;
2260
+ bInitStep = FALSE;
2261
+
2262
+ /* ####### SET VARIABLES FOR NEXT ITERATION IF THEY STILL NEED IT ###### */
2263
+ /* With all integrators, except VV, we need to retain the pressure
2264
+ * at the current step for coupling at the next step.
2265
+ */
2266
+ if ((state->flags & enumValueToBitMask(StateEntry::PressurePrevious))
2267
+ && (bGStatEveryStep || (ir->nstpcouple > 0 && step % ir->nstpcouple == 0)))
2268
+ {
2269
+ /* Store the pressure in t_state for pressure coupling
2270
+ * at the next MD step.
2271
+ */
2272
+ copy_mat(pres, state->pres_prev);
2273
+ }
2274
+
2275
+ /* ####### END SET VARIABLES FOR NEXT ITERATION ###### */
2276
+
2277
+ if ((membed != nullptr) && (!bLastStep))
2278
+ {
2279
+ rescale_membed(step_rel, membed, as_rvec_array(state_global->x.data()));
2280
+ }
2281
+
2282
+ cycles = wallcycle_stop(wcycle, WallCycleCounter::Step);
2283
+ if (haveDDAtomOrdering(*cr) && wcycle)
2284
+ {
2285
+ dd_cycles_add(cr->dd, cycles, ddCyclStep);
2286
+ }
2287
+
2288
+ /* increase the MD step number */
2289
+ step++;
2290
+ step_rel++;
2291
+ observablesReducer.markAsReadyToReduce();
2292
+
2293
+ #if GMX_FAHCORE
2294
+ if (MASTER(cr))
2295
+ {
2296
+ fcReportProgress(ir->nsteps + ir->init_step, step);
2297
+ }
2298
+ #endif
2299
+
2300
+ resetHandler->resetCounters(
2301
+ step, step_rel, mdlog, fplog, cr, fr->nbv.get(), nrnb, fr->pmedata, pme_loadbal, wcycle, walltime_accounting);
2302
+
2303
+ /* If bIMD is TRUE, the master updates the IMD energy record and sends positions to VMD client */
2304
+ imdSession->updateEnergyRecordAndSendPositionsAndEnergies(bInteractiveMDstep, step, bCalcEner);
2305
+ }
2306
+ /* End of main MD loop */
2307
+
2308
+ /* Closing TNG files can include compressing data. Therefore it is good to do that
2309
+ * before stopping the time measurements. */
2310
+ mdoutf_tng_close(outf);
2311
+
2312
+ /* Stop measuring walltime */
2313
+ walltime_accounting_end_time(walltime_accounting);
2314
+
2315
+ if (simulationWork.haveSeparatePmeRank)
2316
+ {
2317
+ /* Tell the PME only node to finish */
2318
+ gmx_pme_send_finish(cr);
2319
+ }
2320
+
2321
+ if (MASTER(cr))
2322
+ {
2323
+ if (ir->nstcalcenergy > 0)
2324
+ {
2325
+ energyOutput.printEnergyConservation(fplog, ir->simulation_part, EI_MD(ir->eI));
2326
+
2327
+ gmx::EnergyOutput::printAnnealingTemperatures(fplog, groups, &(ir->opts));
2328
+ energyOutput.printAverages(fplog, groups);
2329
+ }
2330
+ }
2331
+ done_mdoutf(outf);
2332
+
2333
+ if (bPMETune)
2334
+ {
2335
+ pme_loadbal_done(pme_loadbal, fplog, mdlog, fr->nbv->useGpu());
2336
+ }
2337
+
2338
+ done_shellfc(fplog, shellfc, step_rel);
2339
+
2340
+ if (useReplicaExchange && MASTER(cr))
2341
+ {
2342
+ print_replica_exchange_statistics(fplog, repl_ex);
2343
+ }
2344
+
2345
+ walltime_accounting_set_nsteps_done(walltime_accounting, step_rel);
2346
+
2347
+ global_stat_destroy(gstat);
2348
+ }