经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 大数据/云/AI » 人工智能基础 » 查看文章
Plumed分子模拟后分析
来源:cnblogs  作者:DECHIN  时间:2024/5/6 16:16:09  对本文有异议

技术背景

在前面的几篇博客中,我们分别介绍过Histogram算法的使用Plumed安装与简单使用。Plumed一般就是两种用法:要么在运行分子动力学模拟的过程中实时的对接,要么就是把分子模拟的相关轨迹保存下来,然后再使用Plumed进行后分析,本文介绍的是后面这种使用方法。

轨迹准备

做后分析,我们要先准备一手轨迹。比如我们做Histogram,那么就需要保留一条CV的轨迹,或者说反应坐标的轨迹。一般为了归一化的需求,我们可能还需要保留反应坐标所对应的单点能,或者称之为Bias偏置势。如下是一条轨迹的示例record_cv_bias.txt,含有100个点:

  1. #! FIELDS time rbias dcomb
  2. 0 1.0 0.722307
  3. 1 1.0 0.929853
  4. 2 1.0 1.046353
  5. 3 1.0 0.849326
  6. 4 1.0 0.635665
  7. 5 1.0 1.133585
  8. 6 1.0 1.602735
  9. 7 1.0 1.11138
  10. 8 1.0 0.815045
  11. 9 1.0 0.744088
  12. 10 1.0 0.631533
  13. 11 1.0 1.006049
  14. 12 1.0 0.507855
  15. 13 1.0 0.620414
  16. 14 1.0 1.43557
  17. 15 1.0 0.798832
  18. 16 1.0 1.007135
  19. 17 1.0 0.684447
  20. 18 1.0 1.073844
  21. 19 1.0 0.952023
  22. 20 1.0 0.754293
  23. 21 1.0 0.530406
  24. 22 1.0 1.078594
  25. 23 1.0 1.325044
  26. 24 1.0 1.418314
  27. 25 1.0 1.110357
  28. 26 1.0 0.964378
  29. 27 1.0 0.893131
  30. 28 1.0 1.473515
  31. 29 1.0 1.103729
  32. 30 1.0 1.019812
  33. 31 1.0 1.037889
  34. 32 1.0 1.092906
  35. 33 1.0 0.602312
  36. 34 1.0 1.016394
  37. 35 1.0 0.845226
  38. 36 1.0 1.210281
  39. 37 1.0 0.744589
  40. 38 1.0 0.666467
  41. 39 1.0 1.276913
  42. 40 1.0 0.976801
  43. 41 1.0 0.92263
  44. 42 1.0 1.386575
  45. 43 1.0 1.243241
  46. 44 1.0 1.442755
  47. 45 1.0 1.284636
  48. 46 1.0 0.756184
  49. 47 1.0 1.162758
  50. 48 1.0 1.177665
  51. 49 1.0 0.717487
  52. 50 1.0 1.193379
  53. 51 1.0 0.798996
  54. 52 1.0 1.045093
  55. 53 1.0 1.489541
  56. 54 1.0 1.067574
  57. 55 1.0 1.10109
  58. 56 1.0 1.135074
  59. 57 1.0 1.049557
  60. 58 1.0 0.362635
  61. 59 1.0 1.030856
  62. 60 1.0 1.323538
  63. 61 1.0 1.405822
  64. 62 1.0 0.935292
  65. 63 1.0 0.868032
  66. 64 1.0 0.946401
  67. 65 1.0 1.468123
  68. 66 1.0 1.062565
  69. 67 1.0 1.05637
  70. 68 1.0 0.962974
  71. 69 1.0 1.50403
  72. 70 1.0 0.95933
  73. 71 1.0 1.218142
  74. 72 1.0 1.303102
  75. 73 1.0 0.876645
  76. 74 1.0 1.188313
  77. 75 1.0 1.31572
  78. 76 1.0 0.693456
  79. 77 1.0 0.54377
  80. 78 1.0 1.026873
  81. 79 1.0 1.3925
  82. 80 1.0 1.317733
  83. 81 1.0 0.972162
  84. 82 1.0 1.373311
  85. 83 1.0 1.244547
  86. 84 1.0 1.00565
  87. 85 1.0 1.180062
  88. 86 1.0 1.221193
  89. 87 1.0 1.046702
  90. 88 1.0 1.409161
  91. 89 1.0 1.132955
  92. 90 1.0 0.428334
  93. 91 1.0 0.890674
  94. 92 1.0 0.63586
  95. 93 1.0 0.997099
  96. 94 1.0 0.969676
  97. 95 1.0 1.280118
  98. 96 1.0 1.19793
  99. 97 1.0 1.112535
  100. 98 1.0 1.388056
  101. 99 1.0 0.946911

