Warning in compute group/group

Hello,

When using the compute group/group, I get the following warning:
WARNING: Both groups in compute group/group have a net charge; the Kspace boundary correction to energy will be non-zero (src/compute_group_group.cpp:143)
The compute is:

compute e_all all group/group pf64 kspace yes boundary yes

I have checked my system and the all group is charge neutral. I.e. the warning seems unjustified.

In the code the sum of charges for each group in ComputeGroupGroup::kspace_correction() only includes atoms which are in both groups:

  for (int i = 0; i < atom->nlocal; i++) {                                                              
    if (!((mask[i] & groupbit_A) && (mask[i] & groupbit_B))) continue;                                                                                                                                             
                                                                                                        
    if (mask[i] & groupbit_A) qsum_A += q[i];                                                           
    if (mask[i] & groupbit_B) qsum_B += q[i];                                                           
  } 

IMO the second line should use || instead of && or simply be removed. If this is not the case and the correction is computed correctly, the warning is misleading.

Thank you

1 Like

This does look like a bug, thanks for reporting. I’ll submit a PR on Github.

Edit: I think it is actually a misleading warning, not a numerical bug.

1 Like

Thanks for the quick response