I once derived the equations of geodesic for torus as a byproduct when I was
doing my graduate studies and a course in analytic mechanics (long time ago) .
The task was to find equilibrium points if a particle is restricted to move on a surface of a torus and show that the 'outer equator' of a torus is a stable equilibrium and inner equator is unstable equilibrium.
As it happens : If a particle is restricted to move on a smooth surface with no external
forces (only holonomic constraint forces keeping the particle on the surface) then
the particle moves along the geodesics of the surface. So the solution to equations
of motion are at the same time geodesics of the surface.
I attach here a pdf about my solution. It is in Finnish, but the equations of motion
(1), (2) , (3) and (4) are also equations for the geodesics if you want to analyze them yourself. The parameters I have used
are shown in Fig.1 and I have plotted some figures about the trajectories / geodesics in Fig. 3, Fig.5 and Fig.7.
I hope this kind of thinking helps you since you seem to be a student in physics.
Yeah finnish is not the easiest language :-) But the main conclusions
in the pdf are that for initial velocities small enough the trajectories in the phase plane form closed curves if the particle starts from the outer equator and
the curves are never closed and \theta is increasing if it starts from inner equator. Hence outer equator is stable and inner equator unstable.
I am guessing its due to the fact that the (Gaussian) curvature in inner equator is neqative and in outer equator positive ?
The geodesic curves on a manifold are determined by the so-called Riemann metric tensor. A relatively simple intoductory material could be found in Spence and Moon Field Theory Handbook and in other related monographs.