有了轨迹之后,写一个简单的Plumed配置文件plumed.dat

  1. cv: READ FILE=record_cv_bias.txt VALUES=dcomb IGNORE_TIME
  2. w: READ FILE=record_cv_bias.txt VALUES=rbias IGNORE_TIME
  3. rw: REWEIGHT_BIAS ARG=w TEMP=300
  4. hh: HISTOGRAM ...
  5. ARG=cv
  6. KERNEL=gaussian
  7. GRID_MIN=0.3
  8. GRID_MAX=1.65
  9. GRID_BIN=50
  10. BANDWIDTH=0.05
  11. NORMALIZATION=true
  12. LOGWEIGHTS=rw
  13. ...
  14. DUMPGRID GRID=hh FILE=histo

这个文件的逐行释义为:

  1. 1. 读取record_cv_bias.txt文件中标签为dcomb的一列,作为cv
  2. 2. 读取record_cv_bias.txt文件中标签为rbias的一列,作为w
  3. 3. 使用w定义一个归一化的系数rw,对应的温度为300K
  4. 4~13. 定义Histogram参数,使用高斯核,区间最小值为0.3,区间最大值为1.65,区间内分50个格子,波包带宽为0.05,使用rw进行归一化
  5. 14. 将输出数据保存到名为histo的文件内

运行Plumed

安装好plumed以后,之间在对应文件的目录下运行:

  1. $ plumed driver --plumed plumed.dat --noatoms
  2. PLUMED: PLUMED is starting
  3. PLUMED: Version: 2.7.1 (git: Unknown) compiled on Jul 12 2021 at 09:24:30
  4. PLUMED: Please cite these papers when using PLUMED [1][2]
  5. PLUMED: For further information see the PLUMED web page at http://www.plumed.org
  6. PLUMED: Root: /usr/local/lib/plumed
  7. PLUMED: For installed feature, see /usr/local/lib/plumed/src/config/config.txt
  8. PLUMED: Molecular dynamics engine: driver
  9. PLUMED: Precision of reals: 8
  10. PLUMED: Running over 1 node
  11. PLUMED: Number of threads: 1
  12. PLUMED: Cache line size: 512
  13. PLUMED: Number of atoms: 0
  14. PLUMED: File suffix:
  15. PLUMED: FILE: plumed.dat
  16. PLUMED: Action READ
  17. PLUMED: with label cv
  18. PLUMED: with stride 1
  19. PLUMED: reading data from file record_cv_bias.txt
  20. PLUMED: reading value dcomb and storing as cv
  21. PLUMED: Action READ
  22. PLUMED: with label w
  23. PLUMED: with stride 1
  24. PLUMED: reading data from file record_cv_bias.txt
  25. PLUMED: reading value rbias and storing as w
  26. PLUMED: Action REWEIGHT_BIAS
  27. PLUMED: with label rw
  28. PLUMED: with arguments w
  29. PLUMED: Action HISTOGRAM
  30. PLUMED: with label hh
  31. PLUMED: with stride 1
  32. PLUMED: with arguments cv
  33. PLUMED: reweighting using weights from rw
  34. PLUMED: grid of 51 equally spaced points between (0.3) and (1.65)
  35. PLUMED: Action DUMPGRID
  36. PLUMED: with label @4
  37. PLUMED: with stride 0
  38. PLUMED: outputting grid calculated by action hh to file named histo with format %f
  39. PLUMED: outputting data for replicas 0 END FILE: plumed.dat
  40. PLUMED: Timestep: 1.000000
  41. PLUMED: KbT has not been set by the MD engine
  42. PLUMED: It should be set by hand where needed
  43. PLUMED: Relevant bibliography:
  44. PLUMED: [1] The PLUMED consortium, Nat. Methods 16, 670 (2019)
  45. PLUMED: [2] Tribello, Bonomi, Branduardi, Camilloni, and Bussi, Comput. Phys. Commun. 185, 604 (2014)
  46. PLUMED: Please read and cite where appropriate!
  47. PLUMED: Finished setup
  48. PLUMED: Cycles Total Average Minimum Maximum
  49. PLUMED: 1 0.007538 0.007538 0.007538 0.007538
  50. PLUMED: 1 Prepare dependencies 99 0.000267 0.000003 0.000002 0.000008
  51. PLUMED: 2 Sharing data 99 0.000007 0.000000 0.000000 0.000000
  52. PLUMED: 3 Waiting for data 99 0.000010 0.000000 0.000000 0.000000
  53. PLUMED: 4 Calculating (forward loop) 99 0.001478 0.000015 0.000014 0.000057
  54. PLUMED: 5 Applying (backward loop) 99 0.000130 0.000001 0.000001 0.000003
  55. PLUMED: 6 Update 99 0.003019 0.000030 0.000014 0.000093

