I\'ve have created a small visualisation of particles in python. I\'m caclulation the movement of particels in a 2D space with zero gravity. As each particle attracts all o
You can first try to work with complex numbers: the relevant gravitation and dynamics formulas are very simple in this formalism, and can also be quite fast (because NumPy can do the calculation internally, instead of you handling separately x and y coordinates). For instance, the force between two particules at z and z' is simply:
(z-z')/abs(z-z')**3
NumPy can calculate such a quantity very quickly, for all z/z' pairs. For instance, the matrix of all z-z' values is simply obtained from the 1D array Z
of coordinates as Z-Z[:, numpy.newaxis]
(the diagonal terms [z=z'] do require some special care, when calculating 1/abs(z-z')**3
: they should be set to zero).
As for the time evolution, you can certainly use SciPy's fast differential equation routines: they are much more precise than the step by step Euler integration.
In any case, delving into NumPy would be very useful, especially if you plan to do scientific calculations, as NumPy is very fast.