If command

Hi
I am wondering if anyone can help me.
I want to use atom coordinates as x and y variables in boolean of If command, according to below.
If “x > 0 && y > 0” then …

Is there any way?

I can’t use special atoms coordinates as x[i] and y[i] in my code.
Thank you.

Hi
I am wondering if anyone can help me.
I want to use atom coordinates as x and y variables in boolean of If
command, according to below.
If "x > 0 && y > 0" then ....
Is there any way?

there is not sufficient information here. can you please explain in
more detail, what it is that you want to achieve by this?
from the looks of it, you are failing to understand at a rather
fundamental level what you can use the "if" command for and how it
LAMMPS script commands apply to a simulation.

axel.

I want to apply a radial pressure on CNT; therefore, I want to specify the CNT atoms in four group according their coordinates

group 1 x>0 & y>0,
group 2 x<0 & y>0,
group 3 x<0 & y<0,
group 4 x<0 & y>0

then I want to use displacement_atoms command for each group. As:

displace_atoms 1 move -0.01cos(theta) -0.01sin(theta) 0 units box

displace_atoms 2 move -0.01cos(theta) +0.01sin(theta) 0 units box

displace_atoms 3 move +0.01cos(theta) +0.01sin(theta) 0 units box

displace_atoms 4 move -0.01cos(theta) +0.01sin(theta) 0 units box

Since during simulation, the coordinates of atoms are modified, I want to use “If command” to specify displacement_atoms command according to the new coordinates of atoms. As:

If x>0 && y>0 then displace_atoms all move -0.01cos(theta) -0.01sin(theta) 0 units box

I don’t know, it is possible or not.

Thank you.

I want to apply a radial pressure on CNT; therefore, I want to specify the
CNT atoms in four group according their coordinates

group 1 x>0 & y>0,
group 2 x<0 & y>0,
group 3 x<0 & y<0,
group 4 x<0 & y>0

then I want to use displacement_atoms command for each group. As:

displace_atoms 1 move -0.01*cos(theta) -0.01*sin(theta) 0 units box
displace_atoms 2 move -0.01*cos(theta) +0.01*sin(theta) 0 units box
displace_atoms 3 move +0.01*cos(theta) +0.01*sin(theta) 0 units box
displace_atoms 4 move -0.01*cos(theta) +0.01*sin(theta) 0 units box

Since during simulation, the coordinates of atoms are modified, I want to
use "If command" to specify displacement_atoms command according to the new
coordinates of atoms. As:

If x>0 && y>0 then displace_atoms all move -0.01*cos(theta)
-0.01*sin(theta) 0 units box

I don't know, it is possible or not.

you can achieve the effect you are looking for, but - as i suspected -
your understanding of how scripting in LAMMPS works is *very* wrong.
it cannot work the way you are formulating it. you are trying to
"describe" your problem to the computer in the same way, as you would
explain it to another human, assuming the other person will use common
sense to do things properly. computers don't work this way. you have
to be *extremely* precise and use the available instructions only
within the confines of the syntax and semantics described in the
documentation. a computer will only do *exactly* what you tell it, but
since computer program have no common sense, you have to express
yourself precisely in the terms of the computer program, not your own.
you cannot just shove some expressions in the face of the computer and
expect it to do what you want. in the case of above, there are 3 major
issues. 1) you use expressions, where only numbers of variable
references are allowed, 2) your expressions reference an entity
"theta" that is not defined anywhere, and 3) your if statement makes
assumptions about how the "if" and the "displace_atoms" commands work,
that are in conflict with how they are documented.

you are obviously trying something that is too complex for your level
of understanding of programming in general and LAMMPS in particular.
you need to approach this in stages and teach yourself the necessary
skills step by step. we cannot do this on the mailing list. talk to
your adviser, that is the person tasked with training you!

actually, to do a radial compression, you have can define a suitable
atom style variable, where each atom's position is used to determine
a velocity that can be fed to a fix move command via the variable
command. this will then continually shrink your CNT over the course of
your trajectory. if you place your CNT centered on the z axis, those
are trivial to compute. if not, you have to compensate for that. this
is all rather simple spatial geometry and some middle school level
vector algebra.

again, discuss with your adviser and your colleagues and try solving
and understanding some simpler problems first.

axel.