problem with atomstyle and equalstyle variables

Hi all,

I'd like to access the particle's diameter, but I get errors which I don't understand and I hope you can help and explain why my script doesn't work...

If there are N particles in a volume, I'd like to access the particles diameter, depending on its z-coordinate. I was thinking of using a loop for looping over the particles' ID and then request with a boolean operator the z-coordinate to give it a new diameter.

Here an example; to control the values of the variables I used 3 different lines to output some values,

variable N equal atoms

compute zpos all property/atom z
variable zKoord atom c_zpos

label loop
variable i loop N

     1) print ${zKoord[i]}
     2) variable Z equal v_zKoord[i]
             print $Z
     3) variable Z equal c_zpos[i]
         print $Z

if Z < 1 then "set atom $i diameter 0.1" elife (Z >= 1 & Z < 2) "set atom $i diameter 0.2" else "set atom $i diameter 0.3"
next i
jump in.script loop

but attempting that I got an error for each line.
Line 1) Error: Substitution for illegal variable
Line 2) Error: Non digit character between brackets in input command
Line 3) Error: Non digit character between brackets in input command

Why does it not work like I want to?

Thanks in advance,
kind regards,

Sebastian

Comments below.
All of these errors will make sense if you carefully read the
variable doc page and the rules for how to use variables in
input scripts.

Steve

Hi all,

I'd like to access the particle's diameter, but I get errors which I
don't understand and I hope you can help and explain why my script
doesn't work...

If there are N particles in a volume, I'd like to access the particles
diameter, depending on its z-coordinate. I was thinking of using a loop
for looping over the particles' ID and then request with a boolean
operator the z-coordinate to give it a new diameter.

Here an example; to control the values of the variables I used 3
different lines to output some values,

variable N equal atoms

compute zpos all property/atom z
variable zKoord atom c_zpos

label loop
variable i loop N

1\) print                $\{zKoord\[i\]\}
2\) variable         Z equal v\_zKoord\[i\]
        print                $Z
3\) variable         Z equal c\_zpos\[i\]
    print                $Z

if Z < 1 then "set atom $i diameter 0.1" elife (Z >=
1 & Z < 2) "set atom $i diameter 0.2" else "set atom $i diameter 0.3"
next i
jump in.script loop

but attempting that I got an error for each line.
Line 1) Error: Substitution for illegal variable

zKoord is the variable, not zKoord[i]. And you can't print an
atom-style variable.

Line 2) Error: Non digit character between brackets in input command

i is a variable, you need $i to get its value to use as a subscript

Line 3) Error: Non digit character between brackets in input command

ditto