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