I am trying to integrate the rotational motion of a rigid body (a set of N point masses) $\textbf{in the inertial frame}$, but my results seem totally wrong. What of the following steps could be wrong?
1) Assuming only an inertial frame, we can write:
$$ \frac{d\vec{L}}{dt} = \vec{\tau} \Rightarrow \frac{d(I\vec{\omega})}{dt} = \vec{\tau} \Rightarrow \frac{dI}{dt}\vec{\omega} + I\frac{d\vec{\omega}}{dt} = \vec{\tau} \Rightarrow \boxed{\frac{d\vec{\omega}}{dt} = I^{-1}(\vec{\tau} - \frac{dI}{dt}\vec{\omega})} \hspace{0.2cm} (1) $$
2) In the inertial frame we have:
$$ \vec{r}_i(t) = x_i(t)\hat{x} + y_i(t)\hat{y} + z_i(t)\hat{z} $$ $$ \vec{v}_i(t) = \dot{\vec{r}}_i(t) = \dot{x}_i(t)\hat{x} + \dot{y}_i(t)\hat{y} + \dot{z}_i(t)\hat{z} $$ $$ \vec{\omega}(t) = \omega_x(t)\hat{x} + \omega_y(t)\hat{y} + \omega_z(t)\hat{z} $$ $$ \dot{\vec{r}}_i(t) = \vec{\omega}\times \vec{r}_i $$
3) Since I have assumed only an inertial frame, the inertia tensor $I$ will be a function of time and will be updated at each time step $t$.
$$I(t) = \begin{bmatrix} I_{xx} & I_{xy} & I_{xz} \\ I_{yx} & I_{yy} & I_{yz} \\ I_{zx} & I_{zy} & I_{zz} \\ \end{bmatrix} $$
where
$$I_{xx} = \sum m_i(y_i^2+z_i^2)$$
$$I_{yy} = \sum m_i(x_i^2+z_i^2)$$
$$I_{zz} = \sum m_i(x_i^2+y_i^2)$$
$$I_{xy} = I_{yx} = -\sum m_ix_iy_i$$
$$I_{xz} = I_{zx} = -\sum m_ix_iz_i$$
$$I_{yz} = I_{zy} = -\sum m_iy_iz_i$$
I have calculated the derivative of $I$ to be:
$$ \dot{I} = \begin{bmatrix} \dot{I}_{xx} & \dot{I}_{xy} & \dot{I}_{xz} \\ \dot{I}_{yx} & \dot{I}_{yy} & \dot{I}_{yz} \\ \dot{I}_{zx} & \dot{I}_{zy} & \dot{I}_{zz} \\ \end{bmatrix} $$
where
$$\dot{I}_{xx} = \sum m_i(2y_i\dot{y}_i + 2z_i\dot{z}_i)$$
$$\dot{I}_{yy} = \sum m_i(2x_i\dot{x}_i + 2z_i\dot{z}_i)$$
$$\dot{I}_{zz} = \sum m_i(2x_i\dot{x}_i + 2y_i\dot{y}_i)$$
$$\dot{I}_{xy} = \dot{I}_{yx} = -\sum m_i(\dot{x}_iy_i + x_i\dot{y}_i)$$
$$\dot{I}_{xz} = \dot{I}_{zx} = -\sum m_i(\dot{x}_iz_i + x_i\dot{z}_i)$$
$$\dot{I}_{yz} = \dot{I}_{zy} = -\sum m_i(\dot{y}_iz_i + y_i\dot{z}_i)$$
4) I integrate the differential equation $(1)$ using a simple Runge-Kutta 4 scheme like this:
$$t_{i+1} = t_i + h$$ $$\vec{\omega}_{i+1} = \vec{\omega}_i + \frac{h}{6}(\vec{k}_1+2\vec{k}_2+2\vec{k}_3+\vec{k}_4)$$
where $h$ is the integration time step and
$$\vec{k}_1 = \vec{f}(\vec{\omega}_i)$$ $$\vec{k}_2 = \vec{f}(\vec{\omega}_i + \frac{\vec{k}_1h}{2})$$ $$\vec{k}_3 = \vec{f}(\vec{\omega}_i + \frac{\vec{k}_2h}{2})$$ $$\vec{k}_4 = \vec{f}(\vec{\omega}_i + \vec{k}_3h)$$
I begin the simulation by initializing the system with an angular velocity $\vec{\omega}_0$. After that, at each time step I rotate all $N$ points of the rigid body around the current vector $\vec{\omega}$ by an angle $|\vec{\omega}|h$ using a rotation matrix calculated through Rodrigues formula
$$ R = J + \sin(\omega h)W + [1-\cos(\omega h)]W^2 $$
where $J$ is the $3\times 3$ identity matrix and $W = \begin{bmatrix} 0 & -u_z & u_y \\ u_z & 0 & -u_x \\ -u_y & u_x & 0 \\ \end{bmatrix} \hspace{0.2cm} \text{with} \hspace{0.2cm} \vec{u} = \dfrac{\vec{\omega}}{|\vec{\omega}|}$
After the rotation/update of all $N$ points, I recalculate the inertia tensor $I$ (and thus $\dot{I}$ and $I^{-1}$) and then, through equation $(1)$ I update the angular velocity $\vec{\omega}$. The cycle goes on from $t = 0$ up to some $t_{max}$ with step $h$. The problem is that at first, the results are correct (angular momentum and energy are constant), but after some time iterations, the numbers grow quickly too big and I get full of NaNs. Even for the simplest case were the external torque is $\vec{\tau} = \vec{0}$, the same happens. I checked if there is a problem with the determinant of $I$ (and thus cannot be inversed), but the determinant remains nonzero. Is there anything wrong with any of the equations? Must I perform some kind of normalization to a quantity during the time loop? There must be way in which you can simulate the rigid body rotation in the inertial frame. Thank you.
$\vec{\dot r}=\vec{\omega}\times \vec{r}$ and solve both differential equations , so you solve now $\vec{\dot{y}}=\vec{f}(\vec{y})$ where ${y}=[\vec{\omega},,\vec{r}]^T$. I Wahr about the initial conditions ?
– Eli Oct 07 '19 at 22:14