예제 #1
0
    def test_backwards_time(self):
        sim = rebound.Simulation(binary)
        sim.integrator = "ias15"
        rebx = reboundx.Extras(sim)
        times = [0, 2000., 4000., 6000., 8000., 10000.]
        values = [1., 0.8, 0.6, 0.4, 0.3, 0.2]
        starmass = reboundx.Interpolator(rebx, times, values, "spline")

        Nout = 1000
        ts = np.linspace(0., 1.e4, Nout)
        ps = sim.particles
        a10 = ps[1].a
        m0 = ps[0].m

        for i, time in enumerate(ts):
            sim.integrate(time)
            ps[0].m = starmass.interpolate(rebx, t=sim.t)
            sim.move_to_com(
            )  # lost mass had momentum, so need to move back to COM frame
        sim.dt = -0.001
        for i, time in enumerate(times[::-1]):
            sim.integrate(time)
            ps[0].m = starmass.interpolate(rebx, t=sim.t)
            sim.move_to_com(
            )  # lost mass had momentum, so need to move back to COM frame
        self.assertLess(abs((ps[0].m - m0) / m0), 1.e-2)
        self.assertLess(abs((ps[1].a - a10) / a10), 1.e-2)
예제 #2
0
    def test_klo(self):
        sim = rebound.Simulation(binary)
        sim.integrator = "ias15"
        rebx = reboundx.Extras(sim)
        times = [0, 2000., 4000., 6000., 8000., 10000.]
        values = [1., 0.8, 0.6, 0.4, 0.3, 0.2]
        starmass = reboundx.Interpolator(rebx, times, values, "spline")

        m0 = sim.particles[0].m
        mint0 = starmass.interpolate(rebx, t=0)

        self.assertLess(abs((m0 - mint0) / m0), 1.e-6)

        mint1 = starmass.interpolate(rebx, t=5000)  # advance klo
        mint1 = starmass.interpolate(rebx, t=0)  # advance klo

        self.assertLess(abs((m0 - mint1) / m0), 1.e-6)
예제 #3
0
for i, w in enumerate(watts):
    lumins[i] = (w * ((6.7e-12)**2) * (5e-31)) / ((3.2e-8)**3)
t_fs = np.zeros(lumins.size)  # precalculate t_f (Eq. 1)
for i, l in enumerate(lumins):
    t_fs[i] = np.cbrt(masses[i] * radii[i]**2 / l)
taus = np.zeros(t_fs.size)  # precalc tau (Eq. 2)
G = 4 * np.pi**2  # units of AU, yr, and Msun
for i, t_f in enumerate(t_fs):
    taus[i] = 2. * radii[i]**3 / G / masses[i] / t_f

# main loop
for i, interval in enumerate(intervals):
    # initialize sim and create Interpolator objects
    timer_start = time.perf_counter()
    sim, rebx, tides = makesim()
    starmass = reboundx.Interpolator(rebx, mtimes, masses, 'spline')
    starradius = reboundx.Interpolator(rebx, rtimes, radii, 'spline')
    startau = reboundx.Interpolator(rebx, ltimes, taus, 'spline')

    # update Sun's mass and radius accordingly
    ps = sim.particles
    ps[0].m = starmass.interpolate(rebx, t=T0)
    ps[0].r = starradius.interpolate(rebx, t=T0)
    ps[0].params["tctl_k1"] = 0.038  # ~ lambda_2, Schroder & Smith (2008)
    ps[0].params["tctl_tau"] = startau.interpolate(rebx, t=T0)
    ps[0].params["Omega"] = 0  # explicitly set to 0 (would be 0 by default)

    # initialize main sim
    tmax = 5e6  # max sim integration time
    Nup = int(tmax / interval)  # no. of param updates
    ts = np.linspace(0., tmax, Nup)