hillclimber 0.1.5__cp313-cp313-musllinux_1_2_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 (472) hide show
  1. hillclimber/__init__.py +39 -0
  2. hillclimber/actions.py +53 -0
  3. hillclimber/analysis.py +590 -0
  4. hillclimber/biases.py +293 -0
  5. hillclimber/calc.py +22 -0
  6. hillclimber/cvs.py +1070 -0
  7. hillclimber/interfaces.py +133 -0
  8. hillclimber/metadynamics.py +325 -0
  9. hillclimber/nodes.py +6 -0
  10. hillclimber/opes.py +359 -0
  11. hillclimber/selectors.py +230 -0
  12. hillclimber/virtual_atoms.py +341 -0
  13. hillclimber-0.1.5.dist-info/METADATA +210 -0
  14. hillclimber-0.1.5.dist-info/RECORD +472 -0
  15. hillclimber-0.1.5.dist-info/WHEEL +5 -0
  16. hillclimber-0.1.5.dist-info/entry_points.txt +8 -0
  17. hillclimber-0.1.5.dist-info/licenses/LICENSE +165 -0
  18. hillclimber-0.1.5.dist-info/sboms/auditwheel.cdx.json +1 -0
  19. hillclimber.libs/libgcc_s-2d945d6c.so.1 +0 -0
  20. hillclimber.libs/libgomp-1ede7ee7.so.1.0.0 +0 -0
  21. hillclimber.libs/libstdc++-85f2cd6d.so.6.0.33 +0 -0
  22. plumed/__init__.py +104 -0
  23. plumed/_lib/bin/plumed +0 -0
  24. plumed/_lib/bin/plumed-config +9 -0
  25. plumed/_lib/bin/plumed-patch +9 -0
  26. plumed/_lib/include/plumed/adjmat/AdjacencyMatrixBase.h +659 -0
  27. plumed/_lib/include/plumed/adjmat/ContactMatrix.h +59 -0
  28. plumed/_lib/include/plumed/asmjit/arch.h +228 -0
  29. plumed/_lib/include/plumed/asmjit/arm.h +43 -0
  30. plumed/_lib/include/plumed/asmjit/asmjit.h +69 -0
  31. plumed/_lib/include/plumed/asmjit/asmjit_apibegin.h +143 -0
  32. plumed/_lib/include/plumed/asmjit/asmjit_apiend.h +93 -0
  33. plumed/_lib/include/plumed/asmjit/asmjit_build.h +971 -0
  34. plumed/_lib/include/plumed/asmjit/assembler.h +183 -0
  35. plumed/_lib/include/plumed/asmjit/base.h +56 -0
  36. plumed/_lib/include/plumed/asmjit/codebuilder.h +944 -0
  37. plumed/_lib/include/plumed/asmjit/codecompiler.h +767 -0
  38. plumed/_lib/include/plumed/asmjit/codeemitter.h +528 -0
  39. plumed/_lib/include/plumed/asmjit/codeholder.h +777 -0
  40. plumed/_lib/include/plumed/asmjit/constpool.h +286 -0
  41. plumed/_lib/include/plumed/asmjit/cpuinfo.h +402 -0
  42. plumed/_lib/include/plumed/asmjit/func.h +1327 -0
  43. plumed/_lib/include/plumed/asmjit/globals.h +370 -0
  44. plumed/_lib/include/plumed/asmjit/inst.h +137 -0
  45. plumed/_lib/include/plumed/asmjit/logging.h +317 -0
  46. plumed/_lib/include/plumed/asmjit/misc_p.h +103 -0
  47. plumed/_lib/include/plumed/asmjit/moved_string.h +318 -0
  48. plumed/_lib/include/plumed/asmjit/operand.h +1599 -0
  49. plumed/_lib/include/plumed/asmjit/osutils.h +207 -0
  50. plumed/_lib/include/plumed/asmjit/regalloc_p.h +597 -0
  51. plumed/_lib/include/plumed/asmjit/runtime.h +227 -0
  52. plumed/_lib/include/plumed/asmjit/simdtypes.h +1104 -0
  53. plumed/_lib/include/plumed/asmjit/utils.h +1387 -0
  54. plumed/_lib/include/plumed/asmjit/vmem.h +183 -0
  55. plumed/_lib/include/plumed/asmjit/x86.h +45 -0
  56. plumed/_lib/include/plumed/asmjit/x86assembler.h +125 -0
  57. plumed/_lib/include/plumed/asmjit/x86builder.h +117 -0
  58. plumed/_lib/include/plumed/asmjit/x86compiler.h +322 -0
  59. plumed/_lib/include/plumed/asmjit/x86emitter.h +5149 -0
  60. plumed/_lib/include/plumed/asmjit/x86globals.h +535 -0
  61. plumed/_lib/include/plumed/asmjit/x86inst.h +2547 -0
  62. plumed/_lib/include/plumed/asmjit/x86instimpl_p.h +74 -0
  63. plumed/_lib/include/plumed/asmjit/x86internal_p.h +108 -0
  64. plumed/_lib/include/plumed/asmjit/x86logging_p.h +92 -0
  65. plumed/_lib/include/plumed/asmjit/x86misc.h +417 -0
  66. plumed/_lib/include/plumed/asmjit/x86operand.h +1133 -0
  67. plumed/_lib/include/plumed/asmjit/x86regalloc_p.h +734 -0
  68. plumed/_lib/include/plumed/asmjit/zone.h +1157 -0
  69. plumed/_lib/include/plumed/bias/Bias.h +82 -0
  70. plumed/_lib/include/plumed/bias/ReweightBase.h +58 -0
  71. plumed/_lib/include/plumed/blas/blas.h +253 -0
  72. plumed/_lib/include/plumed/blas/def_external.h +61 -0
  73. plumed/_lib/include/plumed/blas/def_internal.h +97 -0
  74. plumed/_lib/include/plumed/blas/real.h +49 -0
  75. plumed/_lib/include/plumed/cltools/CLTool.h +32 -0
  76. plumed/_lib/include/plumed/clusters/ClusteringBase.h +70 -0
  77. plumed/_lib/include/plumed/colvar/Colvar.h +32 -0
  78. plumed/_lib/include/plumed/colvar/ColvarInput.h +68 -0
  79. plumed/_lib/include/plumed/colvar/ColvarShortcut.h +81 -0
  80. plumed/_lib/include/plumed/colvar/CoordinationBase.h +52 -0
  81. plumed/_lib/include/plumed/colvar/MultiColvarTemplate.h +333 -0
  82. plumed/_lib/include/plumed/colvar/PathMSDBase.h +101 -0
  83. plumed/_lib/include/plumed/colvar/RMSDVector.h +78 -0
  84. plumed/_lib/include/plumed/config/Config.h +118 -0
  85. plumed/_lib/include/plumed/config/version.h +9 -0
  86. plumed/_lib/include/plumed/contour/ContourFindingObject.h +87 -0
  87. plumed/_lib/include/plumed/contour/DistanceFromContourBase.h +82 -0
  88. plumed/_lib/include/plumed/contour/FindContour.h +67 -0
  89. plumed/_lib/include/plumed/core/Action.h +540 -0
  90. plumed/_lib/include/plumed/core/ActionAnyorder.h +48 -0
  91. plumed/_lib/include/plumed/core/ActionAtomistic.h +343 -0
  92. plumed/_lib/include/plumed/core/ActionForInterface.h +99 -0
  93. plumed/_lib/include/plumed/core/ActionPilot.h +57 -0
  94. plumed/_lib/include/plumed/core/ActionRegister.h +124 -0
  95. plumed/_lib/include/plumed/core/ActionSet.h +163 -0
  96. plumed/_lib/include/plumed/core/ActionSetup.h +48 -0
  97. plumed/_lib/include/plumed/core/ActionShortcut.h +73 -0
  98. plumed/_lib/include/plumed/core/ActionToGetData.h +59 -0
  99. plumed/_lib/include/plumed/core/ActionToPutData.h +101 -0
  100. plumed/_lib/include/plumed/core/ActionWithArguments.h +140 -0
  101. plumed/_lib/include/plumed/core/ActionWithMatrix.h +87 -0
  102. plumed/_lib/include/plumed/core/ActionWithValue.h +258 -0
  103. plumed/_lib/include/plumed/core/ActionWithVector.h +94 -0
  104. plumed/_lib/include/plumed/core/ActionWithVirtualAtom.h +123 -0
  105. plumed/_lib/include/plumed/core/CLTool.h +177 -0
  106. plumed/_lib/include/plumed/core/CLToolMain.h +102 -0
  107. plumed/_lib/include/plumed/core/CLToolRegister.h +108 -0
  108. plumed/_lib/include/plumed/core/Colvar.h +115 -0
  109. plumed/_lib/include/plumed/core/DataPassingObject.h +94 -0
  110. plumed/_lib/include/plumed/core/DataPassingTools.h +54 -0
  111. plumed/_lib/include/plumed/core/DomainDecomposition.h +120 -0
  112. plumed/_lib/include/plumed/core/ExchangePatterns.h +47 -0
  113. plumed/_lib/include/plumed/core/FlexibleBin.h +63 -0
  114. plumed/_lib/include/plumed/core/GREX.h +61 -0
  115. plumed/_lib/include/plumed/core/GenericMolInfo.h +89 -0
  116. plumed/_lib/include/plumed/core/Group.h +41 -0
  117. plumed/_lib/include/plumed/core/ModuleMap.h +30 -0
  118. plumed/_lib/include/plumed/core/ParallelTaskManager.h +1023 -0
  119. plumed/_lib/include/plumed/core/PbcAction.h +61 -0
  120. plumed/_lib/include/plumed/core/PlumedMain.h +632 -0
  121. plumed/_lib/include/plumed/core/PlumedMainInitializer.h +118 -0
  122. plumed/_lib/include/plumed/core/RegisterBase.h +340 -0
  123. plumed/_lib/include/plumed/core/TargetDist.h +48 -0
  124. plumed/_lib/include/plumed/core/Value.h +547 -0
  125. plumed/_lib/include/plumed/core/WithCmd.h +93 -0
  126. plumed/_lib/include/plumed/dimred/SMACOF.h +55 -0
  127. plumed/_lib/include/plumed/drr/DRR.h +383 -0
  128. plumed/_lib/include/plumed/drr/colvar_UIestimator.h +777 -0
  129. plumed/_lib/include/plumed/fisst/legendre_rule_fast.h +44 -0
  130. plumed/_lib/include/plumed/function/Custom.h +54 -0
  131. plumed/_lib/include/plumed/function/Function.h +85 -0
  132. plumed/_lib/include/plumed/function/FunctionOfMatrix.h +368 -0
  133. plumed/_lib/include/plumed/function/FunctionOfScalar.h +135 -0
  134. plumed/_lib/include/plumed/function/FunctionOfVector.h +296 -0
  135. plumed/_lib/include/plumed/function/FunctionSetup.h +180 -0
  136. plumed/_lib/include/plumed/function/FunctionShortcut.h +130 -0
  137. plumed/_lib/include/plumed/function/FunctionWithSingleArgument.h +165 -0
  138. plumed/_lib/include/plumed/gridtools/ActionWithGrid.h +43 -0
  139. plumed/_lib/include/plumed/gridtools/EvaluateGridFunction.h +99 -0
  140. plumed/_lib/include/plumed/gridtools/FunctionOfGrid.h +295 -0
  141. plumed/_lib/include/plumed/gridtools/GridCoordinatesObject.h +179 -0
  142. plumed/_lib/include/plumed/gridtools/GridSearch.h +135 -0
  143. plumed/_lib/include/plumed/gridtools/Interpolator.h +45 -0
  144. plumed/_lib/include/plumed/gridtools/KDE.h +455 -0
  145. plumed/_lib/include/plumed/gridtools/RDF.h +40 -0
  146. plumed/_lib/include/plumed/gridtools/SumOfKernels.h +219 -0
  147. plumed/_lib/include/plumed/isdb/MetainferenceBase.h +398 -0
  148. plumed/_lib/include/plumed/lapack/def_external.h +207 -0
  149. plumed/_lib/include/plumed/lapack/def_internal.h +388 -0
  150. plumed/_lib/include/plumed/lapack/lapack.h +899 -0
  151. plumed/_lib/include/plumed/lapack/lapack_limits.h +79 -0
  152. plumed/_lib/include/plumed/lapack/real.h +50 -0
  153. plumed/_lib/include/plumed/lepton/CompiledExpression.h +164 -0
  154. plumed/_lib/include/plumed/lepton/CustomFunction.h +143 -0
  155. plumed/_lib/include/plumed/lepton/Exception.h +93 -0
  156. plumed/_lib/include/plumed/lepton/ExpressionProgram.h +137 -0
  157. plumed/_lib/include/plumed/lepton/ExpressionTreeNode.h +145 -0
  158. plumed/_lib/include/plumed/lepton/Lepton.h +85 -0
  159. plumed/_lib/include/plumed/lepton/MSVC_erfc.h +123 -0
  160. plumed/_lib/include/plumed/lepton/Operation.h +1302 -0
  161. plumed/_lib/include/plumed/lepton/ParsedExpression.h +165 -0
  162. plumed/_lib/include/plumed/lepton/Parser.h +111 -0
  163. plumed/_lib/include/plumed/lepton/windowsIncludes.h +73 -0
  164. plumed/_lib/include/plumed/mapping/Path.h +44 -0
  165. plumed/_lib/include/plumed/mapping/PathProjectionCalculator.h +57 -0
  166. plumed/_lib/include/plumed/matrixtools/MatrixOperationBase.h +54 -0
  167. plumed/_lib/include/plumed/matrixtools/MatrixTimesMatrix.h +309 -0
  168. plumed/_lib/include/plumed/matrixtools/MatrixTimesVectorBase.h +365 -0
  169. plumed/_lib/include/plumed/matrixtools/OuterProduct.h +238 -0
  170. plumed/_lib/include/plumed/maze/Core.h +65 -0
  171. plumed/_lib/include/plumed/maze/Loss.h +86 -0
  172. plumed/_lib/include/plumed/maze/Member.h +66 -0
  173. plumed/_lib/include/plumed/maze/Memetic.h +799 -0
  174. plumed/_lib/include/plumed/maze/Optimizer.h +357 -0
  175. plumed/_lib/include/plumed/maze/Random_MT.h +156 -0
  176. plumed/_lib/include/plumed/maze/Tools.h +183 -0
  177. plumed/_lib/include/plumed/metatomic/vesin.h +188 -0
  178. plumed/_lib/include/plumed/molfile/Gromacs.h +2013 -0
  179. plumed/_lib/include/plumed/molfile/endianswap.h +217 -0
  180. plumed/_lib/include/plumed/molfile/fastio.h +683 -0
  181. plumed/_lib/include/plumed/molfile/largefiles.h +78 -0
  182. plumed/_lib/include/plumed/molfile/libmolfile_plugin.h +77 -0
  183. plumed/_lib/include/plumed/molfile/molfile_plugin.h +1034 -0
  184. plumed/_lib/include/plumed/molfile/periodic_table.h +248 -0
  185. plumed/_lib/include/plumed/molfile/readpdb.h +447 -0
  186. plumed/_lib/include/plumed/molfile/vmdplugin.h +236 -0
  187. plumed/_lib/include/plumed/multicolvar/MultiColvarShortcuts.h +45 -0
  188. plumed/_lib/include/plumed/opes/ExpansionCVs.h +79 -0
  189. plumed/_lib/include/plumed/sasa/Sasa.h +32 -0
  190. plumed/_lib/include/plumed/secondarystructure/SecondaryStructureBase.h +372 -0
  191. plumed/_lib/include/plumed/setup/ActionSetup.h +25 -0
  192. plumed/_lib/include/plumed/small_vector/small_vector.h +6114 -0
  193. plumed/_lib/include/plumed/symfunc/CoordinationNumbers.h +41 -0
  194. plumed/_lib/include/plumed/tools/Angle.h +52 -0
  195. plumed/_lib/include/plumed/tools/AtomDistribution.h +138 -0
  196. plumed/_lib/include/plumed/tools/AtomNumber.h +152 -0
  197. plumed/_lib/include/plumed/tools/BiasRepresentation.h +106 -0
  198. plumed/_lib/include/plumed/tools/BitmaskEnum.h +167 -0
  199. plumed/_lib/include/plumed/tools/Brent1DRootSearch.h +159 -0
  200. plumed/_lib/include/plumed/tools/CheckInRange.h +44 -0
  201. plumed/_lib/include/plumed/tools/Citations.h +74 -0
  202. plumed/_lib/include/plumed/tools/ColvarOutput.h +118 -0
  203. plumed/_lib/include/plumed/tools/Communicator.h +316 -0
  204. plumed/_lib/include/plumed/tools/ConjugateGradient.h +80 -0
  205. plumed/_lib/include/plumed/tools/DLLoader.h +79 -0
  206. plumed/_lib/include/plumed/tools/ERMSD.h +73 -0
  207. plumed/_lib/include/plumed/tools/Exception.h +406 -0
  208. plumed/_lib/include/plumed/tools/File.h +28 -0
  209. plumed/_lib/include/plumed/tools/FileBase.h +153 -0
  210. plumed/_lib/include/plumed/tools/FileTools.h +37 -0
  211. plumed/_lib/include/plumed/tools/ForwardDecl.h +54 -0
  212. plumed/_lib/include/plumed/tools/Grid.h +638 -0
  213. plumed/_lib/include/plumed/tools/HistogramBead.h +136 -0
  214. plumed/_lib/include/plumed/tools/IFile.h +117 -0
  215. plumed/_lib/include/plumed/tools/KernelFunctions.h +113 -0
  216. plumed/_lib/include/plumed/tools/Keywords.h +380 -0
  217. plumed/_lib/include/plumed/tools/LatticeReduction.h +66 -0
  218. plumed/_lib/include/plumed/tools/LeptonCall.h +64 -0
  219. plumed/_lib/include/plumed/tools/LinkCells.h +126 -0
  220. plumed/_lib/include/plumed/tools/Log.h +41 -0
  221. plumed/_lib/include/plumed/tools/LoopUnroller.h +163 -0
  222. plumed/_lib/include/plumed/tools/Matrix.h +721 -0
  223. plumed/_lib/include/plumed/tools/MatrixSquareBracketsAccess.h +138 -0
  224. plumed/_lib/include/plumed/tools/MergeVectorTools.h +153 -0
  225. plumed/_lib/include/plumed/tools/Minimise1DBrent.h +244 -0
  226. plumed/_lib/include/plumed/tools/MinimiseBase.h +120 -0
  227. plumed/_lib/include/plumed/tools/MolDataClass.h +51 -0
  228. plumed/_lib/include/plumed/tools/NeighborList.h +112 -0
  229. plumed/_lib/include/plumed/tools/OFile.h +286 -0
  230. plumed/_lib/include/plumed/tools/OpenACC.h +180 -0
  231. plumed/_lib/include/plumed/tools/OpenMP.h +75 -0
  232. plumed/_lib/include/plumed/tools/PDB.h +154 -0
  233. plumed/_lib/include/plumed/tools/Pbc.h +139 -0
  234. plumed/_lib/include/plumed/tools/PlumedHandle.h +105 -0
  235. plumed/_lib/include/plumed/tools/RMSD.h +493 -0
  236. plumed/_lib/include/plumed/tools/Random.h +80 -0
  237. plumed/_lib/include/plumed/tools/RootFindingBase.h +79 -0
  238. plumed/_lib/include/plumed/tools/Stopwatch.h +475 -0
  239. plumed/_lib/include/plumed/tools/Subprocess.h +142 -0
  240. plumed/_lib/include/plumed/tools/SwitchingFunction.h +208 -0
  241. plumed/_lib/include/plumed/tools/Tensor.h +724 -0
  242. plumed/_lib/include/plumed/tools/TokenizedLine.h +123 -0
  243. plumed/_lib/include/plumed/tools/Tools.h +638 -0
  244. plumed/_lib/include/plumed/tools/Torsion.h +55 -0
  245. plumed/_lib/include/plumed/tools/TrajectoryParser.h +118 -0
  246. plumed/_lib/include/plumed/tools/Tree.h +61 -0
  247. plumed/_lib/include/plumed/tools/TypesafePtr.h +463 -0
  248. plumed/_lib/include/plumed/tools/Units.h +167 -0
  249. plumed/_lib/include/plumed/tools/Vector.h +433 -0
  250. plumed/_lib/include/plumed/tools/View.h +296 -0
  251. plumed/_lib/include/plumed/tools/View2D.h +100 -0
  252. plumed/_lib/include/plumed/tools/h36.h +39 -0
  253. plumed/_lib/include/plumed/vatom/ActionWithVirtualAtom.h +32 -0
  254. plumed/_lib/include/plumed/ves/BasisFunctions.h +380 -0
  255. plumed/_lib/include/plumed/ves/CoeffsBase.h +310 -0
  256. plumed/_lib/include/plumed/ves/CoeffsMatrix.h +220 -0
  257. plumed/_lib/include/plumed/ves/CoeffsVector.h +251 -0
  258. plumed/_lib/include/plumed/ves/FermiSwitchingFunction.h +74 -0
  259. plumed/_lib/include/plumed/ves/GridIntegrationWeights.h +50 -0
  260. plumed/_lib/include/plumed/ves/GridLinearInterpolation.h +81 -0
  261. plumed/_lib/include/plumed/ves/GridProjWeights.h +61 -0
  262. plumed/_lib/include/plumed/ves/LinearBasisSetExpansion.h +303 -0
  263. plumed/_lib/include/plumed/ves/Optimizer.h +444 -0
  264. plumed/_lib/include/plumed/ves/TargetDistModifer.h +53 -0
  265. plumed/_lib/include/plumed/ves/TargetDistribution.h +266 -0
  266. plumed/_lib/include/plumed/ves/VesBias.h +545 -0
  267. plumed/_lib/include/plumed/ves/VesTools.h +142 -0
  268. plumed/_lib/include/plumed/ves/WaveletGrid.h +75 -0
  269. plumed/_lib/include/plumed/volumes/ActionVolume.h +268 -0
  270. plumed/_lib/include/plumed/volumes/VolumeShortcut.h +147 -0
  271. plumed/_lib/include/plumed/wrapper/Plumed.h +5025 -0
  272. plumed/_lib/include/plumed/xdrfile/xdrfile.h +663 -0
  273. plumed/_lib/include/plumed/xdrfile/xdrfile_trr.h +89 -0
  274. plumed/_lib/include/plumed/xdrfile/xdrfile_xtc.h +90 -0
  275. plumed/_lib/lib/PythonCVInterface.so +0 -0
  276. plumed/_lib/lib/libplumed.a +0 -0
  277. plumed/_lib/lib/libplumed.so +0 -0
  278. plumed/_lib/lib/libplumedKernel.so +0 -0
  279. plumed/_lib/lib/libplumedWrapper.a +0 -0
  280. plumed/_lib/lib/pkgconfig/plumed.pc +13 -0
  281. plumed/_lib/lib/pkgconfig/plumedInternals.pc +13 -0
  282. plumed/_lib/lib/pkgconfig/plumedWrapper.pc +13 -0
  283. plumed/_lib/lib/plumed/fortran/plumed.f90 +879 -0
  284. plumed/_lib/lib/plumed/fortran/plumed_f08.f90 +2625 -0
  285. plumed/_lib/lib/plumed/modulefile +69 -0
  286. plumed/_lib/lib/plumed/patches/gromacs-2022.5.config +43 -0
  287. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt +543 -0
  288. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/CMakeLists.txt.preplumed +540 -0
  289. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.cpp +1628 -0
  290. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1590 -0
  291. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.h +103 -0
  292. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/expanded.h.preplumed +99 -0
  293. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/sim_util.cpp +2527 -0
  294. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2513 -0
  295. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
  296. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
  297. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.h +408 -0
  298. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +394 -0
  299. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/md.cpp +2348 -0
  300. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/md.cpp.preplumed +2091 -0
  301. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/minimize.cpp +3573 -0
  302. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3495 -0
  303. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.cpp +1506 -0
  304. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1402 -0
  305. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
  306. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
  307. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/rerun.cpp +997 -0
  308. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/rerun.cpp.preplumed +906 -0
  309. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/runner.cpp +2780 -0
  310. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/mdrun/runner.cpp.preplumed +2738 -0
  311. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
  312. plumed/_lib/lib/plumed/patches/gromacs-2022.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
  313. plumed/_lib/lib/plumed/patches/gromacs-2023.5.config +43 -0
  314. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/CMakeLists.txt +549 -0
  315. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/CMakeLists.txt.preplumed +546 -0
  316. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.cpp +1632 -0
  317. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1594 -0
  318. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.h +104 -0
  319. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/expanded.h.preplumed +100 -0
  320. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/sim_util.cpp +2624 -0
  321. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2610 -0
  322. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
  323. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
  324. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.h +409 -0
  325. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +395 -0
  326. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/md.cpp +2419 -0
  327. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/md.cpp.preplumed +2164 -0
  328. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/minimize.cpp +3546 -0
  329. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3468 -0
  330. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.cpp +1513 -0
  331. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1409 -0
  332. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
  333. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
  334. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/rerun.cpp +991 -0
  335. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/rerun.cpp.preplumed +900 -0
  336. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/runner.cpp +2895 -0
  337. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/mdrun/runner.cpp.preplumed +2849 -0
  338. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
  339. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
  340. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/decidegpuusage.cpp +886 -0
  341. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed +880 -0
  342. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h +347 -0
  343. plumed/_lib/lib/plumed/patches/gromacs-2023.5.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed +345 -0
  344. plumed/_lib/lib/plumed/patches/gromacs-2024.3.config +43 -0
  345. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/CMakeLists.txt +575 -0
  346. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/CMakeLists.txt.preplumed +572 -0
  347. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.cpp +1632 -0
  348. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.cpp.preplumed +1594 -0
  349. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.h +104 -0
  350. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/expanded.h.preplumed +100 -0
  351. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/sim_util.cpp +2564 -0
  352. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdlib/sim_util.cpp.preplumed +2550 -0
  353. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.cpp +208 -0
  354. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.cpp.preplumed +175 -0
  355. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.h +410 -0
  356. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/legacymdrunoptions.h.preplumed +396 -0
  357. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/md.cpp +2435 -0
  358. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/md.cpp.preplumed +2187 -0
  359. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/minimize.cpp +3592 -0
  360. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/minimize.cpp.preplumed +3514 -0
  361. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.cpp +1513 -0
  362. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.cpp.preplumed +1409 -0
  363. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.h +114 -0
  364. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/replicaexchange.h.preplumed +106 -0
  365. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/rerun.cpp +958 -0
  366. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/rerun.cpp.preplumed +929 -0
  367. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/runner.cpp +2987 -0
  368. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/mdrun/runner.cpp.preplumed +2941 -0
  369. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp +224 -0
  370. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/modularsimulator/expandedensembleelement.cpp.preplumed +222 -0
  371. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/decidegpuusage.cpp +904 -0
  372. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/decidegpuusage.cpp.preplumed +898 -0
  373. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h +353 -0
  374. plumed/_lib/lib/plumed/patches/gromacs-2024.3.diff/src/gromacs/taskassignment/include/gromacs/taskassignment/decidegpuusage.h.preplumed +351 -0
  375. plumed/_lib/lib/plumed/patches/gromacs-2025.0.config +39 -0
  376. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/cmake/gmxManagePlumed.cmake +82 -0
  377. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/cmake/gmxManagePlumed.cmake.preplumed +82 -0
  378. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedMDModule.cpp +162 -0
  379. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedMDModule.cpp.preplumed +154 -0
  380. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.cpp +107 -0
  381. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.cpp.preplumed +99 -0
  382. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.h +120 -0
  383. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedOptions.h.preplumed +111 -0
  384. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.cpp +215 -0
  385. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.cpp.preplumed +197 -0
  386. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.h +87 -0
  387. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/applied_forces/plumed/plumedforceprovider.h.preplumed +86 -0
  388. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrun/runner.cpp +2971 -0
  389. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrun/runner.cpp.preplumed +2970 -0
  390. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrunutility/mdmodulesnotifiers.h +430 -0
  391. plumed/_lib/lib/plumed/patches/gromacs-2025.0.diff/src/gromacs/mdrunutility/mdmodulesnotifiers.h.preplumed +429 -0
  392. plumed/_lib/lib/plumed/patches/namd-2.12.config +30 -0
  393. plumed/_lib/lib/plumed/patches/namd-2.12.diff +267 -0
  394. plumed/_lib/lib/plumed/patches/namd-2.13.config +30 -0
  395. plumed/_lib/lib/plumed/patches/namd-2.13.diff +267 -0
  396. plumed/_lib/lib/plumed/patches/namd-2.14.config +30 -0
  397. plumed/_lib/lib/plumed/patches/namd-2.14.diff +268 -0
  398. plumed/_lib/lib/plumed/patches/patch.sh +500 -0
  399. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.config +25 -0
  400. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/forces.f90 +368 -0
  401. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/forces.f90.preplumed +366 -0
  402. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_forces.f90 +71 -0
  403. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_forces.f90.preplumed +24 -0
  404. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_initialization.f90 +62 -0
  405. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  406. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/pwscf.f90 +189 -0
  407. plumed/_lib/lib/plumed/patches/qespresso-5.0.2.diff/PW/src/pwscf.f90.preplumed +185 -0
  408. plumed/_lib/lib/plumed/patches/qespresso-6.2.config +26 -0
  409. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/forces.f90 +422 -0
  410. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/forces.f90.preplumed +420 -0
  411. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90 +70 -0
  412. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
  413. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_initialization.f90 +62 -0
  414. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  415. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/run_pwscf.f90 +233 -0
  416. plumed/_lib/lib/plumed/patches/qespresso-6.2.diff/PW/src/run_pwscf.f90.preplumed +230 -0
  417. plumed/_lib/lib/plumed/patches/qespresso-7.0.config +28 -0
  418. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/Modules/Makefile +175 -0
  419. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/Modules/Makefile.preplumed +171 -0
  420. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/forces.f90 +486 -0
  421. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/forces.f90.preplumed +484 -0
  422. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90 +74 -0
  423. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
  424. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_initialization.f90 +64 -0
  425. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  426. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/run_pwscf.f90 +532 -0
  427. plumed/_lib/lib/plumed/patches/qespresso-7.0.diff/PW/src/run_pwscf.f90.preplumed +518 -0
  428. plumed/_lib/lib/plumed/patches/qespresso-7.2.config +28 -0
  429. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/Modules/Makefile +249 -0
  430. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/Modules/Makefile.preplumed +244 -0
  431. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/forces.f90 +532 -0
  432. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/forces.f90.preplumed +535 -0
  433. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_ext_forces.f90 +74 -0
  434. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_ext_forces.f90.preplumed +23 -0
  435. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_initialization.f90 +64 -0
  436. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/plugin_initialization.f90.preplumed +21 -0
  437. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/run_pwscf.f90 +569 -0
  438. plumed/_lib/lib/plumed/patches/qespresso-7.2.diff/PW/src/run_pwscf.f90.preplumed +560 -0
  439. plumed/_lib/lib/plumed/plumed-config +9 -0
  440. plumed/_lib/lib/plumed/plumed-mklib +9 -0
  441. plumed/_lib/lib/plumed/plumed-newcv +9 -0
  442. plumed/_lib/lib/plumed/plumed-partial_tempering +9 -0
  443. plumed/_lib/lib/plumed/plumed-patch +9 -0
  444. plumed/_lib/lib/plumed/plumed-runtime +0 -0
  445. plumed/_lib/lib/plumed/plumed-selector +9 -0
  446. plumed/_lib/lib/plumed/plumed-vim2html +9 -0
  447. plumed/_lib/lib/plumed/scripts/config.sh +126 -0
  448. plumed/_lib/lib/plumed/scripts/mklib.sh +175 -0
  449. plumed/_lib/lib/plumed/scripts/newcv.sh +26 -0
  450. plumed/_lib/lib/plumed/scripts/partial_tempering.sh +319 -0
  451. plumed/_lib/lib/plumed/scripts/patch.sh +4 -0
  452. plumed/_lib/lib/plumed/scripts/selector.sh +234 -0
  453. plumed/_lib/lib/plumed/scripts/vim2html.sh +190 -0
  454. plumed/_lib/lib/plumed/src/colvar/Template.cpp +116 -0
  455. plumed/_lib/lib/plumed/src/config/compile_options.sh +3 -0
  456. plumed/_lib/lib/plumed/src/config/config.txt +179 -0
  457. plumed/_lib/lib/plumed/src/lib/Plumed.cmake +8 -0
  458. plumed/_lib/lib/plumed/src/lib/Plumed.cmake.runtime +5 -0
  459. plumed/_lib/lib/plumed/src/lib/Plumed.cmake.shared +5 -0
  460. plumed/_lib/lib/plumed/src/lib/Plumed.cmake.static +5 -0
  461. plumed/_lib/lib/plumed/src/lib/Plumed.inc +8 -0
  462. plumed/_lib/lib/plumed/src/lib/Plumed.inc.runtime +5 -0
  463. plumed/_lib/lib/plumed/src/lib/Plumed.inc.shared +5 -0
  464. plumed/_lib/lib/plumed/src/lib/Plumed.inc.static +5 -0
  465. plumed/_lib/lib/plumed/vim/scripts.vim +6 -0
  466. plumed/_plumed_core.cpython-311-aarch64-linux-musl.so +0 -0
  467. plumed/_plumed_core.cpython-312-aarch64-linux-musl.so +0 -0
  468. plumed/_plumed_core.cpython-313-aarch64-linux-musl.so +0 -0
  469. plumedCommunications.cpython-311-aarch64-linux-musl.so +0 -0
  470. plumedCommunications.cpython-312-aarch64-linux-musl.so +0 -0
  471. plumedCommunications.cpython-313-aarch64-linux-musl.so +0 -0
  472. plumedCommunications.pyi +431 -0
