用于分子化学计算分析和记录的python api

pygauss的Python项目详细描述


文档https://pygauss.readthedocs.org

conda发行版https://binstar.org/cjs14/pygauss

项目https://github.com/chrisjsewell/PyGauss

https://readthedocs.org/projects/pygauss/badge/?version=stablehttps://img.shields.io/github/release/chrisjsewell/PyGauss.svg

pygauss是一个交互式工具,用于支持 计算分子化学研究的生命周期。 从视觉和分析探索, 到文档和出版物。

最初的pygauss是为了检查一个或多个 Gaussian量子化学 计算,几何电子。它建在 cclib/chemview/chemlab 包套件和python科学堆栈,因此应该是可扩展的 其他类型的计算化学分析。 pygauss主要用于 IPython Notebook

如实例所示,分子优化可以被认为是 个人(很像 gaussview),但也作为 一群人的一部分。这样,此软件包的优点是:

  • 更快、更高效的分析
  • 可扩展分析
  • 可重复分析

快速启动

OSX和Linux

建议使用pygauss来下载 Anaconda科学Python 分布(64位)。一旦下载,就可以创建一个新的环境 安装在终端和pygauss中:

conda create -n pg_env -c https://conda.binstar.org/cjs14 pygauss

窗口

当前没有pygauss conda可用于windows或 Chemlab,它有需要使用编译器构建的C扩展。 请参阅文档以获取指导。

示例评估

安装pygauss之后,您应该能够打开这个ipython 笔记本; https://github.com/chrisjsewell/PyGauss/blob/master/Example_Assessment.ipynb, 然后运行以下…

fromIPython.displayimportdisplay,Image%matplotlibinlineimportpygaussaspgprint'pygauss version: {}'.format(pg.__version__)
pygauss version: 0.6.0

测试文件夹中有许多高斯输出示例 和。

folder=pg.get_test_folder()len(folder.list_files())
33

注意:无论使用本地 通过ssh的服务器上的路径或路径(使用 paramiko):

folder = pg.Folder('/path/to/folder',
                ssh_server='login.server.com',
                ssh_username='username')

单分子分析

可以创建一个分子,其中包含关于初始几何结构的数据, 优化过程和最终配置分析。

mol=pg.molecule.Molecule(folder_obj=folder,init_fname='CJS1_emim-cl_B_init.com',opt_fname=['CJS1_emim-cl_B_6-311+g-d-p-_gd3bj_opt-modredundant_difrz.log','CJS1_emim-cl_B_6-311+g-d-p-_gd3bj_opt-modredundant_difrz_err.log','CJS1_emim-cl_B_6-311+g-d-p-_gd3bj_opt-modredundant_unfrz.log'],freq_fname='CJS1_emim-cl_B_6-311+g-d-p-_gd3bj_freq_unfrz.log',nbo_fname='CJS1_emim-cl_B_6-311+g-d-p-_gd3bj_pop-nbo-full-_unfrz.log',atom_groups={'emim':range(20),'cl':[20]},alignto=[3,2,1])

几何分析

分子可以静态地或交互地观察。

#mol.show_initial(active=True)vdw=mol.show_initial(represent='vdw',rotations=[[0,0,90],[-90,90,0]])ball_stick=mol.show_optimisation(represent='ball_stick',rotations=[[0,0,90],[-90,90,0]])display(vdw,ball_stick)
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_9_0.pnghttps://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_9_1.png
print'Cl optimised polar coords from aromatic ring : ({0}, {1},{2})'.format(*[round(i,2)foriinmol.calc_polar_coords_from_plane(20,3,2,1)])ax=mol.plot_opt_trajectory(20,[3,2,1])ax.set_title('Cl optimisation path')ax.get_figure().set_size_inches(4,3)
Cl optimised polar coords from aromatic ring : (0.11, -116.42,-170.06)
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_10_1.png

能量学和频率分析
print('Optimised? {0}, Conformer? {1}, Energy = {2} a.u.'.format(mol.is_optimised(),mol.is_conformer(),round(mol.get_opt_energy(units='hartree'),3)))ax=mol.plot_opt_energy(units='hartree')ax.get_figure().set_size_inches(3,2)ax=mol.plot_freq_analysis()ax.get_figure().set_size_inches(4,2)
Optimised? True, Conformer? True, Energy = -805.105 a.u.
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_12_1.pnghttps://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_12_2.png

