【Plumed教程(一)】增强采样Plumed入门
1. 在阿里云ECS的Centos7.9和8.2系統(tǒng)中進(jìn)行Plumed簡(jiǎn)單安裝測(cè)試
2. 在騰訊云ECS的Centos7.9系統(tǒng)中進(jìn)行Plumed簡(jiǎn)單安裝測(cè)試
3. 簡(jiǎn)單的入門(mén)案例
4. 集合變量(CV)
5. 命令行工具
1. 在阿里云ECS的Centos7.9和8.2系統(tǒng)中進(jìn)行Plumed的簡(jiǎn)單安裝測(cè)試
Plumed的官方安裝教程是以以2.4.1為例進(jìn)行的,installation教程地址在此:PLUMED: Installation
最新版本2.8.1下載地址再次:Release Release v2.8.1 · plumed/plumed2 · GitHub
在網(wǎng)上看到大家的安裝過(guò)程都很順利和簡(jiǎn)單,然而我在安裝過(guò)程中卻遇到了各種麻煩,在此分享給大家,希望大家能夠少走彎路!
首先以阿里云ECS的7.9Centos系統(tǒng)(2核2GB,Open MPI?4.1.1,gcc/g++/gfortran 9.3.1)作為plumed的安裝測(cè)試環(huán)境,root賬戶下進(jìn)行。
(1)下載并解壓安裝包。
以2.8.1的安裝為例,首先下載安裝包,上傳到服務(wù)器中,執(zhí)行以下命令解壓縮
tar -xf plumed-2.8.1.tgz(2)進(jìn)入解壓縮的文件夾中,執(zhí)行以下命令進(jìn)行簡(jiǎn)單的編譯安裝。
cd plumed-2.8.1 # 進(jìn)入解壓縮文件夾 ./configure --prefix=/usr/local # 編譯安裝到/usr/local目錄下 make -j 2 # 以2核進(jìn)行編譯安裝,-j參數(shù)可選 make doc # this is optional and requires proper doxygen version installed make check make install使用阿里云ECS的centos系統(tǒng)進(jìn)行configure之后出現(xiàn)了如下很多WARNING,包括提示“Bash completion for plumed will not be installed, please add the following two lines to your bashrc”等等。最重要的是提示:plumed可執(zhí)行文件將不會(huì)在這臺(tái)機(jī)器上執(zhí)行除非以 plumed --no-mpi 形式的命令行運(yùn)行,即不能夠進(jìn)行并行計(jì)算!
configure: WARNING: **** Bash completion for plumed will not be installed, please add the following two lines to your bashrc configure: WARNING: **** _plumed() { eval "$(plumed --no-mpi completion 2>/dev/null)";} configure: WARNING: **** complete -F _plumed -o default plumed configure: **** PLUMED will be compiled using MPI configure: WARNING: plumed executable will not run on this machine configure: WARNING: unless you invoke it as 'plumed --no-mpi' configure: WARNING: all command line tools are thus available as 'plumed --no-mpi name-of-the-tool' configure: WARNING: e.g. 'plumed --no-mpi driver' configure: WARNING: to patch an MD code use 'plumed --no-mpi patch' configure: WARNING: (notice that MPI will be available anyway in the patched code)暫時(shí)先不管上面的WARNING,?繼續(xù)進(jìn)行make安裝,之后進(jìn)行make check,出現(xiàn)以下結(jié)果:
+++++++++++++++++++++++++++++++++++++++++++++++++++++ + Final report: + 249 tests performed, 339 tests not applicable + 0 errors found + Well done!! +++++++++++++++++++++++++++++++++++++++++++++++++++++?再接著進(jìn)行make install之后,顯示已經(jīng)安裝了,同時(shí)提示要配置若干環(huán)境變量,還有一些WARNING,提示內(nèi)容如下。
*** PLUMED has been installed ***Install prefix : /usr/local Full name : plumedSetup your environment - Ensure this is in your execution path : /usr/local/bin - Ensure this is in your include path : /usr/local/include - Ensure this is in your library path : /usr/local/lib - Ensure this is in your PKG_CONFIG_PATH path : /usr/local/lib/pkgconfig For runtime binding: - Set this environment variable : PLUMED_KERNEL=/usr/local/lib/libplumedKernel.soTo create a tcl module that sets all the variables above, use this one as a starting point: /usr/local/lib/plumed/modulefileTo uninstall, remove the following files and directories: /usr/local/lib/plumed /usr/local/share/doc/plumed /usr/local/include/plumed /usr/local/bin/plumed /usr/local/bin/plumed-patch /usr/local/bin/plumed-config /usr/local/lib/pkgconfig/plumed.pc /usr/local/lib/libplumed.so /usr/local/lib/libplumedKernel.so A vim plugin can be found here: /usr/local/lib/plumed/vim/ Copy it to /root/.vim/ directory Alternatively: - Set this environment variable : PLUMED_VIMPATH=/usr/local/lib/plumed/vim - Add the command 'let &runtimepath.=','.$PLUMED_VIMPATH' to your .vimrc file From vim, you can use :set syntax=plumed to enable it WARNING: plumed executable will not run on this machine WARNING: unless you invoke it as 'plumed --no-mpi' WARNING: This is normal if this is the login node of a cluster. WARNING: - to patch an MD code now use 'plumed --no-mpi patch' WARNING: (notice that MPI will be available anyway in the patched code) WARNING: - all command line tools are available as 'plumed --no-mpi name-of-the-tool' WARNING: e.g. 'plumed --no-mpi driver' WARNING: (MPI will be disabled in this case) make[2]: Leaving directory '/root/sun789/software/08_plumed/plumed-2.8.1/src/lib' make[1]: Leaving directory '/root/sun789/software/08_plumed/plumed-2.8.1/src'于是,vi ~/.bashrc文件,添加相關(guān)提示的環(huán)境變量,如下所示 # this is for plumed 部分,然后source ~/.bashrc。這一部分參考了PLUMED系列-安裝教程?的安裝教程。/.bashrc中結(jié)尾環(huán)境變量配置部分對(duì)應(yīng)新添加的plumed部分,兩行##之前的對(duì)應(yīng)bashrc中已有的環(huán)境變量配置。
# .bashrc# User specific aliases and functionsalias rm='rm -i' alias cp='cp -i' alias mv='mv -i'# Source global definitions if [ -f /etc/bashrc ]; then. /etc/bashrc fi# This is for anaconda # 在.bashrc文件底部添加 # 為了避免與其他服務(wù)器用戶產(chǎn)生命令沖突, 使用自己自定義的python8替代python # alias python8='/root/anaconda3/bin/python' # 這里寫(xiě)anaconda的安裝路徑 # export PATH="/root/anaconda3/bin:$PATH"# This is for vaspkit # export PATH=/root/sun789/software/vaspkit.1.3.5/bin:${PATH}# This is for Gaussian09 export g09root=/root/sun789/software/03_gaussian/softwarepackage # g16所在目錄 export GAUSS_SCRDIR=/root/sun789/software/03_gaussian/tmp # 臨時(shí)文件夾tmp所在目錄 source /root/sun789/software/03_gaussian/softwarepackage/g09/bsd/g09.profile # 解壓縮的到的g16.profile所在目錄# this is for openmpi export PATH=$PATH:/usr/local/lib/openmpi/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/openmpi/lib# this is for intel MKL source /opt/intel/oneapi/setvars.sh > /dev/null# this is for gcc and gfortran upgrade source /opt/rh/devtoolset-9/enable # this is for quantum esrpresso # 避免root賬戶下每次調(diào)用openmmpi必須執(zhí)行-allow-run-as-root命令 export OMPI_ALLOW_RUN_AS_ROOT=1 export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 # 寫(xiě)入QE編譯后執(zhí)行文件所在目錄,即QE編譯后bin文件夾所在目錄 export PATH=$PATH:/root/sun789/software/06_quantum_espresso/02_qe_configuration/bin # 寫(xiě)入intel MKL的intel64_lin文件夾所在目錄,在默認(rèn)安裝目錄/opt/intel/oneapi/目錄下面找 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/intel/oneapi/compiler/2022.2.0/linux/compiler/lib/intel64_lin######################################################################################### ######################################################################################### # this is for plumed _plumed() { eval "$(plumed --no-mpi completion 2>/dev/null)";} complete -F _plumed -o default plumed # this is for plumed enviroment variable export PATH=/usr/local/bin:$PATH export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH export PLUMED_KERNEL=/usr/local/lib/libplumedKernel.so:$PLUMED_KERNEL export PLUMED_VIMPATH=/usr/local/lib/plumed/vim:$PLUMED_VIMPATH export INCLUDE=/usr/local/include:$INCLUDE # 若開(kāi)啟了時(shí)間計(jì)算,需要增加 export PLUMED_USE_LEPTON=yes然后在終端輸入 plumed help 之后,再次顯示報(bào)錯(cuò),報(bào)錯(cuò)內(nèi)容如下!!!
[root@CentosDesktopSunYW plumed-2.8.1]# plumed help [CentosDesktopSunYW:02658] [[INVALID],INVALID] ORTE_ERROR_LOG: Unable to start a daemon on the local node in file ess_singleton_module.c at line 716 [CentosDesktopSunYW:02658] [[INVALID],INVALID] ORTE_ERROR_LOG: Unable to start a daemon on the local node in file ess_singleton_module.c at line 172 -------------------------------------------------------------------------- It looks like orte_init failed for some reason; your parallel process is likely to abort. There are many reasons that a parallel process can fail during orte_init; some of which are due to configuration or environment problems. This failure appears to be an internal failure; here's some additional information (which may only be relevant to an Open MPI developer):orte_ess_init failed--> Returned value Unable to start a daemon on the local node (-127) instead of ORTE_SUCCESS -------------------------------------------------------------------------- -------------------------------------------------------------------------- It looks like MPI_INIT failed for some reason; your parallel process is likely to abort. There are many reasons that a parallel process can fail during MPI_INIT; some of which are due to configuration or environment problems. This failure appears to be an internal failure; here's some additional information (which may only be relevant to an Open MPI developer):ompi_mpi_init: ompi_rte_init failed--> Returned "Unable to start a daemon on the local node" (-127) instead of "Success" (0) -------------------------------------------------------------------------- *** An error occurred in MPI_Init *** on a NULL communicator *** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort, *** and potentially your MPI job)聯(lián)想到我之前在阿里ECS的centos7.9系統(tǒng)中編譯安裝科學(xué)計(jì)算軟件總是出問(wèn)題,而在騰訊ECS的centos7.9版本中編譯安裝基本都是一次成功。猜想可能是ECS的centos7.9系統(tǒng)存在問(wèn)題,或者是當(dāng)前系統(tǒng)進(jìn)行了太多軟件的編譯測(cè)試產(chǎn)生了環(huán)境沖突。
一番折騰調(diào)整還是沒(méi)能成功運(yùn)行之后,我果斷將阿里云的ECS系統(tǒng)升級(jí)至8.2版本的centos系統(tǒng)。然后先配置了gcc, g++, gfortran編譯器(8.5版本),接著按照上述步驟重新進(jìn)行編譯。
先進(jìn)行configure,發(fā)現(xiàn)WARNING相比之前由9個(gè)減少至4個(gè)。由于還沒(méi)有安裝openmpi,所以提示還不能并行編譯,但是此處已經(jīng)沒(méi)有僅能使用?plumed --no-mpi ?命令進(jìn)行任務(wù)運(yùn)行的warning了。
configure: **** As of PLUMED 2.5, you cannot change paths anymore during "make install" configure: **** Please configure and make clean to change the prefix configure: WARNING: **** Bash completion for plumed will not be installed, please add the following two lines to your bashrc configure: WARNING: **** _plumed() { eval "$(plumed --no-mpi completion 2>/dev/null)";} configure: WARNING: **** complete -F _plumed -o default plumed configure: WARNING: **** PLUMED will NOT be compiled using MPI because MPI have not been found! configure: creating ./config.status config.status: creating Makefile.conf config.status: creating sourceme.sh config.status: creating stamp-h接著進(jìn)行make安裝,然后make check,結(jié)果如下:
+++++++++++++++++++++++++++++++++++++++++++++++++++++ + Final report: + 247 tests performed, 341 tests not applicable + 0 errors found + Well done!! +++++++++++++++++++++++++++++++++++++++++++++++++++++然后繼續(xù)make install,顯示已經(jīng)安裝了,結(jié)果如下:
*** PLUMED has been installed ***Install prefix : /usr/local Full name : plumedSetup your environment - Ensure this is in your execution path : /usr/local/bin - Ensure this is in your include path : /usr/local/include - Ensure this is in your library path : /usr/local/lib - Ensure this is in your PKG_CONFIG_PATH path : /usr/local/lib/pkgconfig For runtime binding: - Set this environment variable : PLUMED_KERNEL=/usr/local/lib/libplumedKernel.soTo create a tcl module that sets all the variables above, use this one as a starting point: /usr/local/lib/plumed/modulefileTo uninstall, remove the following files and directories: /usr/local/lib/plumed /usr/local/share/doc/plumed /usr/local/include/plumed /usr/local/bin/plumed /usr/local/bin/plumed-patch /usr/local/bin/plumed-config /usr/local/lib/pkgconfig/plumed.pc /usr/local/lib/libplumed.so /usr/local/lib/libplumedKernel.so A vim plugin can be found here: /usr/local/lib/plumed/vim/ Copy it to /root/.vim/ directory Alternatively: - Set this environment variable : PLUMED_VIMPATH=/usr/local/lib/plumed/vim - Add the command 'let &runtimepath.=','.$PLUMED_VIMPATH' to your .vimrc file From vim, you can use :set syntax=plumed to enable it make[2]: Leaving directory '/root/sun789/01_software/01_plumed/plumed-2.8.1/src/lib' make[1]: Leaving directory '/root/sun789/01_software/01_plumed/plumed-2.8.1/src'注意:相比之前,已經(jīng)沒(méi)有WARNING提示了。我輸入plumed help之后,然而還是報(bào)錯(cuò),結(jié)果如下:
[root@CentosDesktopSunYW plumed-2.8.1]# plumed help plumed: error while loading shared libraries: libplumedKernel.so: cannot open shared object file: No such file or directory提示不能夠加載libplumedKernel.so共享庫(kù),其實(shí)上述make install中已經(jīng)提到配置的這個(gè)庫(kù)環(huán)境變量的問(wèn)題了。將相應(yīng)環(huán)境變量進(jìn)行配置,即加入上述環(huán)境變量配置的內(nèi)容,再次運(yùn)行plumed help,結(jié)果如下,終于成功了!
[root@CentosDesktopSunYW plumed-2.8.1]# plumed help Usage: plumed [options] [command] [command options]plumed [command] -h|--help: to print help for a specific command Options:[help|-h|--help] : to print this help[--is-installed] : fails if plumed is not installed[--has-mpi] : fails if plumed is running without MPI[--has-dlopen] : fails if plumed is compiled without dlopen[--load LIB] : loads a shared object (typically a plugin library)[--standalone-executable] : tells plumed not to look for commands implemented as scripts Commands:plumed completion : dump a function usable for programmable completionplumed driver : analyze trajectories with plumedplumed driver-float : analyze trajectories with plumed (single precision version)plumed gen_example : construct an example for the manual that users can interact withplumed gentemplate : print out a template input for a particular actionplumed info : provide informations about plumedplumed kt : print out the value of kT at a particular temperatureplumed manual : print out a description of the keywords for an action in htmlplumed pathtools : print out a description of the keywords for an action in htmlplumed pdbrenumber : Modify atom numbers in a PDB, possibly using hybrid-36 codingplumed pesmd : Langevin dynamics on PLUMED energy landscapeplumed simplemd : run lj codeplumed sum_hills : sum the hills with plumedplumed config : inquire plumed about how it was configureplumed mklib : compile a .cpp file into a shared libraryplumed newcv : create a new collective variable from a templateplumed partial_tempering : scale parameters in a gromacs topology to implement solute or partial temperingplumed patch : patch an MD engine /usr/local/lib/plumed/scripts/selector.sh: line 219: python: command not foundplumed selector : plumed vim2html : convert plumed input file to colored html using vim syntax除此之外,后續(xù)還在阿里云centos8.5系統(tǒng)上進(jìn)行了測(cè)試。發(fā)現(xiàn)與8.2版本centos系統(tǒng)測(cè)試還是有差異的,但是不用設(shè)置環(huán)境變量就可以成功運(yùn)行plumed help命令。
make check之后
+++++++++++++++++++++++++++++++++++++++++++++++++++++ + Final report: + 312 tests performed, 276 tests not applicable + 65 errors found + Find the bug! + To replace references, go to the test directory and + type 'make reset' make[1]: *** [Makefile:14: checkfail] Error 1 make[1]: Leaving directory '/root/01_sun789/02_plumed/plumed-2.8.1/regtest' make: *** [Makefile:66: check] Error 2make install之后
*** PLUMED has been installed ***Install prefix : /usr/local Full name : plumedSetup your environment - Ensure this is in your execution path : /usr/local/bin - Ensure this is in your include path : /usr/local/include - Ensure this is in your library path : /usr/local/lib - Ensure this is in your PKG_CONFIG_PATH path : /usr/local/lib/pkgconfig For runtime binding: - Set this environment variable : PLUMED_KERNEL=/usr/local/lib/libplumedKernel.soTo create a tcl module that sets all the variables above, use this one as a starting point: /usr/local/lib/plumed/modulefileTo uninstall, remove the following files and directories: /usr/local/lib/plumed /usr/local/share/doc/plumed /usr/local/include/plumed /usr/local/bin/plumed /usr/local/bin/plumed-patch /usr/local/bin/plumed-config /usr/local/lib/pkgconfig/plumed.pc /usr/local/lib/libplumed.so /usr/local/lib/libplumedKernel.so A vim plugin can be found here: /usr/local/lib/plumed/vim/ Copy it to /root/.vim/ directory Alternatively: - Set this environment variable : PLUMED_VIMPATH=/usr/local/lib/plumed/vim - Add the command 'let &runtimepath.=','.$PLUMED_VIMPATH' to your .vimrc file From vim, you can use :set syntax=plumed to enable it make[2]: Leaving directory '/root/01_sun789/02_plumed/plumed-2.8.1/src/lib' make[1]: Leaving directory '/root/01_sun789/02_plumed/plumed-2.8.1/src'為了測(cè)試騰訊云ECS上是否存在上述類似問(wèn)題,進(jìn)行了接下來(lái)的測(cè)試。
2. 在騰訊云ECS的Centos7.9系統(tǒng)中進(jìn)行Plumed的簡(jiǎn)單安裝測(cè)試
在騰訊云ECS的centos7.9系統(tǒng)(4核8GB,Open MPI?4.1.1,gcc/g++/gfortran 9.3.1)進(jìn)行測(cè)試,
在configure之后,warning明顯減少,沒(méi)有只能夠進(jìn)行非并行計(jì)算的WARNING:
configure: **** Please configure and make clean to change the prefix configure: WARNING: **** Bash completion for plumed will not be installed, please add the following two lines to your bashrc configure: WARNING: **** _plumed() { eval "$(plumed --no-mpi completion 2>/dev/null)";} configure: WARNING: **** complete -F _plumed -o default plumed configure: **** PLUMED will be compiled using MPI configure: creating ./config.status config.status: creating Makefile.conf config.status: creating sourceme.sh config.status: creating stamp-h?在騰訊云ECS的centos系統(tǒng)進(jìn)行了make check之后,雖然出現(xiàn)了errors,但暫時(shí)可以忽略,因?yàn)榭赡苌婕暗揭恍?kù)沒(méi)有安裝。
+++++++++++++++++++++++++++++++++++++++++++++++++++++ + Final report: + 316 tests performed, 272 tests not applicable + 13 errors found + Find the bug! + To replace references, go to the test directory and + type 'make reset' make[1]: *** [Makefile:14: checkfail] Error 1 make[1]: Leaving directory '/home/lighthouse/06_plumed/plumed-2.8.1/regtest' make: *** [Makefile:66: check] Error 2接著進(jìn)行 make install,顯示已經(jīng)安裝,并且也沒(méi)有WARNING。
*** PLUMED has been installed ***Install prefix : /usr/local Full name : plumedSetup your environment - Ensure this is in your execution path : /usr/local/bin - Ensure this is in your include path : /usr/local/include - Ensure this is in your library path : /usr/local/lib - Ensure this is in your PKG_CONFIG_PATH path : /usr/local/lib/pkgconfig For runtime binding: - Set this environment variable : PLUMED_KERNEL=/usr/local/lib/libplumedKernel.soTo create a tcl module that sets all the variables above, use this one as a starting point: /usr/local/lib/plumed/modulefileTo uninstall, remove the following files and directories: /usr/local/lib/plumed /usr/local/share/doc/plumed /usr/local/include/plumed /usr/local/bin/plumed /usr/local/bin/plumed-patch /usr/local/bin/plumed-config /usr/local/lib/pkgconfig/plumed.pc /usr/local/lib/libplumed.so /usr/local/lib/libplumedKernel.so A vim plugin can be found here: /usr/local/lib/plumed/vim/ Copy it to /root/.vim/ directory Alternatively: - Set this environment variable : PLUMED_VIMPATH=/usr/local/lib/plumed/vim - Add the command 'let &runtimepath.=','.$PLUMED_VIMPATH' to your .vimrc file From vim, you can use :set syntax=plumed to enable it make[2]: Leaving directory '/home/lighthouse/06_plumed/plumed-2.8.1/src/lib' make[1]: Leaving directory '/home/lighthouse/06_plumed/plumed-2.8.1/src'輸入plumed help命令,結(jié)果表明成功運(yùn)行,注意此處是在沒(méi)有配置一些環(huán)境變量的情況下成功運(yùn)行的!
[root@VM-4-6-centos plumed-2.8.1]# plumed help Usage: plumed [options] [command] [command options]plumed [command] -h|--help: to print help for a specific command Options:[help|-h|--help] : to print this help[--is-installed] : fails if plumed is not installed[--has-mpi] : fails if plumed is running without MPI[--has-dlopen] : fails if plumed is compiled without dlopen[--load LIB] : loads a shared object (typically a plugin library)[--standalone-executable] : tells plumed not to look for commands implemented as scripts Commands:plumed completion : dump a function usable for programmable completionplumed driver : analyze trajectories with plumedplumed driver-float : analyze trajectories with plumed (single precision version)plumed gen_example : construct an example for the manual that users can interact withplumed gentemplate : print out a template input for a particular actionplumed info : provide informations about plumedplumed kt : print out the value of kT at a particular temperatureplumed manual : print out a description of the keywords for an action in htmlplumed pathtools : print out a description of the keywords for an action in htmlplumed pdbrenumber : Modify atom numbers in a PDB, possibly using hybrid-36 codingplumed pesmd : Langevin dynamics on PLUMED energy landscapeplumed simplemd : run lj codeplumed sum_hills : sum the hills with plumedplumed selector : create lists of serial atom numbersplumed patch : patch an MD engineplumed partial_tempering : scale parameters in a gromacs topology to implement solute or partial temperingplumed vim2html : convert plumed input file to colored html using vim syntaxplumed config : inquire plumed about how it was configureplumed newcv : create a new collective variable from a templateplumed mklib : compile a .cpp file into a shared library騰訊云ECS的Centos系統(tǒng)再一次不負(fù)眾望。之前在ORCA、Gaussian16的安裝上就已經(jīng)出現(xiàn)過(guò)阿里云ECS無(wú)法成功安裝或運(yùn)行而騰訊ECS成功編譯的經(jīng)歷。這也告訴大家,有時(shí)候軟件編譯或安裝不成功,在排除掉自己的問(wèn)題之后,可能就是系統(tǒng)兼容性問(wèn)題或者軟件環(huán)境變量沖突了。
本小節(jié)參考資料:增強(qiáng)采樣軟件PLUMED的安裝與使用 - 騰訊云開(kāi)發(fā)者社區(qū)-騰訊云
PLUMED系列-安裝教程 | 小康學(xué)習(xí) | 計(jì)算化學(xué)與分子模擬愛(ài)好者
完成上述操作后,plumed可執(zhí)行文件應(yīng)該在執(zhí)行路徑中,您將能夠使用 PLUMED 分析現(xiàn)有軌跡或使用包含的 Lennard-Jones 代碼。但是,由于 PLUMED 主要用于偏向使用分子動(dòng)力學(xué)軟件包執(zhí)行的動(dòng)態(tài)模擬,您可以在下面找到有關(guān)如何修補(bǔ)您喜歡的 MD 代碼以便它可以與 PLUMED 結(jié)合。
3. 簡(jiǎn)單的入門(mén)案例(Collective Variables)
安裝成功之后,建議從官網(wǎng)的Getting Started開(kāi)始學(xué)習(xí)(對(duì)應(yīng)手冊(cè)93頁(yè))。
要運(yùn)行 PLUMED,您需要提供一個(gè)輸入文件。在此文件中,您可以指定 PLUMED 在運(yùn)行過(guò)程中應(yīng)該做什么。通常這將涉及計(jì)算一個(gè)或多個(gè)集體變量,也許是計(jì)算這些 集合變量 的函數(shù),然后對(duì)集體變量/函數(shù)的值進(jìn)行一些分析或運(yùn)行一些自由能計(jì)算的方法。如下所示:
DISTANCE ATOMS=1,2 LABEL=d1 PRINT ARG=d1 FILE=colvar STRIDE=10在這個(gè)輸入文件中,每一行都是 P??LUMED 執(zhí)行某些特定操作的指令(每隔10步將軌跡文件中原子1和原子2之間的距離打印到colvar文件中)。可能是計(jì)算一個(gè)colvar,分析一個(gè)軌跡(trajectory)或者偏置(bias)系統(tǒng)的動(dòng)力學(xué)。
這些行中的第一個(gè)詞指定要執(zhí)行的特定操作。然后是一些關(guān)鍵字,這些關(guān)鍵字為 PLUMED 提供了有關(guān)如何執(zhí)行操作的更多詳細(xì)信息。下面是對(duì)關(guān)鍵詞及集合變量的一些理解:
(1)集合變量通常分為兩類:一類是定義(原子)組和虛擬原子的變量,一般為虛擬原子坐標(biāo)或一組原子序號(hào),用于后續(xù)的第二類集合變量的計(jì)算使用,如center,com,ghost等,這一類的集合變量一共有11個(gè),見(jiàn)手冊(cè)5.1小節(jié);
(2)另外一類是鍵角、原子間距等集合變(CV)如DISTANCE, COORDINATION, 等等,可以將第二類集合變量理解為一種用于描述體系性質(zhì)的函數(shù)變量 。這類變量大概有34個(gè)。
(3)可以將每一個(gè)集合變量和Analysis關(guān)鍵詞理解為一個(gè)多變量的函數(shù),類似于python中定義的函數(shù),有若干限定輸入?yún)?shù)關(guān)鍵字,如上所說(shuō),這些關(guān)鍵字為 PLUMED 提供了有關(guān)如何執(zhí)行操作的更多詳細(xì)信息。比如GROUP集合變量關(guān)鍵詞后面可以跟的參數(shù)關(guān)鍵詞(包括ATOMS, REMOVE, SORT, UNIQUE, NDX_FILE, NDX_GROUP等)及默認(rèn)值如下:
(4)每一行的開(kāi)始要么是用于表示集合變量的小寫(xiě)字母(或與數(shù)字組合)加上冒號(hào),要么就是Analysis Keyword,如PRINT,等。后面跟的就是該函數(shù)可以調(diào)用的一些關(guān)鍵詞,手冊(cè)中在每個(gè)關(guān)鍵詞的說(shuō)明中都明確指出了。
(5)每一行格式: FirstWord ? KeyWords? LabelKeyword? 。注:Firstword一般來(lái)源于CV, Analysis, Bias中的關(guān)鍵詞,LabelKeyword一般是要傳遞的變量值(如計(jì)算得到的距離、鍵角),通常與Firstword含義相同,比如鍵角,距離,原子序號(hào)(原子坐標(biāo))等,常放在一行的開(kāi)頭,用小寫(xiě)字母數(shù)字組合自定義組合進(jìn)行標(biāo)記,后接冒號(hào)“:”。
CV(1):GROUP,? COM, CENTER, FIXEDATOM, ...
CV(2): ? DISTANCE, COORDINATION, ANGLE, ...
Analysis: PRINT, DUMPATOMS, ...
這些關(guān)鍵字要么是單個(gè)詞(它們告訴 PLUMED 以特定方式進(jìn)行計(jì)算 - 例如 NOPBC 告訴 PLUMED 在計(jì)算特定 colvar 時(shí)不要使用周期性邊界條件),或者它們可以是后跟等號(hào)的詞和沒(méi)有空格的逗號(hào)分隔列表數(shù)字或字符(例如 ATOMS=1,2,3,4 告訴 PLUMED 在計(jì)算特定 colvar 時(shí)使用原子編號(hào) 1,2,3 和 4)。不允許空格的原因是 PLUMED 應(yīng)該能夠理解原子列表何時(shí)結(jié)束,并且應(yīng)該期望一個(gè)新的關(guān)鍵字。如果整個(gè)列表包含在花括號(hào)中(例如 ATOMS={1 2 3 4}),則可以使用空格分隔列表而不是逗號(hào)分隔列表。請(qǐng)注意,您可以使用Continuation lines將命令拆分為多行。
這些關(guān)鍵字中最重要的是標(biāo)簽關(guān)鍵字(label keyword),因?yàn)橹挥惺褂眠@些標(biāo)簽,我們才能將數(shù)據(jù)從一個(gè)動(dòng)作傳遞到另一個(gè)動(dòng)作。如
d1: DISTANCE ATOMS=1,2 PRINT ARG=d1 FILE=colvar STRIDE=10然后 PLUMED 將每 10 步將原子 1 和 2 之間的距離值打印到文件 colvar 中,正如您告訴 PLUMED 采用由操作 d1 計(jì)算的值并打印它一樣。您可以使用任何字符串來(lái)標(biāo)記您的操作,只要它不以符號(hào) @ 開(kāi)頭。在 PLUMED 中,以 @ 開(kāi)頭的字符串用于引用特殊的、代碼生成的原子組,并為用戶在輸入中未提供標(biāo)簽的任何操作提供標(biāo)簽。
請(qǐng)注意,如果在行首添加了一個(gè)單詞后跟一列(例如 pippo:),PLUMED 會(huì)自動(dòng)刪除它并添加一個(gè)等效標(biāo)簽(LABEL=pippo)。因此,可以使用以下快捷方式獲得完全等效的結(jié)果。
DISTANCE ATOMS=1,2 LABEL=d1 PRINT ARG=d1 FILE=colvar STRIDE=10# 下面和上面是等效的 # d1: DISTANCE ATOMS=1,2 # PRINT ARG=d1 FILE=colvar STRIDE=10還要注意,所有動(dòng)作都可以被標(biāo)記,除了普通的集體變量之外,許多動(dòng)作可以定義一個(gè)或多個(gè)值,然后可以使用相應(yīng)的標(biāo)簽來(lái)引用。
如果您的系統(tǒng)上有正則表達(dá)式庫(kù)并在配置時(shí)檢測(cè)到,則也可以使用 POSIX 正則表達(dá)式(請(qǐng)參閱正則表達(dá)式)引用操作。您還可以在輸入中添加注釋或在多個(gè)文件中設(shè)置輸入,然后通過(guò)包含其他文件創(chuàng)建復(fù)合輸入。
- 集體變量告訴你計(jì)算原子位置函數(shù)的方法。
- 分析告訴您可以使用 PLUMED 在軌跡上運(yùn)行的各種形式的分析。
- Bias告訴您可以使用 PLUMED 偏置分子動(dòng)力學(xué)模擬的方法。
可以通過(guò)指定plumed默認(rèn)單位的轉(zhuǎn)換因子或使用與下面給出的定義單位之一相對(duì)應(yīng)的字符串來(lái)設(shè)置新單位。該指令必須出現(xiàn)在 plumed.dat 文件的開(kāi)頭。必須在整個(gè) plumed.dat 文件中使用相同的單位。
# this is using Angstrom - kj/mol - fs UNITS LENGTH=A TIME=fs # compute distance between atoms 1 and 4 d: DISTANCE ATOMS=1,4 # print time and distance on a COLVAR file PRINT ARG=d FILE=COLVAR # dump atoms 1 to 100 on a 'out.gro' file DUMPATOMS FILE=out.gro STRIDE=10 ATOMS=1-100 # dump atoms 1 to 100 on a 'out.xyz' file DUMPATOMS FILE=out.xyz STRIDE=10 ATOMS=1-100在COLVAR文件中,時(shí)間和距離將分別出現(xiàn)在 fs 和 A 中,無(wú)論您在主機(jī) MD 代碼中使用的單位是什么。文件中的坐標(biāo)out.gro將以 nm 表示,因?yàn)間ro按照慣例,文件是用 nm 編寫(xiě)的。由于我們使用 UNITS 命令設(shè)置 Angstrom 單位,因此文件中的坐標(biāo)out.xyz將以 Angstrom 寫(xiě)入。事實(shí)上,在 PLUMED xyz 文件中使用的是內(nèi)部 PLUMED 單位,不一定是埃!
LENGTH: nm (default), A (for Angstrom), um (for micrometer), Bohr (0.052917721067 nm)ENERGY: kj/mol (default), j/mol, kcal/mol (4.184 kj/mol), eV (96.48530749925792 kj/mol), Ha (for Hartree,2625.499638 kj/mol)TIME: ps (default), fs, ns, atomic (2.418884326509e-5 ps)MASS: amu (default)CHARGE: e (default)4. 集合變量
化學(xué)系統(tǒng)包含大量原子,在大多數(shù)情況下,這使我們無(wú)法通過(guò)直接監(jiān)測(cè)原子位置來(lái)理解任何事情。因此,我們引入了描述我們感興趣的化學(xué)過(guò)程的集體變量 (CV),并改為監(jiān)控這些更簡(jiǎn)單的數(shù)量。這些 CV 用于 PLUMED 中實(shí)現(xiàn)的許多方法中 - 可以使用PRINT監(jiān)控值,可以計(jì)算它們的函數(shù),或者可以使用PLUMED 中實(shí)現(xiàn)的分析和偏置方法對(duì)它們進(jìn)行分析或偏置。然而,在做任何這些事情之前,我們首先必須告訴 PLUMED 如何計(jì)算它們。
在 PLUMED 中實(shí)現(xiàn)的最簡(jiǎn)單的集合變量采用一組原子位置并輸出一個(gè)或多個(gè)標(biāo)量 CV 值。有關(guān)這些變量的信息在標(biāo)題為CV 文檔的頁(yè)面上提供,而有關(guān)如何選擇原子集的信息可以在Groups 和 Virtual Atoms頁(yè)面中找到。請(qǐng)注意,PLUMED 包含許多其他集體變量的實(shí)現(xiàn),但這些變量的輸入在第一次遇到時(shí)可能不太透明。特別是關(guān)于與參考配置的距離的頁(yè)面描述了計(jì)算與特定參考配置的距離的各種方法。因此,您將在此處找到有關(guān)如何計(jì)算蛋白質(zhì)折疊狀態(tài)的 RMSD 距離的說(shuō)明。同時(shí),Functions頁(yè)面描述了可以在代碼中使用的集合變量的各種功能。這是 PLUMED 的一個(gè)非常強(qiáng)大的功能,因?yàn)槟梢允褂煤瘮?shù)命令來(lái)計(jì)算任何函數(shù)或CV 文檔頁(yè)面上列出的簡(jiǎn)單集合變量的組合。最后,MultiColvar 上的頁(yè)面描述了 MultiColvars。
MultiColvars 允許您使用許多不同的 colvars,并允許我們?cè)跊](méi)有大量代碼的情況下實(shí)現(xiàn)所有這些集體變量。對(duì)于某些事情(例如DISTANCES?GROUPA=1 GROUPB=2-100 LESS_THAN={RATIONAL R_0=3}),plumed 中有更多計(jì)算效率更高的選項(xiàng)(例如COORDINATION)。然而,MultiColvars 值得研究,因?yàn)樗鼈優(yōu)樵S多相當(dāng)復(fù)雜的 CV 提供了靈活的語(yǔ)法。
(1)指定原子
在 PLUMED 中實(shí)現(xiàn)的絕大多數(shù) CV 都是從原子位置列表中計(jì)算出來(lái)的。在 PLUMED 中,原子使用分子動(dòng)力學(xué)輸入文件中的數(shù)字索引指定。
在 PLUMED 中,原子列表可以直接在每個(gè)集合變量的定義中提供,也可以預(yù)定義為可以多次重用的GROUP 。原子列表可以寫(xiě)成:
- 逗號(hào)分隔的數(shù)字列表 (?GROUP ATOMS=10,11,15,20 LABEL=g1)
- 數(shù)值范圍。所以GROUP ATOMS=10-20 LABEL=g2相當(dāng)于GROUP ATOMS=10,11,12,13,14,15,16,17,18,19,20 LABEL=g2
- 具有步幅的數(shù)值范圍。所以GROUP ATOMS=10-100:10 LABEL=g3 is equivalent toGROUP ATOMS=10,20,30,40,50,60,70,80,90,100 LABEL=g3
- atoms ranges with a negative stride. SoGROUP ATOMS=100-10:-10 LABEL=g4 相當(dāng)于GROUP ATOMS=100,90,80,70,60,50,40,30,20,10 LABEL=g4
此外,還有一些快捷方式可以使用:
- @mdatoms表示 MD 引擎中存在的所有物理原子(例如DUMPATOMS ATOMS=@mdatoms)。
- @allatoms表示所有原子,包括那些僅在 PLUMED 中定義的原子(例如DUMPATOMS ATOMS=@allatoms)。
PLUMED 中定義的虛擬原子列表可以通過(guò)命令獲取GROUP ATOMS=@allatoms REMOVE=@mdatoms。
如果您使用MOLINFO命令加載分子的結(jié)構(gòu),則可以使用其他快捷方式。
以上所有方法都可以組合在一起,只需將一個(gè)名稱放在另一個(gè)名稱之后,用逗號(hào)分隔:
g5: DUMPATOMS ATOMS=1,2,10-20,40-60:5,100-70:-2 FILE=test.xyz一些集體變量必須接受固定數(shù)量的原子,例如,DISTANCE僅使用兩個(gè)原子計(jì)算,ANGLE使用 3 或 4 個(gè)原子計(jì)算,TORSION使用 4 個(gè)原子計(jì)算。
plumed的獨(dú)立運(yùn)行通常包含3類文件:軌跡文件、運(yùn)行控制文件input file、運(yùn)行得到的輸出文件。需要重點(diǎn)學(xué)習(xí)plumed的關(guān)鍵詞語(yǔ)法。同時(shí)plumed也包含了若干命令行工具,如下所示(對(duì)應(yīng)手冊(cè)717頁(yè)),接下來(lái)的測(cè)試中會(huì)用到其中的一部分。
5. 命令行工具
plumed的命令行工具主要包含以下這些,調(diào)用格式如下
plumed <toolname> <list of input flags for that tool>
?以config的使用為例,config用于判斷編譯plumed時(shí)是否安裝了某些包。
plumed config makefile_conf??? #
plumed config show??? # 展示plumed所有的configuration
?info 命令行工具 ,查詢plumed的版本,調(diào)用格式如下
?driver 命令行工具??
driver 是一種工具,它允許人們使用 plumed 對(duì)現(xiàn)有軌跡進(jìn)行后處理。 使用下面描述的命令行參數(shù)指定驅(qū)動(dòng)程序的輸入。 此外,您可以在plumed輸入中使用特殊的 READ?命令來(lái)讀取在 MD 模擬期間生成的 colvar 文件。 然后可以將讀入的值視為計(jì)算的 colvars。
下面是一些典型的driver調(diào)用命令
# 后處理trajectory.xyz軌跡文件 plumed driver --plumed plumed.dat --ixyz trajectory.xyz# 后處理trajectory.xyz軌跡文件 # 請(qǐng)注意 xyz文件應(yīng)采用內(nèi)部 PLUMED 單位,默認(rèn)情況下為 nm。 您可以使用 --length-units選項(xiàng) # 在這種情況下,驅(qū)動(dòng)程序讀取 xyz文件假設(shè)它包含以埃為單位的坐標(biāo)。 然而,由此產(chǎn)生的 colvar文件包含以 nm 表示的距離。 plumed driver --plumed plumed.dat --ixyz trajectory.xyz --length-units A # plumed.dat輸入文件內(nèi)容如下 BEGIN_PLUMED_FILE working DATADIR=example-check/driver.tmp # no explicit UNITS action here d: DISTANCE ATOMS=1,2 PRINT ARG=d FILE=colvarplumed driver --plumed plumed.dat --ixyz trajectory.xyz --trajectory-stride 100 --timestep 0.001plumed driver --plumed plumed.dat --pdb diala.pdb --mf_xtc traj.xtc --trajectory-stride 100 --timestep 0.001plumed driver --plumed plumed.dat --imf_crd trajectory.crd --natoms 128?
參考資料:
增強(qiáng)采樣軟件PLUMED的安裝與使用 - DECHIN - 博客園
增強(qiáng)采樣軟件PLUMED的安裝與使用 - 騰訊云開(kāi)發(fā)者社區(qū)-騰訊云
淺談PCA與g_covar+g_anaeig+ddtdp+sigmaplot做自由能面圖的方法 - 思想家公社的門(mén)口:量子化學(xué)·分子模擬·二次元
高斯核函數(shù)_擺爛辦不到的博客-CSDN博客_gaussian kernel
高斯函數(shù)(Gaussian function)的詳細(xì)分析_青龍戰(zhàn)的博客-CSDN博客_高斯函數(shù)
Metadynamic論文1 - 知乎
Umbrella Sampling
【分子模擬】Metadynamics - 知乎
總結(jié)
以上是生活随笔為你收集整理的【Plumed教程(一)】增强采样Plumed入门的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: RENIX软件RTSM基本操作_Linu
- 下一篇: 液晶面板GOA技术