hillclimber 0.1.5a8__cp314-cp314-macosx_15_0_x86_64.whl

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