[lammps-users] About the variable command

Dear all,

I have encountered some difficulties when trying to use the variable command. I want to simulate changing one body’s velocity, e.g. from 1 to 5, and I set up variable as follows:

variable vx loop $5

velocity body set v_vx 0 0

run 1000

next vx
run 1000

However, there is an error: Substitution for illegal variable. What’s wrong with my usage above?

Many thanks,
Damien

2008-06-19

You have not defined variable “5” before and you are trying to substitute value or it. … That is the problem.

try
variable vx loop 5
instead of
variable vx loop $5


velocity body set v_vx 0 0

run 1000
next vx
run 1000

You may also want to use jump command after next, if you want to set the velocities 5 times. Please refer to the manual for that.

Regards,
Vikas