import rebound
sim = rebound.Simulation()
sim.add("Sun")
## Other examples:
# sim.add("Venus")
# sim.add("399")
# sim.add("Europa")
# sim.add("NAME=Ida")
# sim.add("Pluto")
# sim.add("NAME=Pluto")
sim.status()

"""
Explanation: Horizons
REBOUND can add particles to simulations by obtaining ephemerides from NASA's powerful HORIZONS database.  HORIZONS supports many different options, and we will certainly not try to cover everything here.  This is meant to serve as an introduction to the basics, beyond what's in Churyumov-Gerasimenko.ipynb.  If you catch any errors, or would either like to expand on this documentation or improve REBOUND's HORIZONS interface (rebound/horizons.py), please do fork the repository and send us a pull request.
Adding particles
When we add particles by passing a string, REBOUND queries the HORIZONS database and takes the first dataset HORIZONS offers.  For the Sun, moons, and small bodies, this will typically return the body itself.  For planets, it will return the barycenter of the system (for moonless planets like Venus it will say barycenter but there is no distinction).  If you want the planet specifically, you have to use, e.g., "NAME=Pluto" rather than "Pluto".  In all cases, REBOUND will print out the name of the HORIZONS entry it's using.
You can also add bodies using their integer NAIF IDs:  NAIF IDs.  Note that because of the number of small bodies (asteroids etc.) we have discovered, this convention only works for large objetcts.  For small bodies, instead use "NAME=name" (see the SMALL BODIES section in the HORIZONS Documentation).
End of explanation
"""


sim.add("NAME=Ida")
print(sim.particles[-1])    # Ida before setting the mass
sim.particles[-1].m = 2.1e-14 # Setting mass of Ida in Solar masses
print(sim.particles[-1])    # Ida after setting the mass

"""
Explanation: Currently, HORIZONS does not have any mass information for solar system bodies.  rebound/horizons.py has a hard-coded list provided by Jon Giorgini (10 May 2015) that includes the planets, their barycenters (total mass of planet plus moons), and the largest moons.  If REBOUND doesn't find the corresponding mass for an object from this list (like for the asteroid Ida above), it will print a warning message.  If you need the body's mass for your simulation, you can set it manually, e.g. (see Units.ipynb for an overview of using different units):
End of explanation
"""


sim = rebound.Simulation()
date = "2005-06-30 15:24"
sim.add("Venus")
sim.add("Venus", date=date)
sim.status()

"""
Explanation: Time
By default, REBOUND queries HORIZONS for objects' current positions.  Specifically, it caches the current time the first time you call rebound.add, and gets the corresponding ephemeris.  All subsequent calls to rebound.add will then use that initial cached time to make sure you get a synchronized set of ephemerides.
You can also explicitly pass REBOUND the time at which you would like the particles ephemerides:
End of explanation
"""


sim = rebound.Simulation()
date = "2005-06-30 15:24"
sim.add("Venus", date=date)
sim.add("Earth")
sim.status()

"""
Explanation: We see that the two Venus positions are different.  The first call cached the current time, but since the second call specified a date, it overrode the default.  Any time you pass a date, it will overwrite the default cached time, so:
End of explanation
"""


sim = rebound.Simulation()
sim.add("Sun")
sim.status()

"""
Explanation: would set up a simulation with Venus and Earth, all synchronized to 2005-06-30 15:24.  All dates should be passed in the format Year-Month-Day Hour:Minute.  
REBOUND takes these absolute times to the nearest minute, since at the level of seconds you have to worry about exactly what time system you're using, and small additional perturbations probably start to matter.  For reference HORIZONS interprets all times for ephemerides as Coordinate (or Barycentric Dynamical) Time.
Reference Frame
REBOUND queries for particles' positions and velocities relative to the Sun:
End of explanation
"""


