Calculating the Longest Orbital Period

Although we have a working template file, we don't know what we should set the limit to so that all planets can complete their orbits. We can use axana to find the longest amount of time a body will take to finish it's orbit.

Let's write a quick script to analyze the orbital periods:

import axinite as ax
import axinite.tools as axtools
import axinite.analysis as axana

args = axtools.read("examples/solar-system/my-solar-system.tmpl.ax")
bodies = axtools.load(args, verbose=True)

longest = 0

for body in bodies[1:]:
    orbit = axana.Orbit(bodies[0], body)
    print(f"{body.name}: {orbit.orbital_period}")
    if orbit.orbital_period > longest:
        longest = orbit.orbital_period

print(f"The longest orbital period is {longest} seconds, or:")
print(f"{ax.time_to(longest, "min", round_digits=2)},")
print(f"{ax.time_to(longest, "hr", round_digits=2)},")
print(f"{ax.time_to(longest, "d", round_digits=2)},")
print(f"{ax.time_to(longest, "yr", round_digits=2)}")

This script will return multiple values in the console. Take the one that seems most appropriate (for examples, with the template provided eariler, 1.0yr or 366.11d) and replace the old limit with it.

{
    "name": "my-solar-system",
    "limit": "1yr",
    "delta": "1hr",
    ...
}

Last updated