LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Mailing List Archives
[lammps-users] summing too many variables in a loop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lammps-users] summing too many variables in a loop


From: Mostafa Nejatolahi <mostafa.nejatolahi@...24...>
Date: Sat, 15 Jul 2017 04:10:07 +0430

Hello all,

I will be appreciated if someone tells me a way to calculate a summation like the following in a shorter way (the number of variables could be higher like 81, 125, ...).

variable        Jx equal v_Jx1+v_Jx2+v_Jx3+v_Jx4+v_Jx5+v_Jx6+v_Jx7&
+v_Jx8+v_Jx9+v_Jx10+v_Jx11+v_Jx12+v_Jx13+v_Jx14&
+v_Jx15+v_Jx16+v_Jx17+v_Jx18+v_Jx19+v_Jx20+v_Jx21&
+v_Jx22+v_Jx23+v_Jx24+v_Jx25+v_Jx26+v_Jx27

I used a loop-next-jump command but I got this error:
ERROR: Variable has circular dependency (../variable.cpp:1823)

variable sum equal 0 
variable i loop 27 
label start_of_loop_5 
#--------------------------------
variable sum equal v_sum+v_Jx$i
#-------------------------------- 
next
jump SELF start_of_loop_5 



Regards
MN