Jerkwin分享 http://blog.sciencenet.cn/u/Jerkwin

博文

四种计算自由能方法的原理示例教程

已有 12009 次阅读 2017-5-24 22:09 |系统分类:科研笔记

【按】本教程以一个简单实例对计算自由能的四种方法进行了示例. 教程没有过度讲解原理, 而是从实际操作出发, 教你如何手动计算. 知晓了具体的计算操作过程对理解其他自由能计算程序的计算原理和计算结果很有帮助. 故翻译此教程供参考.

在本教程中, 我们将要计算Cu(I)和Cu(II)离子之间转移一个电子导致的自由能变化.

问题: 这个自由能差值有多大呢?

由于我们已经知道要计算的自由能差值的参考值, 所有我们可以验证模拟结果的合理性和精确性. 我们将逐步进行, 使用互不相同却又有联系的几种方法进行计算:

  • 自由能微扰(Zwanzig)

  • 接受比例(Bennet)

  • 热力学积分(Kirkwood)

  • 非平衡近似(Jarzynski)

体系设置

首先, 使用你熟悉的分子编辑软件创建两个铜离子, 将其保存为pdb文件. 然后, 修改文件使两个铜原子处于不同的组中(两个离子具有不同的组编号. 如果你不确定, 请查看pdb文件的格式说明). 此外, 将两个组都命名为CU1+, 其原子名称都是CU. 使用相同组名称的原因在于, 在我们将要使用的GROMOS力场中, 这两个离子所用的Lennard-Jones参数不同, 这会导致后面的处理变得比较复杂. 在这里我们不关心原子类型的精确性, 但对于更精确的工作, 你应该也考虑改变原子类型.

将两个离子置于4x4x4 nm^3立方盒子的中心. 假定你的pdb文件为2Cu.pdb, 可使用如下命令:

gmx editconf -f 2Cu.pdb -c -box 4 4 4 -o 2Cu_in_box.gro

接下来, 我们要使用pdb2gmx来自动生成体系的拓扑文件. 在此之前, 要检查下原子名称是否如我们所要求的那样. 使用熟悉的文本编辑器打开你创建的坐标文件2Cu_in_box.gro, 其内容类似下面:

two copper ions in a box2    1CU1+    CU    1   0.000   0.000   0.000    2CU1+    CU    2   0.000   0.000   2.0004.00000   4.00000   4.00000

如果你的文件如上面所示(否则请修改), 可以使用pdb2gmx命令

gmx pdb2gmx -f 2Cu_in_box.gro

运行命令后会提示你选择力场和水模型, 我们选择GROMOS96 54a7力场和spc水. 查看得到的文件, 特别是topol.top文件, 其中包含了体系的拓扑信息, 两个铜离子所带的电荷. 对于第一个铜离子带1+电荷而第二个铜离子带2+电荷的情况, 我们称其为状态A; 当第一个铜离子带2+电荷而第二个铜离子带1+电荷时, 我们称其为状态B. 本教程的目的是计算状态A和状态B之间的自由能差值. 试着理解拓扑文件中有关电荷的设置. 我们将通过更改这些电荷来创建状态A和B对应的拓扑文件.

由于我们要计算的是两个离子在水中进行电子转移导致的自由能差值, 我们使用GROMACS的solvate命令自动向盒子中添加水分子:

gmx solvate -cp conf.gro -cs spc216.gro -p -o solvated.gro

最后一个选项保证自动更新拓扑文件. 查看修改后的拓扑文件. 你也可以使用熟悉的查看程序查看溶剂化后的体系solvated.gro(或先使用editconf其转换为pdb文件再查看). 你可以看到加入的水看起来比较有序, 我们首先要进行能量最小化消除体系中过大的相互作用力. 你可以使用下面的mdp文件. 查看GROMACS手册中mdp的有关关键词, 学习并理解每个选项的含义.

