[lammps-users] Bugs after recalls a fix

Dear developers:
I have a problem.
I write a fix that needs neighborlist.
I find out there are some bugs when I recall this fix.
To be specific : Is there any step skipped when a certain type of fix is recalled?

crash with multiple cores:

"

fix 1 sph myfix sol wall ${rc} …
run 100

unfix 1
fix 1 sph myfix sol wall ${rc} …
run 100
"

Normal runs:
"

do something…
run 100
fix 1 sph myfix sol wall ${rc} …
run 100

"

I must miss something.
Welcome for any hint:

Here’s the structure of my fix (only show the part with memory allocations and the parts need list):
"
FixNVESPHDIFF::FixNVESPHDIFF(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg)
{

//my computations need several temporary arrays, but they do not neet to live to the next timestep:

dr=NULL;
dkg=NULL;
rho_temp=NULL;
kappa=NULL; (above are per atom arrays)
weight1 = weight2 = NULL;

//my computations need several steps:
comm_forward = 8;
comm_reverse = 12;
}
FixNVESPHDIFF::~FixNVESPHDIFF()
{
memory->destroy(rho_temp);
memory->destroy(dr);
memory->destroy(dkg);
memory->destroy(kappa);
memory->destroy(weight1);
memory->destroy(weight2);
}
int FixNVESPHDIFF::setmask()
{
int mask = 0;
mask |= INITIAL_INTEGRATE;
mask |= FINAL_INTEGRATE;
mask |= INITIAL_INTEGRATE_RESPA;
mask |= FINAL_INTEGRATE_RESPA;
return mask;
}
void FixNVESPHDIFF::init()
{
int irequest = neighbor->request(this,instance_me);
neighbor->requests[irequest]->pair = 0;
neighbor->requests[irequest]->fix = 1;
neighbor->requests[irequest]->full = 0;
neighbor->requests[irequest]->half = 1;
setup array weight1 , weight2 (these are not per-atom array)
}
void FixNVESPHDIFF::init_list(int /id/, NeighList *ptr)
{
list = ptr;
}

void FixNVESPHDIFF::initial_integrate(int vflag)
{
if (atom->nmax > nmax) {
memory->destroy(dr);
memory->destroy(dkg);
memory->destroy(rho_temp);
memory->destroy(kappa);
nmax = atom->nmax;
memory->create(dr,nmax,3,“fix/nve/sph/diff:dr”);
memory->create(dkg,nmax,3,“fix/nve/sph/diff:dkg”);
memory->create(rho_temp,nmax,“fix/nve/sph/diff:rho_temp”);
memory->create(kappa,nmax,3,3,“fix/nve/sph/diff:kappa”);
}

update x, v
comm->forward_comm_fix(this,comm_forward);

inum = list->inum;
ilist = list->ilist;
numneigh = list->numneigh;
firstneigh = list->firstneigh;

Loop over pair to get dr (in order to update x and v)
}
void FixNVESPHDIFF::final_integrate()
{
do not need list shouldn’t be critical
}
int FixNVESPHDIFF::pack_reverse_comm(int n, int first, double *buf)
{

}
void FixNVESPHDIFF::unpack_reverse_comm(int n, int *list, double *buf)
{

}
int FixNVESPHDIFF::pack_forward_comm(int n, int *list, double *buf, int pbc_flag, int *pbc)
{

}

void FixNVESPHDIFF::unpack_forward_comm(int n, int first, double *buf)
{

}

Thanks for any suggestion.

there is not enough information here to give any specific advice. in general, please keep in mind that this is your code, so it is your job to do the debugging.

I have two more comments:

  1. what little information you present is useless without information where exactly the crash happens and what the code is that crashes. this can be found out with a debugger or valgrind. see e.g.,: https://docs.lammps.org/Errors_debug.html

  2. as it happens, the LAMMPS programmer documentation actually has an outline of what needs to be done to write a fix at: https://docs.lammps.org/Developer_write.html

Axel.