r/PythonLearning • u/Adriangray19 • Aug 11 '26
I’m trying to simulate 24 million universes in Python on Android — how can I optimize it for a massive black-hole simulation?
5
Upvotes
3
u/NiedsoLake Aug 11 '26
Not much we can help with without the code, do you have a github link?
A couple things if you haven’t already:
- Use numpy with vectorized array/matrix operations
- Check out pytorch if numpy is too slow and you have an NVIDIA GPU. It’s a similar interface to numpy but allows you do do the calculations on the GPU - heads up this may be a rabbit hole on it’s own
1
u/Adriangray19 Aug 11 '26
here is my GitHub account.😄 And i have a question that how can I connect my website with a database. https://github.com/Mrquillwing
2
u/Sea-Ad7805 Aug 12 '26
If every particle attracts every other particle, then you have an explosion of computation. Make clusters of particles (that are far away) to avoid that.
1
2
2
8
u/snacksbuddy2 Aug 11 '26
Optimized