How can I optimise my N-body Simulation code further?

Chaoyi Zhang
Messages
1
Reaction score
0

Homework Statement


I wrote a brute force O(N^2) N-body code in python and I am not happy with its performance despite the fact that I have cythonised the calculation heavy parts as well as implemented MPI. I am currently out of ideas for how to optimise it further, can I get some advice please?
Edit: the code solve gravitational systems with very large N (10k - 30k) bodies by calculating the trajectories of all the bodies. By brute force, I mean direct summation, summing the force from each particle at each timestep, moving the particles then repeating the process.
Here's a link to my code: https://1drv.ms/f/s!Aks13DdO4pS0jAfWncIFbjg07HpR

calc2.pyx is the acceleration and leapfrog integration calculation written with cython

Nbtest_2.py runs the simulation

setup_calc2.py cythonises calc2.pyx

Homework Equations

The Attempt at a Solution

 
Last edited:
Welcome to the PF. :smile:

Is this really homework? Seems like it would fit better in the Programming forums...

Also, I didn't click into your code, but if it isn't too large, you can use the code tags to post your code here at the PF. Like this but without the spaces inside the brackets:

[ code=Python ]
<< insert your code here >>
[ /code ]
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
9
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
4
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K