@@ -0,0 +1,1632 @@
1
+ /*
2
+ * This file is part of the GROMACS molecular simulation package.
3
+ *
4
+ * Copyright 2012- 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
+ /* PLUMED */
36
+ #include "../../../Plumed.h"
37
+ extern int plumedswitch;
38
+ extern plumed plumedmain;
39
+ /* END PLUMED */
40
+
41
+ #include "gmxpre.h"
42
+
43
+ #include "expanded.h"
44
+
45
+ #include <cmath>
46
+ #include <cstdio>
47
+
48
+ #include "gromacs/math/units.h"
49
+ #include "gromacs/math/utilities.h"
50
+ #include "gromacs/mdtypes/enerdata.h"
51
+ #include "gromacs/mdtypes/forcerec.h"
52
+ #include "gromacs/mdtypes/group.h"
53
+ #include "gromacs/mdtypes/inputrec.h"
54
+ #include "gromacs/mdtypes/md_enums.h"
55
+ #include "gromacs/mdtypes/state.h"
56
+ #include "gromacs/random/threefry.h"
57
+ #include "gromacs/random/uniformrealdistribution.h"
58
+ #include "gromacs/utility/enumerationhelpers.h"
59
+ #include "gromacs/utility/fatalerror.h"
60
+ #include "gromacs/utility/smalloc.h"
61
+
62
+ #include "expanded_internal.h"
63
+
64
+ static void init_df_history_weights(df_history_t* dfhist, const t_expanded* expand, int nlim)
65
+ {
66
+ int i;
67
+ dfhist->wl_delta = expand->init_wl_delta;
68
+ for (i = 0; i < nlim; i++)
69
+ {
70
+ dfhist->sum_weights[i] = expand->init_lambda_weights[i];
71
+ dfhist->sum_dg[i] = expand->init_lambda_weights[i];
72
+ }
73
+ }
74
+
75
+ /* Eventually should contain all the functions needed to initialize expanded ensemble
76
+ before the md loop starts */
77
+ void init_expanded_ensemble(gmx_bool bStateFromCP, const t_inputrec* ir, df_history_t* dfhist)
78
+ {
79
+ if (!bStateFromCP)
80
+ {
81
+ init_df_history_weights(dfhist, ir->expandedvals.get(), ir->fepvals->n_lambda);
82
+ }
83
+ }
84
+
85
+ static void GenerateGibbsProbabilities(const real* ene, double* p_k, double* pks, int minfep, int maxfep)
86
+ {
87
+
88
+ int i;
89
+ real maxene;
90
+
91
+ *pks = 0.0;
92
+ maxene = ene[minfep];
93
+ /* find the maximum value */
94
+ for (i = minfep; i <= maxfep; i++)
95
+ {
96
+ if (ene[i] > maxene)
97
+ {
98
+ maxene = ene[i];
99
+ }
100
+ }
101
+ /* find the denominator */
102
+ for (i = minfep; i <= maxfep; i++)
103
+ {
104
+ *pks += std::exp(ene[i] - maxene);
105
+ }
106
+ /*numerators*/
107
+ for (i = minfep; i <= maxfep; i++)
108
+ {
109
+ p_k[i] = std::exp(ene[i] - maxene) / *pks;
110
+ }
111
+ }
112
+
113
+ static void
114
+ GenerateWeightedGibbsProbabilities(const real* ene, double* p_k, double* pks, int nlim, real* nvals, real delta)
115
+ {
116
+
117
+ int i;
118
+ real maxene;
119
+ real* nene;
120
+ *pks = 0.0;
121
+
122
+ snew(nene, nlim);
123
+ for (i = 0; i < nlim; i++)
124
+ {
125
+ if (nvals[i] == 0)
126
+ {
127
+ /* add the delta, since we need to make sure it's greater than zero, and
128
+ we need a non-arbitrary number? */
129
+ nene[i] = ene[i] + std::log(nvals[i] + delta);
130
+ }
131
+ else
132
+ {
133
+ nene[i] = ene[i] + std::log(nvals[i]);
134
+ }
135
+ }
136
+
137
+ /* find the maximum value */
138
+ maxene = nene[0];
139
+ for (i = 0; i < nlim; i++)
140
+ {
141
+ if (nene[i] > maxene)
142
+ {
143
+ maxene = nene[i];
144
+ }
145
+ }
146
+
147
+ /* subtract off the maximum, avoiding overflow */
148
+ for (i = 0; i < nlim; i++)
149
+ {
150
+ nene[i] -= maxene;
151
+ }
152
+
153
+ /* find the denominator */
154
+ for (i = 0; i < nlim; i++)
155
+ {
156
+ *pks += std::exp(nene[i]);
157
+ }
158
+
159
+ /*numerators*/
160
+ for (i = 0; i < nlim; i++)
161
+ {
162
+ p_k[i] = std::exp(nene[i]) / *pks;
163
+ }
164
+ sfree(nene);
165
+ }
166
+
167
+ static int FindMinimum(const real* min_metric, int N)
168
+ {
169
+
170
+ real min_val;
171
+ int min_nval, nval;
172
+
173
+ min_nval = 0;
174
+ min_val = min_metric[0];
175
+
176
+ for (nval = 0; nval < N; nval++)
177
+ {
178
+ if (min_metric[nval] < min_val)
179
+ {
180
+ min_val = min_metric[nval];
181
+ min_nval = nval;
182
+ }
183
+ }
184
+ return min_nval;
185
+ }
186
+
187
+ static gmx_bool CheckHistogramRatios(int nhisto, const real* histo, real ratio)
188
+ {
189
+
190
+ int i;
191
+ real nmean;
192
+ gmx_bool bIfFlat;
193
+
194
+ nmean = 0;
195
+ for (i = 0; i < nhisto; i++)
196
+ {
197
+ nmean += histo[i];
198
+ }
199
+
200
+ if (nmean == 0)
201
+ {
202
+ /* no samples! is bad!*/
203
+ bIfFlat = FALSE;
204
+ return bIfFlat;
205
+ }
206
+ nmean /= static_cast<real>(nhisto);
207
+
208
+ bIfFlat = TRUE;
209
+ for (i = 0; i < nhisto; i++)
210
+ {
211
+ /* make sure that all points are in the ratio < x < 1/ratio range */
212
+ if (!((histo[i] / nmean < 1.0 / ratio) && (histo[i] / nmean > ratio)))
213
+ {
214
+ bIfFlat = FALSE;
215
+ break;
216
+ }
217
+ }
218
+ return bIfFlat;
219
+ }
220
+
221
+ static gmx_bool CheckIfDoneEquilibrating(int nlim, const t_expanded* expand, const df_history_t* dfhist, int64_t step)
222
+ {
223
+
224
+ int i, totalsamples;
225
+ gmx_bool bDoneEquilibrating = TRUE;
226
+ gmx_bool bIfFlat;
227
+
228
+ /* If we are doing slow growth to get initial values, we haven't finished equilibrating */
229
+ if (expand->lmc_forced_nstart > 0)
230
+ {
231
+ for (i = 0; i < nlim; i++)
232
+ {
233
+ if (dfhist->n_at_lam[i]
234
+ < expand->lmc_forced_nstart) /* we are still doing the initial sweep, so we're
235
+ definitely not done equilibrating*/
236
+ {
237
+ bDoneEquilibrating = FALSE;
238
+ break;
239
+ }
240
+ }
241
+ }
242
+ else
243
+ {
244
+ /* assume we have equilibrated the weights, then check to see if any of the conditions are not met */
245
+ bDoneEquilibrating = TRUE;
246
+
247
+ /* calculate the total number of samples */
248
+ switch (expand->elmceq)
249
+ {
250
+ case LambdaWeightWillReachEquilibrium::No:
251
+ /* We have not equilibrated, and won't, ever. */
252
+ bDoneEquilibrating = FALSE;
253
+ break;
254
+ case LambdaWeightWillReachEquilibrium::Yes:
255
+ /* we have equilibrated -- we're done */
256
+ bDoneEquilibrating = TRUE;
257
+ break;
258
+ case LambdaWeightWillReachEquilibrium::Steps:
259
+ /* first, check if we are equilibrating by steps, if we're still under */
260
+ if (step < expand->equil_steps)
261
+ {
262
+ bDoneEquilibrating = FALSE;
263
+ }
264
+ break;
265
+ case LambdaWeightWillReachEquilibrium::Samples:
266
+ totalsamples = 0;
267
+ for (i = 0; i < nlim; i++)
268
+ {
269
+ totalsamples += dfhist->n_at_lam[i];
270
+ }
271
+ if (totalsamples < expand->equil_samples)
272
+ {
273
+ bDoneEquilibrating = FALSE;
274
+ }
275
+ break;
276
+ case LambdaWeightWillReachEquilibrium::NumAtLambda:
277
+ for (i = 0; i < nlim; i++)
278
+ {
279
+ if (dfhist->n_at_lam[i]
280
+ < expand->equil_n_at_lam) /* we are still doing the initial sweep, so we're
281
+ definitely not done equilibrating*/
282
+ {
283
+ bDoneEquilibrating = FALSE;
284
+ break;
285
+ }
286
+ }
287
+ break;
288
+ case LambdaWeightWillReachEquilibrium::WLDelta:
289
+ if (EWL(expand->elamstats)) /* This check is in readir as well, but
290
+ just to be sure */
291
+ {
292
+ if (dfhist->wl_delta > expand->equil_wl_delta)
293
+ {
294
+ bDoneEquilibrating = FALSE;
295
+ }
296
+ }
297
+ break;
298
+ case LambdaWeightWillReachEquilibrium::Ratio:
299
+ /* we can use the flatness as a judge of good weights, as long as
300
+ we're not doing minvar, or Wang-Landau.
301
+ But turn off for now until we figure out exactly how we do this.
302
+ */
303
+
304
+ if (!(EWL(expand->elamstats) || expand->elamstats == LambdaWeightCalculation::Minvar))
305
+ {
306
+ /* we want to use flatness -avoiding- the forced-through samples. Plus, we need
307
+ to convert to floats for this histogram function. */
308
+
309
+ real* modhisto;
310
+ snew(modhisto, nlim);
311
+ for (i = 0; i < nlim; i++)
312
+ {
313
+ modhisto[i] = 1.0 * (dfhist->n_at_lam[i] - expand->lmc_forced_nstart);
314
+ }
315
+ bIfFlat = CheckHistogramRatios(nlim, modhisto, expand->equil_ratio);
316
+ sfree(modhisto);
317
+ if (!bIfFlat)
318
+ {
319
+ bDoneEquilibrating = FALSE;
320
+ }
321
+ }
322
+ break;
323
+ default: bDoneEquilibrating = TRUE; break;
324
+ }
325
+ }
326
+ return bDoneEquilibrating;
327
+ }
328
+
329
+ static gmx_bool UpdateWeights(int nlim,
330
+ t_expanded* expand,
331
+ df_history_t* dfhist,
332
+ int fep_state,
333
+ const real* scaled_lamee,
334
+ const real* weighted_lamee,
335
+ int64_t step)
336
+ {
337
+ gmx_bool bSufficientSamples;
338
+ real acceptanceWeight;
339
+ int i;
340
+ int min_nvalm, min_nvalp, maxc;
341
+ real omega_m1_0, omega_p1_0;
342
+ real zero_sum_weights;
343
+ real *omegam_array, *weightsm_array, *omegap_array, *weightsp_array, *varm_array, *varp_array,
344
+ *dwp_array, *dwm_array;
345
+ real clam_varm, clam_varp, clam_osum, clam_weightsm, clam_weightsp, clam_minvar;
346
+ real * lam_variance, *lam_dg;
347
+ double* p_k;
348
+ double pks = 0;
349
+
350
+ /* Future potential todos for this function (see #3848):
351
+ * - Update the names in the dhist structure to be clearer. Not done for now since this
352
+ * a bugfix update and we are mininizing other code changes.
353
+ * - Modularize the code some more.
354
+ * - potentially merge with accelerated weight histogram functionality, since it's very similar.
355
+ */
356
+ /* if we have equilibrated the expanded ensemble weights, we are not updating them, so exit now */
357
+ if (dfhist->bEquil)
358
+ {
359
+ return FALSE;
360
+ }
361
+
362
+ if (CheckIfDoneEquilibrating(nlim, expand, dfhist, step))
363
+ {
364
+ dfhist->bEquil = TRUE;
365
+ /* zero out the visited states so we know how many equilibrated states we have
366
+ from here on out.*/
367
+ for (i = 0; i < nlim; i++)
368
+ {
369
+ dfhist->n_at_lam[i] = 0;
370
+ }
371
+ return TRUE;
372
+ }
373
+
374
+ /* If we reached this far, we have not equilibrated yet, keep on
375
+ going resetting the weights */
376
+
377
+ if (EWL(expand->elamstats))
378
+ {
379
+ if (expand->elamstats
380
+ == LambdaWeightCalculation::WL) /* Using standard Wang-Landau for weight updates */
381
+ {
382
+ dfhist->sum_weights[fep_state] -= dfhist->wl_delta;
383
+ dfhist->wl_histo[fep_state] += 1.0;
384
+ }
385
+ else if (expand->elamstats == LambdaWeightCalculation::WWL)
386
+ /* Using weighted Wang-Landau for weight updates.
387
+ * Very closly equivalent to accelerated weight histogram approach
388
+ * applied to expanded ensemble. */
389
+ {
390
+ snew(p_k, nlim);
391
+
392
+ /* first increment count */
393
+ GenerateGibbsProbabilities(weighted_lamee, p_k, &pks, 0, nlim - 1);
394
+ for (i = 0; i < nlim; i++)
395
+ {
396
+ dfhist->wl_histo[i] += static_cast<real>(p_k[i]);
397
+ }
398
+
399
+ /* then increment weights (uses count) */
400
+ pks = 0.0;
401
+ GenerateWeightedGibbsProbabilities(
402
+ weighted_lamee, p_k, &pks, nlim, dfhist->wl_histo, dfhist->wl_delta);
403
+
404
+ for (i = 0; i < nlim; i++)
405
+ {
406
+ dfhist->sum_weights[i] -= dfhist->wl_delta * static_cast<real>(p_k[i]);
407
+ }
408
+ /* Alternate definition, using logarithms. Shouldn't make very much difference! */
409
+ /*
410
+ real di;
411
+ for (i=0;i<nlim;i++)
412
+ {
413
+ di = (real)1.0 + dfhist->wl_delta*(real)p_k[i];
414
+ dfhist->sum_weights[i] -= log(di);
415
+ }
416
+ */
417
+ sfree(p_k);
418
+ }
419
+
420
+ zero_sum_weights = dfhist->sum_weights[0];
421
+ for (i = 0; i < nlim; i++)
422
+ {
423
+ dfhist->sum_weights[i] -= zero_sum_weights;
424
+ }
425
+ }
426
+
427
+ if (expand->elamstats == LambdaWeightCalculation::Barker
428
+ || expand->elamstats == LambdaWeightCalculation::Metropolis
429
+ || expand->elamstats == LambdaWeightCalculation::Minvar)
430
+ {
431
+ maxc = 2 * expand->c_range + 1;
432
+
433
+ snew(lam_dg, nlim);
434
+ snew(lam_variance, nlim);
435
+
436
+ snew(omegap_array, maxc);
437
+ snew(weightsp_array, maxc);
438
+ snew(varp_array, maxc);
439
+ snew(dwp_array, maxc);
440
+
441
+ snew(omegam_array, maxc);
442
+ snew(weightsm_array, maxc);
443
+ snew(varm_array, maxc);
444
+ snew(dwm_array, maxc);
445
+
446
+ /* unpack the values of the free energy differences and the
447
+ * variance in their estimates between nearby lambdas. We will
448
+ * only actually update 2 of these, the state we are currently
449
+ * at and the one we end up moving to
450
+ */
451
+
452
+ for (i = 0; i < nlim - 1; i++)
453
+ { /* only through the second to last */
454
+ lam_dg[i] = dfhist->sum_dg[i + 1] - dfhist->sum_dg[i];
455
+ lam_variance[i] =
456
+ gmx::square(dfhist->sum_variance[i + 1]) - gmx::square(dfhist->sum_variance[i]);
457
+ }
458
+
459
+ /* accumulate running averages of thermodynamic averages for Bennett Acceptance Ratio-based
460
+ * estimates of the free energy .
461
+ * Rather than peforming self-consistent estimation of the free energies at each step,
462
+ * we keep track of an array of possible different free energies (cnvals),
463
+ * and we self-consistently choose the best one. The one that leads to a free energy estimate
464
+ * that is closest to itself is the best estimate of the free energy. It is essentially a
465
+ * parallellized version of self-consistent iteration. maxc is the number of these constants. */
466
+
467
+ for (int nval = 0; nval < maxc; nval++)
468
+ {
469
+ const real cnval = static_cast<real>(nval - expand->c_range);
470
+
471
+ /* Compute acceptance criterion weight to the state below this one for use in averages.
472
+ * Note we do not have to have just moved from that state to use this free energy
473
+ * estimate; these are essentially "virtual" moves. */
474
+
475
+ if (fep_state > 0)
476
+ {
477
+ const auto lambdaEnergyDifference =
478
+ cnval - (scaled_lamee[fep_state] - scaled_lamee[fep_state - 1]);
479
+ acceptanceWeight =
480
+ gmx::calculateAcceptanceWeight(expand->elamstats, lambdaEnergyDifference);
481
+ dfhist->accum_m[fep_state][nval] += acceptanceWeight;
482
+ dfhist->accum_m2[fep_state][nval] += acceptanceWeight * acceptanceWeight;
483
+ }
484
+
485
+ // Compute acceptance criterion weight to transition to the next state
486
+ if (fep_state < nlim - 1)
487
+ {
488
+ const auto lambdaEnergyDifference =
489
+ -cnval + (scaled_lamee[fep_state + 1] - scaled_lamee[fep_state]);
490
+ acceptanceWeight =
491
+ gmx::calculateAcceptanceWeight(expand->elamstats, lambdaEnergyDifference);
492
+ dfhist->accum_p[fep_state][nval] += acceptanceWeight;
493
+ dfhist->accum_p2[fep_state][nval] += acceptanceWeight * acceptanceWeight;
494
+ }
495
+
496
+ /* Determination of Metropolis transition and Barker transition weights */
497
+
498
+ int numObservationsCurrentState = dfhist->n_at_lam[fep_state];
499
+ /* determine the number of observations above and below the current state */
500
+ int numObservationsLowerState = 0;
501
+ if (fep_state > 0)
502
+ {
503
+ numObservationsLowerState = dfhist->n_at_lam[fep_state - 1];
504
+ }
505
+ int numObservationsHigherState = 0;
506
+ if (fep_state < nlim - 1)
507
+ {
508
+ numObservationsHigherState = dfhist->n_at_lam[fep_state + 1];
509
+ }
510
+
511
+ /* Calculate the biases for each expanded ensemble state that minimize the total
512
+ * variance, as implemented in Martinez-Veracoechea and Escobedo,
513
+ * J. Phys. Chem. B 2008, 112, 8120-8128
514
+ *
515
+ * The variance associated with the free energy estimate between two states i and j
516
+ * is calculated as
517
+ * Var(i,j) = {avg[xi(i->j)^2] / avg[xi(i->j)]^2 - 1} / numObservations(i->j)
518
+ * + {avg[xi(j->i)^2] / avg[xi(j->i)]^2 - 1} / numObservations(j->i)
519
+ * where xi(i->j) is the acceptance factor / weight associated with moving from state i to j
520
+ * As we are calculating the acceptance factor to the neighbors every time we're visiting
521
+ * a state, numObservations(i->j) == numObservations(i) and numObservations(j->i) == numObservations(j)
522
+ */
523
+
524
+ /* Accumulation of acceptance weight averages between the current state and the
525
+ * states +1 (p1) and -1 (m1), averaged at current state (0)
526
+ */
527
+ real avgAcceptanceCurrentToLower = 0;
528
+ real avgAcceptanceCurrentToHigher = 0;
529
+ /* Accumulation of acceptance weight averages quantities between states 0
530
+ * and states +1 and -1, squared
531
+ */
532
+ real avgAcceptanceCurrentToLowerSquared = 0;
533
+ real avgAcceptanceCurrentToHigherSquared = 0;
534
+ /* Accumulation of free energy quantities from lower state (m1) to current state (0) and squared */
535
+ real avgAcceptanceLowerToCurrent = 0;
536
+ real avgAcceptanceLowerToCurrentSquared = 0;
537
+ /* Accumulation of free energy quantities from upper state (p1) to current state (0) and squared */
538
+ real avgAcceptanceHigherToCurrent = 0;
539
+ real avgAcceptanceHigherToCurrentSquared = 0;
540
+
541
+ if (numObservationsCurrentState > 0)
542
+ {
543
+ avgAcceptanceCurrentToLower = dfhist->accum_m[fep_state][nval] / numObservationsCurrentState;
544
+ avgAcceptanceCurrentToHigher =
545
+ dfhist->accum_p[fep_state][nval] / numObservationsCurrentState;
546
+ avgAcceptanceCurrentToLowerSquared =
547
+ dfhist->accum_m2[fep_state][nval] / numObservationsCurrentState;
548
+ avgAcceptanceCurrentToHigherSquared =
549
+ dfhist->accum_p2[fep_state][nval] / numObservationsCurrentState;
550
+ }
551
+
552
+ if ((fep_state > 0) && (numObservationsLowerState > 0))
553
+ {
554
+ avgAcceptanceLowerToCurrent =
555
+ dfhist->accum_p[fep_state - 1][nval] / numObservationsLowerState;
556
+ avgAcceptanceLowerToCurrentSquared =
557
+ dfhist->accum_p2[fep_state - 1][nval] / numObservationsLowerState;
558
+ }
559
+
560
+ if ((fep_state < nlim - 1) && (numObservationsHigherState > 0))
561
+ {
562
+ avgAcceptanceHigherToCurrent =
563
+ dfhist->accum_m[fep_state + 1][nval] / numObservationsHigherState;
564
+ avgAcceptanceHigherToCurrentSquared =
565
+ dfhist->accum_m2[fep_state + 1][nval] / numObservationsHigherState;
566
+ }
567
+ /* These are accumulation of positive values (see definition of acceptance functions
568
+ * above), or of squares of positive values.
569
+ * We're taking this for granted in the following calculation, so make sure
570
+ * here that nothing weird happened. Although technically all values should be positive,
571
+ * because of floating point precisions, they might be numerically zero. */
572
+ GMX_RELEASE_ASSERT(
573
+ avgAcceptanceCurrentToLower >= 0 && avgAcceptanceCurrentToLowerSquared >= 0
574
+ && avgAcceptanceCurrentToHigher >= 0
575
+ && avgAcceptanceCurrentToHigherSquared >= 0 && avgAcceptanceLowerToCurrent >= 0
576
+ && avgAcceptanceLowerToCurrentSquared >= 0 && avgAcceptanceHigherToCurrent >= 0
577
+ && avgAcceptanceHigherToCurrentSquared >= 0,
578
+ "By definition, the acceptance factors should all be nonnegative.");
579
+
580
+ real varianceCurrentToLower = 0;
581
+ real varianceCurrentToHigher = 0;
582
+ real weightDifferenceToLower = 0;
583
+ real weightDifferenceToHigher = 0;
584
+ real varianceToLower = 0;
585
+ real varianceToHigher = 0;
586
+
587
+ if (fep_state > 0)
588
+ {
589
+ if (numObservationsCurrentState > 0)
590
+ {
591
+ /* Calculate {avg[xi(i->j)^2] / avg[xi(i->j)]^2 - 1}
592
+ *
593
+ * Note that if avg[xi(i->j)] == 0, also avg[xi(i->j)^2] == 0 (since the
594
+ * acceptances are all positive!), and hence
595
+ * {avg[xi(i->j)^2] / avg[xi(i->j)]^2 - 1} -> 0 for avg[xi(i->j)] -> 0
596
+ * We're catching that case explicitly to avoid numerical
597
+ * problems dividing by zero when the overlap between states is small (#3304)
598
+ */
599
+ if (avgAcceptanceCurrentToLower > 0)
600
+ {
601
+ varianceCurrentToLower =
602
+ avgAcceptanceCurrentToLowerSquared
603
+ / (avgAcceptanceCurrentToLower * avgAcceptanceCurrentToLower)
604
+ - 1.0;
605
+ }
606
+ if (numObservationsLowerState > 0)
607
+ {
608
+ /* Calculate {avg[xi(i->j)^2] / avg[xi(i->j)]^2 - 1}
609
+ *
610
+ * Note that if avg[xi(i->j)] == 0, also avg[xi(i->j)^2] == 0 (since the
611
+ * acceptances are all positive!), and hence
612
+ * {avg[xi(i->j)^2] / avg[xi(i->j)]^2 - 1} -> 0 for avg[xi(i->j)] -> 0
613
+ * We're catching that case explicitly to avoid numerical
614
+ * problems dividing by zero when the overlap between states is small (#3304)
615
+ */
616
+ real varianceLowerToCurrent = 0;
617
+ if (avgAcceptanceLowerToCurrent > 0)
618
+ {
619
+ varianceLowerToCurrent =
620
+ avgAcceptanceLowerToCurrentSquared
621
+ / (avgAcceptanceLowerToCurrent * avgAcceptanceLowerToCurrent)
622
+ - 1.0;
623
+ }
624
+ /* Free energy difference to the state one state lower */
625
+ /* if these either of these quantities are zero, the energies are */
626
+ /* way too large for the dynamic range. We need an alternate guesstimate */
627
+ if ((avgAcceptanceCurrentToLower == 0) || (avgAcceptanceLowerToCurrent == 0))
628
+ {
629
+ weightDifferenceToLower =
630
+ (scaled_lamee[fep_state] - scaled_lamee[fep_state - 1]);
631
+ }
632
+ else
633
+ {
634
+ weightDifferenceToLower = (std::log(avgAcceptanceCurrentToLower)
635
+ - std::log(avgAcceptanceLowerToCurrent))
636
+ + cnval;
637
+ }
638
+ /* Variance of the free energy difference to the one state lower */
639
+ varianceToLower =
640
+ (1.0 / numObservationsCurrentState) * (varianceCurrentToLower)
641
+ + (1.0 / numObservationsLowerState) * (varianceLowerToCurrent);
642
+ }
643
+ }
644
+ }
645
+
646
+ if (fep_state < nlim - 1)
647
+ {
648
+ if (numObservationsCurrentState > 0)
649
+ {
650
+ /* Calculate {avg[xi(i->j)^2] / avg[xi(i->j)]^2 - 1}
651
+ *
652
+ * Note that if avg[xi(i->j)] == 0, also avg[xi(i->j)^2] == 0 (since the
653
+ * acceptances are all positive!), and hence
654
+ * {avg[xi(i->j)^2] / avg[xi(i->j)]^2 - 1} -> 0 for avg[xi(i->j)] -> 0
655
+ * We're catching that case explicitly to avoid numerical
656
+ * problems dividing by zero when the overlap between states is small (#3304)
657
+ */
658
+
659
+ if (avgAcceptanceCurrentToHigher < 0)
660
+ {
661
+ varianceCurrentToHigher =
662
+ avgAcceptanceCurrentToHigherSquared
663
+ / (avgAcceptanceCurrentToHigher * avgAcceptanceCurrentToHigher)
664
+ - 1.0;
665
+ }
666
+ if (numObservationsHigherState > 0)
667
+ {
668
+ /* Calculate {avg[xi(i->j)^2] / avg[xi(i->j)]^2 - 1}
669
+ *
670
+ * Note that if avg[xi(i->j)] == 0, also avg[xi(i->j)^2] == 0 (since the
671
+ * acceptances are all positive!), and hence
672
+ * {avg[xi(i->j)^2] / avg[xi(i->j)]^2 - 1} -> 0 for avg[xi(i->j)] -> 0
673
+ * We're catching that case explicitly to avoid numerical
674
+ * problems dividing by zero when the overlap between states is small (#3304)
675
+ */
676
+ real varianceHigherToCurrent = 0;
677
+ if (avgAcceptanceHigherToCurrent > 0)
678
+ {
679
+ varianceHigherToCurrent =
680
+ avgAcceptanceHigherToCurrentSquared
681
+ / (avgAcceptanceHigherToCurrent * avgAcceptanceHigherToCurrent)
682
+ - 1.0;
683
+ }
684
+ /* Free energy difference to the state one state higher */
685
+ /* if these either of these quantities are zero, the energies are */
686
+ /* way too large for the dynamic range. We need an alternate guesstimate */
687
+ if ((avgAcceptanceHigherToCurrent == 0) || (avgAcceptanceCurrentToHigher == 0))
688
+ {
689
+ weightDifferenceToHigher =
690
+ (scaled_lamee[fep_state + 1] - scaled_lamee[fep_state]);
691
+ }
692
+ else
693
+ {
694
+ weightDifferenceToHigher = (std::log(avgAcceptanceHigherToCurrent)
695
+ - std::log(avgAcceptanceCurrentToHigher))
696
+ + cnval;
697
+ }
698
+ /* Variance of the free energy difference to the one state higher */
699
+ varianceToHigher =
700
+ (1.0 / numObservationsHigherState) * (varianceHigherToCurrent)
701
+ + (1.0 / numObservationsCurrentState) * (varianceCurrentToHigher);
702
+ }
703
+ }
704
+ }
705
+
706
+ if (numObservationsCurrentState > 0)
707
+ {
708
+ omegam_array[nval] = varianceCurrentToLower;
709
+ }
710
+ else
711
+ {
712
+ omegam_array[nval] = 0;
713
+ }
714
+ weightsm_array[nval] = weightDifferenceToLower;
715
+ varm_array[nval] = varianceToLower;
716
+ if (numObservationsLowerState > 0)
717
+ {
718
+ dwm_array[nval] =
719
+ fabs((cnval + std::log((1.0 * numObservationsCurrentState) / numObservationsLowerState))
720
+ - lam_dg[fep_state - 1]);
721
+ }
722
+ else
723
+ {
724
+ dwm_array[nval] = std::fabs(cnval - lam_dg[fep_state - 1]);
725
+ }
726
+
727
+ if (numObservationsCurrentState > 0)
728
+ {
729
+ omegap_array[nval] = varianceCurrentToHigher;
730
+ }
731
+ else
732
+ {
733
+ omegap_array[nval] = 0;
734
+ }
735
+ weightsp_array[nval] = weightDifferenceToHigher;
736
+ varp_array[nval] = varianceToHigher;
737
+ if ((numObservationsHigherState > 0) && (numObservationsCurrentState > 0))
738
+ {
739
+ dwp_array[nval] =
740
+ fabs((cnval + std::log((1.0 * numObservationsHigherState) / numObservationsCurrentState))
741
+ - lam_dg[fep_state]);
742
+ }
743
+ else
744
+ {
745
+ dwp_array[nval] = std::fabs(cnval - lam_dg[fep_state]);
746
+ }
747
+ }
748
+
749
+ /* find the free energy estimate closest to the guessed weight's value */
750
+
751
+ min_nvalm = FindMinimum(dwm_array, maxc);
752
+ omega_m1_0 = omegam_array[min_nvalm];
753
+ clam_weightsm = weightsm_array[min_nvalm];
754
+ clam_varm = varm_array[min_nvalm];
755
+
756
+ min_nvalp = FindMinimum(dwp_array, maxc);
757
+ omega_p1_0 = omegap_array[min_nvalp];
758
+ clam_weightsp = weightsp_array[min_nvalp];
759
+ clam_varp = varp_array[min_nvalp];
760
+
761
+ clam_osum = omega_m1_0 + omega_p1_0;
762
+ clam_minvar = 0;
763
+ if (clam_osum > 0)
764
+ {
765
+ clam_minvar = 0.5 * std::log(clam_osum);
766
+ }
767
+
768
+ if (fep_state > 0)
769
+ {
770
+ lam_dg[fep_state - 1] = clam_weightsm;
771
+ lam_variance[fep_state - 1] = clam_varm;
772
+ }
773
+
774
+ if (fep_state < nlim - 1)
775
+ {
776
+ lam_dg[fep_state] = clam_weightsp;
777
+ lam_variance[fep_state] = clam_varp;
778
+ }
779
+
780
+ if (expand->elamstats == LambdaWeightCalculation::Minvar)
781
+ {
782
+ bSufficientSamples = TRUE;
783
+ /* make sure the number of samples in each state are all
784
+ * past a user-specified threshold
785
+ */
786
+ for (i = 0; i < nlim; i++)
787
+ {
788
+ if (dfhist->n_at_lam[i] < expand->minvarmin)
789
+ {
790
+ bSufficientSamples = FALSE;
791
+ }
792
+ }
793
+ if (bSufficientSamples)
794
+ {
795
+ dfhist->sum_minvar[fep_state] = clam_minvar;
796
+ if (fep_state == 0)
797
+ {
798
+ for (i = 0; i < nlim; i++)
799
+ {
800
+ dfhist->sum_minvar[i] += (expand->minvar_const - clam_minvar);
801
+ }
802
+ expand->minvar_const = clam_minvar;
803
+ dfhist->sum_minvar[fep_state] = 0.0;
804
+ }
805
+ else
806
+ {
807
+ dfhist->sum_minvar[fep_state] -= expand->minvar_const;
808
+ }
809
+ }
810
+ }
811
+
812
+ /* we need to rezero minvar now, since it could change at fep_state = 0 */
813
+ dfhist->sum_dg[0] = 0.0;
814
+ dfhist->sum_variance[0] = 0.0;
815
+ dfhist->sum_weights[0] = dfhist->sum_dg[0] + dfhist->sum_minvar[0]; /* should be zero */
816
+
817
+ for (i = 1; i < nlim; i++)
818
+ {
819
+ dfhist->sum_dg[i] = lam_dg[i - 1] + dfhist->sum_dg[i - 1];
820
+ dfhist->sum_variance[i] =
821
+ std::sqrt(lam_variance[i - 1] + gmx::square(dfhist->sum_variance[i - 1]));
822
+ dfhist->sum_weights[i] = dfhist->sum_dg[i] + dfhist->sum_minvar[i];
823
+ }
824
+
825
+ sfree(lam_dg);
826
+ sfree(lam_variance);
827
+
828
+ sfree(omegam_array);
829
+ sfree(weightsm_array);
830
+ sfree(varm_array);
831
+ sfree(dwm_array);
832
+
833
+ sfree(omegap_array);
834
+ sfree(weightsp_array);
835
+ sfree(varp_array);
836
+ sfree(dwp_array);
837
+ }
838
+ return FALSE;
839
+ }
840
+
841
+ static int ChooseNewLambda(int nlim,
842
+ const t_expanded* expand,
843
+ df_history_t* dfhist,
844
+ int fep_state,
845
+ const real* weighted_lamee,
846
+ double* p_k,
847
+ int64_t seed,
848
+ int64_t step)
849
+ {
850
+ /* Choose new lambda value, and update transition matrix */
851
+
852
+ int i, ifep, minfep, maxfep, lamnew, lamtrial, starting_fep_state;
853
+ real r1, r2, de, trialprob, tprob = 0;
854
+ double * propose, *accept, *remainder;
855
+ double pks;
856
+ real pnorm;
857
+ gmx::ThreeFry2x64<0> rng(
858
+ seed, gmx::RandomDomain::ExpandedEnsemble); // We only draw once, so zero bits internal counter is fine
859
+ gmx::UniformRealDistribution<real> dist;
860
+
861
+ starting_fep_state = fep_state;
862
+ lamnew = fep_state; /* so that there is a default setting -- stays the same */
863
+
864
+ // Don't equilibrate weights when using PLUMED
865
+ if (!plumedswitch || !EWL(expand->elamstats)) /* ignore equilibrating the weights if using WL */
866
+ {
867
+ if ((expand->lmc_forced_nstart > 0) && (dfhist->n_at_lam[nlim - 1] <= expand->lmc_forced_nstart))
868
+ {
869
+ /* Use a marching method to run through the lambdas and get preliminary free energy data,
870
+ before starting 'free' sampling. We start free sampling when we have enough at each lambda */
871
+
872
+ /* if we have enough at this lambda, move on to the next one */
873
+
874
+ if (dfhist->n_at_lam[fep_state] == expand->lmc_forced_nstart)
875
+ {
876
+ lamnew = fep_state + 1;
877
+ if (lamnew == nlim) /* whoops, stepped too far! */
878
+ {
879
+ lamnew -= 1;
880
+ }
881
+ }
882
+ else
883
+ {
884
+ lamnew = fep_state;
885
+ }
886
+ return lamnew;
887
+ }
888
+ }
889
+
890
+ snew(propose, nlim);
891
+ snew(accept, nlim);
892
+ snew(remainder, nlim);
893
+
894
+ for (i = 0; i < expand->lmc_repeats; i++)
895
+ {
896
+ rng.restart(step, i);
897
+ dist.reset();
898
+
899
+ for (ifep = 0; ifep < nlim; ifep++)
900
+ {
901
+ propose[ifep] = 0;
902
+ accept[ifep] = 0;
903
+ }
904
+
905
+ if ((expand->elmcmove == LambdaMoveCalculation::Gibbs)
906
+ || (expand->elmcmove == LambdaMoveCalculation::MetropolisGibbs))
907
+ {
908
+ /* use the Gibbs sampler, with restricted range */
909
+ if (expand->gibbsdeltalam < 0)
910
+ {
911
+ minfep = 0;
912
+ maxfep = nlim - 1;
913
+ }
914
+ else
915
+ {
916
+ minfep = fep_state - expand->gibbsdeltalam;
917
+ maxfep = fep_state + expand->gibbsdeltalam;
918
+ if (minfep < 0)
919
+ {
920
+ minfep = 0;
921
+ }
922
+ if (maxfep > nlim - 1)
923
+ {
924
+ maxfep = nlim - 1;
925
+ }
926
+ }
927
+
928
+ GenerateGibbsProbabilities(weighted_lamee, p_k, &pks, minfep, maxfep);
929
+
930
+ if (expand->elmcmove == LambdaMoveCalculation::Gibbs)
931
+ {
932
+ for (ifep = minfep; ifep <= maxfep; ifep++)
933
+ {
934
+ propose[ifep] = p_k[ifep];
935
+ accept[ifep] = 1.0;
936
+ }
937
+ /* Gibbs sampling */
938
+ r1 = dist(rng);
939
+ for (lamnew = minfep; lamnew <= maxfep; lamnew++)
940
+ {
941
+ if (r1 <= p_k[lamnew])
942
+ {
943
+ break;
944
+ }
945
+ r1 -= p_k[lamnew];
946
+ }
947
+ }
948
+ else if (expand->elmcmove == LambdaMoveCalculation::MetropolisGibbs)
949
+ {
950
+
951
+ /* Metropolized Gibbs sampling */
952
+ for (ifep = minfep; ifep <= maxfep; ifep++)
953
+ {
954
+ remainder[ifep] = 1 - p_k[ifep];
955
+ }
956
+
957
+ /* find the proposal probabilities */
958
+
959
+ if (remainder[fep_state] == 0)
960
+ {
961
+ /* only the current state has any probability */
962
+ /* we have to stay at the current state */
963
+ lamnew = fep_state;
964
+ }
965
+ else
966
+ {
967
+ for (ifep = minfep; ifep <= maxfep; ifep++)
968
+ {
969
+ if (ifep != fep_state)
970
+ {
971
+ propose[ifep] = p_k[ifep] / remainder[fep_state];
972
+ }
973
+ else
974
+ {
975
+ propose[ifep] = 0;
976
+ }
977
+ }
978
+
979
+ r1 = dist(rng);
980
+ for (lamtrial = minfep; lamtrial <= maxfep; lamtrial++)
981
+ {
982
+ pnorm = p_k[lamtrial] / remainder[fep_state];
983
+ if (lamtrial != fep_state)
984
+ {
985
+ if (r1 <= pnorm)
986
+ {
987
+ break;
988
+ }
989
+ r1 -= pnorm;
990
+ }
991
+ }
992
+
993
+ /* we have now selected lamtrial according to p(lamtrial)/1-p(fep_state) */
994
+ tprob = 1.0;
995
+ /* trial probability is min{1,\frac{1 - p(old)}{1-p(new)} MRS 1/8/2008 */
996
+ trialprob = (remainder[fep_state]) / (remainder[lamtrial]);
997
+ if (trialprob < tprob)
998
+ {
999
+ tprob = trialprob;
1000
+ }
1001
+ r2 = dist(rng);
1002
+ if (r2 < tprob)
1003
+ {
1004
+ lamnew = lamtrial;
1005
+ }
1006
+ else
1007
+ {
1008
+ lamnew = fep_state;
1009
+ }
1010
+ }
1011
+
1012
+ /* now figure out the acceptance probability for each */
1013
+ for (ifep = minfep; ifep <= maxfep; ifep++)
1014
+ {
1015
+ tprob = 1.0;
1016
+ if (remainder[ifep] != 0)
1017
+ {
1018
+ trialprob = (remainder[fep_state]) / (remainder[ifep]);
1019
+ }
1020
+ else
1021
+ {
1022
+ trialprob = 1.0; /* this state is the only choice! */
1023
+ }
1024
+ if (trialprob < tprob)
1025
+ {
1026
+ tprob = trialprob;
1027
+ }
1028
+ /* probability for fep_state=0, but that's fine, it's never proposed! */
1029
+ accept[ifep] = tprob;
1030
+ }
1031
+ }
1032
+
1033
+ if (lamnew > maxfep)
1034
+ {
1035
+ /* it's possible some rounding is failing */
1036
+ if (gmx_within_tol(remainder[fep_state], 0, 50 * GMX_DOUBLE_EPS))
1037
+ {
1038
+ /* numerical rounding error -- no state other than the original has weight */
1039
+ lamnew = fep_state;
1040
+ }
1041
+ else
1042
+ {
1043
+ /* probably not a numerical issue */
1044
+ int loc = 0;
1045
+ int nerror = 200 + (maxfep - minfep + 1) * 60;
1046
+ char* errorstr;
1047
+ snew(errorstr, nerror);
1048
+ /* if its greater than maxfep, then something went wrong -- probably underflow
1049
+ in the calculation of sum weights. Generated detailed info for failure */
1050
+ loc += sprintf(
1051
+ errorstr,
1052
+ "Something wrong in choosing new lambda state with a Gibbs move -- "
1053
+ "probably underflow in weight determination.\nDenominator is: "
1054
+ "%3d%17.10e\n i dE numerator weights\n",
1055
+ 0,
1056
+ pks);
1057
+ for (ifep = minfep; ifep <= maxfep; ifep++)
1058
+ {
1059
+ loc += sprintf(&errorstr[loc],
1060
+ "%3d %17.10e%17.10e%17.10e\n",
1061
+ ifep,
1062
+ weighted_lamee[ifep],
1063
+ p_k[ifep],
1064
+ dfhist->sum_weights[ifep]);
1065
+ }
1066
+ gmx_fatal(FARGS, "%s", errorstr);
1067
+ }
1068
+ }
1069
+ }
1070
+ else if ((expand->elmcmove == LambdaMoveCalculation::Metropolis)
1071
+ || (expand->elmcmove == LambdaMoveCalculation::Barker))
1072
+ {
1073
+ /* use the metropolis sampler with trial +/- 1 */
1074
+ r1 = dist(rng);
1075
+ if (r1 < 0.5)
1076
+ {
1077
+ if (fep_state == 0)
1078
+ {
1079
+ lamtrial = fep_state;
1080
+ }
1081
+ else
1082
+ {
1083
+ lamtrial = fep_state - 1;
1084
+ }
1085
+ }
1086
+ else
1087
+ {
1088
+ if (fep_state == nlim - 1)
1089
+ {
1090
+ lamtrial = fep_state;
1091
+ }
1092
+ else
1093
+ {
1094
+ lamtrial = fep_state + 1;
1095
+ }
1096
+ }
1097
+
1098
+ de = weighted_lamee[lamtrial] - weighted_lamee[fep_state];
1099
+ if (expand->elmcmove == LambdaMoveCalculation::Metropolis)
1100
+ {
1101
+ tprob = 1.0;
1102
+ if (de < 0)
1103
+ {
1104
+ tprob = std::exp(de);
1105
+ }
1106
+ propose[fep_state] = 0;
1107
+ propose[lamtrial] = 1.0; /* note that this overwrites the above line if fep_state = ntrial, which only occurs at the ends */
1108
+ accept[fep_state] =
1109
+ 1.0; /* doesn't actually matter, never proposed unless fep_state = ntrial, in which case it's 1.0 anyway */
1110
+ accept[lamtrial] = tprob;
1111
+ }
1112
+ else if (expand->elmcmove == LambdaMoveCalculation::Barker)
1113
+ {
1114
+ if (de > 0) /* Numerically stable version */
1115
+ {
1116
+ tprob = 1.0 / (1.0 + std::exp(-de));
1117
+ }
1118
+ else if (de < 0)
1119
+ {
1120
+ tprob = std::exp(de) / (std::exp(de) + 1.0);
1121
+ }
1122
+ propose[fep_state] = (1 - tprob);
1123
+ propose[lamtrial] +=
1124
+ tprob; /* we add, to account for the fact that at the end, they might be the same point */
1125
+ accept[fep_state] = 1.0;
1126
+ accept[lamtrial] = 1.0;
1127
+ }
1128
+
1129
+ r2 = dist(rng);
1130
+ if (r2 < tprob)
1131
+ {
1132
+ lamnew = lamtrial;
1133
+ }
1134
+ else
1135
+ {
1136
+ lamnew = fep_state;
1137
+ }
1138
+ }
1139
+
1140
+ for (ifep = 0; ifep < nlim; ifep++)
1141
+ {
1142
+ dfhist->Tij[fep_state][ifep] += propose[ifep] * accept[ifep];
1143
+ dfhist->Tij[fep_state][fep_state] += propose[ifep] * (1.0 - accept[ifep]);
1144
+ }
1145
+ fep_state = lamnew;
1146
+ }
1147
+
1148
+ dfhist->Tij_empirical[starting_fep_state][lamnew] += 1.0;
1149
+
1150
+ sfree(propose);
1151
+ sfree(accept);
1152
+ sfree(remainder);
1153
+
1154
+ return lamnew;
1155
+ }
1156
+
1157
+ /* print out the weights to the log, along with current state */
1158
+ void PrintFreeEnergyInfoToFile(FILE* outfile,
1159
+ const t_lambda* fep,
1160
+ const t_expanded* expand,
1161
+ const t_simtemp* simtemp,
1162
+ const df_history_t* dfhist,
1163
+ int fep_state,
1164
+ int frequency,
1165
+ int64_t step)
1166
+ {
1167
+ int nlim, ifep, jfep;
1168
+ real dw, dg, dv, Tprint;
1169
+ gmx_bool bSimTemp = FALSE;
1170
+
1171
+ nlim = fep->n_lambda;
1172
+ if (simtemp != nullptr)
1173
+ {
1174
+ bSimTemp = TRUE;
1175
+ }
1176
+
1177
+ if (step % frequency == 0)
1178
+ {
1179
+ fprintf(outfile, " MC-lambda information\n");
1180
+ // Ignore Wang-Landau when using plumed
1181
+ if (EWL(expand->elamstats) && (!(dfhist->bEquil)) && !plumedswitch) /* PLUMED */
1182
+ {
1183
+ fprintf(outfile, " Wang-Landau incrementor is: %11.5g\n", dfhist->wl_delta);
1184
+ }
1185
+ fprintf(outfile, " N");
1186
+ for (auto i : keysOf(fep->separate_dvdl))
1187
+ {
1188
+ if (fep->separate_dvdl[i])
1189
+ {
1190
+ fprintf(outfile, "%7s", enumValueToString(i));
1191
+ }
1192
+ else if ((i == FreeEnergyPerturbationCouplingType::Temperature) && bSimTemp)
1193
+ {
1194
+ fprintf(outfile, "%10s", enumValueToString(i)); /* more space for temperature formats */
1195
+ }
1196
+ }
1197
+ fprintf(outfile, " Count ");
1198
+ if (expand->elamstats == LambdaWeightCalculation::Minvar)
1199
+ {
1200
+ fprintf(outfile, "W(in kT) G(in kT) dG(in kT) dV(in kT)\n");
1201
+ }
1202
+ else
1203
+ {
1204
+ fprintf(outfile, "G(in kT) dG(in kT)\n");
1205
+ }
1206
+ for (ifep = 0; ifep < nlim; ifep++)
1207
+ {
1208
+ if (ifep == nlim - 1)
1209
+ {
1210
+ dw = 0.0;
1211
+ dg = 0.0;
1212
+ dv = 0.0;
1213
+ }
1214
+ else
1215
+ {
1216
+ dw = dfhist->sum_weights[ifep + 1] - dfhist->sum_weights[ifep];
1217
+ dg = dfhist->sum_dg[ifep + 1] - dfhist->sum_dg[ifep];
1218
+ dv = std::sqrt(gmx::square(dfhist->sum_variance[ifep + 1])
1219
+ - gmx::square(dfhist->sum_variance[ifep]));
1220
+ }
1221
+ fprintf(outfile, "%3d", (ifep + 1));
1222
+ for (auto i : keysOf(fep->separate_dvdl))
1223
+ {
1224
+ if (fep->separate_dvdl[i])
1225
+ {
1226
+ fprintf(outfile, "%7.3f", fep->all_lambda[i][ifep]);
1227
+ }
1228
+ else if (i == FreeEnergyPerturbationCouplingType::Temperature && bSimTemp)
1229
+ {
1230
+ fprintf(outfile, "%9.3f", simtemp->temperatures[ifep]);
1231
+ }
1232
+ }
1233
+ // No Wang-Landau when using Plumed
1234
+ if (EWL(expand->elamstats) && (!plumedswitch) /* PLUMED */
1235
+ && (!(dfhist->bEquil))) /* if performing WL and still haven't equilibrated */
1236
+ {
1237
+ if (expand->elamstats == LambdaWeightCalculation::WL)
1238
+ {
1239
+ fprintf(outfile, " %8d", static_cast<int>(dfhist->wl_histo[ifep]));
1240
+ }
1241
+ else
1242
+ {
1243
+ fprintf(outfile, " %8.3f", dfhist->wl_histo[ifep]);
1244
+ }
1245
+ }
1246
+ else /* we have equilibrated weights */
1247
+ {
1248
+ fprintf(outfile, " %8d", dfhist->n_at_lam[ifep]);
1249
+ }
1250
+ if (expand->elamstats == LambdaWeightCalculation::Minvar)
1251
+ {
1252
+ fprintf(outfile,
1253
+ " %10.5f %10.5f %10.5f %10.5f",
1254
+ dfhist->sum_weights[ifep],
1255
+ dfhist->sum_dg[ifep],
1256
+ dg,
1257
+ dv);
1258
+ }
1259
+ else
1260
+ {
1261
+ fprintf(outfile, " %10.5f %10.5f", dfhist->sum_weights[ifep], dw);
1262
+ }
1263
+ if (ifep == fep_state)
1264
+ {
1265
+ fprintf(outfile, " <<\n");
1266
+ }
1267
+ else
1268
+ {
1269
+ fprintf(outfile, " \n");
1270
+ }
1271
+ }
1272
+ fprintf(outfile, "\n");
1273
+
1274
+ if ((step % expand->nstTij == 0) && (expand->nstTij > 0) && (step > 0))
1275
+ {
1276
+ fprintf(outfile, " Transition Matrix\n");
1277
+ for (ifep = 0; ifep < nlim; ifep++)
1278
+ {
1279
+ fprintf(outfile, "%12d", (ifep + 1));
1280
+ }
1281
+ fprintf(outfile, "\n");
1282
+ for (ifep = 0; ifep < nlim; ifep++)
1283
+ {
1284
+ for (jfep = 0; jfep < nlim; jfep++)
1285
+ {
1286
+ if (dfhist->n_at_lam[ifep] > 0)
1287
+ {
1288
+ if (expand->bSymmetrizedTMatrix)
1289
+ {
1290
+ Tprint = (dfhist->Tij[ifep][jfep] + dfhist->Tij[jfep][ifep])
1291
+ / (dfhist->n_at_lam[ifep] + dfhist->n_at_lam[jfep]);
1292
+ }
1293
+ else
1294
+ {
1295
+ Tprint = (dfhist->Tij[ifep][jfep]) / (dfhist->n_at_lam[ifep]);
1296
+ }
1297
+ }
1298
+ else
1299
+ {
1300
+ Tprint = 0.0;
1301
+ }
1302
+ fprintf(outfile, "%12.8f", Tprint);
1303
+ }
1304
+ fprintf(outfile, "%3d\n", (ifep + 1));
1305
+ }
1306
+
1307
+ fprintf(outfile, " Empirical Transition Matrix\n");
1308
+ for (ifep = 0; ifep < nlim; ifep++)
1309
+ {
1310
+ fprintf(outfile, "%12d", (ifep + 1));
1311
+ }
1312
+ fprintf(outfile, "\n");
1313
+ for (ifep = 0; ifep < nlim; ifep++)
1314
+ {
1315
+ for (jfep = 0; jfep < nlim; jfep++)
1316
+ {
1317
+ if (dfhist->n_at_lam[ifep] > 0)
1318
+ {
1319
+ if (expand->bSymmetrizedTMatrix)
1320
+ {
1321
+ Tprint = (dfhist->Tij_empirical[ifep][jfep] + dfhist->Tij_empirical[jfep][ifep])
1322
+ / (dfhist->n_at_lam[ifep] + dfhist->n_at_lam[jfep]);
1323
+ }
1324
+ else
1325
+ {
1326
+ Tprint = dfhist->Tij_empirical[ifep][jfep] / (dfhist->n_at_lam[ifep]);
1327
+ }
1328
+ }
1329
+ else
1330
+ {
1331
+ Tprint = 0.0;
1332
+ }
1333
+ fprintf(outfile, "%12.8f", Tprint);
1334
+ }
1335
+ fprintf(outfile, "%3d\n", (ifep + 1));
1336
+ }
1337
+ }
1338
+ }
1339
+ }
1340
+
1341
+ int expandedEnsembleUpdateLambdaState(FILE* log,
1342
+ const t_inputrec* ir,
1343
+ const gmx_enerdata_t* enerd,
1344
+ int fep_state,
1345
+ df_history_t* dfhist,
1346
+ int64_t step,
1347
+ real* realFepState) /* PLUMED */
1348
+ {
1349
+ real * pfep_lamee, *scaled_lamee, *weighted_lamee;
1350
+ double* p_k;
1351
+ int i, nlim, lamnew, totalsamples;
1352
+ real oneovert, maxscaled = 0, maxweighted = 0;
1353
+ t_expanded* expand;
1354
+ t_simtemp* simtemp;
1355
+ gmx_bool bIfReset, bSwitchtoOneOverT, bDoneEquilibrating = FALSE;
1356
+
1357
+ expand = ir->expandedvals.get();
1358
+ simtemp = ir->simtempvals.get();
1359
+ nlim = ir->fepvals->n_lambda;
1360
+
1361
+ snew(scaled_lamee, nlim);
1362
+ snew(weighted_lamee, nlim);
1363
+ snew(pfep_lamee, nlim);
1364
+ snew(p_k, nlim);
1365
+
1366
+ /* update the count at the current lambda*/
1367
+ dfhist->n_at_lam[fep_state]++;
1368
+
1369
+ /* need to calculate the PV term somewhere, but not needed here? Not until there's a lambda
1370
+ state that's pressure controlled.*/
1371
+ /*
1372
+ pVTerm = 0;
1373
+ where does this PV term go?
1374
+ for (i=0;i<nlim;i++)
1375
+ {
1376
+ fep_lamee[i] += pVTerm;
1377
+ }
1378
+ */
1379
+
1380
+ /* determine the minimum value to avoid overflow. Probably a better way to do this */
1381
+ /* we don't need to include the pressure term, since the volume is the same between the two.
1382
+ is there some term we are neglecting, however? */
1383
+
1384
+ if (ir->efep != FreeEnergyPerturbationType::No)
1385
+ {
1386
+ for (i = 0; i < nlim; i++)
1387
+ {
1388
+ if (ir->bSimTemp)
1389
+ {
1390
+ /* Note -- this assumes no mass changes, since kinetic energy is not added . . . */
1391
+ scaled_lamee[i] =
1392
+ enerd->foreignLambdaTerms.deltaH(i) / (simtemp->temperatures[i] * gmx::c_boltz)
1393
+ + enerd->term[F_EPOT]
1394
+ * (1.0 / (simtemp->temperatures[i])
1395
+ - 1.0 / (simtemp->temperatures[fep_state]))
1396
+ / gmx::c_boltz;
1397
+ }
1398
+ else
1399
+ {
1400
+ scaled_lamee[i] = enerd->foreignLambdaTerms.deltaH(i) / (expand->mc_temp * gmx::c_boltz);
1401
+ /* mc_temp is currently set to the system reft unless otherwise defined */
1402
+ }
1403
+
1404
+ /* save these energies for printing, so they don't get overwritten by the next step */
1405
+ /* they aren't overwritten in the non-free energy case, but we always print with these
1406
+ for simplicity */
1407
+ }
1408
+ }
1409
+ else
1410
+ {
1411
+ if (ir->bSimTemp)
1412
+ {
1413
+ for (i = 0; i < nlim; i++)
1414
+ {
1415
+ scaled_lamee[i] =
1416
+ enerd->term[F_EPOT]
1417
+ * (1.0 / simtemp->temperatures[i] - 1.0 / simtemp->temperatures[fep_state])
1418
+ / gmx::c_boltz;
1419
+ }
1420
+ }
1421
+ }
1422
+
1423
+ for (i = 0; i < nlim; i++)
1424
+ {
1425
+ pfep_lamee[i] = scaled_lamee[i];
1426
+
1427
+ weighted_lamee[i] = dfhist->sum_weights[i] - scaled_lamee[i];
1428
+ if (i == 0)
1429
+ {
1430
+ maxscaled = scaled_lamee[i];
1431
+ maxweighted = weighted_lamee[i];
1432
+ }
1433
+ else
1434
+ {
1435
+ if (scaled_lamee[i] > maxscaled)
1436
+ {
1437
+ maxscaled = scaled_lamee[i];
1438
+ }
1439
+ if (weighted_lamee[i] > maxweighted)
1440
+ {
1441
+ maxweighted = weighted_lamee[i];
1442
+ }
1443
+ }
1444
+ }
1445
+
1446
+ for (i = 0; i < nlim; i++)
1447
+ {
1448
+ scaled_lamee[i] -= maxscaled;
1449
+ weighted_lamee[i] -= maxweighted;
1450
+ }
1451
+
1452
+ if (plumedswitch && !EWL(expand->elamstats)) /* PLUMED */
1453
+ {
1454
+ // Update weights at all lambda states with current values from Plumed.
1455
+ // For acceptance criterion, expanded ensemble is expecting the weight at
1456
+ // lambda i=0 to be zero.
1457
+ real zeroBias = 0;
1458
+ for (i = 0; i < nlim; i++)
1459
+ {
1460
+ *realFepState = i;
1461
+ real bias = 0;
1462
+ plumed_cmd(plumedmain, "prepareCalc", nullptr);
1463
+ plumed_cmd(plumedmain, "performCalcNoForces", nullptr);
1464
+ plumed_cmd(plumedmain, "getBias", &bias);
1465
+ bias /= expand->mc_temp * gmx::c_boltz;
1466
+ if (i == 0)
1467
+ {
1468
+ zeroBias = bias;
1469
+ }
1470
+ dfhist->sum_weights[i] = -bias + zeroBias;
1471
+ }
1472
+ *realFepState = fep_state;
1473
+ }
1474
+ else // Don't update weights using different method when PLUMED is active
1475
+ {
1476
+ /* update weights - we decide whether or not to actually do this inside */
1477
+
1478
+ bDoneEquilibrating =
1479
+ UpdateWeights(nlim, expand, dfhist, fep_state, scaled_lamee, weighted_lamee, step);
1480
+ if (bDoneEquilibrating)
1481
+ {
1482
+ if (log)
1483
+ {
1484
+ fprintf(log,
1485
+ "\nStep %" PRId64 ": Weights have equilibrated, using criteria: %s\n",
1486
+ step,
1487
+ enumValueToString(expand->elmceq));
1488
+ }
1489
+ }
1490
+ }
1491
+
1492
+ // Accept / reject is handled by GROMACS (possibly with PLUMED weights).
1493
+ lamnew = ChooseNewLambda(
1494
+ nlim, expand, dfhist, fep_state, weighted_lamee, p_k, ir->expandedvals->lmc_seed, step);
1495
+
1496
+ /* now check on the Wang-Landau updating critera */
1497
+
1498
+ if (EWL(expand->elamstats))
1499
+ {
1500
+ bSwitchtoOneOverT = FALSE;
1501
+ if (expand->bWLoneovert)
1502
+ {
1503
+ totalsamples = 0;
1504
+ for (i = 0; i < nlim; i++)
1505
+ {
1506
+ totalsamples += dfhist->n_at_lam[i];
1507
+ }
1508
+ oneovert = (1.0 * nlim) / totalsamples;
1509
+ /* oneovert has decreasd by a bit since last time, so we actually make sure its within one of this number */
1510
+ /* switch to 1/t incrementing when wl_delta has decreased at least once, and wl_delta is now less than 1/t */
1511
+ if ((dfhist->wl_delta <= ((totalsamples) / (totalsamples - 1.00001)) * oneovert)
1512
+ && (dfhist->wl_delta < expand->init_wl_delta))
1513
+ {
1514
+ bSwitchtoOneOverT = TRUE;
1515
+ }
1516
+ }
1517
+ if (bSwitchtoOneOverT)
1518
+ {
1519
+ dfhist->wl_delta =
1520
+ oneovert; /* now we reduce by this each time, instead of only at flatness */
1521
+ }
1522
+ else
1523
+ {
1524
+ bIfReset = CheckHistogramRatios(nlim, dfhist->wl_histo, expand->wl_ratio);
1525
+ if (bIfReset)
1526
+ {
1527
+ for (i = 0; i < nlim; i++)
1528
+ {
1529
+ dfhist->wl_histo[i] = 0;
1530
+ }
1531
+ dfhist->wl_delta *= expand->wl_scale;
1532
+ if (log)
1533
+ {
1534
+ fprintf(log, "\nStep %d: weights are now:", static_cast<int>(step));
1535
+ for (i = 0; i < nlim; i++)
1536
+ {
1537
+ fprintf(log, " %.5f", dfhist->sum_weights[i]);
1538
+ }
1539
+ fprintf(log, "\n");
1540
+ }
1541
+ }
1542
+ }
1543
+ }
1544
+ sfree(pfep_lamee);
1545
+ sfree(scaled_lamee);
1546
+ sfree(weighted_lamee);
1547
+ sfree(p_k);
1548
+
1549
+ return lamnew;
1550
+ }
1551
+
1552
+ //! Update reference temperature for simulated tempering state change
1553
+ static void simulatedTemperingUpdateTemperature(const t_inputrec& ir,
1554
+ gmx_ekindata_t* ekind,
1555
+ t_state* state,
1556
+ t_extmass* MassQ,
1557
+ rvec* v,
1558
+ const int homenr,
1559
+ gmx::ArrayRef<const unsigned short> cTC,
1560
+ const int lamnew)
1561
+ {
1562
+ const t_simtemp* simtemp = ir.simtempvals.get();
1563
+ std::vector<real> buf_ngtc(ir.opts.ngtc);
1564
+
1565
+ for (int i = 0; i < ir.opts.ngtc; i++)
1566
+ {
1567
+ const real tOld = ekind->currentReferenceTemperature(i);
1568
+ if (tOld > 0)
1569
+ {
1570
+ ekind->setCurrentReferenceTemperature(i, simtemp->temperatures[lamnew]);
1571
+ /* using the buffer as temperature scaling */
1572
+ buf_ngtc[i] = std::sqrt(ekind->currentReferenceTemperature(i) / tOld);
1573
+ }
1574
+ }
1575
+
1576
+ /* we don't need to manipulate the ekind information, as it isn't due to be reset until the next step anyway */
1577
+
1578
+ for (int n = 0; n < homenr; n++)
1579
+ {
1580
+ const int gt = cTC.empty() ? 0 : cTC[n];
1581
+ for (int d = 0; d < DIM; d++)
1582
+ {
1583
+ v[n][d] *= buf_ngtc[gt];
1584
+ }
1585
+ }
1586
+
1587
+ if (inputrecNptTrotter(&ir) || inputrecNphTrotter(&ir) || inputrecNvtTrotter(&ir))
1588
+ {
1589
+ /* we need to recalculate the masses if the temperature has changed */
1590
+ init_npt_masses(ir, *ekind, state, MassQ, FALSE);
1591
+ for (int i = 0; i < state->nnhpres; i++)
1592
+ {
1593
+ for (int j = 0; j < ir.opts.nhchainlength; j++)
1594
+ {
1595
+ state->nhpres_vxi[i + j] *= buf_ngtc[i];
1596
+ }
1597
+ }
1598
+ for (int i = 0; i < ir.opts.ngtc; i++)
1599
+ {
1600
+ for (int j = 0; j < ir.opts.nhchainlength; j++)
1601
+ {
1602
+ state->nosehoover_vxi[i + j] *= buf_ngtc[i];
1603
+ }
1604
+ }
1605
+ }
1606
+ }
1607
+
1608
+ int ExpandedEnsembleDynamics(FILE* log,
1609
+ const t_inputrec& ir,
1610
+ const gmx_enerdata_t& enerd,
1611
+ gmx_ekindata_t* ekind,
1612
+ t_state* state,
1613
+ t_extmass* MassQ,
1614
+ int fep_state,
1615
+ df_history_t* dfhist,
1616
+ int64_t step,
1617
+ rvec* v,
1618
+ real* realFepState, /* PLUMED */
1619
+ const int homenr,
1620
+ gmx::ArrayRef<const unsigned short> cTC)
1621
+ /* Note that the state variable is only needed for simulated tempering, not
1622
+ Hamiltonian expanded ensemble. May be able to remove it after integrator refactoring. */
1623
+ {
1624
+ const int newLambda = expandedEnsembleUpdateLambdaState(log, &ir, &enerd, fep_state, dfhist, step, realFepState); /* PLUMED */
1625
+ // if using simulated tempering, we need to adjust the temperatures
1626
+ // only need to change the temperatures if we change the state
1627
+ if (ir.bSimTemp && (newLambda != fep_state))
1628
+ {
1629
+ simulatedTemperingUpdateTemperature(ir, ekind, state, MassQ, v, homenr, cTC, newLambda);
1630
+ }
1631
+ return newLambda;
1632
+ }