# [lammps-users] Increasing the maximum group size

Hi,

I need to use more groups than its restricted by lammps. Maximum one can use 32 groups including "all". I tried to modify "group.cpp" by changing MAX_GROUP define parameter. However later I found that bitmasking would fail by doing so. I guess the way it works is like following: first it creates bitmask[igroup] for all the groups such that the binary expression should involve only one 1 and the rest 0. Obviously this means one can offer only these numbers - 1, 2, 4, 8, 16, 32, 64, 128,...2^31 - to the bitmask[igroup] where igroup can be from 0 to 31. Then using the OR bit operation it changes mask[i] of the atom to bitmask[igroup] - for example first 10 atoms could be assigned to igroup = 3 i.e. mask[i] of all those first atoms would be 8 (2^3). Now any atom not lying in the igroup=3, whose binary expression is not 1000, would give the value 0 when AND operation is performed with mask[i] and bitmask[igroup], and any atom exactly lying in igroup=3 would give the value 1 after AND operation. This is how whether any atom should perform any particular group operation in ensured.

One way to circumvent this problem would be to perform the masking in integer terms instead of binary terms, i.e. assign integer expression to bitmask[igroup] and while checking use "mask[i] && bitmask[igroup]" in place of "mask[i] & bitmask[igroup]". But the problem is its a very time consuming process, because one has to change all fix.cpp, modify.cpp, compute.cpp and so on. And also I don't know what other problems I'd face further by this.

Thanks,
Amit

Thanks,
Amit

Why do you need more than 32 groups? Usually there
is another way to do what you want, rather than use groups.

Steve

Thanks Steve for the question.

I'm more interested in binning. Its like diving the cubic box into many sub-cubes, then thermostatting some of them and also computing Temp, Stress etc for all of the sub-cubes after the run. The groups are helpful because one can do several operations (like zero linear momentum, angular mometum etc).

Hope it helps to understand the problem.

Thanks for the response,
Amit

Since atoms presumably move in/out of boxes,
a zillion of them. You will need to do what you
are asking by writing a fix that locates particles in
the same bin and applies the operations you
want to them: thermostat, zero momentum, etc.
You will also need to worry about particles on
2 procs being in the same bin, which may require
communication.

Steve

Thanks Steve,

But isn't it true that fix, velocity, compute - all these commands require group-ids? May be there exists something better than group command to do the problem which I'm working upon. Following is the script for the problem. Please suggest anything if I want to increase the dpd groups to 100 instead of 5 (please see below the implementation).

-Amit

boundary s s s
units metal
atom_style dpd

variable cut equal 4.5

neighbor 0.2*\${cut} bin

# create geometry
lattice fcc 5.3437 region box block 0 10 0 2 0 2
create_box 1 box
create_atoms 1 box

mass * 39.948
# define groups
group dpd bin 5 #it creates 5 groups and a part added by me in the lammps code
group rightcore subtract all dpd1
group innercore subtract rightcore dpd5

velocity dpd1 create 100.0 4459 mom no dist gaussian
velocity dpd5 create 100.0 4459 mom no dist gaussian
velocity innercore create 100.0 4459 mom no dist gaussian
velocity all zero linear
velocity all zero angular

pair_style lj/cut \${cut}
pair_coeff * * 0.3 3.4

fix 100 dpd1 nvt 60.0 60.0 1.0e1
fix 200 dpd5 nvt 100.0 100.0 1.0e1

fix 300 innercore nve

compute 1 all temp
compute 2 dpd1 temp
compute 3 dpd2 temp
compute 4 dpd3 temp
compute 5 dpd4 temp
compute 6 dpd5 temp

compute 101 all temp/partial 1 0 0
compute 102 dpd1 temp/partial 1 0 0
compute 103 dpd2 temp/partial 1 0 0
compute 104 dpd3 temp/partial 1 0 0
compute 105 dpd4 temp/partial 1 0 0
compute 106 dpd5 temp/partial 1 0 0

compute 201 all temp/partial 0 1 0
compute 202 dpd1 temp/partial 0 1 0
compute 203 dpd2 temp/partial 0 1 0
compute 204 dpd3 temp/partial 0 1 0
compute 205 dpd4 temp/partial 0 1 0
compute 206 dpd5 temp/partial 0 1 0

compute 301 all temp/partial 0 0 1
compute 302 dpd1 temp/partial 0 0 1
compute 303 dpd2 temp/partial 0 0 1
compute 304 dpd3 temp/partial 0 0 1
compute 305 dpd4 temp/partial 0 0 1
compute 306 dpd5 temp/partial 0 0 1

fix 12 all oneave/time 1 1000 1000 c_2 c_102 c_202 c_302 c_3 c_103 c_203 c_303 c_4 c_104 c_204 c_304 c_5 c_105 c_205 c_305 c_6 c_106 c_206 c_306 ave running file temp.profile
# run

timestep 0.001
thermo 1000

dump 1 all xyz \${ntemp} beam.xyz
run 10000

Forget groups. I would write a fix like:

fix 1 all bin/thermostat ...

and have that fix partition the atoms into bins
and compute all the quantities you want for each
bin or thermostat each bin as desired.

Steve