几何构型的势能扫描分析…

mol2=pg.molecule.Molecule(folder_obj=folder,alignto=[3,2,1],pes_fname=['CJS_emim_6311_plus_d3_scan.log','CJS_emim_6311_plus_d3_scan_bck.log'])ax=mol2.plot_pes_scans([1,4,9,10],rotation=[0,0,90],img_pos='local_maxs',zoom=0.5)ax.set_title('Ethyl chain rotational conformer analysis')ax.get_figure().set_size_inches(7,3)
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_14_0.png

部分电荷分析

使用自然键轨道(nbo)分析

print'+ve charge centre polar coords from aromatic ring: ({0} {1},{2})'.format(*[round(i,2)foriinmol.calc_nbo_charge_center(3,2,1)])display(mol.show_nbo_charges(represent='ball_stick',axis_length=0.4,rotations=[[0,0,90],[-90,90,0]]))
+ve charge centre polar coords from aromatic ring: (0.02 -51.77,-33.15)
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_16_1.png

状态密度分析
print'Number of Orbitals: {}'.format(mol.get_orbital_count())homo,lumo=mol.get_orbital_homo_lumo()homoe,lumoe=mol.get_orbital_energies([homo,lumo])print'HOMO at {} eV'.format(homoe)print'LUMO at {} eV'.format(lumoe)
Number of Orbitals: 272
HOMO at -4.91492036773 eV
LUMO at -1.85989816817 eV
ax=mol.plot_dos(per_energy=1,lbound=-20,ubound=10,legend_size=12)
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_19_0.png

键合分析

用二阶微扰理论。

print'H inter-bond energy = {} kJmol-1'.format(mol.calc_hbond_energy(eunits='kJmol-1',atom_groups=['emim','cl']))print'Other inter-bond energy = {} kJmol-1'.format(mol.calc_sopt_energy(eunits='kJmol-1',no_hbonds=True,atom_groups=['emim','cl']))display(mol.show_sopt_bonds(min_energy=1,eunits='kJmol-1',atom_groups=['emim','cl'],no_hbonds=True,rotations=[[0,0,90]]))display(mol.show_hbond_analysis(cutoff_energy=5.,alpha=0.6,atom_groups=['emim','cl'],rotations=[[0,0,90],[90,0,0]]))
H inter-bond energy = 111.7128 kJmol-1
Other inter-bond energy = 11.00392 kJmol-1
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_21_1.pnghttps://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_21_2.png

多计算分析

多重计算,例如不同的起始构象, 可以分组到一个analysis类中,并集体进行分析。

analysis=pg.Analysis(folder_obj=folder)errors=analysis.add_runs(headers=['Cation','Anion','Initial'],values=[['emim'],['cl'],['B','BE','BM','F','FE']],init_pattern='*{0}-{1}_{2}_init.com',opt_pattern='*{0}-{1}_{2}_6-311+g-d-p-_gd3bj_opt*unfrz.log',freq_pattern='*{0}-{1}_{2}_6-311+g-d-p-_gd3bj_freq*.log',nbo_pattern='*{0}-{1}_{2}_6-311+g-d-p-_gd3bj_pop-nbo-full-*.log',alignto=[3,2,1],atom_groups={'emim':range(1,20),'cl':[20]},ipython_print=True)
Reading data 5 of 5

分子比较
fig,caption=analysis.plot_mol_images(mtype='optimised',max_cols=3,info_columns=['Cation','Anion','Initial'],rotations=[[0,0,90]])printcaption
(A) emim, cl, B, (B) emim, cl, BE, (C) emim, cl, BM, (D) emim, cl, F, (E) emim, cl, FE
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_26_1.png

数据比较
fig,caption=analysis.plot_mol_graphs(gtype='dos',max_cols=3,lbound=-20,ubound=10,legend_size=0,band_gap_value=False,info_columns=['Cation','Anion','Initial'])printcaption
(A) emim, cl, B, (B) emim, cl, BE, (C) emim, cl, BM, (D) emim, cl, F, (E) emim, cl, FE
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_28_1.png

所述的间接分子方法可应用于所有或 这些计算的一个子集。

