XJTUhehuan的个人博客分享 http://blog.sciencenet.cn/u/XJTUhehuan

博文

lammps中如何获取某个时刻,某个原子的compute量?

已有 10198 次阅读 2018-10-31 10:57 |系统分类:科研笔记| lammps

 lammps计算中,如果你想获得,ID为1的原子在1000timestep的动能,一般的写法可能就是如下:

compute  1  all  pe/atom
variable  pe equal c_1[1]
timestep  0.001
thermo          100 
thermo_style custom temp pe etotal press
run 1000
variable  pe_init equal ${pe}

但这样会报错,Error: compute used in variable between runs is not current

这是为什么?原因就在于 lammps中要获取compute的量时,要调用compute,而这个调用的过程是不能在run中调用。

lammps手册中给了一种解决方法就是,perform a 0-timestep run before using the variable。

但在加了run 0之后还是会报错,Error: compute used in variable between runs is not current

compute  1  all  pe/atom
variable  pe equal c_1[1]
timestep  0.001
thermo          100 
thermo_style custom temp pe etotal press
run 1000
run 0
variable  pe_init equal ${pe}

翻了翻官方论坛后发现。

其实,最好的解决方案应该是将你要variable的这个量,输出到屏幕出来,这样就会保存这个量,从而可以随时调用,随时读取。

正确的写法应该是

compute  1  all  pe/atom
variable  pe equal c_1[1]
timestep  0.001
thermo          100 
thermo_style custom temp pe etotal press v_pe
run 1000
variable  pe_init equal ${pe}

这样你就可以取到ID为1的原子在1000timestep的动能

具体的可以仔细看看 variable这一章下面的variable accuracy

有不对的理解,欢迎指正和批评



https://blog.sciencenet.cn/blog-3362186-1143738.html

上一篇:Torque在CentOS7上单机安装
收藏 IP: 111.20.225.*| 热度|

0

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

数据加载中...

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

GMT+8, 2024-4-23 21:16

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部