Done!
You just need to calculate a new chart with calculatesid(), but make the final variable trop = 0.
char trop = 0;
calculatesid(1, julianDay, geoLong, geoLat, -2, trop);
real tropPlanets[PLANETS];
getplanets(1, tropPlanets);
Subtracting the sidereal position of the Sun from the tropical position given by this calculation gives the ayanamsa.