#!/usr/bin/env python # coding: utf-8 # # Embedded Operator Splitting (EOS) Methods # # This examples shows how to use the Embedded Operator Splitting (EOS) Methods described in Rein (2019). The idea is to embedded one operator splitting method inside another. The inner operator splitting method solves the Keplerian motion, whereas the outer solves the planet-planet interactions. The accuracy and speed of the EOS methods are comparable to standard Wisdom-Holman type methods. However, the main advantage of the EOS methods is that they do not require a Kepler solver. This significantly simplifies the implementation. And in certain cases this can lead to a speed-up by a factor of 2-3x. # In[1]: import rebound get_ipython().run_line_magic('matplotlib', 'inline') import matplotlib.pylab as plt import numpy as np import time linestyles = ["--","-","-.",":"] labels = {"LF": "LF", "LF4": "LF4", "LF6": "LF6", "LF8": "LF8", "LF4_2": "LF(4,2)", "LF8_6_4": "LF(8,6,4)", "PLF7_6_4": "PLF(7,6,4)", "PMLF4": "PMLF4", "PMLF6": "PMLF6"} # We first create a function to setup our initial conditions of two Jupiter-mass planets with moderate eccentricities . We also create a function to run the simulation and periodically measure the relative energy error. The function then runs the simulation again, this not only measuring the runtime. This way we don't include the time required to calculate the energy error in our run time measurements. # In[2]: def initial_conditions(): sim = rebound.Simulation() sim.add(m=1) sim.add(m=1e-3,a=1,e=0.05,f=0.) sim.add(m=1e-3,a=1.6,e=0.05,f=1.) sim.move_to_com() return sim def run(sim): simc = sim.copy() # Use later for timing tmax = 100. # First run to measure energy error Emax = 0 E0 = sim.energy() while sim.t