A mass m is situated at the end of a spring of (unstretched) length L0 and negligible mass. The spring is fixed at the other end and the motion is restricted to two spatial dimensions in a vertical plane, with the y-axis representing the vertical (if gravity is switched on).
We use Hooke's law (with spring constant k) for the spring force, and include a damping term that is proportional to the velocity of the mass. You can also choose for the spring to behave like a spring only when stretched, and have no effect when compressed (i.e. it is more like a string).
Applying Newton's Second Law yields a second-order ordinary differential equation, which we solve numerically in the simulation and visualise the results.