Why (sometimes) the param maxttemps means less attemps? in insert/pack

Submitted by iluvatar on Mon, 03/18/2019 - 16:48

Hi, I am using some very wide grain size distributions (gsd). I have discretized the gsd as input to liggghts. I am using large prime numbers as seeds (which is a strange constrain) and all.

Sometimes is just really hard to get a good representation of the gsd, so I am starting to play with the maxattempts parameters. The problem is that, in contrast to what the manual says, maxattempt is not used per particle but for the whole number of particles per processor. After looking at the source code I found that the local variable maxtry, which is used to put the particles, is an integer (32 bits), and roughly is the result of the local number of particles times the maxattempt parameter. The thing is that being an int it overflows for a large number of particles and a large number of attempts. In my case, for instance, it is normal to have 100000 particles per processor ( I just have 16 processors to play) and I was testing like 100000 attepts, which of course overflows for 32 integers (100000*100000 > MAX_INT_32). I changed the type of maxtry on several source files to long long int (c++11 extension, or to int64_t) and it nows can be used for some large number of attempts( but not all...). But this only hides the problem. This also explains why I was getting different results (not just in a statistics way, but very different) when using different number of processors. For a small amount of processors I would get overflows so the maxtry was negative so no tries were done, while for more processors the overflow dissapeared and I was actually getting the tries I was expecting.

Is it possible to:
- Tell the user this kind of implicits limits? I expect that when I increase max attempt it will operate per particle (as per the manual) and is not used to compute an auxiliary var that might overflows (giving , for example, a negative number of maxtry ...)

- Change the related variable types to long long int (c++11) to increase the limit? I already did this but I think it just hides the problem. It would be much better to change the logic behind the computation of maxtry and not use this intermediate vars that might diverge. I do not know enough of the internal liggghts structure to make this changes.

- Maybe I am using this as it is not intended so please tell me my mistake?

This is an example of the insertion utils in my in.input

fix ins nve_group insert/pack seed 32452867 distributiontemplate pdd2 &
maxattempt 100000 insert_every once overlapcheck yes verbose yes &
random_distribute exact &
all_in yes vel gaussian 0. 0. 0. 0.0 0.0 0.0 &
region reg volumefraction_region 0.035 &
ntry_mc 10000

Thanks in advance