What should I do if I want to calculate the volume of a group in LAMMPS.
If I calculate the volume of each atom and sum it up, could I calculate the volume of the group.
How do you define the volume of one atom for your system? This is a little ill-defined. Is the group spread out across the simulation box, or does it make up it’s own region?
You cannot really do that, because that is - in essence - a fractional property.
The best you can do are one of two options:
- partition the volume of the simulation cell and assign a part to that group
- make an assumption of the volume per atom (e.g. based on covalent radii or density of the pure material) and then count how many atoms you have in that group
Either method is an approximation and it depends on the details of your system which is the better approximation. To partition the volume of the cell, you could use the compute voronoi/atom command — LAMMPS documentation
To count the atoms in a region you can use an equal style variable and the count function and then multiply with the volume. This - of course - assumes all atoms are of the same type.
To assign a volume to each atom you can use for example an atomfile style variable and then use compute reduce with a suitable group ID to compute the sum of those. Or use compute reduce/region if you need to narrow this down by region as well.
Thanks for your reply. I want to calculate the stress of atom in the group. I calculated stress of each atom in the group by ''compute stress/atom ''and sum it up by ‘‘compute reduce’’ , but it involves volume terms as manuscript points out, hence I need to divide by the volume of the group. In addition, I calculated the pressure of system by ‘‘compute pressure’’. I want to compare the difference between the two results. You’re right. The first method of calculating the volume is approximate. The second method of calculating the stress may be more accurate.
I apologize for not being able to articulate my question. There are many atoms in the group, and I calculate the stress of each atom by ‘compute stress/atom’ and the sum by ‘compute reduce’. However, it involves volume terms as manuscript points out, hence, I need to divide by the volume of the group to obtain pressure(stress).