Reading Energy in Custom Pair Function

Hi,

I am writing a custom pair potential, where I first need to read the energy of every particle before the custom pair potential is applied, and then apply the custom pair potential to certain particles based on their energy readings.

I am guessing that I need to use the “pair->vdW” command.

Can anybody suggest a definite strategy in terms of writing necessary codes?

S

Can you clarify what you mean here?
Is the pair style you are writing not already calculating the (pair contribution to) the energy per particle? (… that is…excluding many-body forces or long range electrostatics… Are you using these?)
What contributions to the energy do you mean?
Contributions to the energy from bonds, angles, dihedrals… containing that atom? (What about fixes like “fix spring” or “fix wall”?)

?
This is not an input script command (and this string does not appear anywhere in the source code)

My guess would be what you are trying to do is not easy to do in a general way. But perhaps if you clarify what you want, someone can suggest something.

Cheers

Andrew

Hi,

I am writing a custom pair potential, where I first need to read the
energy of every particle before the custom pair potential is applied, and
then apply the custom pair potential to certain particles based on their
energy readings.

I am guessing that I need to use the "pair->vdW" command.

Can anybody suggest a definite strategy in terms of writing necessary
codes?

​not based on such insufficient and vague information provided. in fact,
your e-mail can serve as an example for how *not* to ask questions.

- you say you are writing a custom pair potential, but you are not saying
what its purpose is, what its underlying physics is, whether it is top be
used in combination with another (pairwise?) potential and so on.

- you ask about very unspecific things, e.g., "energy". there is a
gazillion kinds of energies. in MD​ specifically we differentiate between
kinetic and potential energy and the potential energy by the parts of the
model. do you need the "energy" at previous or the same time step?

- you "guess" what you should be doing (and are guessing something without
a reference to any part of the source code). not to mention, that it cannot
be a "command"

​- you talk about "certain particles ​based on their energy readings",
which is a vague as it gets.

yet at the end, you ask about receiving specific help and a definite
strategy. how can anybody can provide "definite" help without having *any*
kind of useful information? the only "definite" strategy that can be
provided has to be as vague as your inquiry:

- make sure you have sufficient C++ programming (and reading other people's
sources) skills
- read the part of the LAMMPS manual concerning modifying and extending
LAMMPS
- read the LAMMPS developer's guide
- with the information of the developer's guide in mind, study relevant
parts of the LAMMPS source code
- keep in mind, that per-atom energies either need to be computed (kinetic
energy) or explicitly requested to be tallied during force computation
(potential energy).
- keep in mind, that forces/energies are computed in "stages" and you
cannot easily go back to a previous stage unless you are playing tricks,
e.g. hook a pairwise computation into fix to be run at a later stage. but
also keep in mind, that adding to forces *after* the second part of the
velocity verlet integration is ignored.

axel.

Ok, here is the full scenario:

I have a group of atoms at low temperature that interact with each other only via a LJ potential. At every timestep, I want to read the potential energy (from the LJ interaction) of every atom. Then, I want to identify the atom with the maximum potential energy, and weaken the forces acting on it, so that it is able to rapidly escape from the vicinity of the rest of the atoms.

  • When writing my previous email, I was thinking of applying a repulsive pair potential to the atom having the maximum potential energy, that would effectively weaken the original LJ interaction. That is why I thought about writing a custom pair potential that applies only to that specific atom in the group.

  • Now, I am thinking that the same can be achieved by applying an additional force on that same atom (and subsequent reaction forces on the other atoms), similar to the ‘fix addforce’ function. In this case, I would have to write a custom fix.

In either of the above, I have to identify the atom with the maximum potential energy at every timestep.

Can anybody provide some advice about how to proceed?

Thanks,
S