integrator           = steepnsteps               = 500comm-mode            = Linearnstcomm              = 1comm-grps            =emtol                = 100emstep               = 0.01nstxout              = 0nstvout              = 0nstfout              = 0nstlog               = 500nstenergy            = 500nstlist              = 5ns_type              = gridpbc                  = xyzrlist                = 0.9coulombtype          = PMErcoulomb-switch      = 0rcoulomb             = 0.9epsilon-r            = 1vdw-type             = Cut-offrvdw-switch          = 0rvdw                 = 0.9DispCorr             = EnerPresfourierspacing       = 0.12pme_order            = 4ewald_rtol           = 1e-05ewald_geometry       = 3depsilon_surface      = 0optimize_fft         = noTcoupl               = berendsentc-grps              = Systemtau_t                = 0.1ref_t                = 300Pcoupl               = berendsenPcoupltype           = isotropictau_p                = 0.5compressibility      = 4.5e-5ref_p                = 1.0gen_vel              = yesgen_temp             = 300gen_seed             = 1993

将以上设置保存为em.mdp, 然后使用grompp创建运行mdrun所需的输入文件:

gmx grompp -f em.mdp -c solvated.gro -p topol.top

正常情况下会得到topol.tpr. 如果出现错误或警告, 检查并修正它们.

得到topol.tpr后, 我们可以使用mdrun进行能量最小化(最速下降方法)

gmx mdrun -v

能量最小化完成后检查得到的结构. 这一步中, 设定的能量收敛阈值达到与否并不重要, 因为我们只是为了消除由未正确放置的水分子导致的过大相互作用力. 你可以使用熟悉的分子查看软件来检查结构. 如果一切都看起来正常, 添加3个Cl-作为抗衡离子使体系满足电中性. 在Ewald和PME方法中, 电中性是很重要的. 我们使用genion命令来自动完成这个工作. 运行这个命令需要一个tpr文件, 因此, 我们首先需要使用grompp创建一个tpr文件, 我们使用confout.gro(即能量最小化后的结构)作为输入结构文件

gmx grompp -c confout.gro -f em.mdp -p topol.top

然后使用genion

gmx genion -s topol.tpr -p topol.top -nname CL -nn 3 -nq -1 -o neutral.gro

提示时选择溶剂SOL组.

对得到的结构neutral.gro进行能量最小化可能会更好, 但由于体系比较简单, 不进行这一步也无大碍.

接下来, 进行100 ps的平衡模拟, 我们不知道在这段时间内体系能否充分达到热力学平衡, 但我们先忽略这个问题吧.

问题: 根据哪些信息你可判定体系已经充分平衡了?

我们进行等温模拟, 使用所谓的弱耦合方法. 所用的npt.mdp文件如下. 请确保你理解其中选项的作用以及使用的原因.

integrator               = mdtinit                    = 0dt                       = 0.002nsteps                   = 50000init_step                = 0comm-mode                = Linearnstcomm                  = 1nstxout                  = 500nstvout                  = 0nstfout                  = 0nstcheckpoint            = 1000nstlog                   = 500nstenergy                = 500nstlist                  = 5ns_type                  = gridpbc                      = xyzrlist                    = 0.9domain-decomposition     = nocoulombtype              = PMErcoulomb-switch          = 0rcoulomb                 = 0.9epsilon-r                = 1vdw-type                 = Cut-offrvdw-switch              = 0rvdw                     = 0.9DispCorr                 = EnerPresfourierspacing           = 0.12fourier_nx               = 0fourier_ny               = 0fourier_nz               = 0pme_order                = 4ewald_rtol               = 1e-05ewald_geometry           = 3depsilon_surface          = 0optimize_fft             = noTcoupl                   = berendsentc-grps                  = Systemtau_t                    = 0.1ref_t                    = 300Pcoupl                   = berendsenPcoupltype               = isotropictau_p                    = 0.5compressibility          = 4.5e-5ref_p                    = 1.0gen_vel                  = yesgen_temp                 = 300gen_seed                 = 1993

使用这一输入文件, 你可以创建tpr文件, 然后使用mdrun运行得到的tpr文件:

gmx grompp -c neutral.gro -f npt.mdpgmx mdrun
自由能微扰(FEP)

