Hi, last week I wrote a fix to apply a boost force to a selected atom in a
group. Now, I am trying to create a neighbor list in the same fix. I have
used the following syntax (lines 346-353 in attached code):
class NeighList *list;
this line is _wrong_! there is no precedence in any other LAMMPS
source files for it. the segfault is well deserved.
inum = list->inum;
ilist = list->ilist;
numneigh = list->numneigh;
firstneigh = list->firstneigh;
But I get "segmentation fault (core dumped)." I am guessing that the
neighbor array is not allocated properly. I have looked at other fixes but
have not found any example to follow. Can anybody help me correct my code?
you need to study other LAMMPS sources more thoroughly and more
carefully. then you will find:
- there are several examples to follow, e.g. fix orient/bcc or
orient/fcc, or fix qeq
- to obtain a neighbor list, you need to create a neighbor list
request instance and configure it for your needs
- you also need to add an init_list() method to your class to get hold
of the neighbor list pointer
- you won't need to request an explicit neighbor list build, but can
stick with the default perpetual neighbor list, that will likely be a
copy of or derived from an existing list.
The .cpp file is attached.
P.S. Also, for some reason, this fix functions about three times slower than
a similar fix (e.g. fix addforce, which was modified into this fix). I am
not sure what makes it so slow, and I doubt that the absence of a neighbor
list is the reason (I tested by bypassing the loop). If anybody can spare
the time to go through my code, please help me figure out how to make it
you are asking for A LOT here. after all, it is *your* code and *your*
work. please ask yourself, would you do this kind of work on somebody
there are plenty tools to assist in determining performance
bottlenecks and to profile applications. there are tutorials, courses
and more. if you care about the performance of your code, you *will*
need to learn what is making code fast and what is slowing you down.
for example, have you checked, how much time you spend opening,
reading and parsing (text format) files?
if you feel unable to do this, you need to find a suitable
collaborator, that you can share the credit with, or hire an expert.