I am trying to see if there are ballistic trajectories in the surface of the torus that are not periodic and to what extent. Maybe it not only quasiperiodic but chaotic. I guess there are quasiperiodic trajectories but I tried some angle-action variables approach and could not solve it.
I wrote the Lagrangian $$L=\frac{(a+b\cos\vartheta)^2\dot\varphi^2}{2}+\frac{b^2\dot\vartheta^2}{2}$$ and from it the Hamiltonian $$H=\frac{p_\varphi^2}{2(a+b\cos\vartheta)^2}+\frac{p_\vartheta^2}{2b^2}$$ where $a$ is the larger radius, $b$ is the smallest radius, $\varphi$ is the azimuthal angle (motion in the plane of the torus) and $\vartheta$ is the angle with respect to $z$ axis (perpendicular to the plane of the torus). Both $\varphi$ and $\vartheta$ can take values from $0$ to $2\pi$.
The conjugate momentum $p_\varphi$ is conserved and then I wanted to calculate the action-angle variable for $\vartheta$ but I cannot solve the integral:
$$I_\vartheta=\frac{b}{2\pi}\oint \sqrt{2E-\frac{p_\varphi^2}{(a+b\cos\vartheta)^2}} \mathrm{d}\vartheta,$$ where $E>\frac{p_\varphi^2}{2(a+b\cos\vartheta)^2}$ is the energy. I do not know how to integrate this nor I am sure to know what are the turning angles (if any). Hopefully, I could use commensurability condition between the frequencies to see what is the periodic orbit condition.
Maybe there is an easier way to solve it. I guess that if the motion in $\vartheta$ completes full rotations and it is so that $\dot\vartheta=\mathrm{constant}$, some geometrical analysis can be made. I will try toroidal coordinates to see if it helps.
Additional insight: my guess is that there are quasiperiodic trajectories. When discussing KAM theorem, one visualizes the phase-space dynamics with a picture of spiral-like trajectories in a $d$-dimensional torus. If the trajectories are non-commensurate, the trajectories will cover the whole torus. Which implies for the case above, that we could draw some non-periodic spiral-like orbits on the surface of the 2-torus. However, it is unclear if the Hamiltonian above is equivalent to that picture of spiral like trajectories.