analysis.add_mol_property_subset('Opt','is_optimised',rows=[2,3])analysis.add_mol_property('Energy (au)','get_opt_energy',units='hartree')analysis.add_mol_property('Cation chain, $\\psi$','calc_dihedral_angle',[1,4,9,10])analysis.add_mol_property('Cation Charge','calc_nbo_charge','emim')analysis.add_mol_property('Anion Charge','calc_nbo_charge','cl')analysis.add_mol_property(['Anion-Cation, $r$','Anion-Cation, $\\theta$','Anion-Cation, $\\phi$'],'calc_polar_coords_from_plane',3,2,1,20)analysis.add_mol_property('Anion-Cation h-bond','calc_hbond_energy',eunits='kJmol-1',atom_groups=['emim','cl'])analysis.get_table(row_index=['Anion','Cation','Initial'],column_index=['Cation','Anion','Anion-Cation'])

还有一个选项(要求 pdflatexghostscript+imagemagik) 将表输出为乳胶格式的图像。

analysis.get_table(row_index=['Anion','Cation','Initial'],column_index=['Cation','Anion','Anion-Cation'],as_image=True,font_size=12)
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_32_0.png

多变量分析

radviz是一种可视化多变量数据的方法。

ax=analysis.plot_radviz_comparison('Anion',columns=range(4,10))
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_35_0.png

kmeans算法通过尝试将样本分为n个来聚类数据。 等方差组。

pg.utils.imgplot_kmean_groups(analysis,'Anion','cl',4,range(4,10),output=['Initial'],mtype='optimised',rotations=[[0,0,90],[-90,90,0]],axis_length=0.3)
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_37_0.png
(A) BM
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_37_2.png
(A) FE
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_37_4.png
(A) B, (B) BE
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_37_6.png
(A) F

文档(MS Word)

在分析了计算结果后,有理由希望 记录我们的一些发现。这可以通过输出 通过文件夹对象的单个图形或表图像。

file_path=folder.save_ipyimg(vdw,'image_of_molecule')Image(file_path)
https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/output_40_0.png

但你也可能想要更全面地记录你的分析, 这里是python-docx 介入。在这个包的基础上,pygauss msdocument类可以 生成分析的完整文档。

importmatplotlib.pyplotaspltd=pg.MSDocument()d.add_heading('A Pygauss Example Assessment',level=0)d.add_docstring("""
# Introduction

We have looked at the following aspects
of [EMIM]^{+}[Cl]^{-} (C_{6}H_{11}ClN_{2});

- Geometric conformers
- Electronic structure

# Geometric Conformers
""")fig,caption=analysis.plot_mol_images(max_cols=2,rotations=[[90,0,0],[0,0,90]],info_columns=['Anion','Cation','Initial'])d.add_mpl(fig,dpi=96,height=9,caption=caption)plt.close()d.add_paragraph()df=analysis.get_table(columns=['Anion Charge','Cation Charge'],row_index=['Anion','Cation','Initial'])d.add_dataframe(df,incl_indx=True,style='Medium Shading 1 Accent 1',caption='Analysis of Conformer Charge')d.add_docstring("""
# Molecular Orbital Analysis
## Density of States

It is **important** to *emphasise* that the
computations have only been run in the gas phase.
""")fig,caption=analysis.plot_mol_graphs(gtype='dos',max_cols=3,lbound=-20,ubound=10,legend_size=0,band_gap_value=False,info_columns=['Cation','Anion','Initial'])d.add_mpl(fig,dpi=96,height=9,caption=caption)plt.close()d.save('exmpl_assess.docx')

这给了我们以下信息:

https://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/example_docx1.pnghttps://github.com/chrisjsewell/PyGauss/raw/master/docs/source/images/example_docx2.png

还有更多!!

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Eclipse无法识别jsonsimple   linux Tomcat是否在符号链接/usr/bin/java下使用java?   使用Swing工具包构建Java GUI   java Subversive SVN只检出丢失的文件   java语言在没有显式类型转换的情况下能否“完整”?   Selenium>Webdriver>Java>单击模型窗口中的按钮时,另一个后台按钮正在触发   Java私有视频YouTube   JavaScriptJava。lang.NullPointerException servlet   java More Mockito返回\u DEEP\u STUBS悲哀   迭代器Java,谷歌收藏库;AbstractIterator有问题吗?   使用java在flash网页中获取验证码会话的http图像   sql从java向ms access插入数据   java Android WebView不加载URL?   制作java自定义注释以标记用于html清理的bean属性   java如何在Jframe中输出结果