I am confused about the multiple usage of the CNA compute. I execute the following code on a polycrystal.
compute precna all cna/atom 3.46440
dump precornr all cfg 1 dump_precor.*.cfg mass type xs ys zs c_precna
variable prelig atom c_precna==3
group pregrain variable prelig
compute cna pregrain cna/atom 3.4644
dump cornr all cfg 1 dump_cor.*.cfg mass type xs ys zs c_cna
variable lig atom c_cna==3
group grain variable lig
And I would suspect the Group grain to include less atoms than the group pergrain, but that is not the case. Does this mean all atoms are taken into account for the CNA calculation even though I limited the compute to the group pregrain and the output is only set to zero for those not in the group ?
What I want to do is remove the outer shell of each grain and collect all atoms inner atoms in one group. When executing CNA the first time this works, but removing the second shell does not work.
Looking at the source code, there is this comment when the
neighbor lists of near-neighbors are built:
// find the neigbours of each atom within cutoff using full neighbor list
// nearest = atom indices of nearest neighbors, up to MAXNEAR
// do this for all atoms, not just compute group
// since CNA calculation requires neighbors of neighbors
and then later when the CNA is actually computed for each atom:
// compute CNA for each atom in group
So your conclusion is correct:
Does this mean all atoms are taken into account for the CNA calculation even though I limited the compute to the group >pregrain and the output is only set to zero for those not in the group ?
I suppose there could be options for doing this in different ways.
Let’s see if Alex wants to comment (CCd).
It has been a while that I last looked at the implementation details of the current cna/atom compute, but the described behavior matches my expectation:
Only atoms from the selected group are considered to be ‘central’ atoms, for which a structure type is calculated. But when it comes to what neighbors are taken into account for the CNA calculation, all atoms are considered, irrespective of their group membership.
So peeling off the grains like you tried to, without actually deleting the outer layer of atoms, doesn’t work.
In principle it would be straightforward to change this behavior in the code. When looping over the neighbors in the CNA routine, one simply has to skip neighbors that don’t belong to the selected group. But I would be careful with changing this, because other LAMMPS users might rely on the current behavior.