I want to calculate the number density distribution (1D or 2D) based on molecular center of mass in lammps, how can I do it?
You can probably pull something together using:
compute chunk/atomto chunk atoms into molecules
compute com/chunkto produce a vector of centres of mass
fix ave/histoto create a histogram of centres of mass (taking into account periodic images)
Or you can do it by post-processing a trajectory. My recommendation is to go with post-processing since, if you were pulling together a list of LAMMPS commands like I suggested, you’d still need to test it and make sure it’s correct – for which you need a trajectory post-processing approach anyway.
Indeed. For instance the DensityPlanar module of MAICoS allows for calculating density from the center-of-mass of molecules.