||
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
有不对的理解,欢迎指正和批评
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-4-23 21:16
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社