Git Product home page Git Product logo

Comments (6)

hannorein avatar hannorein commented on August 30, 2024

You need to think about what the primary object should be when calculating orbital elements. Right now you use the star (sim.particles[0]). But there are also planets in the system which pull on the star. Calculate the centre of mass of the star and all planets interior to STARMAN. Then use that as the primary when calculating orbital parameters for STARMAN. This procedure is referred to as Jacobi coordinates. It will reduce the spikes but not completely get rid of them because there will still be other interactions with planets that affect the instantaneous orbital elements. I hope this helps.

from rebound.

hannorein avatar hannorein commented on August 30, 2024

I'll close this issue for now but feel free to reopen it if you have further questions.

from rebound.

VincentPujau avatar VincentPujau commented on August 30, 2024

Hi, thanks for your answer, I have tried to do calculate the center of mass including the star and the planets and use this as reference but I don't get how I can later use orbit = sim.particles[-1].calculate_orbit(primary=com) to have accurate orbital elements if the primary is not the sun. I have tried it and get a = 4000 AU and even negative semi major axis.

from rebound.

hannorein avatar hannorein commented on August 30, 2024

That suggests the centre of mass you calculate is not correct. How do you calculate it?

from rebound.

VincentPujau avatar VincentPujau commented on August 30, 2024

This is my code

sim = rebound.Simulation()
sim.add(["Sun","Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"],date="2018-02-10 00:00")
sim.save("ss.bin")

sim.move_to_com()
com = sim.calculate_com()

sim = rebound.Simulation("ss.bin")
sim.add("SpaceX Roadster")

sim.dt = sim.particles[1].P/60. # small fraction of Mercury's period
sim.integrator = "mercurius"  

tmax = 1e3
N = 100000
times = np.linspace(0.,2.*np.pi*tmax,N)

for i,t in enumerate(times):
    sim.integrate(t,exact_finish_time=0)
    orbit = sim.particles[-1].calculate_orbit(primary=com)

I skipped a few lines to make it easier for you

from rebound.

hannorein avatar hannorein commented on August 30, 2024

As I wrote before you need to calculate the centre of mass of all the planets interior to the spacecraft. You can do something like this:

sim = rebound.Simulation()
sim.add(["Sun","Mercury","Venus","Earth"],date="2018-02-10 00:00")
com_inner = sim.calculate_com()
sim.add(["Mars","Jupiter","Saturn","Uranus","Neptune"],date="2018-02-10 00:00")
sim.add("SpaceX Roadster")
sim.save("ss.bin")
a = sim.particles[-1].calculate_orbit(primary=com_inner).a

By the way, these lines don't make sense in your code

sim.save("ss.bin")
sim.move_to_com()
com = sim.calculate_com()
sim = rebound.Simulation("ss.bin")

If you first move the simulation to the centre of mass frame, then the centre of mass will be zero. No need to calculate it! Even more confusingly, you are then loading a simulation which was saved before you moved to the com. I suggest you go through the code line by line and try to understand what it does. Coordinate systems and especially orbital elements can be confusing!

from rebound.

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.