LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Mailing List Archives
Re: [lammps-users] Fw: Reading Energy in Custom Pair Function
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lammps-users] Fw: Reading Energy in Custom Pair Function


From: Axel Kohlmeyer <akohlmey@...24...>
Date: Sat, 1 Jul 2017 18:38:40 -0400

On Sat, Jul 1, 2017 at 5:47 PM, S M <smatrix_2012@...8...> wrote:
>
> Hi, here is my update:
>
> I am writing a fix (fix_addboost) that identifies the particle in a group
> possessing the highest pair potential energy, and then applies a repulsive
> potential to that particle only (this principle is used in the bond-boost
> method, especially of Miron-Fichthorn).
>
> My code compiles, but I get a "segmentation fault (core dumped)" error upon
> running. I have located the problem in the following lines (lines 277-278 in
> the full code attached) that try to read "eatoms[i]".
>
> fprintf(screen,"eatom[i] = %f \n", eatom[i]);
> currentEnergy = eatom[i];
>
> I am guessing that eatoms[i] have not been called properly. I have followed
> the syntax in "compute_pe_atom.cpp" and used the following in my code:
>
> if (force->pair){
> double *eatom = force->pair->eatom;
>         ....
> }
>
> I have also included pair.h and force.h at the beginning. I have gone
> through the LAMMPS developer manual also, but I still cannot figure out what
> is going wrong.

with your current setup, LAMMPS doesn't know, that you want to use
per-atom energies, so the array is not allocated and the energy not
tallied into that array.
the clean way to deal with this would be:
- create an instance of compute pe/atom with the suitable arguments
from within your fix
- read the data from the compute's vector_atom member after having
called its compute_peratom() method
- call modify->clearstep_compute() /
modify->addstep_compute(nextstep), where nextstep is the next
timestep, where you need access to the data from the compute.

see other fixes that maintain their own compute instances for more details.

axel.

>
> Can anybody help me solve this problem?
>
> Thanks,
> S
>
>
> ________________________________
> From: S M
> Sent: Sunday, June 18, 2017 2:16 PM
> To: lammps
>
> Subject: Re: [lammps-users] Reading Energy in Custom Pair Function
>
>
>
> 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
>
>
> ________________________________
> From: jewett.aij@...24... <jewett.aij@...24...> on behalf of Andrew Jewett
> <jewett@...1937...>
> Sent: Saturday, June 17, 2017 1:55 AM
> To: S M
> Cc: lammps
> Subject: Re: [lammps-users] Reading Energy in Custom Pair Function
>
>
>
> On Jun 16, 2017 5:45 PM, "S M" <smatrix_2012@...8...> wrote:
>
> Hi,
>
> I am writing a custom pair potential, where I first need to read the energy
> of every particle
>
>
> 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"?)
>
>
> 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.
>
>
> ?
> This is not an input script command (and this string does not appear
> anywhere in the source code)
>
>
> Can anybody suggest a definite strategy in terms of writing necessary codes?
>
>
> 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
>
>
>
> S
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> lammps-users mailing list
> lammps-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lammps-users
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> lammps-users mailing list
> lammps-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lammps-users
>



-- 
Dr. Axel Kohlmeyer  akohlmey@...24...  http://goo.gl/1wk0
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.