[lammps-users] can we implement 'do loop'??

Dear forum,

I would like to incorporate something similar to what is written below in my input script. But not sure how
to implement this.

do i = 1, N
if (mod(i,2) == 0) then
fix command 1
else
fix command 2
end if
end do

Here ‘i’ is the time step. I want to use ‘fix command 1’ if the time step is even and ‘fix command 2’ if it is odd.

Cheers
Srikanth

Dear forum,

I would like to incorporate something similar to what is written below in my
input script. But not sure how
to implement this.

have a closer look at the documentation!
particularly, the examples for the "next" command.

cheers,
   axel.

The next command will do a loop but its not a loop
within a run with timestepping. Thus it makes no
sense to define a fix N/2 times on odd steps and
another fix N/2 times on even steps. Fixes are
defined before a run takes place.

Steve

I think I have got what I want but still there is a small problem.

variable pi equal 3.14159265
variable tp equal 10
variable alpha equal 0.005
variable con equal 2*{pi}/{tp}
variable nts equal 20
print “{pi} {tp} {alpha} {con} ${nts}”

variable t loop ${nts}
label loop
print "t" variable f equal 0.05+{alpha}sin(${con}$t)
print “$f” # line 1
fix 4 flow addforce f 0.0 0.0 # line 2
run 1
unfix 4
next t
jump equil.in loop
print “out of the loop now”

Using the definition of ‘f’ in line 1 or line 2 produces an error “Group ID in variable formula does not exist”. Where am I going wrong?

Cheers
Srikanth

Run your script with -echo screen and figure out what
line is producing the error. That line is an incorrect
variable. Also there is a difference between
using ${con} in a variable vs v_con. Read the doc
page on variables to learn about it.

Steve