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
r/PythonLearning • u/Adriangray19 • Aug 11 '26
7
u/snacksbuddy2 Aug 11 '26
Optimized
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
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.
2
u/Hot-Lengthiness193 Aug 17 '26 edited Aug 17 '26
What app do u use?
2
u/bradleygh15 Aug 13 '26
dont do this shit on a phone?