运行完成后,如果没有报错,会在当前目录下生成一个histo文件,内容为:

  1. #! FIELDS cv hh dhh_cv
  2. #! SET normalisation 146.331611
  3. #! SET min_cv 0.3
  4. #! SET max_cv 1.65
  5. #! SET nbins_cv 50
  6. #! SET periodic_cv false
  7. 0.300000 0.040185 1.087032
  8. 0.327000 0.073737 1.333674
  9. 0.354000 0.108112 1.138788
  10. 0.381000 0.132720 0.673529
  11. 0.408000 0.146143 0.387485
  12. 0.435000 0.158725 0.647624
  13. 0.462000 0.185775 1.399849
  14. 0.489000 0.233253 2.034814
  15. 0.516000 0.290241 2.109999
  16. 0.543000 0.347304 2.200385
  17. 0.570000 0.415370 2.931229
  18. 0.597000 0.504292 3.503145
  19. 0.624000 0.592054 2.763309
  20. 0.651000 0.645747 1.208607
  21. 0.678000 0.663637 0.297321
  22. 0.705000 0.670123 0.268624
  23. 0.732000 0.677724 0.233552
  24. 0.759000 0.679871 -0.077180
  25. 0.786000 0.677381 0.020735
  26. 0.813000 0.688778 0.956408
  27. 0.840000 0.733653 2.431984
  28. 0.867000 0.822586 4.209499
  29. 0.894000 0.963284 6.230239
  30. 0.921000 1.155414 7.841243
  31. 0.948000 1.373556 8.056159
  32. 0.975000 1.575612 6.691082
  33. 1.002000 1.725112 4.227284
  34. 1.029000 1.795526 0.856452
  35. 1.056000 1.767797 -2.871105
  36. 1.083000 1.648824 -5.650900
  37. 1.110000 1.480563 -6.442901
  38. 1.137000 1.318483 -5.309715
  39. 1.164000 1.198476 -3.600376
  40. 1.191000 1.115220 -2.744803
  41. 1.218000 1.043134 -2.600741
  42. 1.245000 0.977289 -2.155749
  43. 1.272000 0.928752 -1.443136
  44. 1.299000 0.894999 -1.109955
  45. 1.326000 0.868484 -0.743408
  46. 1.353000 0.859332 0.120417
  47. 1.380000 0.869809 0.444883
  48. 1.407000 0.867177 -0.906627
  49. 1.434000 0.811246 -3.257711
  50. 1.461000 0.694147 -5.274589
  51. 1.488000 0.536089 -6.215685
  52. 1.515000 0.370839 -5.747150
  53. 1.542000 0.236681 -4.040289
  54. 1.569000 0.154469 -2.128090
  55. 1.596000 0.112702 -1.142470
  56. 1.623000 0.083908 -1.071380
  57. 1.650000 0.053970 -1.101246

这个结果的三列数据分别为:cv值、密度值和标准差,对于我们而言,主要关注下前两列的结果即可,可以写一个Python脚本做一下简单的可视化:

  1. import numpy as np
  2. with open('histo', 'r') as hfile:
  3. hlines = hfile.readlines()
  4. hcv = []
  5. hbar = []
  6. for hline in hlines[6:]:
  7. hcv.append(float(hline.strip().split()[0]))
  8. hbar.append(float(hline.strip().split()[1]))
  9. hcv = np.array(hcv)
  10. hbar = np.array(hbar)
  11. from matplotlib import pyplot as plt
  12. plt.figure()
  13. plt.plot(hcv, hbar, color='black')
  14. plt.show()

输出结果为:

得到的这个概率密度曲线,就是我们使用KDE方法模拟出来的真实概率密度。

总结概要

Plumed是一个强大的分子模拟数据处理工具,可以在模拟的过程中逐步分析,也可以保存模拟的轨迹做后分析。本文紧接前面的“增强采样软件PLUMED的安装与使用”文章,还有“直方图与核密度估计”文章。介绍了如何使用Plumed后分析工具,对输出的反应坐标的轨迹进行核密度估计。

版权声明

本文首发链接为:https://www.cnblogs.com/dechinphy/p/plumed-post.html

作者ID:DechinPhy

更多原著文章:https://www.cnblogs.com/dechinphy/

请博主喝咖啡:https://www.cnblogs.com/dechinphy/gallery/image/379634.html

参考链接

  1. https://www.plumed.org/doc-v2.8/user-doc/html/_h_i_s_t_o_g_r_a_m.html
  2. https://www.cnblogs.com/dechinphy/p/18140812/kde

原文链接:https://www.cnblogs.com/dechinphy/p/18174362/plumed-post

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号