平衡后, 我们进行1 ns的成品模拟, 并使用得到的轨迹进行FEP计算. 将mdp文件中的模拟步数改为1 ns对应的值, 然后进行模拟, 每ps保存一次构型. 这一模拟所用时间大约是平衡模拟的10倍.

模拟完成后, 我们使用mdrun的-rerun选项来计算轨迹中每一帧的 VBVAVB−VA. 因而-rerun所用的拓扑文件应对应于状态B(即第一个铜离子带+2电荷, 第二个铜离子带+1电荷). 将我们前面使用的状态A的拓扑文件另存为其他文件名, 如topol_B.itp, 并修改[ atom ]段的电荷使其对应于状态B.

使用状态B的拓扑文件创建新的tpr文件, 最好使用与以前不同的文件名(state_B.tpr). 更好的做法是创建一个新的目录并在其中进行新的计算. 你需要将输出选项设置为1, 即每一步都输出, 因为前面得到的轨迹仅包含每500步(即每ps)一次的快照.

得到新的tpr文件后, 将前面属于状态A的轨迹文件复制到工作目录下重命名为traj_A.trr, 然后运行:

gmx mdrun -rerun traj_A.trr -s state_B.tpr

使用energy命令抽取edr文件中的能量并选择势能(为什么?), 分别抽取状态A和状态B对应的势能. 利用这些能量, 根据Zwanzig方程计算自由能,

<span class="MathJax" id="MathJax-Element-2-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi mathvariant="normal">&#x0394;F=&#x2212;RTln&#x2061;[&#x27E8;exp&#x2061;(&#x2212;<mrow class="MJX-TeXAtom-ORD">VB&#x2212;VART)&#x27E9;A]" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ΔF=RTln[exp(VBVART)A]ΔF=−RTln⁡[⟨exp⁡(−VB−VART)⟩A]

问题: 自由能差值为多少? 误差来源于哪里? 为什么这么大?

误差来源于重叠不够. 我们对构型空间的抽样不充分, 其中的水分子取向倾向于产物状态.

为减小误差, 我们要使用更小的步骤进行FEP计算. 考虑根据更小的步骤来计算自由能, 如 Cu++Cu2+ → Cu1.1++Cu1.9+, Cu1.1++Cu1.9+ → Cu1.2++Cu1.8+ 等等. 当然, 这种步骤在现实中是没有的, 因为不存在非整数电荷, 但由于自由能是状态函数, 所以我们可以选择任意的路径来计算它. 总的自由能是所有这些小步骤的自由能差值之和:

<span class="MathJax" id="MathJax-Element-3-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi mathvariant="normal">&#x0394;F=<mo movablelimits="false">&#x2211;<mrow class="MJX-TeXAtom-ORD">i=1n&#x03B4;Fi" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ΔF=i=1nδFiΔF=∑i=1nδFi

其中

<span class="MathJax" id="MathJax-Element-4-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">&#x03B4;Fi=&#x2212;RTln&#x2061;[&#x27E8;exp&#x2061;[&#x2212;<mrow class="MJX-TeXAtom-ORD">V<mo stretchy="false">(Cu<mrow class="MJX-TeXAtom-ORD"><mo stretchy="false">(1+i<mrow class="MJX-TeXAtom-ORD">/n<mo stretchy="false">)++Cu<mrow class="MJX-TeXAtom-ORD"><mo stretchy="false">(2&#x2212;i<mrow class="MJX-TeXAtom-ORD">/n<mo stretchy="false">)+<mo stretchy="false">)&#x2212;V<mo stretchy="false">(Cu<mrow class="MJX-TeXAtom-ORD"><mo stretchy="false">(1+<mo stretchy="false">(i&#x2212;1<mo stretchy="false">)<mrow class="MJX-TeXAtom-ORD">/n<mo stretchy="false">)++Cu<mrow class="MJX-TeXAtom-ORD"><mo stretchy="false">(2&#x2212;<mo stretchy="false">(i&#x2212;1<mo stretchy="false">)<mrow class="MJX-TeXAtom-ORD">/n<mo stretchy="false">)+<mo stretchy="false">)RT]&#x27E9;<mrow class="MJX-TeXAtom-ORD">i&#x2212;1]" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">δFi=RTln[exp[V(Cu(1+i/n)++Cu(2i/n)+)V(Cu(1+(i1)/n)++Cu(2(i1)/n)+)RT]i1]δFi=−RTln⁡[⟨exp⁡[−V(Cu(1+i/n)++Cu(2−i/n)+)−V(Cu(1+(i−1)/n)++Cu(2−(i−1)/n)+)RT]⟩i−1]

