Problem in implementing nested loop.

Submitted by rsharma on Tue, 04/06/2021 - 20:44

Hi,
I am trying to implement a nested loop in the following manner.

label loop
variable a loop 10

#variable level equal 200

label loop
variable b loop 200

variable tar_loading equal ${sigma_3}*${sample_width}*${sample_width} + 0.5*$b*${sample_width}*${sample_width}

# APPLING LOADING
fix_modify twall_servo servo/target_val -${tar_loading}
run ${load_unload_step}

next b
jump SELF loop

label loop
variable c loop 180

variable tar_unloading equal ${sigma_1_max}*${sample_width}*${sample_width} - 0.5*$c*${sample_width}*${sample_width}

# APPLING UNLOADING
fix_modify twall_servo servo/target_val -${tar_unloading}
run ${load_unload_step}

next c
jump SELF loop

run 20*${load_unload_step}

# RELAX SAMPLE
run ${relax_step}

next a
jump SELF loop

But I am getting the following error after unpacking of "tar_loading".

ERROR: Illegal variable command (/build/liggghts-YO7u74/liggghts-3.8.0+repack1/src/variable.cpp:383)

Please let me know what am I missing?

Thanks in advance.

rsharma | Wed, 04/07/2021 - 07:28

Hi,
I gave unique labels for each loop, still I am getting the same error.

mschramm | Wed, 04/07/2021 - 20:06

Hello,
You have spaces in your variable command ("+")
Try changing
variable tar_loading equal ${sigma_3}*${sample_width}*${sample_width} + 0.5*$b*${sample_width}*${sample_width}
to
variable tar_loading equal ${sigma_3}*${sample_width}*${sample_width}+0.5*$b*${sample_width}*${sample_width}