About adding a condition during running the system

Hi All,

I am trying to apply a condition to my system. At each step of run, I would like the LAMMPS check every atom’s coordinate. If atom[i] is inside the region(BLOCK), some additional forces will be added.

I tried two methods, neither of them work.

First, I add a loop into the input file.

variable NOAtom loop 1 1000
label loopforce
variable coordy atom y
variable coordz atom z
if "({coordz} <= 0.0) && ({coordy} <= 10.0) && ({coordz} >= -10.0)" then f[{NOAtom}][1] += q[${NOAtom}]*1000
run 1
next NOAtom
jump SELF loopforce

Then I try to define a region in every step.
region BLOCK1 block INF INF -15.0 INF INF 0.0 side in units box
group molecules1 region BLOCK1
fix 1 molecules1 addforce 0.0 10000.0 0.0
run 1
ungroup molecules1
unfix 1
And then re-do the commands above for many times.

These methods look stupid, I am wondering what I can do in this situation. Any inputs are extremely appreciated.

Best Regards,
Joy

Hi All,

I am trying to apply a condition to my system. At each step of run, I would
like the LAMMPS check every atom's coordinate. If atom[i] is inside the
region(BLOCK), some additional forces will be added.

I tried two methods, neither of them work.

First, I add a loop into the input file.
variable NOAtom loop 1 1000
label loopforce
variable coordy atom y
variable coordz atom z
if "(\{coordz\} &lt;= 0\.0\) &amp;&amp; \({coordy} <= 10.0) && (\{coordz\} &gt;= \-10\.0\)&quot; then f\[{NOAtom}][1] += q[${NOAtom}]*1000
run 1
next NOAtom
jump SELF loopforce

Then I try to define a region in every step.
region BLOCK1 block INF INF -15.0 INF INF 0.0 side in units box
group molecules1 region BLOCK1
fix 1 molecules1 addforce 0.0 10000.0 0.0
run 1
ungroup molecules1
unfix 1
And then re-do the commands above for many times.

These methods look stupid, I am wondering what I can do in this situation.
Any inputs are extremely appreciated.

why don't you use this?

fix 1 all addforce 0.0 10000.0 0.0 region BLOCK1

axel.

Hi Axel,

I took your advice and run several examples, but there is an ERROR: Insufficient Jacobi rotations for rigid body.

I guess this command “fix 1 all addforce 0.0 10000.0 0.0 region BLOCK1” have to add force to one charge, not to other sites of the same molecule. So I got an error message.

If I need to add force to every charge of one molecule depending on where the center of the molecule is, what would I do? Can I use a loop or I have to revise the code?

For the command fix efield: if the field component values are given as 3 numbers, will lammps update the force induced by this field every step?

Thanks very much!

Joy

Hi Axel,

I took your advice and run several examples, but there is an ERROR:
Insufficient Jacobi rotations for rigid body.

I guess this command "fix 1 all addforce 0.0 10000.0 0.0 region BLOCK1" have
to add force to one charge, not to other sites of the same molecule. So I
got an error message.

i don't really understand what you are trying to do.
you are just describing the commands, not what
the system and the objectives are. it is very difficult
to give advice based on that.

overall, the magnitude of the force that you are
adding seems large. have you checked whether
it is actually reasonable?

If I need to add force to every charge of one molecule depending on where
the center of the molecule is, what would I do? Can I use a loop or I have
to revise the code?

first off, without knowing any details,
this doesn't sound like a very physically
meaningful model. how would you be
able to construct something that would
apply to molecules selectively, but not
just to atoms in a region?

second. if you want something that is
not available in the code, you'll have to
write it yourself (or persuade/convince/bribe/beg/...
somebody else to do it for you). that is a fact of life.

For the command fix efield: if the field component values are given as 3
numbers, will lammps update the force induced by this field every step?

yes. the force is recomputed at every step.
if it wasn't like that, the simulation(s) that i
am currently running wouldn't work.

axel.