如果你不擅长编程, 可以创建 <span class="MathJax" id="MathJax-Element-5-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">n" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">nn 个子目录(或更多), 将状态A的拓扑文件复制到每个子目录中. 然后, 在子目录 <span class="MathJax" id="MathJax-Element-6-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">i" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ii 中将第一个铜离子的电荷改为 <span class="MathJax" id="MathJax-Element-7-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">1+i<mrow class="MJX-TeXAtom-ORD">/n" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">1+i/n1+i/n, 第二个铜离子的电荷改为 <span class="MathJax" id="MathJax-Element-8-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">2&#x2212;i<mrow class="MJX-TeXAtom-ORD">/n" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">2i/n2−i/n. 然后mdrun -rerun所有的模拟, 并计算总的 <span class="MathJax" id="MathJax-Element-9-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="normal">&#x0394;F" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ΔFΔF.

问题: 误差变小了么? 为什么(回想分布拖尾现象)?

为了便于进行后面的教程, 保存系综(即轨迹) <span class="MathJax" id="MathJax-Element-10-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">i" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ii 中计算的 <span class="MathJax" id="MathJax-Element-11-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">V<mrow class="MJX-TeXAtom-ORD">i+1&#x2212;Vi" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">Vi+1ViVi+1−Vi 到文件中.

接受比例

FEP方法是非对称的, 而且我们已经看到, 即便使用非常小的微扰步骤, 我们得到的自由能结果与参考值0仍有差距. 为解决这一问题, 我们将使用 Bennet 接受比例方法处理我们得到的FEP数据.

当满足下面的条件时, 每一FEP步骤的统计误差最小

<span class="MathJax" id="MathJax-Element-12-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mo movablelimits="false">&#x2211;sim. B<mrow class="MJX-TeXAtom-ORD">11+exp&#x2061;<mo stretchy="false">[&#x03B2;<mo stretchy="false">(VA<mo stretchy="false">(r<mo stretchy="false">)&#x2212;VB<mo stretchy="false">(r<mo stretchy="false">)+C<mo stretchy="false">)<mo stretchy="false">]=<mo movablelimits="false">&#x2211;sim. A<mrow class="MJX-TeXAtom-ORD">11+exp&#x2061;<mo stretchy="false">[&#x03B2;<mo stretchy="false">(VB<mo stretchy="false">(r<mo stretchy="false">)&#x2212;VA<mo stretchy="false">(r<mo stretchy="false">)&#x2212;C<mo stretchy="false">)<mo stretchy="false">]" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">sim. B11+exp[β(VA(r)VB(r)+C)]=sim. A11+exp[β(VB(r)VA(r)C)]∑sim. B11+exp⁡[β(VA(r)−VB(r)+C)]=∑sim. A11+exp⁡[β(VB(r)−VA(r)−C)]

累加对所有快照进行, 对应的势能保存在edr文件中(每nstenergy一次). 自由能的最佳值为满足上面方程的 <span class="MathJax" id="MathJax-Element-13-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">C" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">CC, 即 <span class="MathJax" id="MathJax-Element-14-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mi mathvariant="normal">&#x0394;F=C" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ΔF=CΔF=C, 由于 <span class="MathJax" id="MathJax-Element-15-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">C" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">CC 出现于方程的两边, 我们只能对其进行数值求解. 最直接但可能并非最高效的求解方法是, 从小到大逐渐增加 <span class="MathJax" id="MathJax-Element-16-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">C" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">CC 的值, 计算方程两边的值, 直至 <span class="MathJax" id="MathJax-Element-17-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">C" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">CC 满足方程. 我们可以先使用大的间隔对 <span class="MathJax" id="MathJax-Element-18-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">C" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">CC 进行扫描, 即相邻 <span class="MathJax" id="MathJax-Element-19-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">C" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">CC值的间距较大. 根据所得的初始扫描结果, 我们可以取使方程左右两边差值最小的 <span class="MathJax" id="MathJax-Element-20-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">C" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">CC 值, 然后在第二次扫描中围绕此值进行更精细的扫描.

