If then usage in LIGGGHTS

willchennewcastle's picture
Submitted by willchennewcastle on Mon, 02/25/2013 - 04:02

Hi All,

I have a few lines of codes which I designed to count the particle numbers in the region mid_reg. I used if & then sentences, however, I found the if-then codes only worked on run 1, not constantly updating.

Has anyone got any ideas.

Cheers,

Will
##################################################
region mid_reg block -0.2 0.2 -0.05 0.05 -0.5 -0.249882 units box
variable p equal count(all,mid_reg)
variable t equal step #store the timestep which satisfies the criterion
fix out_file all print 1 &
"$p,${t}" file particle_number.csv screen no title "particle_number,time_step"

if "$p < 20 && ${flag} < 1" then &
"print '${et} = $t'" & #et has been predefined as 0
"print '${flag} = 3'" #Flag has been predefined as 0

dump_modify dmp_particles label ${et}_${ff}_${rf}_${wf}_${dt}

run 300000
#########################################

mojgan | Mon, 02/25/2013 - 08:02

hi will,
I think that if you read the related section of the fix/variable entitled "Immediate Evaluation of Variables:" your problem may be solved. I had the same problem. and think changing the script like this may work, try it,

variable p equal count(all,mid_reg)
variable pp equal v_p
variable t equal step #store the timestep which satisfies the criterion
fix out_file all print 1 &
"${pp},${t}" file particle_number.csv screen no title "particle_number,time_step"

if "${pp} < 20 && ${flag} < 1" then &
"print '${et} = $t'" & #et has been predefined as 0
"print '${flag} = 3'" #Flag has been predefined as 0
cheers
mojgan

willchennewcastle's picture

willchennewcastle | Tue, 02/26/2013 - 03:59

Thanks mojgan for you reply,

I have tried your answer, however, I got the same results. Then, I set up a loop to go thought the if-then every run, it works.

I understand the setting of if-then for LIGGGHTS so maybe a alternative fix/variable will be helpful.

greetings,

Will