Learning Scientific Programming with Python (2nd edition)
P8.2.3: Volume and moment of inertia of a torus
Question P8.2.3
Consider a torus of uniform density, unit mass, average radius $R$ and cross sectional radius $r$. The volume and moments of inertia of such a torus may be evaluated analytically and give the results: $$ \begin{align*} V &= 2\pi^2 Rr^2,\\ I_z &= R^2 + \textstyle \frac{3}{4}r^2,\\ I_x = I_y &= \textstyle \frac{1}{2}R^2 + \frac{5}{8}r^2, \end{align*} $$ where the centre of mass of the torus is at the origin and the $z$ axis is taken to be its symmetry axis.
Here we take a numerical approach. In cylindrical coordinates, $(\rho, \theta, z)$, it may be shown that: $$ \begin{align*} V &= 2\int_0^{2\pi} \int_{R-r}^{R+r} \int_0^{\sqrt{r^2 - (\rho-R)^2}} \rho \;\mathrm{d}z\,\mathrm{d}\rho\,\mathrm{d}\theta,\\ I_z &= \frac{2}{V}\int_0^{2\pi} \int_{R-r}^{R+r} \int_0^{\sqrt{r^2 - (\rho-R)^2}} \rho^3 \;\mathrm{d}z\,\mathrm{d}\rho\,\mathrm{d}\theta,\\ I_x = I_y &= \frac{2}{V}\int_0^{2\pi} \int_{R-r}^{R+r} \int_0^{\sqrt{r^2 - (\rho-R)^2}} (\rho^2\sin^2\theta + z^2)\rho \;\mathrm{d}z\,\mathrm{d}\rho\,\mathrm{d}\theta. \end{align*} $$
Evaluate these integrals for the torus with dimensions $R=4$, $r=1$ and compare with the exact values.