Exemplo n.º 1
0
def simulation(par):
    S, dt,e0 = par

    rebound.reset()
    rebound.set_integrator("wh")
    #rebound.set_integrator("whfast")
    rebound.set_dt(dt)

    rebound.particle_add(m=1.)
    rebound.particle_add(m=0.,a=1.,e=e0)

    #rebound.move_to_center_of_momentum()
    #rebound.megno_init(1.e-16)


    particles = rebound.particles_get()
    def starkforce(): # need to put inside simulation(par) to have access to S and particles
        particles[1].ax += -S

    rebound.set_additional_forces(starkforce)

    rebound.integrate(50000.*np.pi)

    return [rebound.get_megno(), rebound.get_t()]
Exemplo n.º 2
0
# Import the rebound module
import sys; sys.path.append('../')
import rebound
from rebound import Particle
import numpy as np
from interruptible_pool import InterruptiblePool


for i in np.linspace(-2.*np.pi,2.*np.pi,1000):
    rebound.reset()
    rebound.set_integrator("whfast-nocor")
    rebound.set_dt(0.01*2.*np.pi)

    try:
        rebound.particle_add(m=1.)
        rebound.particle_add(m=0., a=1., e=1.01, anom=i)
        particles = rebound.particles_get()
        print particles[1].x, particles[1].y, i
        #rebound.step()
        #print particles[1].x, particles[1].y, i
    except:
        pass
    
Exemplo n.º 3
0
from rebound import Particle

# Add particles
# We work in units where G=1.  
rebound.particle_add( Particle(m=1.) )                  # Test particle
rebound.particle_add( Particle(m=1e-3,x=1.,vy=1.) )     # Planet

# Move particles so that the center of mass is (and stays) at the origin  
rebound.move_to_center_of_momentum()

# You can provide a function, written in python to REBOUND.
# This function gets called every time the forces are evaluated.
# Simple add any any additional (non-gravitational) forces to the 
# particle accelerations. Here, we add a simple drag force. This 
# will make the planet spiral into the star.
particles = rebound.particles_get()                     # Pointer to the particle structure
N = rebound.get_N()                 
def dragforce():
    dragcoefficient = 1e-2
    for i in range(N):
        particles[i].ax += -dragcoefficient * particles[i].vx
        particles[i].ay += -dragcoefficient * particles[i].vy
        particles[i].az += -dragcoefficient * particles[i].vz

# Tell rebound which function to call
rebound.set_additional_forces(dragforce)

# Integrate until t=100 (roughly 16 orbits at 1 AU) 
rebound.integrate(100.)

# Output something at the end (the planet will be at ~0.1 AU)