hillclimber 0.1.6__cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (475) hide show
  1. hillclimber/__init__.py +41 -0
  2. hillclimber/actions.py +53 -0
  3. hillclimber/analysis.py +590 -0
  4. hillclimber/biases.py +293 -0
  5. hillclimber/calc.py +22 -0
  6. hillclimber/cvs.py +1070 -0
  7. hillclimber/interfaces.py +133 -0
  8. hillclimber/metadynamics.py +416 -0
  9. hillclimber/nodes.py +6 -0
  10. hillclimber/opes.py +359 -0
  11. hillclimber/pycv.py +362 -0
  12. hillclimber/selectors.py +230 -0
  13. hillclimber/virtual_atoms.py +341 -0
  14. hillclimber-0.1.6.dist-info/METADATA +325 -0
  15. hillclimber-0.1.6.dist-info/RECORD +475 -0
  16. hillclimber-0.1.6.dist-info/WHEEL +6 -0
  17. hillclimber-0.1.6.dist-info/entry_points.txt +8 -0
  18. hillclimber-0.1.6.dist-info/licenses/LICENSE +165 -0
  19. hillclimber-0.1.6.dist-info/sboms/auditwheel.cdx.json +1 -0
  20. hillclimber.libs/libgomp-a49a47f9.so.1.0.0 +0 -0
  21. plumed/__init__.py +104 -0
  22. plumed/_lib/bin/plumed +0 -0
  23. plumed/_lib/bin/plumed-config +9 -0
  24. plumed/_lib/bin/plumed-patch +9 -0
  25. plumed/_lib/include/plumed/adjmat/AdjacencyMatrixBase.h +659 -0
  26. plumed/_lib/include/plumed/adjmat/ContactMatrix.h +59 -0
  27. plumed/_lib/include/plumed/asmjit/arch.h +228 -0
  28. plumed/_lib/include/plumed/asmjit/arm.h +43 -0
  29. plumed/_lib/include/plumed/asmjit/asmjit.h +69 -0
  30. plumed/_lib/include/plumed/asmjit/asmjit_apibegin.h +143 -0
  31. plumed/_lib/include/plumed/asmjit/asmjit_apiend.h +93 -0
  32. plumed/_lib/include/plumed/asmjit/asmjit_build.h +971 -0
  33. plumed/_lib/include/plumed/asmjit/assembler.h +183 -0
  34. plumed/_lib/include/plumed/asmjit/base.h +56 -0
  35. plumed/_lib/include/plumed/asmjit/codebuilder.h +944 -0
  36. plumed/_lib/include/plumed/asmjit/codecompiler.h +767 -0
  37. plumed/_lib/include/plumed/asmjit/codeemitter.h +528 -0
  38. plumed/_lib/include/plumed/asmjit/codeholder.h +777 -0
  39. plumed/_lib/include/plumed/asmjit/constpool.h +286 -0
  40. plumed/_lib/include/plumed/asmjit/cpuinfo.h +402 -0
  41. plumed/_lib/include/plumed/asmjit/func.h +1327 -0
  42. plumed/_lib/include/plumed/asmjit/globals.h +370 -0
  43. plumed/_lib/include/plumed/asmjit/inst.h +137 -0
  44. plumed/_lib/include/plumed/asmjit/logging.h +317 -0
  45. plumed/_lib/include/plumed/asmjit/misc_p.h +103 -0
  46. plumed/_lib/include/plumed/asmjit/moved_string.h +318 -0
  47. plumed/_lib/include/plumed/asmjit/operand.h +1599 -0
  48. plumed/_lib/include/plumed/asmjit/osutils.h +207 -0
  49. plumed/_lib/include/plumed/asmjit/regalloc_p.h +597 -0
  50. plumed/_lib/include/plumed/asmjit/runtime.h +227 -0
  51. plumed/_lib/include/plumed/asmjit/simdtypes.h +1104 -0
  52. plumed/_lib/include/plumed/asmjit/utils.h +1387 -0
  53. plumed/_lib/include/plumed/asmjit/vmem.h +183 -0
  54. plumed/_lib/include/plumed/asmjit/x86.h +45 -0
  55. plumed/_lib/include/plumed/asmjit/x86assembler.h +125 -0
  56. plumed/_lib/include/plumed/asmjit/x86builder.h +117 -0
  57. plumed/_lib/include/plumed/asmjit/x86compiler.h +322 -0
  58. plumed/_lib/include/plumed/asmjit/x86emitter.h +5149 -0
  59. plumed/_lib/include/plumed/asmjit/x86globals.h +535 -0
  60. plumed/_lib/include/plumed/asmjit/x86inst.h +2547 -0
  61. plumed/_lib/include/plumed/asmjit/x86instimpl_p.h +74 -0
  62. plumed/_lib/include/plumed/asmjit/x86internal_p.h +108 -0
  63. plumed/_lib/include/plumed/asmjit/x86logging_p.h +92 -0
  64. plumed/_lib/include/plumed/asmjit/x86misc.h +417 -0
  65. plumed/_lib/include/plumed/asmjit/x86operand.h +1133 -0
  66. plumed/_lib/include/plumed/asmjit/x86regalloc_p.h +734 -0
  67. plumed/_lib/include/plumed/asmjit/zone.h +1157 -0
  68. plumed/_lib/include/plumed/bias/Bias.h +82 -0
  69. plumed/_lib/include/plumed/bias/ReweightBase.h +58 -0
  70. plumed/_lib/include/plumed/blas/blas.h +253 -0
  71. plumed/_lib/include/plumed/blas/def_external.h +61 -0
  72. plumed/_lib/include/plumed/blas/def_internal.h +97 -0
  73. plumed/_lib/include/plumed/blas/real.h +49 -0
  74. plumed/_lib/include/plumed/cltools/CLTool.h +32 -0
  75. plumed/_lib/include/plumed/clusters/ClusteringBase.h +70 -0
  76. plumed/_lib/include/plumed/colvar/Colvar.h +32 -0
  77. plumed/_lib/include/plumed/colvar/ColvarInput.h +68 -0
  78. plumed/_lib/include/plumed/colvar/ColvarShortcut.h +81 -0
  79. plumed/_lib/include/plumed/colvar/CoordinationBase.h +52 -0
  80. plumed/_lib/include/plumed/colvar/MultiColvarTemplate.h +333 -0
  81. plumed/_lib/include/plumed/colvar/PathMSDBase.h +101 -0
  82. plumed/_lib/include/plumed/colvar/RMSDVector.h +78 -0
  83. plumed/_lib/include/plumed/config/Config.h +118 -0
  84. plumed/_lib/include/plumed/config/version.h +9 -0
  85. plumed/_lib/include/plumed/contour/ContourFindingObject.h +87 -0
  86. plumed/_lib/include/plumed/contour/DistanceFromContourBase.h +82 -0
  87. plumed/_lib/include/plumed/contour/FindContour.h +67 -0
  88. plumed/_lib/include/plumed/core/Action.h +540 -0
  89. plumed/_lib/include/plumed/core/ActionAnyorder.h +48 -0
  90. plumed/_lib/include/plumed/core/ActionAtomistic.h +343 -0
  91. plumed/_lib/include/plumed/core/ActionForInterface.h +99 -0
  92. plumed/_lib/include/plumed/core/ActionPilot.h +57 -0
  93. plumed/_lib/include/plumed/core/ActionRegister.h +124 -0
  94. plumed/_lib/include/plumed/core/ActionSet.h +163 -0
  95. plumed/_lib/include/plumed/core/ActionSetup.h +48 -0
  96. plumed/_lib/include/plumed/core/ActionShortcut.h +73 -0
  97. plumed/_lib/include/plumed/core/ActionToGetData.h +59 -0
  98. plumed/_lib/include/plumed/core/ActionToPutData.h +101 -0
  99. plumed/_lib/include/plumed/core/ActionWithArguments.h +140 -0
  100. plumed/_lib/include/plumed/core/ActionWithMatrix.h +87 -0
  101. plumed/_lib/include/plumed/core/ActionWithValue.h +258 -0
  102. plumed/_lib/include/plumed/core/ActionWithVector.h +94 -0
  103. plumed/_lib/include/plumed/core/ActionWithVirtualAtom.h +123 -0
  104. plumed/_lib/include/plumed/core/CLTool.h +177 -0
  105. plumed/_lib/include/plumed/core/CLToolMain.h +102 -0
  106. plumed/_lib/include/plumed/core/CLToolRegister.h +108 -0
  107. plumed/_lib/include/plumed/core/Colvar.h +115 -0
  108. plumed/_lib/include/plumed/core/DataPassingObject.h +94 -0
  109. plumed/_lib/include/plumed/core/DataPassingTools.h +54 -0
  110. plumed/_lib/include/plumed/core/DomainDecomposition.h +120 -0
  111. plumed/_lib/include/plumed/core/ExchangePatterns.h +47 -0
  112. plumed/_lib/include/plumed/core/FlexibleBin.h +63 -0
  113. plumed/_lib/include/plumed/core/GREX.h +61 -0
  114. plumed/_lib/include/plumed/core/GenericMolInfo.h +89 -0
  115. plumed/_lib/include/plumed/core/Group.h +41 -0
  116. plumed/_lib/include/plumed/core/ModuleMap.h +30 -0
  117. plumed/_lib/include/plumed/core/ParallelTaskManager.h +1023 -0
  118. plumed/_lib/include/plumed/core/PbcAction.h +61 -0
  119. plumed/_lib/include/plumed/core/PlumedMain.h +632 -0
  120. plumed/_lib/include/plumed/core/PlumedMainInitializer.h +118 -0
  121. plumed/_lib/include/plumed/core/RegisterBase.h +340 -0
  122. plumed/_lib/include/plumed/core/TargetDist.h +48 -0
  123. plumed/_lib/include/plumed/core/Value.h +547 -0
  124. plumed/_lib/include/plumed/core/WithCmd.h +93 -0
  125. plumed/_lib/include/plumed/dimred/SMACOF.h +55 -0
  126. plumed/_lib/include/plumed/drr/DRR.h +383 -0
  127. plumed/_lib/include/plumed/drr/colvar_UIestimator.h +777 -0
  128. plumed/_lib/include/plumed/fisst/legendre_rule_fast.h +44 -0
  129. plumed/_lib/include/plumed/function/Custom.h +54 -0
  130. plumed/_lib/include/plumed/function/Function.h +85 -0
  131. plumed/_lib/include/plumed/function/FunctionOfMatrix.h +368 -0
  132. plumed/_lib/include/plumed/function/FunctionOfScalar.h +135 -0
  133. plumed/_lib/include/plumed/function/FunctionOfVector.h +296 -0
  134. plumed/_lib/include/plumed/function/FunctionSetup.h +180 -0
  135. plumed/_lib/include/plumed/function/FunctionShortcut.h +130 -0
  136. plumed/_lib/include/plumed/function/FunctionWithSingleArgument.h +165 -0
  137. plumed/_lib/include/plumed/gridtools/ActionWithGrid.h +43 -0
  138. plumed/_lib/include/plumed/gridtools/EvaluateGridFunction.h +99 -0
  139. plumed/_lib/include/plumed/gridtools/FunctionOfGrid.h +295 -0
  140. plumed/_lib/include/plumed/gridtools/GridCoordinatesObject.h +179 -0
  141. plumed/_lib/include/plumed/gridtools/GridSearch.h +135 -0
  142. plumed/_lib/include/plumed/gridtools/Interpolator.h +45 -0
  143. plumed/_lib/include/plumed/gridtools/KDE.h +455 -0
  144. plumed/_lib/include/plumed/gridtools/RDF.h +40 -0
  145. plumed/_lib/include/plumed/gridtools/SumOfKernels.h +219 -0
  146. plumed/_lib/include/plumed/isdb/MetainferenceBase.h +398 -0
  147. plumed/_lib/include/plumed/lapack/def_external.h +207 -0
  148. plumed/_lib/include/plumed/lapack/def_internal.h +388 -0
  149. plumed/_lib/include/plumed/lapack/lapack.h +899 -0
  150. plumed/_lib/include/plumed/lapack/lapack_limits.h +79 -0
  151. plumed/_lib/include/plumed/lapack/real.h +50 -0
  152. plumed/_lib/include/plumed/lepton/CompiledExpression.h +164 -0
  153. plumed/_lib/include/plumed/lepton/CustomFunction.h +143 -0
  154. plumed/_lib/include/plumed/lepton/Exception.h +93 -0
  155. plumed/_lib/include/plumed/lepton/ExpressionProgram.h +137 -0
  156. plumed/_lib/include/plumed/lepton/ExpressionTreeNode.h +145 -0
  157. plumed/_lib/include/plumed/lepton/Lepton.h +85 -0
  158. plumed/_lib/include/plumed/lepton/MSVC_erfc.h +123 -0
  159. plumed/_lib/include/plumed/lepton/Operation.h +1302 -0
  160. plumed/_lib/include/plumed/lepton/ParsedExpression.h +165 -0
  161. plumed/_lib/include/plumed/lepton/Parser.h +111 -0
  162. plumed/_lib/include/plumed/lepton/windowsIncludes.h +73 -0
  163. plumed/_lib/include/plumed/mapping/Path.h +44 -0
  164. plumed/_lib/include/plumed/mapping/PathProjectionCalculator.h +57 -0
  165. plumed/_lib/include/plumed/matrixtools/MatrixOperationBase.h +54 -0
  166. plumed/_lib/include/plumed/matrixtools/MatrixTimesMatrix.h +309 -0
  167. plumed/_lib/include/plumed/matrixtools/MatrixTimesVectorBase.h +365 -0
  168. plumed/_lib/include/plumed/matrixtools/OuterProduct.h +238 -0
  169. plumed/_lib/include/plumed/maze/Core.h +65 -0
  170. plumed/_lib/include/plumed/maze/Loss.h +86 -0
  171. plumed/_lib/include/plumed/maze/Member.h +66 -0
  172. plumed/_lib/include/plumed/maze/Memetic.h +799 -0
  173. plumed/_lib/include/plumed/maze/Optimizer.h +357 -0
  174. plumed/_lib/include/plumed/maze/Random_MT.h +156 -0
  175. plumed/_lib/include/plumed/maze/Tools.h +183 -0
  176. plumed/_lib/include/plumed/metatomic/vesin.h +188 -0
  177. plumed/_lib/include/plumed/molfile/Gromacs.h +2013 -0
  178. plumed/_lib/include/plumed/molfile/endianswap.h +217 -0
  179. plumed/_lib/include/plumed/molfile/fastio.h +683 -0
  180. plumed/_lib/include/plumed/molfile/largefiles.h +78 -0
  181. plumed/_lib/include/plumed/molfile/libmolfile_plugin.h +77 -0
  182. plumed/_lib/include/plumed/molfile/molfile_plugin.h +1034 -0
  183. plumed/_lib/include/plumed/molfile/periodic_table.h +248 -0
  184. plumed/_lib/include/plumed/molfile/readpdb.h +447 -0
  185. plumed/_lib/include/plumed/molfile/vmdplugin.h +236 -0
  186. plumed/_lib/include/plumed/multicolvar/MultiColvarShortcuts.h +45 -0
  187. plumed/_lib/include/plumed/opes/ExpansionCVs.h +79 -0
  188. plumed/_lib/include/plumed/sasa/Sasa.h +32 -0
  189. plumed/_lib/include/plumed/secondarystructure/SecondaryStructureBase.h +372 -0
  190. plumed/_lib/include/plumed/setup/ActionSetup.h +25 -0
  191. plumed/_lib/include/plumed/small_vector/small_vector.h +6114 -0
  192. plumed/_lib/include/plumed/symfunc/CoordinationNumbers.h +41 -0
  193. plumed/_lib/include/plumed/tools/Angle.h +52 -0
  194. plumed/_lib/include/plumed/tools/AtomDistribution.h +138 -0
  195. plumed/_lib/include/plumed/tools/AtomNumber.h +152 -0
  196. plumed/_lib/include/plumed/tools/BiasRepresentation.h +106 -0
  197. plumed/_lib/include/plumed/tools/BitmaskEnum.h +167 -0
  198. plumed/_lib/include/plumed/tools/Brent1DRootSearch.h +159 -0
  199. plumed/_lib/include/plumed/tools/CheckInRange.h +44 -0
  200. plumed/_lib/include/plumed/tools/Citations.h +74 -0
  201. plumed/_lib/include/plumed/tools/ColvarOutput.h +118 -0
  202. plumed/_lib/include/plumed/tools/Communicator.h +316 -0
  203. plumed/_lib/include/plumed/tools/ConjugateGradient.h +80 -0
  204. plumed/_lib/include/plumed/tools/DLLoader.h +79 -0
  205. plumed/_lib/include/plumed/tools/ERMSD.h +73 -0
  206. plumed/_lib/include/plumed/tools/Exception.h +406 -0
  207. plumed/_lib/include/plumed/tools/File.h +28 -0
  208. plumed/_lib/include/plumed/tools/FileBase.h +153 -0
  209. plumed/_lib/include/plumed/tools/FileTools.h +37 -0
  210. plumed/_lib/include/plumed/tools/ForwardDecl.h +54 -0
  211. plumed/_lib/include/plumed/tools/Grid.h +638 -0
  212. plumed/_lib/include/plumed/tools/HistogramBead.h +136 -0
  213. plumed/_lib/include/plumed/tools/IFile.h +117 -0
  214. plumed/_lib/include/plumed/tools/KernelFunctions.h +113 -0
  215. plumed/_lib/include/plumed/tools/Keywords.h +380 -0
  216. plumed/_lib/include/plumed/tools/LatticeReduction.h +66 -0
  217. plumed/_lib/include/plumed/tools/LeptonCall.h +64 -0
  218. plumed/_lib/include/plumed/tools/LinkCells.h +126 -0
  219. plumed/_lib/include/plumed/tools/Log.h +41 -0
  220. plumed/_lib/include/plumed/tools/LoopUnroller.h +163 -0
  221. plumed/_lib/include/plumed/tools/Matrix.h +721 -0
  222. plumed/_lib/include/plumed/tools/MatrixSquareBracketsAccess.h +138 -0
  223. plumed/_lib/include/plumed/tools/MergeVectorTools.h +153 -0
  224. plumed/_lib/include/plumed/tools/Minimise1DBrent.h +244 -0
  225. plumed/_lib/include/plumed/tools/MinimiseBase.h +120 -0
  226. plumed/_lib/include/plumed/tools/MolDataClass.h +51 -0
  227. plumed/_lib/include/plumed/tools/NeighborList.h +112 -0
  228. plumed/_lib/include/plumed/tools/OFile.h +286 -0
  229. plumed/_lib/include/plumed/tools/OpenACC.h +180 -0
  230. plumed/_lib/include/plumed/tools/OpenMP.h +75 -0
  231. plumed/_lib/include/plumed/tools/PDB.h +154 -0
  232. plumed/_lib/include/plumed/tools/Pbc.h +139 -0
  233. plumed/_lib/include/plumed/tools/PlumedHandle.h +105 -0
  234. plumed/_lib/include/plumed/tools/RMSD.h +493 -0
  235. plumed/_lib/include/plumed/tools/Random.h +80 -0
  236. plumed/_lib/include/plumed/tools/RootFindingBase.h +79 -0
  237. plumed/_lib/include/plumed/tools/Stopwatch.h +475 -0
  238. plumed/_lib/include/plumed/tools/Subprocess.h +142 -0
  239. plumed/_lib/include/plumed/tools/SwitchingFunction.h +208 -0
  240. plumed/_lib/include/plumed/tools/Tensor.h +724 -0
  241. plumed/_lib/include/plumed/tools/TokenizedLine.h +123 -0
  242. plumed/_lib/include/plumed/tools/Tools.h +638 -0
  243. plumed/_lib/include/plumed/tools/Torsion.h +55 -0
  244. plumed/_lib/include/plumed/tools/TrajectoryParser.h +118 -0
  245. plumed/_lib/include/plumed/tools/Tree.h +61 -0
  246. plumed/_lib/include/plumed/tools/TypesafePtr.h +463 -0
  247. plumed/_lib/include/plumed/tools/Units.h +167 -0
  248. plumed/_lib/include/plumed/tools/Vector.h +433 -0
  249. plumed/_lib/include/plumed/tools/View.h +296 -0
  250. plumed/_lib/include/plumed/tools/View2D.h +100 -0
  251. plumed/_lib/include/plumed/tools/h36.h +39 -0
  252. plumed/_lib/include/plumed/vatom/ActionWithVirtualAtom.h +32 -0
  253. plumed/_lib/include/plumed/ves/BasisFunctions.h +380 -0
  254. plumed/_lib/include/plumed/ves/CoeffsBase.h +310 -0
  255. plumed/_lib/include/plumed/ves/CoeffsMatrix.h +220 -0
  256. plumed/_lib/include/plumed/ves/CoeffsVector.h +251 -0
  257. plumed/_lib/include/plumed/ves/FermiSwitchingFunction.h +74 -0
  258. plumed/_lib/include/plumed/ves/GridIntegrationWeights.h +50 -0
  259. plumed/_lib/include/plumed/ves/GridLinearInterpolation.h +81 -0
  260. plumed/_lib/include/plumed/ves/GridProjWeights.h +61 -0
  261. plumed/_lib/include/plumed/ves/LinearBasisSetExpansion.h +303 -0
  262. plumed/_lib/include/plumed/ves/Optimizer.h +444 -0
  263. plumed/_lib/include/plumed/ves/TargetDistModifer.h +53 -0
  264. plumed/_lib/include/plumed/ves/TargetDistribution.h +266 -0
  265. plumed/_lib/include/plumed/ves/VesBias.h +545 -0
  266. plumed/_lib/include/plumed/ves/VesTools.h +142 -0
  267. plumed/_lib/include/plumed/ves/WaveletGrid.h +75 -0
  268. plumed/_lib/include/plumed/volumes/ActionVolume.h +268 -0
  269. plumed/_lib/include/plumed/volumes/VolumeShortcut.h +147 -0
  270. plumed/_lib/include/plumed/wrapper/Plumed.h +5025 -0
  271. plumed/_lib/include/plumed/xdrfile/xdrfile.h +663 -0
  272. plumed/_lib/include/plumed/xdrfile/xdrfile_trr.h +89 -0
  273. plumed/_lib/include/plumed/xdrfile/xdrfile_xtc.h +90 -0
  274. plumed/_lib/lib/PythonCVInterface.so +0 -0
  275. plumed/_lib/lib/libplumed.a +0 -0
  276. plumed/_lib/lib/libplumed.so +0 -0
  277. plumed/_lib/lib/libplumedKernel.so +0 -0
  278. plumed/_lib/lib/libplumedWrapper.a +0 -0
  279. plumed/_lib/lib/pkgconfig/plumed.pc +13 -0
  280. plumed/_lib/lib/pkgconfig/plumedInternals.pc +13 -0
  281. plumed/_lib/lib/pkgconfig/plumedWrapper.pc +13 -0
  282. plumed/_lib/lib/plumed/fortran/plumed.f90 +879 -0
  283. plumed/_lib/lib/plumed/fortran/plumed_f08.f90 +2625 -0
  284. plumed/_lib/lib/plumed/modulefile +69 -0
  285. plumed/_lib/lib/plumed/patches/gromacs-2022.5.config +43 -0
  286. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt +543 -0
  287. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt.preplumed +540 -0
  288. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.cpp +1628 -0
  289. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1590 -0
  290. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.h +103 -0
  291. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.h.preplumed +99 -0
  292. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/sim_util.cpp +2527 -0
  293. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2513 -0
  294. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
  295. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
  296. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.h +408 -0
  297. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +394 -0
  298. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/md.cpp +2348 -0
  299. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/md.cpp.preplumed +2091 -0
  300. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/minimize.cpp +3573 -0
  301. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3495 -0
  302. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.cpp +1506 -0
  303. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1402 -0
  304. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
  305. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
  306. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/rerun.cpp +997 -0
  307. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/rerun.cpp.preplumed +906 -0
  308. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/runner.cpp +2780 -0
  309. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/runner.cpp.preplumed +2738 -0
  310. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
  311. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
  312. plumed/_lib/lib/plumed/patches/gromacs-2023.5.config +43 -0
  313. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/CMakeLists.txt +549 -0
  314. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/CMakeLists.txt.preplumed +546 -0
  315. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.cpp +1632 -0
  316. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1594 -0
  317. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.h +104 -0
  318. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.h.preplumed +100 -0
  319. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/sim_util.cpp +2624 -0
  320. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2610 -0
  321. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
  322. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
  323. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.h +409 -0
  324. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +395 -0
  325. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/md.cpp +2419 -0
  326. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/md.cpp.preplumed +2164 -0
  327. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/minimize.cpp +3546 -0
  328. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3468 -0
  329. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.cpp +1513 -0
  330. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1409 -0
  331. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
  332. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
  333. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/rerun.cpp +991 -0
  334. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/rerun.cpp.preplumed +900 -0
  335. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/runner.cpp +2895 -0
  336. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/runner.cpp.preplumed +2849 -0
  337. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
  338. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
  339. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/decidegpuusage.cpp +886 -0
  340. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed +880 -0
  341. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h +347 -0
  342. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed +345 -0
  343. plumed/_lib/lib/plumed/patches/gromacs-2024.3.config +43 -0
  344. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/CMakeLists.txt +575 -0
  345. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/CMakeLists.txt.preplumed +572 -0
  346. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.cpp +1632 -0
  347. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1594 -0
  348. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.h +104 -0
  349. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.h.preplumed +100 -0
  350. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/sim_util.cpp +2564 -0
  351. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2550 -0
  352. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
  353. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
  354. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.h +410 -0
  355. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +396 -0
  356. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/md.cpp +2435 -0
  357. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/md.cpp.preplumed +2187 -0
  358. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/minimize.cpp +3592 -0
  359. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3514 -0
  360. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.cpp +1513 -0
  361. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1409 -0
  362. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
  363. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
  364. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/rerun.cpp +958 -0
  365. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/rerun.cpp.preplumed +929 -0
  366. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/runner.cpp +2987 -0
  367. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/runner.cpp.preplumed +2941 -0
  368. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
  369. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
  370. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/decidegpuusage.cpp +904 -0
  371. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed +898 -0
  372. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h +353 -0
  373. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed +351 -0
  374. plumed/_lib/lib/plumed/patches/gromacs-2025.0.config +39 -0
  375. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/cmake/gmxManagePlumed.cmake +82 -0
  376. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/cmake/gmxManagePlumed.cmake.preplumed +82 -0
  377. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedMDModule.cpp +162 -0
  378. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedMDModule.cpp.preplumed +154 -0
  379. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.cpp +107 -0
  380. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.cpp.preplumed +99 -0
  381. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.h +120 -0
  382. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.h.preplumed +111 -0
  383. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.cpp +215 -0
  384. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.cpp.preplumed +197 -0
  385. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.h +87 -0
  386. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.h.preplumed +86 -0
  387. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrun/runner.cpp +2971 -0
  388. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrun/runner.cpp.preplumed +2970 -0
  389. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrunutility/mdmodulesnotifiers.h +430 -0
  390. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrunutility/mdmodulesnotifiers.h.preplumed +429 -0
  391. plumed/_lib/lib/plumed/patches/namd-2.12.config +30 -0
  392. plumed/_lib/lib/plumed/patches/namd-2.12.diff +267 -0
  393. plumed/_lib/lib/plumed/patches/namd-2.13.config +30 -0
  394. plumed/_lib/lib/plumed/patches/namd-2.13.diff +267 -0
  395. plumed/_lib/lib/plumed/patches/namd-2.14.config +30 -0
  396. plumed/_lib/lib/plumed/patches/namd-2.14.diff +268 -0
  397. plumed/_lib/lib/plumed/patches/patch.sh +500 -0
  398. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.config +25 -0
  399. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/forces.f90 +368 -0
  400. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/forces.f90.preplumed +366 -0
  401. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_forces.f90 +71 -0
  402. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_forces.f90.preplumed +24 -0
  403. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_initialization.f90 +62 -0
  404. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  405. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/pwscf.f90 +189 -0
  406. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/pwscf.f90.preplumed +185 -0
  407. plumed/_lib/lib/plumed/patches/qespresso-6.2.config +26 -0
  408. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/forces.f90 +422 -0
  409. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/forces.f90.preplumed +420 -0
  410. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90 +70 -0
  411. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
  412. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_initialization.f90 +62 -0
  413. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  414. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/run_pwscf.f90 +233 -0
  415. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/run_pwscf.f90.preplumed +230 -0
  416. plumed/_lib/lib/plumed/patches/qespresso-7.0.config +28 -0
  417. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/Modules/Makefile +175 -0
  418. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/Modules/Makefile.preplumed +171 -0
  419. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/forces.f90 +486 -0
  420. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/forces.f90.preplumed +484 -0
  421. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90 +74 -0
  422. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
  423. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_initialization.f90 +64 -0
  424. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  425. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/run_pwscf.f90 +532 -0
  426. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/run_pwscf.f90.preplumed +518 -0
  427. plumed/_lib/lib/plumed/patches/qespresso-7.2.config +28 -0
  428. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/Modules/Makefile +249 -0
  429. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/Modules/Makefile.preplumed +244 -0
  430. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/forces.f90 +532 -0
  431. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/forces.f90.preplumed +535 -0
  432. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_ext_forces.f90 +74 -0
  433. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
  434. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_initialization.f90 +64 -0
  435. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  436. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/run_pwscf.f90 +569 -0
  437. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/run_pwscf.f90.preplumed +560 -0
  438. plumed/_lib/lib/plumed/plumed-config +9 -0
  439. plumed/_lib/lib/plumed/plumed-mklib +9 -0
  440. plumed/_lib/lib/plumed/plumed-newcv +9 -0
  441. plumed/_lib/lib/plumed/plumed-partial_tempering +9 -0
  442. plumed/_lib/lib/plumed/plumed-patch +9 -0
  443. plumed/_lib/lib/plumed/plumed-runtime +0 -0
  444. plumed/_lib/lib/plumed/plumed-selector +9 -0
  445. plumed/_lib/lib/plumed/plumed-vim2html +9 -0
  446. plumed/_lib/lib/plumed/scripts/config.sh +126 -0
  447. plumed/_lib/lib/plumed/scripts/mklib.sh +175 -0
  448. plumed/_lib/lib/plumed/scripts/newcv.sh +26 -0
  449. plumed/_lib/lib/plumed/scripts/partial_tempering.sh +319 -0
  450. plumed/_lib/lib/plumed/scripts/patch.sh +4 -0
  451. plumed/_lib/lib/plumed/scripts/selector.sh +234 -0
  452. plumed/_lib/lib/plumed/scripts/vim2html.sh +190 -0
  453. plumed/_lib/lib/plumed/src/colvar/Template.cpp +116 -0
  454. plumed/_lib/lib/plumed/src/config/compile_options.sh +3 -0
  455. plumed/_lib/lib/plumed/src/config/config.txt +179 -0
  456. plumed/_lib/lib/plumed/src/lib/Plumed.cmake +8 -0
  457. plumed/_lib/lib/plumed/src/lib/Plumed.cmake.runtime +5 -0
  458. plumed/_lib/lib/plumed/src/lib/Plumed.cmake.shared +5 -0
  459. plumed/_lib/lib/plumed/src/lib/Plumed.cmake.static +5 -0
  460. plumed/_lib/lib/plumed/src/lib/Plumed.inc +8 -0
  461. plumed/_lib/lib/plumed/src/lib/Plumed.inc.runtime +5 -0
  462. plumed/_lib/lib/plumed/src/lib/Plumed.inc.shared +5 -0
  463. plumed/_lib/lib/plumed/src/lib/Plumed.inc.static +5 -0
  464. plumed/_lib/lib/plumed/vim/scripts.vim +6 -0
  465. plumed/_plumed_core.cpython-311-aarch64-linux-gnu.so +0 -0
  466. plumed/_plumed_core.cpython-312-aarch64-linux-gnu.so +0 -0
  467. plumed/_plumed_core.cpython-313-aarch64-linux-gnu.so +0 -0
  468. plumed/_plumed_core.cpython-314-aarch64-linux-gnu.so +0 -0
  469. plumed/_plumed_core.cpython-314t-aarch64-linux-gnu.so +0 -0
  470. plumedCommunications.cpython-311-aarch64-linux-gnu.so +0 -0
  471. plumedCommunications.cpython-312-aarch64-linux-gnu.so +0 -0
  472. plumedCommunications.cpython-313-aarch64-linux-gnu.so +0 -0
  473. plumedCommunications.cpython-314-aarch64-linux-gnu.so +0 -0
  474. plumedCommunications.cpython-314t-aarch64-linux-gnu.so +0 -0
  475. plumedCommunications.pyi +431 -0
