Here are 2 Python codes: one to simulate the dynamics of N simple pendulums without friction, and another to simulate N double pendulums without friction.
I will detail the equations and the code that allowed me to obtain this result only for the double pendulum (it will be exactly the same for a simple pendulum).
First, take a pen and paper, and let's determine the equations of motion for the generalized coordinates
It gives us 2 coupled diffenretial equations for
and we solve these ODEs with odeint from the scipy library. We repeat these process for N double pendulums and put all values in a matrix
Then, we choose our initial condition for our angles
In this code, I choose that my N double pendulums all have the same initial conditions except for
Once every couple of angle
Then, we animate our 2N angles in function of time by using FuncAnimation from the matplotlib.animation library.
Video.sans.titre.Realisee.avec.Clipchamp.7.mp4
We could add dots to explicitly show the masses but I find it more elegant without them.
We could also plot the behavior of the 2 angles in their respective phase spaces, which could be interesting. We could improve our model by considering friction.