LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Mailing List Archives
Re: [lammps-users] Questions about loop in lammps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lammps-users] Questions about loop in lammps


From: "Xuechen Zheng" <xuechen_zheng@...730...>
Date: Wed, 13 Dec 2017 09:17:36 +0800 (GMT+08:00)


Dear Dr Axel,

    I have another question. The python scripts need to input a atom coordinate to get the force. It cannot input all atoms' coordinate. The previous way is to set the first atom's coordinate as the input for python. I do not know how to use compute reduce to input the coordinate to python one by one and then get the sum of the force. Could you tell me more about it?


Thanks!   




Xuechen Zheng



-----原始邮件-----
发件人:"Axel Kohlmeyer" <akohlmey@...24...>
发送时间:2017-12-13 00:05:48 (星期三)
收件人: "Xuechen Zheng" <xuechen_zheng@...730...>
抄送: "LAMMPS Users Mailing List" <lammps-users@lists.sourceforge.net>
主题: Re: [lammps-users] Questions about loop in lammps

Don't do a loop, use compute reduce instead. 
Axel 



--
Dr. Axel Kohlmeyer  akohlmey@...24...  http://goo.gl/1wk0
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.

On Dec 12, 2017 10:54, "Xuechen Zheng" <xuechen_zheng@...730...> wrote:

Dear all,

   I would like to addforce to lammps and the force is calculated by python scripts. However, it seems that it just evaluates the forces per atom. I want to sum the force of all atoms and add it to all atoms. The present input file is 

variable         tz2 equal z[1]
 variable         tx2 equal x[1]

 variable         tz2 equal z[1]

 variable         force_z python force_CH4_z
 python           force_CH4_z input 3 v_tx2 v_ty2 v_tz2 return v_force_z format ffff file  interp.py

 fix               3 all addforce 0 0 v_force_z

It just calculate the first atom's force and it works. Could you tell me how to do a loop that can sum the force of all atoms and do the remaining calculation. I tried the flowing commend

label            loop 

variable         a loop 100

variable         tz2 equal z[a]

variable         tx2 equal x[a]

variable         ty2 equal y[a]


variable         force_z python force_CH4_z

python           force_CH4_z input 3 v_tx2 v_ty2 v_tz2 return v_force_z format ffff file interp.py

fix               3 all addforce 0 0 v_force_z

clear

next              a

jump             z_move.force

"

But the result is that "Segmentation fault". Could you tell me how to set a corect loop? 

Thanks!



Xuechen Zheng



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
lammps-users mailing list
lammps-users@...396...sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lammps-users