J2 coefficient. Earth is flat. Isn’t it?
For trajectory simulation on low earth orbit was implemented 3 different groups of functions in source code. At first (for Earth’s simulation as a dot mass) kepler’s elements of a satellite (eccentricity, inclination, longitude of ascending node, argument of perihelion, and mean anomaly) converted to position and velocity, then plugged to a simulation. To confirm that conversion and simulation is “OK” was ported (as a second group) source code from http://www.projectpluto.com/source.htm (functions for keplers reverse conversion from position and velocity to a keplers elements). After some sign adjustments was confirmed that dot mass simulation is correct == after one orbit (or 1 day flight) satellite’s Keplers elements has had an error lower then 1.E-10. Then comes third group – old fortran source code from “SPACETRACK REPORT NO 3” (http://www.amsat.org/amsat/ftp/docs/spacetrk.pdf ) function for SGP4 gives (looks like) gives better precision than SGP. Then model was switched from dot mass to a something better suitable like GEM-T3 or JGM3. Basically this model deals with “flatness” of the earth (or differently saying orange like model of earth, or “pear” shape-like earth model). All those models suppose to allow to calculate value a gravitation potential assuming that earth is not a perfect sphere. Recursive function Pn(cosTtetta) does not take much time to implement. Was confirmed that coefficient J2=1082.6360229830E-6 has biggest impact. Because in first lines of a report was stated: “The NORAD element sets are “mean" values obtained by removing periodic variations in a particular way. In order to obtain good predictions, these periodic variations must be reconstructed (by the prediction model) in exactly the same way they were removed by NORAD.” This statement was confirmed by analyzing source code – mean motion and semimajor axis (eccentricity) was readjusted before use. Also by reverse conversion was confirmed that period/mean-motion of the orbit is different from “mean” mean motion (terminology of a report), and different from “mean motion”, and difference btw all 3 values is 4 seconds each. To avoid such errors was decided to use position and velocity from SPG4 model and compare that data with corresponded values from a model with J2-J8 and Sxx + Cxx coefficients to simulate gravity. Result was discouraging. Error was in 50km after one orbit. Was made an attempt to minimize difference. It was found that best match (17km in position and 8m in velocity) was when instead of cos(co-latitude) was used cos(latitude) – which is a nonsense - it shows that earth has more flatness on equator instead on a poles. Then it was manual attempt to match SPG4 data by adjusting J2 coefficient (commented out code in function IteraSat in http://www.adobri.com/misc/tra/tra.cpp) – was found that J2 was to be increased in some moments 10 times. Was done attempted to adjust initial velocity and position from SGP4 model to match result after one orbit simulation – this also did not bring suitable match. To be continue. For sure bug in a model, but without finding it will be totally impossible to do navigation to flight to the moon.