Coder Social home page Coder Social logo

Comments (2)

dtamayo avatar dtamayo commented on August 28, 2024

Hi Darren, I'm sorry for the long delay. I think this is working correctly, but it is tricky getting the output relative to the right body. Here's how I set things up with roughly a coplanar sun earth moon system:

import rebound
import reboundx
import numpy as np
sim = rebound.Simulation()
sim.G = 4*np.pi**2
sim.add(m=1.)
sim.add(m=3e-6,a=1)
sim.add(m=3e-8,a=60*6.4e3/1.5e8, primary=sim.particles[1])
sim.move_to_com() # Moves to the center of momentum frame
ps = sim.particles

Let's make sure we can read the moon's earth-centric orbit right

o = ps[2].calculate_orbit(primary=ps[1])
a0 = o.a
print(a0, o.e)

This prints 0.00256, 1.8e-15, with the semi major axis of the moon in AU. Now let's set up reboundx:

rebx = reboundx.Extras(sim)
mof = rebx.load_force("modify_orbits_forces")
rebx.add_force(mof)

tmax = 1.e3
ps[2].params["tau_a"] = -tmax*3
mof.params['coordinates'] = reboundx.coordinates["PARTICLE"]
ps[1].params["primary"] = 1

I've made up numbers to integrate for 1000 earth years, with a semi major axis decay timescale 3x longer. Now we run and store the earth-centric semi major axis at every output

Nout = 1000
a = np.zeros(Nout)
times = np.linspace(0.,tmax,Nout)
for i,time in enumerate(times):
    sim.integrate(time)
    orb = ps[2].calculate_orbit(primary=ps[1])
    a[i] = orb.a

and plot

apred = [a0*np.e**(t/ps[2].params["tau_a"]) for t in times]

%matplotlib inline
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(15,5))
ax = plt.subplot(111)
ax.set_yscale('log')
ax.plot(times,a, 'r.',  label='Integration')
ax.plot(times,apred, 'k--',label='Prediction')
ax.set_xlabel("Time", fontsize=24)
ax.set_ylabel("Semimajor axis", fontsize=24)
ax.legend(fontsize=24)

This gives me a semi major axis evolution for the moon that follows the predicted exponential decay. Hope this is helpful (and still relevant!)

from reboundx.

dtamayo avatar dtamayo commented on August 28, 2024

I'll close this for now for my own checklist, but feel free to reopen it with any follow-up issues/questions. I should be much more responsive after our move this Sunday

from reboundx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.