# Calculation of inertia for molecule composed of finite size spheres

Dear LAMMPSer:

I am curious about how LAMMPS compute the inertia tensor of a molecule composed of finite size spheres.

According to the function compute_inertia() in “molecule.cpp”:

1. if (!inertiaflag) {
2. inertiaflag = 1;
3. atom->check_mass(FLERR);
4. double onemass,dx,dy,dz;
5. for (int i = 0; i < 6; i++) itensor[i] = 0.0;
6. for (int i = 0; i < natoms; i++) {
7. if (rmassflag) onemass = rmass[i];
8. else onemass = atom->mass[type[i]];
9. dx = dxcom[i][0];
10. dy = dxcom[i][1];
11. dz = dxcom[i][2];
12. itensor[0] += onemass * (dydy + dzdz);
13. itensor[1] += onemass * (dxdx + dzdz);
14. itensor[2] += onemass * (dxdx + dydy);
15. itensor[3] -= onemass * dy*dz;
16. itensor[4] -= onemass * dx*dz;
17. itensor[5] -= onemass * dx*dy;
18. }
20. for (int i = 0; i < natoms; i++) {
21. if (rmassflag) onemass = rmass[i];
22. else onemass = atom->mass[type[i]];
26. }
27. }
28. }

If the molecule consists of a set of point spheres, then the inertia tensor is simply calculated by the line 6-18.

If the component spheres are finite size (radiusflag is true), then Ixx, Iyy, Izz are updated by adding every sphere’s inertia 2/5* m_i* r_i* r_i via line 23-25.

Can someone give some source about how to calculate the inertia about the center of mass, for a system of non-overlap solid spheres?

Best,

for

atom_style hybrid sphere molecular

I can confirm that LAMMPS calculates the inertia tensor with point spheres (line 6-18) by output

variable Ixx equal inertia(all,xx)
variable Iyy equal inertia(all,yy)
variable Izz equal inertia(all,zz)

variable Ixy equal inertia(all,xy)
variable Ixz equal inertia(all,xz)
variable Iyz equal inertia(all,yz)

where only one molecule is in the sysmtem.