Skip to content

alternative for speed #3

Answered by rafael-fuente
DanShai asked this question in Q&A
Discussion options

You must be logged in to vote

You cannot take advantage of NumPy arrays in a trivial way here because you need to compute the interaction with each particle with the others individually. The best solution for speed is just rewriting the code with C++. There is also an algorithm called "Sweep and Prune" that can also be used to avoid evaluating a lot of collisions and offer a speed boost, but it's going to make the implementation a bit more complex.

You can replace matplotlib Animation with the slider. Personally for testing, I prefer the slider, because it allows me to see the position of the particles at any moment.

Thank you :)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by rafael-fuente
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1 on June 06, 2021 17:49.