How to request a full neighbour list

Hello everyone,
I am trying to implement my own pair_style which requires a full neighbour list. I am new to working with lammps and don’t completely understand the structure. I have the following questions:

  1. Since the pair class has access to the pointer *listfull, can I call this directly in compute with the default structure of init_style()

  2. Or I suppose I need to modify init_style() to get the full neighbour list, in this case could someone please give me an ‘example’ of how this can be done? And does *list now point to the ‘full’ list or do we use *listfull?

  3. In particular, I don’t want full lists for my ‘other’ pair styles (to save on compute time), so basically I want newton off only for this pair style.

Thanks!

1 Like

Please note that the code to request neighbor lists has been changed in recent LAMMPS versions, so you are advised to do your development based on a recent checkout of the “develop” branch.
https://docs.lammps.org/Developer_updating.html#simplified-and-more-compact-neighbor-list-requests

To get a neighbor list, it must be requested. For pair styles the default is in the “Pair::init_style()” function and requests a half neighbor list by default. If you want a full neighbor list, you need to provide your own “init_style()” function (unless you already do so). See pair_sw.cpp for an example.

The neighbor list code will call the “Pair::init_list()” function to assign the list to a pointer in the class. Unless you have a pair style that requests multiple neighbor lists (very few do), you can go with the default which assigns the neighbor list to the “Pair::list” pointer.

Neighbor list requests are accumulated and served for multiple sources, not just pair styles (fixes, computes, commands may use neighbor lists). The neighbor list code will try to optimize the neighbor list construction (e.g. try to serve pointers to the same neighbor list, if multiple requests require the same kind of neighbor list, or try to construct a half neighbor list from a full list, which is faster, or construct “skip” lists for sub-styles of a hybrid style).

The newton on/off setting has nothing to do with selecting a full or half neighbor list. It is an independent setting affecting only pairs where one atom is a ghost atom. It is honored by the neighbor list code anyway and has no effect on full neighbor lists.

1 Like

Thanks a lot for your response. I was able to implement it with the function (following pair_cw.cpp)

void PairAlignOwn::init_style()
{

int irequest = neighbor->request(this,NeighConst::REQ_FULL);

}

however, upon execution, the output says

1 neighbour lists, perpetual/occasional/extra = 1 0 0
(1) pair align/own, perpetual
attributes: half, newton on
pair build: half/bin/newton
stencil: half/bin/2d
bin: standard

here it seems like a ‘half’ neighbour list is being constructed, is this just related to implementation detail? or have I missed something?

what change did you make to the .h file matching your custom .cpp file?

Ah I see that I haven’t added an override to init_style() in the .h file, is this causing the issue?

Possibly, or you could have used an old executable, or compilation could have failed, or …?
I cannot see what you see, so I can only guess.

I figured out the issue, I was using (wrong)
neighbor->request(this,NeighConst::REQ_FULL);

instead of
neighbor->add_request(this,NeighConst::REQ_FULL); (correct)

now it works correctly !
thanks a lot

1 Like