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