Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    $\begingroup$Hello @uhoh ! Thank you very much for your awnser it's really helpfull ! I will let the kepler equation and work with solving a system of equation ! your n-body simulation is really impressive ! Just to understand , using the method in your code, if I want to add more body, I modify the deriv function to add to the equation the influence of other mass and I solve it using odeint method ?$\endgroup$
    – Celoo3
    CommentedMar 23 at 9:01
  • $\begingroup$@Celoo3 Great, I'm glad you're enjoying this. It's really quite fun. Yes, it takes a little work, but to include the effect of other planets on an asteroid, inside deriv() you need to call some method that returns the position of other planets and for each, calculates an additional acceleration term due to it. Maybe start with only one planet first (for debugging purposes) and show that it has only a tiny effect unless the asteroid passes close by, when it can deflect the asteroid a lot. The calculation will slow down because solve_ivp() will be calling the planet position interpolator...$\endgroup$
    – uhoh
    CommentedMar 24 at 0:00
  • $\begingroup$...like Skyfield or your Horizons API many times. How many? Well the result object has many attributes. You can see them by just typing result into a Python command line, or just print('number of evaluations: ', result.nfev). Alternatively you can do a proper n-body calculation where you integrate the motion of n objects and all their interactions (n(n-1) accelerations) simultaneously; what I did in that linked script. First get it to work, then later, if it's slow, work on (and post questions about) ways to implement it faster. This kind of project can develop many programming skills.$\endgroup$
    – uhoh
    CommentedMar 24 at 0:09
  • 1
    $\begingroup$Thanks for the precision ! I've worked on it lately and I get some solutions that appear to be logical. I can easily impact my asteroid at a given time with a speed and see the new solutions and the one without impact . I've compute the error betwwen my code and the JPL data over two years: I still got instability over the cartesian position with error growing linearly over time (~10^7m) but an harmonic error for the speed that remain consistent over time. I didn't include Jupiter influence nor General Relativity, maybe it's that ... Now I gotta work on that ahah and try to reduce it$\endgroup$
    – Celoo3
    CommentedMar 25 at 7:42
  • $\begingroup$@Celoo3 excellent! When you have something to show or additional advice for future readers, please feel free to add it in an answer post here. It’s always OK to answer your own question!$\endgroup$
    – uhoh
    CommentedMar 25 at 8:13

close