occam-hpf仿真分析与综合工具
occamtools的Python项目详细描述
occamtools公司 ·
分子动力学/混合粒子场模拟的分析和合成工具。
对OCCAM的输入主要包括三种文件类型;fort.1
(模拟元数据)、fort.3
(粒子和键参数)和fort.5
(位置和键结构)。运行的输出是一个fort.8
文件,遵循^{
安装
安装方式(要求python>;=3.6)
> pip install occamtools
用法
加载数据 · 加载模拟数据由
importnumpyasnpfromoccamtoolsimportOccamDatadata=OccamData('your/file/or/directory/here')
其中data
对象现在保存有关模拟运行的所有信息,例如打印模拟包含的粒子种类
print('Simulation consists of...')fortype_nameindata.type_dict:num_type=sum(data.type==data.type_dict[type_name])print(f' - {num_type} particles of type {type_name}')# Simulation consists of...# - 400 particles of type H# - 100 particles of type C# - 250 particles of type Ar# ...
或者在模拟盒的扩散部分绘制一个简单的粒子图(需要pip install asciichartpy
)
fromasciichartpyimportplotindices=(data.x[0,:]>20.0)&(data.x[0,:]<25.0)diffused=data.x[-1,indices]bins,hist=np.histogram(diffused)print(plot(bins.tolist(),hist.tolist()))# 9.00 ┤ ╭─╮# 8.00 ┤ │ ╰╮# 7.00 ┤ │ │# 6.00 ┤ ╭╯ ╰╮# 5.00 ┤ │ ╰╮# 4.00 ┤ │ │# 3.00 ┤╭╯ │# 2.00 ┤│ ╰╮# 1.00 ┼╯ ╰
或者绘制总动能与模拟运行平均值的偏差(同样需要pip install asciichartpy
)
kinetic_energy_deviations=data.kinetic_energy-np.mean(data.kinetic_energy)print(plot(kinetic_energy_deviations.tolist()))# 60.53 ┤ ╭╮# 50.62 ┤ ││ ╭╮╭╮# 40.71 ┤ ││ ││││ ╭╮# 30.81 ┤ ││ ││││ ││ ╭╮ ╭─# 20.90 ┤ ╭╮ ││ ││││ ╭─╮ ││ ││ │# 10.99 ┤ ││ ╭─╮ ╭╮ ╭╯│ ││││╭╮ │ │ ╭╮ ││ ││ │# 10.09 ┤ ││ │ │ ││ │ │ │││││╰╮ │ ╰╮││ ││ ╭╮ ││╭╮╭╮│# 0.18 ┼╮││ │ │ ││ │ ╰╮ │││╰╯ │ │ ╰╯│╭╮ │╰╮││╭╮│││││││# -00.73 ┤│││ │ │ ││ │ ╰─╯││ │╭╯ ││╰──╯ ╰╯││││││││││# -10.64 ┤│││╭╯ │ ││╭╯ ││ ││ ╰╯ ││││││││╰╯# -20.54 ┤││╰╯ │ │╰╯ ╰╯ ╰╯ ││││││╰╯# -30.45 ┤╰╯ ╰─╯ ││││╰╯# -40.36 ┤ ││││# -50.26 ┤ ││╰╯# -60.17 ┤ ╰╯
文件存储
·
在幕后,使用.npy
(对于numpy数组)和.json
(对于任何其他文件)来表示模拟数据。默认情况下,加载模拟运行会导致保存包含数据的小(相对于原始fort.5/7/8
)二进制文件。这些用于从后续调用中加载。这意味着在第一次调用后,对OccamData('your/file/here')
的OccamData.load('your/file/here')
的调用将显著加快。在这个具体的例子中,达到了25倍的加速(但是你的里程数可能会有所不同)。
使用tox
运行测试
假设python3.7
已经安装,使用pyenv
by安装单独的3.6
和3.8
实例
> brew install pyenv > pyenv install 3.6.6 > pyenv install 3.8-dev
然后在occamtools
目录中执行
> git clone git@github.com:mortele/OccamTools.git occamtools > cd occamtools > pyenv local3.6.6 3.8-dev > pip3 install tox-pyenv > tox
它将对python版本3.6
、3.7
和3.8
开发构建运行单元测试(使用pytest
)。
occam
occam是一个分子动力学模拟程序,能够进行混合粒子场(pf)理论分子动力学模拟。最近的pf技术结合了分子动力学(md)和自洽场理论(scf)。Read more.
更改日志
0.3.3:添加选项以在加载OccamData
对象时不保存.npy
文件。修复在读取非常短的.xyz
文件时导致错误的错误。修复使用replace_in_fort3
时导致网格大小无法正确更新的错误。
0.3.2:添加python alpha版本的测试3.8-dev
,stream line travis集成和覆盖率报告。
0.3.1:将bins
关键字参数从显式参数移到由np.histogram
处理的**kwargs
。
0.3.0:添加直方图计算功能。
0.2.7:将velocity_traj
标志添加到fort1
文件读取器。
0.2.6:使用^{3.6
和3.7
添加适当的测试。
0.2.5:将所需的python版本更改为>=3.6
(从>=3.7
)。
0.2.4:添加读取带有附加速度信息的.xyz
文件的功能,当在fort.1
中设置velocity_traj
标志时由occam输出。
0.2.3:代码清理。
0.2.2:扩展repace_in_fort3
以允许改变压缩性和非键相互作用。修复一个错误,该错误导致在写入fort.3
文件时添加的新粒子类型破坏chi矩阵。
0.2.1:更新__init__.py
的__all__
变量,以反映新添加的类和方法。
0.2.0:添加编辑fort.3
文件的功能(在plac中或者创造新的)。
0.1.0:添加编辑fort.1
文件的功能(就地或创建新文件)。