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

  • #1
Chaoyi Zhang
1
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:

Answers and Replies

  • #2
berkeman
Mentor
64,441
15,791
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 ]
 

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

  • Last Post
Replies
3
Views
754
Replies
2
Views
123
Replies
2
Views
614
Replies
0
Views
242
Replies
1
Views
53
  • Last Post
Replies
2
Views
776
  • Last Post
Replies
6
Views
657
Replies
6
Views
342
Replies
2
Views
708
Replies
0
Views
385
Top