@@ -0,0 +1,1506 @@
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
+
35
+ /*! \internal \file
36
+ *
37
+ * \brief Implements the replica exchange routines.
38
+ *
39
+ * \author David van der Spoel <david.vanderspoel@icm.uu.se>
40
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
41
+ * \ingroup module_mdrun
42
+ */
43
+ #include "gmxpre.h"
44
+
45
+ #include "gromacs/utility/enumerationhelpers.h"
46
+ #include "replicaexchange.h"
47
+
48
+ #include "config.h"
49
+
50
+ #include <cmath>
51
+
52
+ #include <random>
53
+
54
+ #include "gromacs/domdec/collect.h"
55
+ #include "gromacs/gmxlib/network.h"
56
+ #include "gromacs/math/units.h"
57
+ #include "gromacs/math/vec.h"
58
+ #include "gromacs/mdrunutility/multisim.h"
59
+ #include "gromacs/mdtypes/commrec.h"
60
+ #include "gromacs/mdtypes/enerdata.h"
61
+ #include "gromacs/mdtypes/inputrec.h"
62
+ #include "gromacs/mdtypes/md_enums.h"
63
+ #include "gromacs/mdtypes/state.h"
64
+ #include "gromacs/random/threefry.h"
65
+ #include "gromacs/random/uniformintdistribution.h"
66
+ #include "gromacs/random/uniformrealdistribution.h"
67
+ #include "gromacs/utility/enumerationhelpers.h"
68
+ #include "gromacs/utility/fatalerror.h"
69
+ #include "gromacs/utility/pleasecite.h"
70
+ #include "gromacs/utility/smalloc.h"
71
+
72
+
73
+ /* PLUMED */
74
+ #include "../../../Plumed.h"
75
+ extern int plumedswitch;
76
+ extern plumed plumedmain;
77
+ /* END PLUMED */
78
+
79
+ /* PLUMED HREX */
80
+ extern int plumed_hrex;
81
+ /* END PLUMED HREX */
82
+
83
+ //! Helps cut off probability values.
84
+ constexpr int c_probabilityCutoff = 100;
85
+
86
+ /* we don't bother evaluating if events are more rare than exp(-100) = 3.7x10^-44 */
87
+
88
+ //! Rank in the multisimulation
89
+ #define MSRANK(ms, nodeid) (nodeid)
90
+
91
+ //! Enum for replica exchange flavours
92
+ enum class ReplicaExchangeType : int
93
+ {
94
+ Temperature,
95
+ Lambda,
96
+ EndSingle,
97
+ TemperatureLambda,
98
+ Count
99
+ };
100
+ /*! \brief Strings describing replica exchange flavours.
101
+ *
102
+ * end_single_marker merely notes the end of single variable replica
103
+ * exchange. All types higher than it are multiple replica exchange
104
+ * methods.
105
+ *
106
+ * Eventually, should add 'pressure', 'temperature and pressure',
107
+ * 'lambda_and_pressure', 'temperature_lambda_pressure'?; Let's wait
108
+ * until we feel better about the pressure control methods giving
109
+ * exact ensembles. Right now, we assume constant pressure */
110
+ static const char* enumValueToString(ReplicaExchangeType enumValue)
111
+ {
112
+ constexpr gmx::EnumerationArray<ReplicaExchangeType, const char*> replicateExchangeTypeNames = {
113
+ "temperature", "lambda", "end_single_marker", "temperature and lambda"
114
+ };
115
+ return replicateExchangeTypeNames[enumValue];
116
+ }
117
+
118
+ //! Working data for replica exchange.
119
+ struct gmx_repl_ex
120
+ {
121
+ //! Replica ID
122
+ int repl;
123
+ //! Total number of replica
124
+ int nrepl;
125
+ //! Temperature
126
+ real temp;
127
+ //! Replica exchange type from ReplicaExchangeType enum
128
+ ReplicaExchangeType type;
129
+ //! Quantity, e.g. temperature or lambda; first index is ere, second index is replica ID
130
+ gmx::EnumerationArray<ReplicaExchangeType, real*> q;
131
+ //! Use constant pressure and temperature
132
+ gmx_bool bNPT;
133
+ //! Replica pressures
134
+ real* pres;
135
+ //! Replica indices
136
+ int* ind;
137
+ //! Used for keeping track of all the replica swaps
138
+ int* allswaps;
139
+ //! Replica exchange interval (number of steps)
140
+ int nst;
141
+ //! Number of exchanges per interval
142
+ int nex;
143
+ //! Random seed
144
+ int seed;
145
+ //! Number of even and odd replica change attempts
146
+ int nattempt[2];
147
+ //! Sum of probabilities
148
+ real* prob_sum;
149
+ //! Number of moves between replicas i and j
150
+ int** nmoves;
151
+ //! i-th element of the array is the number of exchanges between replica i-1 and i
152
+ int* nexchange;
153
+
154
+ /*! \brief Helper arrays for replica exchange; allocated here
155
+ * so they don't have to be allocated each time */
156
+ //! \{
157
+ int* destinations;
158
+ int** cyclic;
159
+ int** order;
160
+ int* tmpswap;
161
+ gmx_bool* incycle;
162
+ gmx_bool* bEx;
163
+ //! \}
164
+
165
+ //! Helper arrays to hold the quantities that are exchanged.
166
+ //! \{
167
+ real* prob;
168
+ real* Epot;
169
+ real* beta;
170
+ real* Vol;
171
+ real** de;
172
+ //! \}
173
+ };
174
+
175
+ // TODO We should add Doxygen here some time.
176
+ //! \cond
177
+
178
+ static gmx_bool repl_quantity(const gmx_multisim_t* ms, struct gmx_repl_ex* re, ReplicaExchangeType ere, real q)
179
+ {
180
+ real* qall;
181
+ gmx_bool bDiff;
182
+ int s;
183
+
184
+ snew(qall, ms->numSimulations_);
185
+ qall[re->repl] = q;
186
+ gmx_sum_sim(ms->numSimulations_, qall, ms);
187
+
188
+ /* PLUMED */
189
+ //bDiff = FALSE;
190
+ //for (s = 1; s < ms->numSimulations_; s++)
191
+ //{
192
+ // if (fabs(qall[s] - qall[0]) > 1e-5) /* Each quantity normally has 2-4 significant digits */
193
+ // {
194
+ bDiff = TRUE;
195
+ // }
196
+ //}
197
+ /* PLUMED */
198
+
199
+ if (bDiff)
200
+ {
201
+ /* Set the replica exchange type and quantities */
202
+ re->type = ere;
203
+
204
+ snew(re->q[ere], re->nrepl);
205
+ for (s = 0; s < ms->numSimulations_; s++)
206
+ {
207
+ re->q[ere][s] = qall[s];
208
+ }
209
+ }
210
+ sfree(qall);
211
+ return bDiff;
212
+ }
213
+
214
+ gmx_repl_ex_t init_replica_exchange(FILE* fplog,
215
+ const gmx_multisim_t* ms,
216
+ int numAtomsInSystem,
217
+ const t_inputrec* ir,
218
+ const ReplicaExchangeParameters& replExParams)
219
+ {
220
+ real pres;
221
+ int i, j;
222
+ struct gmx_repl_ex* re;
223
+ gmx_bool bTemp;
224
+ gmx_bool bLambda = FALSE;
225
+
226
+ fprintf(fplog, "\nInitializing Replica Exchange\n");
227
+
228
+ if (!isMultiSim(ms) || ms->numSimulations_ == 1)
229
+ {
230
+ gmx_fatal(FARGS,
231
+ "Nothing to exchange with only one replica, maybe you forgot to set the "
232
+ "-multidir option of mdrun?");
233
+ }
234
+ if (replExParams.numExchanges < 0)
235
+ {
236
+ gmx_fatal(FARGS, "Replica exchange number of exchanges needs to be positive");
237
+ }
238
+
239
+ if (!EI_DYNAMICS(ir->eI))
240
+ {
241
+ gmx_fatal(FARGS, "Replica exchange is only supported by dynamical simulations");
242
+ /* Note that PAR(cr) is defined by cr->nnodes > 1, which is
243
+ * distinct from isMultiSim(ms). A multi-simulation only runs
244
+ * with real MPI parallelism, but this does not imply PAR(cr)
245
+ * is true!
246
+ *
247
+ * Since we are using a dynamical integrator, the only
248
+ * decomposition is DD, so PAR(cr) and haveDDAtomOrdering(*cr) are
249
+ * synonymous. The only way for cr->nnodes > 1 to be true is
250
+ * if we are using DD. */
251
+ }
252
+
253
+ snew(re, 1);
254
+
255
+ re->repl = ms->simulationIndex_;
256
+ re->nrepl = ms->numSimulations_;
257
+
258
+ fprintf(fplog, "Repl There are %d replicas:\n", re->nrepl);
259
+
260
+ /* We only check that the number of atoms in the systms match.
261
+ * This, of course, do not guarantee that the systems are the same,
262
+ * but it does guarantee that we can perform replica exchange.
263
+ */
264
+ check_multi_int(fplog, ms, numAtomsInSystem, "the number of atoms", FALSE);
265
+ check_multi_int(fplog, ms, static_cast<int>(ir->eI), "the integrator", FALSE);
266
+ check_multi_int64(fplog, ms, ir->init_step + ir->nsteps, "init_step+nsteps", FALSE);
267
+ const int nst = replExParams.exchangeInterval;
268
+ check_multi_int64(
269
+ fplog, ms, (ir->init_step + nst - 1) / nst, "first exchange step: init_step/-replex", FALSE);
270
+ check_multi_int(fplog, ms, static_cast<int>(ir->etc), "the temperature coupling", FALSE);
271
+ check_multi_int(fplog, ms, ir->opts.ngtc, "the number of temperature coupling groups", FALSE);
272
+ check_multi_int(fplog, ms, static_cast<int>(ir->epc), "the pressure coupling", FALSE);
273
+ check_multi_int(fplog, ms, static_cast<int>(ir->efep), "free energy", FALSE);
274
+ check_multi_int(fplog, ms, ir->fepvals->n_lambda, "number of lambda states", FALSE);
275
+
276
+ re->temp = ir->opts.ref_t[0];
277
+ for (i = 1; (i < ir->opts.ngtc); i++)
278
+ {
279
+ if (ir->opts.ref_t[i] != re->temp)
280
+ {
281
+ fprintf(fplog,
282
+ "\nWARNING: The temperatures of the different temperature coupling groups are "
283
+ "not identical\n\n");
284
+ fprintf(stderr,
285
+ "\nWARNING: The temperatures of the different temperature coupling groups are "
286
+ "not identical\n\n");
287
+ }
288
+ }
289
+
290
+ re->type = ReplicaExchangeType::Count;
291
+ bTemp = repl_quantity(ms, re, ReplicaExchangeType::Temperature, re->temp);
292
+ if (ir->efep != FreeEnergyPerturbationType::No)
293
+ {
294
+ bLambda = repl_quantity(
295
+ ms, re, ReplicaExchangeType::Lambda, static_cast<real>(ir->fepvals->init_fep_state));
296
+ }
297
+ if (re->type == ReplicaExchangeType::Count) /* nothing was assigned */
298
+ {
299
+ gmx_fatal(FARGS,
300
+ "The properties of the %d systems are all the same, there is nothing to exchange",
301
+ re->nrepl);
302
+ }
303
+ if (bLambda && bTemp)
304
+ {
305
+ re->type = ReplicaExchangeType::TemperatureLambda;
306
+ }
307
+
308
+ if (bTemp)
309
+ {
310
+ please_cite(fplog, "Sugita1999a");
311
+ if (ir->epc != PressureCoupling::No)
312
+ {
313
+ re->bNPT = TRUE;
314
+ fprintf(fplog, "Repl Using Constant Pressure REMD.\n");
315
+ please_cite(fplog, "Okabe2001a");
316
+ }
317
+ if (ir->etc == TemperatureCoupling::Berendsen)
318
+ {
319
+ gmx_fatal(FARGS,
320
+ "REMD with the %s thermostat does not produce correct potential energy "
321
+ "distributions, consider using the %s thermostat instead",
322
+ enumValueToString(ir->etc),
323
+ enumValueToString(TemperatureCoupling::VRescale));
324
+ }
325
+ }
326
+ if (bLambda)
327
+ {
328
+ if (ir->fepvals->delta_lambda != 0) /* check this? */
329
+ {
330
+ gmx_fatal(FARGS, "delta_lambda is not zero");
331
+ }
332
+ }
333
+ if (re->bNPT)
334
+ {
335
+ snew(re->pres, re->nrepl);
336
+ if (ir->epct == PressureCouplingType::SurfaceTension)
337
+ {
338
+ pres = ir->ref_p[ZZ][ZZ];
339
+ }
340
+ else
341
+ {
342
+ pres = 0;
343
+ j = 0;
344
+ for (i = 0; i < DIM; i++)
345
+ {
346
+ if (ir->compress[i][i] != 0)
347
+ {
348
+ pres += ir->ref_p[i][i];
349
+ j++;
350
+ }
351
+ }
352
+ pres /= j;
353
+ }
354
+ re->pres[re->repl] = pres;
355
+ gmx_sum_sim(re->nrepl, re->pres, ms);
356
+ }
357
+
358
+ /* Make an index for increasing replica order */
359
+ /* only makes sense if one or the other is varying, not both!
360
+ if both are varying, we trust the order the person gave. */
361
+ snew(re->ind, re->nrepl);
362
+ for (i = 0; i < re->nrepl; i++)
363
+ {
364
+ re->ind[i] = i;
365
+ }
366
+
367
+ /* PLUMED */
368
+ // plumed2: check if we want alternative patterns (i.e. for bias-exchange metaD)
369
+ // in those cases replicas can share the same temperature.
370
+ /*
371
+ if (re->type < ReplicaExchangeType::EndSingle)
372
+ {
373
+
374
+ for (i = 0; i < re->nrepl; i++)
375
+ {
376
+ for (j = i + 1; j < re->nrepl; j++)
377
+ {
378
+ if (re->q[re->type][re->ind[j]] < re->q[re->type][re->ind[i]])
379
+ {*/
380
+ /* Unordered replicas are supposed to work, but there
381
+ * is still an issues somewhere.
382
+ * Note that at this point still re->ind[i]=i.
383
+ */
384
+ /*
385
+ gmx_fatal(FARGS,
386
+ "Replicas with indices %d < %d have %ss %g > %g, please order your "
387
+ "replicas on increasing %s",
388
+ i,
389
+ j,
390
+ enumValueToString(re->type),
391
+ re->q[re->type][i],
392
+ re->q[re->type][j],
393
+ enumValueToString(re->type));
394
+ }
395
+ else if (re->q[re->type][re->ind[j]] == re->q[re->type][re->ind[i]])
396
+ {
397
+ gmx_fatal(FARGS, "Two replicas have identical %ss", enumValueToString(re->type));
398
+ }
399
+ }
400
+ }
401
+ }
402
+ */
403
+ /* END PLUMED */
404
+
405
+ /* keep track of all the swaps, starting with the initial placement. */
406
+ snew(re->allswaps, re->nrepl);
407
+ for (i = 0; i < re->nrepl; i++)
408
+ {
409
+ re->allswaps[i] = re->ind[i];
410
+ }
411
+
412
+ switch (re->type)
413
+ {
414
+ case ReplicaExchangeType::Temperature:
415
+ fprintf(fplog, "\nReplica exchange in temperature\n");
416
+ for (i = 0; i < re->nrepl; i++)
417
+ {
418
+ fprintf(fplog, " %5.1f", re->q[re->type][re->ind[i]]);
419
+ }
420
+ fprintf(fplog, "\n");
421
+ break;
422
+ case ReplicaExchangeType::Lambda:
423
+ fprintf(fplog, "\nReplica exchange in lambda\n");
424
+ for (i = 0; i < re->nrepl; i++)
425
+ {
426
+ fprintf(fplog, " %3d", static_cast<int>(re->q[re->type][re->ind[i]]));
427
+ }
428
+ fprintf(fplog, "\n");
429
+ break;
430
+ case ReplicaExchangeType::TemperatureLambda:
431
+ fprintf(fplog, "\nReplica exchange in temperature and lambda state\n");
432
+ for (i = 0; i < re->nrepl; i++)
433
+ {
434
+ fprintf(fplog, " %5.1f", re->q[ReplicaExchangeType::Temperature][re->ind[i]]);
435
+ }
436
+ fprintf(fplog, "\n");
437
+ for (i = 0; i < re->nrepl; i++)
438
+ {
439
+ fprintf(fplog, " %5d", static_cast<int>(re->q[ReplicaExchangeType::Lambda][re->ind[i]]));
440
+ }
441
+ fprintf(fplog, "\n");
442
+ break;
443
+ default: gmx_incons("Unknown replica exchange quantity");
444
+ }
445
+ if (re->bNPT)
446
+ {
447
+ fprintf(fplog, "\nRepl p");
448
+ for (i = 0; i < re->nrepl; i++)
449
+ {
450
+ fprintf(fplog, " %5.2f", re->pres[re->ind[i]]);
451
+ }
452
+
453
+ for (i = 0; i < re->nrepl; i++)
454
+ {
455
+ if ((i > 0) && (re->pres[re->ind[i]] < re->pres[re->ind[i - 1]]))
456
+ {
457
+ fprintf(fplog,
458
+ "\nWARNING: The reference pressures decrease with increasing "
459
+ "temperatures\n\n");
460
+ fprintf(stderr,
461
+ "\nWARNING: The reference pressures decrease with increasing "
462
+ "temperatures\n\n");
463
+ }
464
+ }
465
+ }
466
+ re->nst = nst;
467
+ if (replExParams.randomSeed == -1)
468
+ {
469
+ if (isMasterSim(ms))
470
+ {
471
+ re->seed = static_cast<int>(gmx::makeRandomSeed());
472
+ }
473
+ else
474
+ {
475
+ re->seed = 0;
476
+ }
477
+ gmx_sumi_sim(1, &(re->seed), ms);
478
+ }
479
+ else
480
+ {
481
+ re->seed = replExParams.randomSeed;
482
+ }
483
+ fprintf(fplog, "\nReplica exchange interval: %d\n", re->nst);
484
+ fprintf(fplog, "\nReplica random seed: %d\n", re->seed);
485
+
486
+ re->nattempt[0] = 0;
487
+ re->nattempt[1] = 0;
488
+
489
+ snew(re->prob_sum, re->nrepl);
490
+ snew(re->nexchange, re->nrepl);
491
+ snew(re->nmoves, re->nrepl);
492
+ for (i = 0; i < re->nrepl; i++)
493
+ {
494
+ snew(re->nmoves[i], re->nrepl);
495
+ }
496
+ fprintf(fplog, "Replica exchange information below: ex and x = exchange, pr = probability\n");
497
+
498
+ /* generate space for the helper functions so we don't have to snew each time */
499
+
500
+ snew(re->destinations, re->nrepl);
501
+ snew(re->incycle, re->nrepl);
502
+ snew(re->tmpswap, re->nrepl);
503
+ snew(re->cyclic, re->nrepl);
504
+ snew(re->order, re->nrepl);
505
+ for (i = 0; i < re->nrepl; i++)
506
+ {
507
+ snew(re->cyclic[i], re->nrepl + 1);
508
+ snew(re->order[i], re->nrepl);
509
+ }
510
+ /* allocate space for the functions storing the data for the replicas */
511
+ /* not all of these arrays needed in all cases, but they don't take
512
+ up much space, since the max size is nrepl**2 */
513
+ snew(re->prob, re->nrepl);
514
+ snew(re->bEx, re->nrepl);
515
+ snew(re->beta, re->nrepl);
516
+ snew(re->Vol, re->nrepl);
517
+ snew(re->Epot, re->nrepl);
518
+ snew(re->de, re->nrepl);
519
+ for (i = 0; i < re->nrepl; i++)
520
+ {
521
+ snew(re->de[i], re->nrepl);
522
+ }
523
+ re->nex = replExParams.numExchanges;
524
+ return re;
525
+ }
526
+
527
+ static void exchange_reals(const gmx_multisim_t gmx_unused* ms, int gmx_unused b, real* v, int n)
528
+ {
529
+ real* buf;
530
+ int i;
531
+
532
+ if (v)
533
+ {
534
+ snew(buf, n);
535
+ #if GMX_MPI
536
+ /*
537
+ MPI_Sendrecv(v, n*sizeof(real),MPI_BYTE,MSRANK(ms,b),0,
538
+ buf,n*sizeof(real),MPI_BYTE,MSRANK(ms,b),0,
539
+ ms->mastersComm_,MPI_STATUS_IGNORE);
540
+ */
541
+ {
542
+ MPI_Request mpi_req;
543
+
544
+ MPI_Isend(v, n * sizeof(real), MPI_BYTE, MSRANK(ms, b), 0, ms->mastersComm_, &mpi_req);
545
+ MPI_Recv(buf, n * sizeof(real), MPI_BYTE, MSRANK(ms, b), 0, ms->mastersComm_, MPI_STATUS_IGNORE);
546
+ MPI_Wait(&mpi_req, MPI_STATUS_IGNORE);
547
+ }
548
+ #endif
549
+ for (i = 0; i < n; i++)
550
+ {
551
+ v[i] = buf[i];
552
+ }
553
+ sfree(buf);
554
+ }
555
+ }
556
+
557
+
558
+ static void exchange_doubles(const gmx_multisim_t gmx_unused* ms, int gmx_unused b, double* v, int n)
559
+ {
560
+ double* buf;
561
+ int i;
562
+
563
+ if (v)
564
+ {
565
+ snew(buf, n);
566
+ #if GMX_MPI
567
+ /*
568
+ MPI_Sendrecv(v, n*sizeof(double),MPI_BYTE,MSRANK(ms,b),0,
569
+ buf,n*sizeof(double),MPI_BYTE,MSRANK(ms,b),0,
570
+ ms->mastersComm_,MPI_STATUS_IGNORE);
571
+ */
572
+ {
573
+ MPI_Request mpi_req;
574
+
575
+ MPI_Isend(v, n * sizeof(double), MPI_BYTE, MSRANK(ms, b), 0, ms->mastersComm_, &mpi_req);
576
+ MPI_Recv(buf, n * sizeof(double), MPI_BYTE, MSRANK(ms, b), 0, ms->mastersComm_, MPI_STATUS_IGNORE);
577
+ MPI_Wait(&mpi_req, MPI_STATUS_IGNORE);
578
+ }
579
+ #endif
580
+ for (i = 0; i < n; i++)
581
+ {
582
+ v[i] = buf[i];
583
+ }
584
+ sfree(buf);
585
+ }
586
+ }
587
+
588
+ static void exchange_rvecs(const gmx_multisim_t gmx_unused* ms, int gmx_unused b, rvec* v, int n)
589
+ {
590
+ rvec* buf;
591
+ int i;
592
+
593
+ if (v)
594
+ {
595
+ snew(buf, n);
596
+ #if GMX_MPI
597
+ /*
598
+ MPI_Sendrecv(v[0], n*sizeof(rvec),MPI_BYTE,MSRANK(ms,b),0,
599
+ buf[0],n*sizeof(rvec),MPI_BYTE,MSRANK(ms,b),0,
600
+ ms->mastersComm_,MPI_STATUS_IGNORE);
601
+ */
602
+ {
603
+ MPI_Request mpi_req;
604
+
605
+ MPI_Isend(v[0], n * sizeof(rvec), MPI_BYTE, MSRANK(ms, b), 0, ms->mastersComm_, &mpi_req);
606
+ MPI_Recv(buf[0], n * sizeof(rvec), MPI_BYTE, MSRANK(ms, b), 0, ms->mastersComm_, MPI_STATUS_IGNORE);
607
+ MPI_Wait(&mpi_req, MPI_STATUS_IGNORE);
608
+ }
609
+ #endif
610
+ for (i = 0; i < n; i++)
611
+ {
612
+ copy_rvec(buf[i], v[i]);
613
+ }
614
+ sfree(buf);
615
+ }
616
+ }
617
+
618
+ /* PLUMED HREX */
619
+ void exchange_state(const gmx_multisim_t* ms, int b, t_state* state)
620
+ /* END PLUMED HREX */
621
+ {
622
+ /* When t_state changes, this code should be updated. */
623
+ int ngtc, nnhpres;
624
+ ngtc = state->ngtc * state->nhchainlength;
625
+ nnhpres = state->nnhpres * state->nhchainlength;
626
+ exchange_rvecs(ms, b, state->box, DIM);
627
+ exchange_rvecs(ms, b, state->box_rel, DIM);
628
+ exchange_rvecs(ms, b, state->boxv, DIM);
629
+ exchange_reals(ms, b, &(state->veta), 1);
630
+ exchange_reals(ms, b, &(state->vol0), 1);
631
+ exchange_rvecs(ms, b, state->svir_prev, DIM);
632
+ exchange_rvecs(ms, b, state->fvir_prev, DIM);
633
+ exchange_rvecs(ms, b, state->pres_prev, DIM);
634
+ exchange_doubles(ms, b, state->nosehoover_xi.data(), ngtc);
635
+ exchange_doubles(ms, b, state->nosehoover_vxi.data(), ngtc);
636
+ exchange_doubles(ms, b, state->nhpres_xi.data(), nnhpres);
637
+ exchange_doubles(ms, b, state->nhpres_vxi.data(), nnhpres);
638
+ exchange_doubles(ms, b, state->therm_integral.data(), state->ngtc);
639
+ exchange_doubles(ms, b, &state->baros_integral, 1);
640
+ exchange_rvecs(ms, b, state->x.rvec_array(), state->natoms);
641
+ exchange_rvecs(ms, b, state->v.rvec_array(), state->natoms);
642
+ }
643
+
644
+ /* PLUMED HREX */
645
+ void copy_state_serial(const t_state* src, t_state* dest)
646
+ /* END PLUMED HREX */
647
+ {
648
+ if (dest != src)
649
+ {
650
+ /* Currently the local state is always a pointer to the global
651
+ * in serial, so we should never end up here.
652
+ * TODO: Implement a (trivial) t_state copy once converted to C++.
653
+ */
654
+ GMX_RELEASE_ASSERT(false, "State copying is currently not implemented in replica exchange");
655
+ }
656
+ }
657
+
658
+ static void scale_velocities(gmx::ArrayRef<gmx::RVec> velocities, real fac)
659
+ {
660
+ for (auto& v : velocities)
661
+ {
662
+ v *= fac;
663
+ }
664
+ }
665
+
666
+ static void print_transition_matrix(FILE* fplog, int n, int** nmoves, const int* nattempt)
667
+ {
668
+ int i, j, ntot;
669
+ float Tprint;
670
+
671
+ ntot = nattempt[0] + nattempt[1];
672
+ fprintf(fplog, "\n");
673
+ fprintf(fplog, "Repl");
674
+ for (i = 0; i < n; i++)
675
+ {
676
+ fprintf(fplog, " "); /* put the title closer to the center */
677
+ }
678
+ fprintf(fplog, "Empirical Transition Matrix\n");
679
+
680
+ fprintf(fplog, "Repl");
681
+ for (i = 0; i < n; i++)
682
+ {
683
+ fprintf(fplog, "%8d", (i + 1));
684
+ }
685
+ fprintf(fplog, "\n");
686
+
687
+ for (i = 0; i < n; i++)
688
+ {
689
+ fprintf(fplog, "Repl");
690
+ for (j = 0; j < n; j++)
691
+ {
692
+ Tprint = 0.0;
693
+ if (nmoves[i][j] > 0)
694
+ {
695
+ Tprint = nmoves[i][j] / (2.0 * ntot);
696
+ }
697
+ fprintf(fplog, "%8.4f", Tprint);
698
+ }
699
+ fprintf(fplog, "%3d\n", i);
700
+ }
701
+ }
702
+
703
+ static void print_ind(FILE* fplog, const char* leg, int n, int* ind, const gmx_bool* bEx)
704
+ {
705
+ int i;
706
+
707
+ fprintf(fplog, "Repl %2s %2d", leg, ind[0]);
708
+ for (i = 1; i < n; i++)
709
+ {
710
+ fprintf(fplog, " %c %2d", (bEx != nullptr && bEx[i]) ? 'x' : ' ', ind[i]);
711
+ }
712
+ fprintf(fplog, "\n");
713
+ }
714
+
715
+ static void print_allswitchind(FILE* fplog, int n, int* pind, int* allswaps, int* tmpswap)
716
+ {
717
+ int i;
718
+
719
+ for (i = 0; i < n; i++)
720
+ {
721
+ tmpswap[i] = allswaps[i];
722
+ }
723
+ for (i = 0; i < n; i++)
724
+ {
725
+ allswaps[i] = tmpswap[pind[i]];
726
+ }
727
+
728
+ fprintf(fplog, "\nAccepted Exchanges: ");
729
+ for (i = 0; i < n; i++)
730
+ {
731
+ fprintf(fplog, "%d ", pind[i]);
732
+ }
733
+ fprintf(fplog, "\n");
734
+
735
+ /* the "Order After Exchange" is the state label corresponding to the configuration that
736
+ started in state listed in order, i.e.
737
+
738
+ 3 0 1 2
739
+
740
+ means that the:
741
+ configuration starting in simulation 3 is now in simulation 0,
742
+ configuration starting in simulation 0 is now in simulation 1,
743
+ configuration starting in simulation 1 is now in simulation 2,
744
+ configuration starting in simulation 2 is now in simulation 3
745
+ */
746
+ fprintf(fplog, "Order After Exchange: ");
747
+ for (i = 0; i < n; i++)
748
+ {
749
+ fprintf(fplog, "%d ", allswaps[i]);
750
+ }
751
+ fprintf(fplog, "\n\n");
752
+ }
753
+
754
+ static void print_prob(FILE* fplog, const char* leg, int n, real* prob)
755
+ {
756
+ int i;
757
+ char buf[8];
758
+
759
+ fprintf(fplog, "Repl %2s ", leg);
760
+ for (i = 1; i < n; i++)
761
+ {
762
+ if (prob[i] >= 0)
763
+ {
764
+ sprintf(buf, "%4.2f", prob[i]);
765
+ fprintf(fplog, " %3s", buf[0] == '1' ? "1.0" : buf + 1);
766
+ }
767
+ else
768
+ {
769
+ fprintf(fplog, " ");
770
+ }
771
+ }
772
+ fprintf(fplog, "\n");
773
+ }
774
+
775
+ static void print_count(FILE* fplog, const char* leg, int n, int* count)
776
+ {
777
+ int i;
778
+
779
+ fprintf(fplog, "Repl %2s ", leg);
780
+ for (i = 1; i < n; i++)
781
+ {
782
+ fprintf(fplog, " %4d", count[i]);
783
+ }
784
+ fprintf(fplog, "\n");
785
+ }
786
+
787
+ static real calc_delta(FILE* fplog, gmx_bool bPrint, struct gmx_repl_ex* re, int a, int b, int ap, int bp)
788
+ {
789
+
790
+ real ediff, dpV, delta = 0;
791
+ real* Epot = re->Epot;
792
+ real* Vol = re->Vol;
793
+ real** de = re->de;
794
+ real* beta = re->beta;
795
+
796
+ /* Two cases; we are permuted and not. In all cases, setting ap = a and bp = b will reduce
797
+ to the non permuted case */
798
+
799
+ switch (re->type)
800
+ {
801
+ case ReplicaExchangeType::Temperature:
802
+ /*
803
+ * Okabe et. al. Chem. Phys. Lett. 335 (2001) 435-439
804
+ */
805
+ ediff = Epot[b] - Epot[a];
806
+ delta = -(beta[bp] - beta[ap]) * ediff;
807
+ break;
808
+ case ReplicaExchangeType::Lambda:
809
+ /* two cases: when we are permuted, and not. */
810
+ /* non-permuted:
811
+ ediff = E_new - E_old
812
+ = [H_b(x_a) + H_a(x_b)] - [H_b(x_b) + H_a(x_a)]
813
+ = [H_b(x_a) - H_a(x_a)] + [H_a(x_b) - H_b(x_b)]
814
+ = de[b][a] + de[a][b] */
815
+
816
+ /* permuted:
817
+ ediff = E_new - E_old
818
+ = [H_bp(x_a) + H_ap(x_b)] - [H_bp(x_b) + H_ap(x_a)]
819
+ = [H_bp(x_a) - H_ap(x_a)] + [H_ap(x_b) - H_bp(x_b)]
820
+ = [H_bp(x_a) - H_a(x_a) + H_a(x_a) - H_ap(x_a)] + [H_ap(x_b) - H_b(x_b) + H_b(x_b) - H_bp(x_b)]
821
+ = [H_bp(x_a) - H_a(x_a)] - [H_ap(x_a) - H_a(x_a)] + [H_ap(x_b) - H_b(x_b)] - H_bp(x_b) - H_b(x_b)]
822
+ = (de[bp][a] - de[ap][a]) + (de[ap][b] - de[bp][b]) */
823
+ /* but, in the current code implementation, we flip configurations, not indices . . .
824
+ So let's examine that.
825
+ = [H_b(x_ap) - H_a(x_a)] - [H_a(x_ap) - H_a(x_a)] + [H_a(x_bp) - H_b(x_b)] - H_b(x_bp) - H_b(x_b)]
826
+ = [H_b(x_ap) - H_a(x_ap)] + [H_a(x_bp) - H_b(x_pb)]
827
+ = (de[b][ap] - de[a][ap]) + (de[a][bp] - de[b][bp]
828
+ So, if we exchange b<=> bp and a<=> ap, we return to the same result.
829
+ So the simple solution is to flip the
830
+ position of perturbed and original indices in the tests.
831
+ */
832
+
833
+ ediff = (de[bp][a] - de[ap][a]) + (de[ap][b] - de[bp][b]);
834
+ delta = ediff * beta[a]; /* assume all same temperature in this case */
835
+ break;
836
+ case ReplicaExchangeType::TemperatureLambda:
837
+ /* not permuted: */
838
+ /* delta = reduced E_new - reduced E_old
839
+ = [beta_b H_b(x_a) + beta_a H_a(x_b)] - [beta_b H_b(x_b) + beta_a H_a(x_a)]
840
+ = [beta_b H_b(x_a) - beta_a H_a(x_a)] + [beta_a H_a(x_b) - beta_b H_b(x_b)]
841
+ = [beta_b dH_b(x_a) + beta_b H_a(x_a) - beta_a H_a(x_a)] +
842
+ [beta_a dH_a(x_b) + beta_a H_b(x_b) - beta_b H_b(x_b)]
843
+ = [beta_b dH_b(x_a) + [beta_a dH_a(x_b) +
844
+ beta_b (H_a(x_a) - H_b(x_b)]) - beta_a (H_a(x_a) - H_b(x_b))
845
+ = beta_b dH_b(x_a) + beta_a dH_a(x_b) - (beta_b - beta_a)(H_b(x_b) - H_a(x_a) */
846
+ /* delta = beta[b]*de[b][a] + beta[a]*de[a][b] - (beta[b] - beta[a])*(Epot[b] - Epot[a]; */
847
+ /* permuted (big breath!) */
848
+ /* delta = reduced E_new - reduced E_old
849
+ = [beta_bp H_bp(x_a) + beta_ap H_ap(x_b)] - [beta_bp H_bp(x_b) + beta_ap H_ap(x_a)]
850
+ = [beta_bp H_bp(x_a) - beta_ap H_ap(x_a)] + [beta_ap H_ap(x_b) - beta_bp H_bp(x_b)]
851
+ = [beta_bp H_bp(x_a) - beta_ap H_ap(x_a)] + [beta_ap H_ap(x_b) - beta_bp H_bp(x_b)]
852
+ - beta_pb H_a(x_a) + beta_ap H_a(x_a) + beta_pb H_a(x_a) - beta_ap H_a(x_a)
853
+ - beta_ap H_b(x_b) + beta_bp H_b(x_b) + beta_ap H_b(x_b) - beta_bp H_b(x_b)
854
+ = [(beta_bp H_bp(x_a) - beta_bp H_a(x_a)) - (beta_ap H_ap(x_a) - beta_ap H_a(x_a))] +
855
+ [(beta_ap H_ap(x_b) - beta_ap H_b(x_b)) - (beta_bp H_bp(x_b) - beta_bp H_b(x_b))]
856
+ + beta_pb H_a(x_a) - beta_ap H_a(x_a) + beta_ap H_b(x_b) - beta_bp H_b(x_b)
857
+ = [beta_bp (H_bp(x_a) - H_a(x_a)) - beta_ap (H_ap(x_a) - H_a(x_a))] +
858
+ [beta_ap (H_ap(x_b) - H_b(x_b)) - beta_bp (H_bp(x_b) - H_b(x_b))]
859
+ + beta_pb (H_a(x_a) - H_b(x_b)) - beta_ap (H_a(x_a) - H_b(x_b))
860
+ = ([beta_bp de[bp][a] - beta_ap de[ap][a]) + beta_ap de[ap][b] - beta_bp de[bp][b])
861
+ + (beta_pb-beta_ap)(H_a(x_a) - H_b(x_b)) */
862
+ delta = beta[bp] * (de[bp][a] - de[bp][b]) + beta[ap] * (de[ap][b] - de[ap][a])
863
+ - (beta[bp] - beta[ap]) * (Epot[b] - Epot[a]);
864
+ break;
865
+ default: gmx_incons("Unknown replica exchange quantity");
866
+ }
867
+ if (bPrint)
868
+ {
869
+ fprintf(fplog, "Repl %d <-> %d dE_term = %10.3e (kT)\n", a, b, delta);
870
+ }
871
+ /* PLUMED HREX */
872
+ /* this is necessary because with plumed HREX the energy contribution is
873
+ already taken into account */
874
+ if(plumed_hrex) delta=0.0;
875
+ /* END PLUMED HREX */
876
+ if (re->bNPT)
877
+ {
878
+ /* revist the calculation for 5.0. Might be some improvements. */
879
+ dpV = (beta[ap] * re->pres[ap] - beta[bp] * re->pres[bp]) * (Vol[b] - Vol[a]) / gmx::c_presfac;
880
+ if (bPrint)
881
+ {
882
+ fprintf(fplog, " dpV = %10.3e d = %10.3e\n", dpV, delta + dpV);
883
+ }
884
+ delta += dpV;
885
+ }
886
+ return delta;
887
+ }
888
+
889
+ static void test_for_replica_exchange(FILE* fplog,
890
+ const gmx_multisim_t* ms,
891
+ struct gmx_repl_ex* re,
892
+ const gmx_enerdata_t* enerd,
893
+ real vol,
894
+ int64_t step,
895
+ real time)
896
+ {
897
+ int m, i, j, a, b, ap, bp, i0, i1, tmp;
898
+ real delta = 0;
899
+ gmx_bool bPrint, bMultiEx;
900
+ gmx_bool* bEx = re->bEx;
901
+ real* prob = re->prob;
902
+ int* pind = re->destinations; /* permuted index */
903
+ gmx_bool bEpot = FALSE;
904
+ gmx_bool bDLambda = FALSE;
905
+ gmx_bool bVol = FALSE;
906
+ gmx::ThreeFry2x64<64> rng(re->seed, gmx::RandomDomain::ReplicaExchange);
907
+ gmx::UniformRealDistribution<real> uniformRealDist;
908
+ gmx::UniformIntDistribution<int> uniformNreplDist(0, re->nrepl - 1);
909
+
910
+ bMultiEx = (re->nex > 1); /* multiple exchanges at each state */
911
+ fprintf(fplog, "Replica exchange at step %" PRId64 " time %.5f\n", step, time);
912
+
913
+ if (re->bNPT)
914
+ {
915
+ for (i = 0; i < re->nrepl; i++)
916
+ {
917
+ re->Vol[i] = 0;
918
+ }
919
+ bVol = TRUE;
920
+ re->Vol[re->repl] = vol;
921
+ }
922
+ if ((re->type == ReplicaExchangeType::Temperature || re->type == ReplicaExchangeType::TemperatureLambda))
923
+ {
924
+ for (i = 0; i < re->nrepl; i++)
925
+ {
926
+ re->Epot[i] = 0;
927
+ }
928
+ bEpot = TRUE;
929
+ re->Epot[re->repl] = enerd->term[F_EPOT];
930
+ /* temperatures of different states*/
931
+ for (i = 0; i < re->nrepl; i++)
932
+ {
933
+ re->beta[i] = 1.0 / (re->q[ReplicaExchangeType::Temperature][i] * gmx::c_boltz);
934
+ }
935
+ }
936
+ else
937
+ {
938
+ for (i = 0; i < re->nrepl; i++)
939
+ {
940
+ re->beta[i] = 1.0 / (re->temp * gmx::c_boltz); /* we have a single temperature */
941
+ }
942
+ }
943
+ if (re->type == ReplicaExchangeType::Lambda || re->type == ReplicaExchangeType::TemperatureLambda)
944
+ {
945
+ bDLambda = TRUE;
946
+ /* lambda differences. */
947
+ /* de[i][j] is the energy of the jth simulation in the ith Hamiltonian
948
+ minus the energy of the jth simulation in the jth Hamiltonian */
949
+ for (i = 0; i < re->nrepl; i++)
950
+ {
951
+ for (j = 0; j < re->nrepl; j++)
952
+ {
953
+ re->de[i][j] = 0;
954
+ }
955
+ }
956
+ for (i = 0; i < re->nrepl; i++)
957
+ {
958
+ re->de[i][re->repl] =
959
+ enerd->foreignLambdaTerms.deltaH(re->q[ReplicaExchangeType::Lambda][i]);
960
+ }
961
+ }
962
+
963
+ /* now actually do the communication */
964
+ if (bVol)
965
+ {
966
+ gmx_sum_sim(re->nrepl, re->Vol, ms);
967
+ }
968
+ if (bEpot)
969
+ {
970
+ gmx_sum_sim(re->nrepl, re->Epot, ms);
971
+ }
972
+ if (bDLambda)
973
+ {
974
+ for (i = 0; i < re->nrepl; i++)
975
+ {
976
+ gmx_sum_sim(re->nrepl, re->de[i], ms);
977
+ }
978
+ }
979
+
980
+ /* make a duplicate set of indices for shuffling */
981
+ for (i = 0; i < re->nrepl; i++)
982
+ {
983
+ pind[i] = re->ind[i];
984
+ }
985
+
986
+ rng.restart(step, 0);
987
+
988
+ /* PLUMED */
989
+ int plumed_test_exchange_pattern=0;
990
+ if(plumed_test_exchange_pattern && plumed_hrex) gmx_fatal(FARGS,"hrex not compatible with ad hoc exchange patterns");
991
+ /* END PLUMED */
992
+
993
+ if (bMultiEx)
994
+ {
995
+ /* multiple random switch exchange */
996
+ int nself = 0;
997
+
998
+
999
+ for (i = 0; i < re->nex + nself; i++)
1000
+ {
1001
+ // For now this is superfluous, but just in case we ever add more
1002
+ // calls in different branches it is safer to always reset the distribution.
1003
+ uniformNreplDist.reset();
1004
+
1005
+ /* randomly select a pair */
1006
+ /* in theory, could reduce this by identifying only which switches had a nonneglibible
1007
+ probability of occurring (log p > -100) and only operate on those switches */
1008
+ /* find out which state it is from, and what label that state currently has. Likely
1009
+ more work that useful. */
1010
+ i0 = uniformNreplDist(rng);
1011
+ i1 = uniformNreplDist(rng);
1012
+ if (i0 == i1)
1013
+ {
1014
+ nself++;
1015
+ continue; /* self-exchange, back up and do it again */
1016
+ }
1017
+
1018
+ a = re->ind[i0]; /* what are the indices of these states? */
1019
+ b = re->ind[i1];
1020
+ ap = pind[i0];
1021
+ bp = pind[i1];
1022
+
1023
+ bPrint = FALSE; /* too noisy */
1024
+ /* calculate the energy difference */
1025
+ /* if the code changes to flip the STATES, rather than the configurations,
1026
+ use the commented version of the code */
1027
+ /* delta = calc_delta(fplog,bPrint,re,a,b,ap,bp); */
1028
+ delta = calc_delta(fplog, bPrint, re, ap, bp, a, b);
1029
+
1030
+ /* we actually only use the first space in the prob and bEx array,
1031
+ since there are actually many switches between pairs. */
1032
+
1033
+ if (delta <= 0)
1034
+ {
1035
+ /* accepted */
1036
+ prob[0] = 1;
1037
+ bEx[0] = TRUE;
1038
+ }
1039
+ else
1040
+ {
1041
+ if (delta > c_probabilityCutoff)
1042
+ {
1043
+ prob[0] = 0;
1044
+ }
1045
+ else
1046
+ {
1047
+ prob[0] = exp(-delta);
1048
+ }
1049
+ // roll a number to determine if accepted. For now it is superfluous to
1050
+ // reset, but just in case we ever add more calls in different branches
1051
+ // it is safer to always reset the distribution.
1052
+ uniformRealDist.reset();
1053
+ bEx[0] = uniformRealDist(rng) < prob[0];
1054
+ }
1055
+ re->prob_sum[0] += prob[0];
1056
+
1057
+ if (bEx[0])
1058
+ {
1059
+ /* swap the states */
1060
+ tmp = pind[i0];
1061
+ pind[i0] = pind[i1];
1062
+ pind[i1] = tmp;
1063
+ }
1064
+ }
1065
+ re->nattempt[0]++; /* keep track of total permutation trials here */
1066
+ print_allswitchind(fplog, re->nrepl, pind, re->allswaps, re->tmpswap);
1067
+ }
1068
+ else
1069
+ {
1070
+ /* standard nearest neighbor replica exchange */
1071
+
1072
+ m = (step / re->nst) % 2;
1073
+ /* PLUMED */
1074
+ if(plumedswitch){
1075
+ int partner=re->repl;
1076
+ plumed_cmd(plumedmain,"getExchangesFlag",&plumed_test_exchange_pattern);
1077
+ if(plumed_test_exchange_pattern>0){
1078
+ int *list;
1079
+ snew(list,re->nrepl);
1080
+ plumed_cmd(plumedmain,"setNumberOfReplicas",&(re->nrepl));
1081
+ plumed_cmd(plumedmain,"getExchangesList",list);
1082
+ for(i=0; i<re->nrepl; i++) re->ind[i]=list[i];
1083
+ sfree(list);
1084
+ }
1085
+
1086
+ for(i=1; i<re->nrepl; i++) {
1087
+ if (i % 2 != m) continue;
1088
+ a = re->ind[i-1];
1089
+ b = re->ind[i];
1090
+ if(re->repl==a) partner=b;
1091
+ if(re->repl==b) partner=a;
1092
+ }
1093
+ plumed_cmd(plumedmain,"GREX setPartner",&partner);
1094
+ plumed_cmd(plumedmain,"GREX calculate",nullptr);
1095
+ plumed_cmd(plumedmain,"GREX shareAllDeltaBias",nullptr);
1096
+ }
1097
+ /* END PLUMED */
1098
+ for (i = 1; i < re->nrepl; i++)
1099
+ {
1100
+ a = re->ind[i - 1];
1101
+ b = re->ind[i];
1102
+
1103
+ bPrint = (re->repl == a || re->repl == b);
1104
+ if (i % 2 == m)
1105
+ {
1106
+ delta = calc_delta(fplog, bPrint, re, a, b, a, b);
1107
+ /* PLUMED */
1108
+ if(plumedswitch){
1109
+ real adb,bdb,dplumed;
1110
+ char buf[300];
1111
+ sprintf(buf,"GREX getDeltaBias %d",a); plumed_cmd(plumedmain,buf,&adb);
1112
+ sprintf(buf,"GREX getDeltaBias %d",b); plumed_cmd(plumedmain,buf,&bdb);
1113
+ dplumed=adb*re->beta[a]+bdb*re->beta[b];
1114
+ delta+=dplumed;
1115
+ if (bPrint)
1116
+ fprintf(fplog,"dplumed = %10.3e dE_Term = %10.3e (kT)\n",dplumed,delta);
1117
+ }
1118
+ /* END PLUMED */
1119
+ if (delta <= 0)
1120
+ {
1121
+ /* accepted */
1122
+ prob[i] = 1;
1123
+ bEx[i] = TRUE;
1124
+ }
1125
+ else
1126
+ {
1127
+ if (delta > c_probabilityCutoff)
1128
+ {
1129
+ prob[i] = 0;
1130
+ }
1131
+ else
1132
+ {
1133
+ prob[i] = exp(-delta);
1134
+ }
1135
+ // roll a number to determine if accepted. For now it is superfluous to
1136
+ // reset, but just in case we ever add more calls in different branches
1137
+ // it is safer to always reset the distribution.
1138
+ uniformRealDist.reset();
1139
+ bEx[i] = uniformRealDist(rng) < prob[i];
1140
+ }
1141
+ re->prob_sum[i] += prob[i];
1142
+
1143
+ if (bEx[i])
1144
+ {
1145
+ /* PLUMED */
1146
+ if(!plumed_test_exchange_pattern) {
1147
+ /* standard neighbour swapping */
1148
+ /* swap these two */
1149
+ tmp = pind[i - 1];
1150
+ pind[i - 1] = pind[i];
1151
+ pind[i] = tmp;
1152
+ re->nexchange[i]++; /* statistics for back compatibility */
1153
+ } else {
1154
+ /* alternative swapping patterns */
1155
+ tmp = pind[a];
1156
+ pind[a] = pind[b];
1157
+ pind[b] = tmp;
1158
+ re->nexchange[i]++; /* statistics for back compatibility */
1159
+ }
1160
+ /* END PLUMED */
1161
+ }
1162
+ }
1163
+ else
1164
+ {
1165
+ prob[i] = -1;
1166
+ bEx[i] = FALSE;
1167
+ }
1168
+ }
1169
+ /* print some statistics */
1170
+ print_ind(fplog, "ex", re->nrepl, re->ind, bEx);
1171
+ print_prob(fplog, "pr", re->nrepl, prob);
1172
+ fprintf(fplog, "\n");
1173
+ re->nattempt[m]++;
1174
+ }
1175
+
1176
+ /* PLUMED */
1177
+ if(plumed_test_exchange_pattern>0) {
1178
+ for (i = 0; i < re->nrepl; i++)
1179
+ {
1180
+ re->ind[i] = i;
1181
+ }
1182
+ }
1183
+ /* END PLUMED */
1184
+
1185
+ /* record which moves were made and accepted */
1186
+ for (i = 0; i < re->nrepl; i++)
1187
+ {
1188
+ re->nmoves[re->ind[i]][pind[i]] += 1;
1189
+ re->nmoves[pind[i]][re->ind[i]] += 1;
1190
+ }
1191
+ fflush(fplog); /* make sure we can see what the last exchange was */
1192
+ }
1193
+
1194
+ static void cyclic_decomposition(const int* destinations, int** cyclic, gmx_bool* incycle, const int nrepl, int* nswap)
1195
+ {
1196
+
1197
+ int i, j, c, p;
1198
+ int maxlen = 1;
1199
+ for (i = 0; i < nrepl; i++)
1200
+ {
1201
+ incycle[i] = FALSE;
1202
+ }
1203
+ for (i = 0; i < nrepl; i++) /* one cycle for each replica */
1204
+ {
1205
+ if (incycle[i])
1206
+ {
1207
+ cyclic[i][0] = -1;
1208
+ continue;
1209
+ }
1210
+ cyclic[i][0] = i;
1211
+ incycle[i] = TRUE;
1212
+ c = 1;
1213
+ p = i;
1214
+ for (j = 0; j < nrepl; j++) /* potentially all cycles are part, but we will break first */
1215
+ {
1216
+ p = destinations[p]; /* start permuting */
1217
+ if (p == i)
1218
+ {
1219
+ cyclic[i][c] = -1;
1220
+ if (c > maxlen)
1221
+ {
1222
+ maxlen = c;
1223
+ }
1224
+ break; /* we've reached the original element, the cycle is complete, and we marked the end. */
1225
+ }
1226
+ else
1227
+ {
1228
+ cyclic[i][c] = p; /* each permutation gives a new member of the cycle */
1229
+ incycle[p] = TRUE;
1230
+ c++;
1231
+ }
1232
+ }
1233
+ }
1234
+ *nswap = maxlen - 1;
1235
+
1236
+ if (debug)
1237
+ {
1238
+ for (i = 0; i < nrepl; i++)
1239
+ {
1240
+ fprintf(debug, "Cycle %d:", i);
1241
+ for (j = 0; j < nrepl; j++)
1242
+ {
1243
+ if (cyclic[i][j] < 0)
1244
+ {
1245
+ break;
1246
+ }
1247
+ fprintf(debug, "%2d", cyclic[i][j]);
1248
+ }
1249
+ fprintf(debug, "\n");
1250
+ }
1251
+ fflush(debug);
1252
+ }
1253
+ }
1254
+
1255
+ static void compute_exchange_order(int** cyclic, int** order, const int nrepl, const int maxswap)
1256
+ {
1257
+ int i, j;
1258
+
1259
+ for (j = 0; j < maxswap; j++)
1260
+ {
1261
+ for (i = 0; i < nrepl; i++)
1262
+ {
1263
+ if (cyclic[i][j + 1] >= 0)
1264
+ {
1265
+ order[cyclic[i][j + 1]][j] = cyclic[i][j];
1266
+ order[cyclic[i][j]][j] = cyclic[i][j + 1];
1267
+ }
1268
+ }
1269
+ for (i = 0; i < nrepl; i++)
1270
+ {
1271
+ if (order[i][j] < 0)
1272
+ {
1273
+ order[i][j] = i; /* if it's not exchanging, it should stay this round*/
1274
+ }
1275
+ }
1276
+ }
1277
+
1278
+ if (debug)
1279
+ {
1280
+ fprintf(debug, "Replica Exchange Order\n");
1281
+ for (i = 0; i < nrepl; i++)
1282
+ {
1283
+ fprintf(debug, "Replica %d:", i);
1284
+ for (j = 0; j < maxswap; j++)
1285
+ {
1286
+ if (order[i][j] < 0)
1287
+ {
1288
+ break;
1289
+ }
1290
+ fprintf(debug, "%2d", order[i][j]);
1291
+ }
1292
+ fprintf(debug, "\n");
1293
+ }
1294
+ fflush(debug);
1295
+ }
1296
+ }
1297
+
1298
+ static void prepare_to_do_exchange(struct gmx_repl_ex* re, const int replica_id, int* maxswap, gmx_bool* bThisReplicaExchanged)
1299
+ {
1300
+ int i, j;
1301
+ /* Hold the cyclic decomposition of the (multiple) replica
1302
+ * exchange. */
1303
+ gmx_bool bAnyReplicaExchanged = FALSE;
1304
+ *bThisReplicaExchanged = FALSE;
1305
+
1306
+ for (i = 0; i < re->nrepl; i++)
1307
+ {
1308
+ if (re->destinations[i] != re->ind[i])
1309
+ {
1310
+ /* only mark as exchanged if the index has been shuffled */
1311
+ bAnyReplicaExchanged = TRUE;
1312
+ break;
1313
+ }
1314
+ }
1315
+ if (bAnyReplicaExchanged)
1316
+ {
1317
+ /* reinitialize the placeholder arrays */
1318
+ for (i = 0; i < re->nrepl; i++)
1319
+ {
1320
+ for (j = 0; j < re->nrepl; j++)
1321
+ {
1322
+ re->cyclic[i][j] = -1;
1323
+ re->order[i][j] = -1;
1324
+ }
1325
+ }
1326
+
1327
+ /* Identify the cyclic decomposition of the permutation (very
1328
+ * fast if neighbor replica exchange). */
1329
+ cyclic_decomposition(re->destinations, re->cyclic, re->incycle, re->nrepl, maxswap);
1330
+
1331
+ /* Now translate the decomposition into a replica exchange
1332
+ * order at each step. */
1333
+ compute_exchange_order(re->cyclic, re->order, re->nrepl, *maxswap);
1334
+
1335
+ /* Did this replica do any exchange at any point? */
1336
+ for (j = 0; j < *maxswap; j++)
1337
+ {
1338
+ if (replica_id != re->order[replica_id][j])
1339
+ {
1340
+ *bThisReplicaExchanged = TRUE;
1341
+ break;
1342
+ }
1343
+ }
1344
+ }
1345
+ }
1346
+
1347
+ gmx_bool replica_exchange(FILE* fplog,
1348
+ const t_commrec* cr,
1349
+ const gmx_multisim_t* ms,
1350
+ struct gmx_repl_ex* re,
1351
+ t_state* state,
1352
+ const gmx_enerdata_t* enerd,
1353
+ t_state* state_local,
1354
+ int64_t step,
1355
+ real time)
1356
+ {
1357
+ int j;
1358
+ int replica_id = 0;
1359
+ int exchange_partner;
1360
+ int maxswap = 0;
1361
+ /* Number of rounds of exchanges needed to deal with any multiple
1362
+ * exchanges. */
1363
+ /* Where each replica ends up after the exchange attempt(s). */
1364
+ /* The order in which multiple exchanges will occur. */
1365
+ gmx_bool bThisReplicaExchanged = FALSE;
1366
+
1367
+ /* PLUMED */
1368
+ if(plumedswitch)plumed_cmd(plumedmain,"GREX prepare",nullptr);
1369
+ /* END PLUMED */
1370
+
1371
+ if (MASTER(cr))
1372
+ {
1373
+ replica_id = re->repl;
1374
+ test_for_replica_exchange(fplog, ms, re, enerd, det(state_local->box), step, time);
1375
+ prepare_to_do_exchange(re, replica_id, &maxswap, &bThisReplicaExchanged);
1376
+ }
1377
+ /* Do intra-simulation broadcast so all processors belonging to
1378
+ * each simulation know whether they need to participate in
1379
+ * collecting the state. Otherwise, they might as well get on with
1380
+ * the next thing to do. */
1381
+ if (haveDDAtomOrdering(*cr))
1382
+ {
1383
+ #if GMX_MPI
1384
+ MPI_Bcast(&bThisReplicaExchanged, sizeof(gmx_bool), MPI_BYTE, MASTERRANK(cr), cr->mpi_comm_mygroup);
1385
+ #endif
1386
+ }
1387
+
1388
+ if (bThisReplicaExchanged)
1389
+ {
1390
+ /* Exchange the states */
1391
+ /* Collect the global state on the master node */
1392
+ if (haveDDAtomOrdering(*cr))
1393
+ {
1394
+ dd_collect_state(cr->dd, state_local, state);
1395
+ }
1396
+ else
1397
+ {
1398
+ copy_state_serial(state_local, state);
1399
+ }
1400
+
1401
+ if (MASTER(cr))
1402
+ {
1403
+ /* There will be only one swap cycle with standard replica
1404
+ * exchange, but there may be multiple swap cycles if we
1405
+ * allow multiple swaps. */
1406
+
1407
+ for (j = 0; j < maxswap; j++)
1408
+ {
1409
+ exchange_partner = re->order[replica_id][j];
1410
+
1411
+ if (exchange_partner != replica_id)
1412
+ {
1413
+ /* Exchange the global states between the master nodes */
1414
+ if (debug)
1415
+ {
1416
+ fprintf(debug, "Exchanging %d with %d\n", replica_id, exchange_partner);
1417
+ }
1418
+ exchange_state(ms, exchange_partner, state);
1419
+ }
1420
+ }
1421
+ /* For temperature-type replica exchange, we need to scale
1422
+ * the velocities. */
1423
+ if (re->type == ReplicaExchangeType::Temperature || re->type == ReplicaExchangeType::TemperatureLambda)
1424
+ {
1425
+ scale_velocities(
1426
+ state->v,
1427
+ std::sqrt(re->q[ReplicaExchangeType::Temperature][replica_id]
1428
+ / re->q[ReplicaExchangeType::Temperature][re->destinations[replica_id]]));
1429
+ }
1430
+ }
1431
+
1432
+ /* With domain decomposition the global state is distributed later */
1433
+ if (!haveDDAtomOrdering(*cr))
1434
+ {
1435
+ /* Copy the global state to the local state data structure */
1436
+ copy_state_serial(state, state_local);
1437
+ }
1438
+ }
1439
+
1440
+ return bThisReplicaExchanged;
1441
+ }
1442
+
1443
+ void print_replica_exchange_statistics(FILE* fplog, struct gmx_repl_ex* re)
1444
+ {
1445
+ int i;
1446
+
1447
+ fprintf(fplog, "\nReplica exchange statistics\n");
1448
+
1449
+ if (re->nex == 0)
1450
+ {
1451
+ fprintf(fplog,
1452
+ "Repl %d attempts, %d odd, %d even\n",
1453
+ re->nattempt[0] + re->nattempt[1],
1454
+ re->nattempt[1],
1455
+ re->nattempt[0]);
1456
+
1457
+ fprintf(fplog, "Repl average probabilities:\n");
1458
+ for (i = 1; i < re->nrepl; i++)
1459
+ {
1460
+ if (re->nattempt[i % 2] == 0)
1461
+ {
1462
+ re->prob[i] = 0;
1463
+ }
1464
+ else
1465
+ {
1466
+ re->prob[i] = re->prob_sum[i] / re->nattempt[i % 2];
1467
+ }
1468
+ }
1469
+ print_ind(fplog, "", re->nrepl, re->ind, nullptr);
1470
+ print_prob(fplog, "", re->nrepl, re->prob);
1471
+
1472
+ fprintf(fplog, "Repl number of exchanges:\n");
1473
+ print_ind(fplog, "", re->nrepl, re->ind, nullptr);
1474
+ print_count(fplog, "", re->nrepl, re->nexchange);
1475
+
1476
+ fprintf(fplog, "Repl average number of exchanges:\n");
1477
+ for (i = 1; i < re->nrepl; i++)
1478
+ {
1479
+ if (re->nattempt[i % 2] == 0)
1480
+ {
1481
+ re->prob[i] = 0;
1482
+ }
1483
+ else
1484
+ {
1485
+ re->prob[i] = (static_cast<real>(re->nexchange[i])) / re->nattempt[i % 2];
1486
+ }
1487
+ }
1488
+ print_ind(fplog, "", re->nrepl, re->ind, nullptr);
1489
+ print_prob(fplog, "", re->nrepl, re->prob);
1490
+
1491
+ fprintf(fplog, "\n");
1492
+ }
1493
+ /* print the transition matrix */
1494
+ print_transition_matrix(fplog, re->nrepl, re->nmoves, re->nattempt);
1495
+ }
1496
+
1497
+ /* PLUMED HREX */
1498
+ int replica_exchange_get_repl(const gmx_repl_ex_t re){
1499
+ return re->repl;
1500
+ };
1501
+
1502
+ int replica_exchange_get_nrepl(const gmx_repl_ex_t re){
1503
+ return re->nrepl;
1504
+ };
1505
+ /* END PLUMED HREX */
1506
+ //! \endcond