Numerical mechanics¶
For each point, you need to keep track of four numbers: the position and velocity in the two dimensions:
In the simplest numerical solver, the positions are updated by adding the velocities:
The velocities are updated similarly by adding the accelerations in the different directions:
The actual physical behaviour of the system is encoded in the calculation of the accelerations \(a_{x,i}\) at each time step. Sum up all forces acting in that direction, and divide by the mass of the point:
Alternative methods¶
Like all numeric methods, this Euler method has several pitfalls to be aware of. The size of the numerical error at a given time scales with \(\Delta t\).
The Euler method is also not suited to oscillating problems (try it out to see why!), you should use something like the Runge-Kutta fourth-order method instead. At the cost of quadrupling the number of calculations, the error of the numerical result scales much better: with \(\Delta t^4\).
Ask for help if needed, solving the physics is not the core task here!