コード例 #1
0
ファイル: problem.py プロジェクト: dsspiegel/rebound
def simulation(par):
    saturn_a, saturn_e = par
    rebound.reset()
    rebound.set_min_dt(0.1)
    
    # These parameters are only approximately those of Jupiter and Saturn.
    sun     = rebound.Particle(m=1.)
    rebound.particle_add(sun)
    jupiter = rebound.particle_add(primary=sun,m=0.000954, a=5.204, anom=0.600, omega=0.257, e=0.048)
    saturn  = rebound.particle_add(primary=sun,m=0.000285, a=saturn_a, anom=0.871, omega=1.616, e=saturn_e)

    rebound.move_to_center_of_momentum()
    rebound.megno_init(1e-16)
    rebound.integrate(1e4*2.*np.pi)

    return [rebound.get_megno(),1./(rebound.get_lyapunov()*2.*np.pi)] # returns MEGNO and Lypunov timescale in years
コード例 #2
0
ファイル: problem.py プロジェクト: tasha-urbancic/rebound
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()]
コード例 #3
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
    
コード例 #4
0
ファイル: problem.py プロジェクト: dsspiegel/rebound
# Import the rebound module
import sys; sys.path.append('../')
import rebound
from rebound import Particle

# Set variables (defaults are G=1, t=0, dt=0.01)
k = 0.01720209895       # Gaussian constant 
rebound.set_G(k*k)      # Gravitational constant

# Setup particles (data taken from NASA Horizons)
# This could also be easily read in from a file.
rebound.particle_add( Particle( m=1.00000597682, x=-4.06428567034226e-3, y=-6.08813756435987e-3, z=-1.66162304225834e-6, vx=+6.69048890636161e-6, vy=-6.33922479583593e-6, vz=-3.13202145590767e-9) )  # Sun
rebound.particle_add( Particle( m=1./1047.355,   x=+3.40546614227466e+0, y=+3.62978190075864e+0, z=+3.42386261766577e-2, vx=-5.59797969310664e-3, vy=+5.51815399480116e-3, vz=-2.66711392865591e-6) )  # Jupiter
rebound.particle_add( Particle( m=1./3501.6,     x=+6.60801554403466e+0, y=+6.38084674585064e+0, z=-1.36145963724542e-1, vx=-4.17354020307064e-3, vy=+3.99723751748116e-3, vz=+1.67206320571441e-5) )  # Saturn
rebound.particle_add( Particle( m=1./22869.,     x=+1.11636331405597e+1, y=+1.60373479057256e+1, z=+3.61783279369958e-1, vx=-3.25884806151064e-3, vy=+2.06438412905916e-3, vz=-2.17699042180559e-5) )  # Uranus
rebound.particle_add( Particle( m=1./19314.,     x=-3.01777243405203e+1, y=+1.91155314998064e+0, z=-1.53887595621042e-1, vx=-2.17471785045538e-4, vy=-3.11361111025884e-3, vz=+3.58344705491441e-5) )  # Neptune
rebound.particle_add( Particle( m=0,             x=-2.13858977531573e+1, y=+3.20719104739886e+1, z=+2.49245689556096e+0, vx=-1.76936577252484e-3, vy=-2.06720938381724e-3, vz=+6.58091931493844e-4) )  # Pluto

# Set the center of momentum to be at the origin
rebound.move_to_center_of_momentum()

# Get the particle data
# Note: this is a pointer and will automatically update as the simulation progresses
particles = rebound.particles_get()
# timestep counter
steps = 0 
# Integrate until t=1e6 (unit of time in this example is days)
while rebound.get_t()<1e6:
    rebound.step()
    steps += 1
    # Print particle positions every 100 timesteps
コード例 #5
0
# Import the rebound module
import sys; sys.path.append('../')
import rebound

# Set variables (defaults are G=1, t=0, dt=0.01)
#rebound.set_G(1.)  
#rebound.set_t(0.)  
#rebound.set_dt(0.01)  

# Add particles
# All parameters omitted are set to 0 by default.
rebound.particle_add( m=1. )                  # Star
rebound.particle_add( 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()

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

# Modify particles 
# As an example, we are reverting the velocities 
particles = rebound.particles_get()
for i in range(rebound.get_N()):
    particles[i].vx *= -1.
    particles[i].vy *= -1.
    particles[i].vz *= -1.

# Integrate another 100 time units, until t=200
rebound.integrate(200.)
コード例 #6
0
# Import the rebound module
import sys; sys.path.append('../')
import rebound
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) 
コード例 #7
0
ファイル: problem.py プロジェクト: dsspiegel/rebound
# Import the rebound module
import sys

sys.path.append("../")
import rebound
from rebound import Particle

# Set variables (defaults are G=1, t=0, dt=0.01)
# rebound.set_G(1.)
# rebound.set_t(0.)
# rebound.set_dt(0.01)

# Add particles
rebound.particle_add(Particle(m=1.0))  # Star
rebound.particle_add(Particle(m=1e-3, x=1.0, vy=1.0))  # Planet

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

# Integrate until t=100 (roughly 16 orbits)
rebound.integrate(100.0)

# Modify particles
# As an example, we are reverting the velocities
particles = rebound.particles_get()
for i in range(rebound.get_N()):
    particles[i].vx *= -1.0
    particles[i].vy *= -1.0
    particles[i].vz *= -1.0

# Integrate another 100 time units, until t=200
コード例 #8
0
ファイル: problem.py プロジェクト: dsspiegel/rebound
import sys; sys.path.append('../')
import rebound

# Add a particle at the origin with mass 1
rebound.particle_add(m=1.)  

# Add a particle with mass 1e-3 on a Keplerian 
# orbit around the center of mass (including all 
# particles added so far) with semi-major axis 1
rebound.particle_add(m=1e-3, a=1.)

# Add a test particle (mass=0) on a Keplerian orbit 
# around the center of mass (both particles added above)
# with a semi-major axis of 2 and eccentricity of 0.1.
# This corresponds to Jacobi coordinates.
rebound.particle_add(a=1., e=0.1)

# Move all particles to the-center-of-momentum frame.
rebound.move_to_center_of_momentum()

# Print the resulting cartesian coordinates.
p = rebound.particles_get()
for i in range(rebound.get_N()):
    print(p[i].m, p[i].x, p[i].y, p[i].z, p[i].vx, p[i].vy, p[i].vz)

# Integrate for 100 time units
rebound.integrate(100.)