Counting up number of molecules

Is there is a smart way of counting up all molecules that are defined by an atom group. To give either a) a total number of molecules or b) specific molecules for each of the groups specified. One can use atom to get the number of atoms in the group, but I cant see an obvious way to extend this to molecules without resorting to coding/scripting. I've tried looking at compute options but there does not seem to be an obvious way to pull out this info with ease.


Hi Donovan, having just been through this myself, I can point you to the right place in the code. Look in compute.cpp for Compute::molecules_in_group and you will see how Lammps does it.

Hi Jeremy

Thanks for that. Do you know if there is a way of exposing it in the in.* scripts?


In the variable comand,
count(groupID) function returns
the number of atoms in the group.
I suppose a function could be added
to count molecules in a group, though
its a more complicated operation.


Hi Steve

This functionality would be very useful, especially to the membrane guys who routinely are interested in computing stats that involve quantities per molecule. It simply means more processing can be done within scripts without having to change for the number of lipids/atoms in the system.

I have tried to use the count (groupID) to get the atoms but that still leaves the issue of the atoms per molecule which I don't think can be obtained and this may vary over multi species systems with different atoms per molecule.