hillclimber 0.1.6__cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

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