Update if -elif else loop every run step

Submitted by Sounik on Tue, 01/22/2019 - 21:49

Hi Users,

I want to apply a constant velocity to a specimen until a target value of variables a17 and a15 are reached, afterwards, I reverse the Velocity direction as my variables don't meet them. But, while the loop is working, LIGGGHTS is reading through the loop only once hence the variable is not updated to change the velocity direction.

if "(${a17} > 0.0) && (${a15} >10)" then &
"fix 123456 atom move linear 0.000000000000001 -0.001 -0.00000000000000001 units box" &
elif "(${a17} < 0.0) && (${a15} <-10)" &
"fix 123456 atom move linear 0.000000000000001 0.001 -0.00000000000000001 units box" &
else &
"fix 123456 atom move linear 0.000000000000001 0.001 -0.00000000000000001 units box"

Any help will be greatly appreciated.

Regards,
Sounik

Philippe's picture

Philippe | Wed, 01/23/2019 - 07:58

Hi Sounik,

can you provide a little more context? It is not fully clear to me what you want to achieve.

cheers
Philippe

Sounik | Thu, 01/24/2019 - 21:11

Hi Philippe,
I appreciate your response.
I have a system of particles in a region compressed at top and bottom with rigid particle plates, other sides have periodic boundaries. Now I want to shear the system, by fix move with a constant velocity. But, after I reach a certain level of stress (computed and stored in variable ${a15}), the constant velocity should reverse its sign (stored in ${a17)}. Hope this helps you to understand.

Thanks,
Sounik

mschramm | Thu, 01/24/2019 - 15:30

You will want to look into the label command to form loops

variable loop_count equal 0
variable loop_count_max equal 500 # I want to do the following loop 500 times
label start_loop
variable loop_count equal ${loop_count}+1
if "(${a17} > 0.0) && (${a15} >10)" then &
"fix 123456 atom move linear 0.000000000000001 -0.001 -0.00000000000000001 units box" &
elif "(${a17} < 0.0) && (${a15} <-10)" &
"fix 123456 atom move linear 0.000000000000001 0.001 -0.00000000000000001 units box" &
else &
"fix 123456 atom move linear 0.000000000000001 0.001 -0.00000000000000001 units box"
run 1 pre yes post no # Need to do pre yes because you changed a fix...
if "${loop_count}<${loop_count_max}" then "jump in.liggghts start_loop"

# Rest of your script

Sounik | Tue, 01/29/2019 - 04:25

Thank you mschramm.