为了使用多步FEP计算中的数据, 我们也需要后向的FEP数据, 即, 从最后一点 <span class="MathJax" id="MathJax-Element-21-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">n" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">nn 开始, 对每一步骤 <span class="MathJax" id="MathJax-Element-22-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">i" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ii 我们需要计算

<span class="MathJax" id="MathJax-Element-23-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">&#x03B4;Fi=&#x2212;RTln&#x2061;[&#x27E8;exp&#x2061;[&#x2212;<mrow class="MJX-TeXAtom-ORD">V<mo stretchy="false">(Cu<mrow class="MJX-TeXAtom-ORD"><mo stretchy="false">(2&#x2212;<mo stretchy="false">(i&#x2212;1<mo stretchy="false">)<mrow class="MJX-TeXAtom-ORD">/n<mo stretchy="false">)++Cu<mrow class="MJX-TeXAtom-ORD"><mo stretchy="false">(1+<mo stretchy="false">(i&#x2212;1<mo stretchy="false">)<mrow class="MJX-TeXAtom-ORD">/n<mo stretchy="false">)+<mo stretchy="false">)&#x2212;V<mo stretchy="false">(Cu<mrow class="MJX-TeXAtom-ORD"><mo stretchy="false">(2&#x2212;i<mrow class="MJX-TeXAtom-ORD">/n<mo stretchy="false">)++Cu<mrow class="MJX-TeXAtom-ORD"><mo stretchy="false">(1+i<mrow class="MJX-TeXAtom-ORD">/n<mo stretchy="false">)+<mo stretchy="false">)RT]&#x27E9;i]" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">δFi=RTln[exp[V(Cu(2(i1)/n)++Cu(1+(i1)/n)+)V(Cu(2i/n)++Cu(1+i/n)+)RT]i]δFi=−RTln⁡[⟨exp⁡[−V(Cu(2−(i−1)/n)++Cu(1+(i−1)/n)+)−V(Cu(2−i/n)++Cu(1+i/n)+)RT]⟩i]

其中的累加 <span class="MathJax" id="MathJax-Element-24-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">i" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ii 遍及 <span class="MathJax" id="MathJax-Element-25-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">n" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">nn 到1. 现在我们只使用系综 <span class="MathJax" id="MathJax-Element-26-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">i" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ii 中 <span class="MathJax" id="MathJax-Element-27-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">V<mrow class="MJX-TeXAtom-ORD">i&#x2212;1&#x2212;Vi" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">Vi1ViVi−1−Vi 的数据. 你需要创建并保存这些数据.

现在你有了每一步骤 <span class="MathJax" id="MathJax-Element-28-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">i" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ii 中正向和反向FEP的 <span class="MathJax" id="MathJax-Element-29-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">VA" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">VAVA 和 <span class="MathJax" id="MathJax-Element-30-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">VB" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">VBVB 数据, 查找每一步骤 <span class="MathJax" id="MathJax-Element-31-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">i" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ii 中的最佳 <span class="MathJax" id="MathJax-Element-32-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">C" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">CC 值. 个人建议用Excel, MatLab或Mathematica进行. 或者, 如果你知道如何写脚本, 并知道一点awk的话, 会更容易.

问题: Bennet接受比例方法估计的自由能差值为多少?

热力学积分

在这一部分, 我们将使用GROMACS来进行热力学积分计算. 自由能的估计值为

