Create Your Own Spring Network Simulation (With Python)

Philip Mocz
4 min readMar 20, 2021

For today’s recreational coding exercise, we will simulate a spring network: an array of nodes connected by springs that obey Hooke’s Law. The spring system will fall down due to gravity and bounce off the floor. We use a particle algorithm similar to our N-body simulation.

You may find the accompanying Python code on github.

Before we begin, below is a gif of what running our simulation looks like:

--

--

Philip Mocz

Computational Physicist. Sharing intro tutorials on creating your own computer simulations! Harvard ’12 (A.B), ’17 (PhD). Connect with me @PMocz