Skip to main content

OrbitSystem.add_planet

add_planet(
    name,
    *,
    parent,
    nu=0,
    a=None,
    e=None,
    i=None,
    lan=None,
    arg_pe=None,
    mass=None,
)

Add a known solar system body by name.

Looks up the real mass and orbital elements of a well-known body and passes them to add_body_keplerian(). Instead of typing out the mass, semi-major axis, eccentricity and angles by hand, give the name and the parent. Any element, or the mass, can be overridden to explore a “what if” while keeping the rest of the real values. Also available as orb.add_planet(system, ...).

The built-in values are mean orbital elements at the J2000 epoch, with angles measured from the plane of Earth’s orbit. The mass and semi-major axis are the package constants (for example orb.mass_mars and orb.distance_mars_sun).

Name a (m) e i (deg) lan (deg) arg_pe (deg)
Mercury 5.791e10 0.2056 7.00 48.33 29.12
Venus 1.082e11 0.0068 3.39 76.68 54.88
Earth 1.496e11 0.0167 0.00 -11.26 114.21
Mars 2.279e11 0.0934 1.85 49.58 286.50
Jupiter 7.785e11 0.0489 1.30 100.46 273.87
Saturn 1.434e12 0.0565 2.49 113.72 339.39
Uranus 2.871e12 0.0457 0.77 74.23 96.99
Neptune 4.495e12 0.0113 1.77 131.72 273.19
Moon 3.844e8 0.0549 5.15 125.08 318.15
Pluto 5.906e12 0.2488 17.16 110.30 113.83

Parameters

Name Type Description Default
name str The body to add. One of "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Moon" or "Pluto". Case does not matter: "earth" is stored as "Earth". required
parent str The name of the body being orbited, which must already be in the system. For the planets and Pluto this is normally "Sun"; for the Moon it is "Earth". Case does not matter. Must be passed by keyword. required
nu float True anomaly in degrees: where the body starts along its orbit. Default 0, which is periapsis. This is the element most often changed. Use it to spread planets around their orbits instead of starting them all at closest approach. 0
a float Semi-major axis in meters. The default, None, uses the built-in value. None
e float Eccentricity. The default, None, uses the built-in value. None
i float Inclination in degrees. The default, None, uses the built-in value. None
lan float Longitude of the ascending node in degrees. The default, None, uses the built-in value. None
arg_pe float Argument of periapsis in degrees. The default, None, uses the built-in value. None
mass float Mass in kilograms. The default, None, uses the built-in value. None

Returns

Name Type Description
OrbitSystem A new system with the body added under its standard name. The original system is not modified.

Raises

Name Type Description
ValueError If parent is not in the system, if name is not one of the ten available bodies, if the body is already in the system, or if an override fails the checks in add_body_keplerian().

See Also

Notes

The elements are taken relative to whichever parent you name. The function does not check that the pairing is the real one, so add_planet("Moon", parent="Sun") puts a Moon-mass body in a Moon-sized orbit around the Sun.

Examples

The inner solar system, simulated for one year and drawn from above (three_d=False gives the flat view of the x-y plane).

import pyorbiter as orb

sim = (
    orb.create_system()
    .add_sun()
    .add_planet("Mercury", parent="Sun")
    .add_planet("Venus", parent="Sun")
    .add_planet("Earth", parent="Sun")
    .add_planet("Mars", parent="Sun")
    .simulate(time_step=orb.seconds_per_day, duration=orb.seconds_per_year)
)
orb.plot_orbits(sim, three_d=False)

Override values to ask “what if”. Here Mars has a circular orbit and Jupiter has twice its real mass and starts a quarter of the way round.

import pyorbiter as orb

system = (
    orb.create_system()
    .add_sun()
    .add_planet("Mars", parent="Sun", e=0)
    .add_planet("Jupiter", parent="Sun", mass=2 * orb.mass_jupiter, nu=90)
)
system
───────────────────────────────── orbit_system ─────────────────────────────────
G: 6.6743e-11 (standard)
Bodies: 3

     id         mass             x             y             z            vx           vy         vz
    Sun 1.989000e+30  0.000000e+00  0.000000e+00  0.000000e+00      0.000000     0.000000   0.000000
   Mars 6.417000e+23  2.082395e+11 -9.233064e+10 -7.054316e+09   9788.531757 22059.828065 221.290885
Jupiter 3.796000e+27 -1.922097e+11  7.524768e+11  1.189215e+09 -12822.210747 -2615.873542 296.918386