<span class="MathJax" id="MathJax-Element-33-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mi mathvariant="normal">&#x0394;F<mrow class="MJX-TeXAtom-ORD">AB=&#x222B;10&#x27E8;<mrow class="MJX-TeXAtom-ORD"><mi mathvariant="normal">&#x2202;V<mi mathvariant="normal">&#x2202;&#x03BB;&#x27E9;&#x03BB;<mrow class="MJX-TeXAtom-OP"><mrow class="MJX-TeXAtom-ORD"><mi mathvariant="normal">d&#x03BB;&#x2248;<mo movablelimits="false">&#x2211;i<mrow class="MJX-TeXAtom-ORD">nsteps&#x27E8;<mrow class="MJX-TeXAtom-ORD"><mi mathvariant="normal">&#x2202;V<mi mathvariant="normal">&#x2202;&#x03BB;&#x27E9;&#x03BB;<mi mathvariant="normal">&#x0394;&#x03BB;" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">ΔFAB=01VλλdλinstepsVλλΔλΔFAB=∫10⟨∂V∂λ⟩λdλ≈∑insteps⟨∂V∂λ⟩λΔλ

最好在新的目录中进行这一部分的计算. 如前面一样, 我们将使用10个步骤进行计算. 因此, 你需要创建10个子目录, 并将mdp文件复制到每个子目录中. 在每个mdp文件中添加下面的关键词来启用热力学积分

free-energy     = yesinit-lambda     = 0delta-lambda    = 0sc-alpha        = 0sc-sigma        = 0.3

我们可以用初始init-lambda关键词控制labmda的值, 将其设置为0, 0.1, 0.2,…1, 对应于每一子目录.

使用这些设置, GROMACS会对状态A和B之间的相互作用函数进行线性内插. 因此我们同时需要设定状态B, 只要简单地在拓扑文件中添加状态B的信息(电荷)即可

[ atoms ];   nr    type  resnr residue  atom  cgnr charge  mass    typeB  chargeB  massB    1     CU1+      1   CU1+   CU    1    1       63.546   CU1+   2       63.546    2     CU1+      2   CU2+   CU    2    2       63.546   CU1+   1       63.546

在每一子目录中进行固定 <span class="MathJax" id="MathJax-Element-34-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">&#x03BB;" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">λλ 值的模拟, mdrun的输出文件之一为dhdl.xvg, 其中包含了随模拟时间变化的 <span class="MathJax" id="MathJax-Element-35-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow class="MJX-TeXAtom-ORD"><mi mathvariant="normal">&#x2202;V<mi mathvariant="normal">&#x2202;&#x03BB;" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">Vλ∂V∂λ. 你可以使用analyze命令来计算平均值和误差估计随 <span class="MathJax" id="MathJax-Element-36-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">&#x03BB;" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">λλ 的变化. 当得到 <span class="MathJax" id="MathJax-Element-37-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">&#x27E8;<mrow class="MJX-TeXAtom-ORD"><mi mathvariant="normal">&#x2202;V<mi mathvariant="normal">&#x2202;&#x03BB;&#x27E9;&#x03BB;" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">Vλλ⟨∂V∂λ⟩λ 与 <span class="MathJax" id="MathJax-Element-38-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">&#x03BB;" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">λλ (0到1)的关系后, 你也可以使用analyze命令计算从0到1的积分.

问题: 热力学积分给出的自由能为多少? 是否好于FEP和BAR?

Jarzynski方法

创建一个新的子目录, 并复制用于热力学积分计算的mdp文件和拓扑文件. 在本部分中, 我们将进行很短时间的慢增长模拟. 慢增长是热力学积分的连续形式, 其中的 <span class="MathJax" id="MathJax-Element-39-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">&#x03BB;" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">λλ 作为时间的函数连续变化, 因此, <span class="MathJax" id="MathJax-Element-40-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">&#x03BB;<mo stretchy="false">(t<mrow class="MJX-TeXAtom-ORD">init<mo stretchy="false">)=0" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">λ(tinit)=0λ(tinit)=0, <span class="MathJax" id="MathJax-Element-41-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">&#x03BB;<mo stretchy="false">(t<mrow class="MJX-TeXAtom-ORD">final<mo stretchy="false">)=1" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">λ(tfinal)=1λ(tfinal)=1. 在mdp文件中, 增加下面的选项(在这个例子中我们进行20 ps的模拟)

dt               = 0.002nsteps           = 10000free-energy      = yesinit-lambda      = 0delta-lambda     = 0.0001

