access to 'list' from fix class

Dear LAMMPS Users and Developers,

I am now writing a new fix called shakevolume in which I need to have access at the neighbor list. I included all this headers:

#include “lmptype.h”
#include “mpi.h”
#include “math.h”
#include “stdlib.h”
#include “string.h”
#include “stdio.h”
#include “fix_shakevolume.h”
#include “atom.h”
#include “atom_vec.h”
#include “update.h”
#include “compute.h”
#include “group.h”
#include “input.h”
#include “variable.h”
#include “modify.h”
#include “domain.h”
#include “force.h”
#include “comm.h”
#include “neighbor.h”
#include “neigh_list.h”
#include “math_const.h”
#include “memory.h”
#include “error.h”

and in the function allocate() I have following lines:

int inum = list->inum; // # of I atoms neighbors are stored for
int gnum = list -> gnum; // # of ghost atoms neighbors are stored for

I get following error message: ‘list’ was not declared in this scope

I tried to fix this problem without success. Does someone have an Idea how I could get access to list?

Thank you in advance,
Best

Dear LAMMPS Users and Developers,

I am now writing a new fix called *shakevolume* in which I need to have
access at the neighbor list. I included all this headers:

*#include "lmptype.h"*
*#include "mpi.h"*
*#include "math.h"*
*#include "stdlib.h"*
*#include "string.h"*
*#include "stdio.h"*
*#include "fix_shakevolume.h"*
*#include "atom.h"*
*#include "atom_vec.h"*
*#include "update.h"*
*#include "compute.h" *
*#include "group.h" *
*#include "input.h" *
*#include "variable.h"*
*#include "modify.h"*
*#include "domain.h"*
*#include "force.h"*
*#include "comm.h"*
*#include "neighbor.h"*
*#include "neigh_list.h"*
*#include "math_const.h"*
*#include "memory.h"*
*#include "error.h"*

​this makes no sense and shows, that you haven't understood the basic code
structure of LAMMPS.
for example, have you read this​: http://lammps.sandia.gov/doc/Developer.pdf
?
also, it shows disregard for C/C++ programming methodology. you only
include header files that provide declarations for the objects you are
trying to access. just unconditionally including all of them, is pointless.
instead you need to check which information is provided by each header and
then decide which you need.

finally, the syntax and ordering you use, shows that you are following an
outdated version of LAMMPS.
please seriously consider checking out the latest development version and
start from there.

and in the function allocate() I have following lines:

* int inum = list->inum; // # of I atoms neighbors are stored
for *
* int gnum = list -> gnum; // # of ghost atoms neighbors are stored for *

I get following error message:

* ‘list’ was not declared in this scope *I tried to fix this problem
without success. Does someone have an Idea how I could get access to list?

​there is not *the* neighbor list in LAMMPS. there are different kinds,
because different styles (classes) and different settings in LAMMPS need
different ​kinds of neighbor lists (half, full, with/without newton's third
law applied for pairs between ghosts and local atoms, with/without
neighbors of ghosts, and more, every step or occasionally). the neighbor
list code will then generated the requested lists and goes to significant
lengths to do it in an efficient way. if you are using a recent LAMMPS
version, you can see a quite detailed report of that in the output.

thus to obtain access to a neighbor list, you have to submit/add a request.
that means you need to include the neigh_request.h header file and there
add some code like it is done in FixBondCreate::init() fix_bond_create.cpp:

  // need a half neighbor list, built every Nevery steps

  int irequest = neighbor->request(this,instance_me);
  neighbor->requests[irequest]->pair = 0;
  neighbor->requests[irequest]->fix = 1;
  neighbor->requests[irequest]->occasional = 1;

or in fix_qeq_point.cpp (which needs a full, perpetual neighbor list):

  int irequest = neighbor->request(this,instance_me);
  neighbor->requests[irequest]->pair = 0;
  neighbor->requests[irequest]->fix = 1;
  neighbor->requests[irequest]->half = 0;
  neighbor->requests[irequest]->full = 1;

please understand that in LAMMPS status is stored in each instance of a
class and thus many properties are not globally accessible, but handed to
the individual class instance. by passing the value of "this" to the
neighbor->request() method, the neighbor list instance/code has a handle to
send the neighbor list information as requested back to the fix and store
it into its corresponding location.

HTH,
    axel.

p.s.: it really helps to spend some time reading the existing code
(preferably pieces that do something similar than what you want) and trying
to understand what it is doing and why it works, before just copying code
and hoping for the best. there are several constructs and conventions in
LAMMPS that are different from typical (naiive) MD code implementations and
you can save yourself a lot of trouble by having some appreciation for it.