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: Axel Kohlmeyer Date: Tue, 12 Dec 2017 11:05:48 -0500

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@...6297....sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lammps-users