我们创建许多子目录, 每一个都进行短时间(几ps)的慢增长模拟. 如果你会写脚本的话, 会更容易.

执行完所有模拟后, 可以使用anlyze程序计算所有模拟的非可逆功

gmx analyze -f dhdl.xvg -integrate

注意, x值是以ps为单位的时间, 从0到20. 因此你需要将所得的功除以20使得 <span class="MathJax" id="MathJax-Element-42-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">&#x03BB;" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">λλ 处于0到1之间, 间隔正确. 得到这些功后, 你可以使用你熟悉的数据分析程序创建一个直方图, 并试着将其拟合为高斯函数, 使用Jarzynski 方程(指数平均)来计算可逆功

<span class="MathJax" id="MathJax-Element-43-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">exp&#x2061;[&#x2212;&#x03B2;<mi mathvariant="normal">&#x0394;F]=<mrow class="MJX-TeXAtom-ORD">1nsim.<mo movablelimits="false">&#x2211;<mrow class="MJX-TeXAtom-ORD">nsim.exp&#x2061;[&#x2212;&#x03B2;&#x222B;<mrow class="MJX-TeXAtom-ORD">ti<mrow class="MJX-TeXAtom-ORD">tf<mrow class="MJX-TeXAtom-ORD"><mi mathvariant="normal">&#x2202;V<mi mathvariant="normal">&#x2202;&#x03BB;<mrow class="MJX-TeXAtom-ORD"><mrow class="MJX-TeXAtom-OP"><mrow class="MJX-TeXAtom-ORD"><mi mathvariant="normal">d&#x03BB;<mrow class="MJX-TeXAtom-OP"><mrow class="MJX-TeXAtom-ORD"><mi mathvariant="normal">dt<mrow class="MJX-TeXAtom-OP"><mrow class="MJX-TeXAtom-ORD"><mi mathvariant="normal">dt]" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">exp[βΔF]=1nsim.nsim.exp[βtftiVλdλdtdt]exp⁡[−βΔF]=1nsim.∑nsim.exp⁡[−β∫titf∂V∂λdλdtdt]

问题: 要得到准确的自由能估计值, 需要多少个慢增长步骤?

结论

我们已经使用不同方法计算了自由能. 显然, 不应该使用非对称的自由能微扰方法, 但当它与对称的Bennet接受比例方法一起使用时, 能够给出精确的自由能估计值. 热力学积分也是对称的, 当 <span class="MathJax" id="MathJax-Element-44-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">&#x03BB;" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">λλ 间隔足够小, 相应 <span class="MathJax" id="MathJax-Element-45-Frame" tabindex="0" data-mathml="<math xmlns="http://www.w3.org/1998/Math/MathML">&#x03BB;" role="presentation" style="margin:0px;padding:0px;display:inline;line-height:normal;text-align:left;word-spacing:normal;word-wrap:normal;float:none;direction:ltr;max-width:none;max-height:none;min-width:0px;min-height:0px;border:0px;position:relative;">λλ 系综间有重叠时, 这种方法同样能够给出精确的自由能估计值. 前面三种方法假定体系哈密顿量的变化足够缓慢, 体系始终处于平衡态, 因此, 这些方法都被称为平衡方法. 然而, 由于采样时间的限制, 实际情况很少这样. 与平衡方法相反, Jarzynski方法用于远离平衡的体系. 尽管考虑到我们的限制, 这听起来不错, 但由于平均问题, 需要非常多的模拟才能得到精确的自由能估计值. 最后的结果就是你并不能节省多少模拟时间. 这样, 具体使用哪种方法依赖于你要研究的问题, 要由你来决定使用哪种方法.

在此教程中, 我们仅仅改变了电荷, 但所用方法是通用的, 我们也可以改变成键相互作用. 然而, 对于构型改变, 基于伞形采样的其他方法通常更合适.



https://blog.sciencenet.cn/blog-548663-1056904.html

上一篇:xvg曲线中心移动平均平滑脚本
下一篇:【转载】[在人间]第48期:一所山村小学的日常
收藏 IP: 130.184.252.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-9-2 12:17

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部