adding a force proportional to the coordination number of each atom

Dear all,

I am trying to add a force to each atom and integrate the dynamics.
The force needs to be proportional to the number of neighbours the
atom has within a cut-off at the given timestep.

I can calculate the coordination number of each atom using the
"compute coord/atom". However, the "fix addforce" does not accept a
per-atom value returned by this compute.

I'm wondering what would be the most efficient way of modifying lammps
for this purpose?

One way is to write a new fix that uses the returned vector from the
compute coord/atom and adds the force to each particle. This might not
be efficient if the compute's neghbour list has to be built at each
timestep, additionally to the main neghbourlist of the simulation.

any suggestions?

Best,
Nima

Dear all,

I am trying to add a force to each atom and integrate the dynamics.
The force needs to be proportional to the number of neighbours the
atom has within a cut-off at the given timestep.

I can calculate the coordination number of each atom using the
"compute coord/atom". However, the "fix addforce" does not accept a
per-atom value returned by this compute.

​but it does accept atom style variables, which in turn can utilize data
from per-atom compute​s.

I'm wondering what would be the most efficient way of modifying lammps

for this purpose?

​by not modifying LAMMPS at all.​

One way is to write a new fix that uses the returned vector from the
compute coord/atom and adds the force to each particle. This might not
be efficient if the compute's neghbour list has to be built at each
timestep, additionally to the main neghbourlist of the simulation.

​that reasoning is wrong. the compute's neighbor list rebuild requirements
are unchanged.

axel.

As Axel says, fix addforce can take a atom-style variable

for each component of force. And the variable could

access the per-atom values of a compute coord/atom command.

So if you can write your force formula as atom-style

variables (component by component) you can do it that

way. I’m guessing you can’t, e.g. how do you specify

the direction of the force just based on coordination #.

So if the force eq is more complicated you’ll likely need

to write your own fix or pair style. But it can also use

the output of coord/atom as an input if you like.

Steve

Thanks Steve,

So if the force eq is more complicated you'll likely need
to write your own fix or pair style. But it can also use
the output of coord/atom as an input if you like.

I'd like to use the returned vector from the coord/atom within my own
pair style. Is there an example in which the result of a compute is
used within a pair style. What would be the key steps for doing that?

Nima

There are many fixes which use values from computes, It wouldn’t

be substantially different for a pair style. See fix_ave_time.cpp

as an example.

Steve