Scroll down fully to view the simulation
You may have to wait a bit for the pendulums to diverge before the lines start appearing
Open DevTools (f12) to view time taken for each frame (miliseconds). Each frame will print one line.
Press S to save
Double click to view the pendulum in a new tab
Source code:
https://github.com/itzmetanjim/double-pendulumYou can find many extra screenshots and images there.
Presets:
You should go with 600 or 300px. Note that reducing the resolution will increase the speed in n^2 rate.Parameters:
Canvas size in pixels:
Reduce to make plot faster. If you enabled deltaTime, reducing this will make it more accurate (for the plotted values)
Damping factor:
0 to 1, example: 0.999. The velocities get multiplied by this every tick
DeltaTime enabled?
If true, the simulation will use deltatime. This may make the viewing experience better, but it also may make it less accurate for laggier PCs.
Time step:
The time step. If deltaTime is enabled it will be multiplied by deltatime.
Use RK4:
If true, this will use a more accurate 4th order Runge Kutta simulation (RK4).
If false, it will use the simpler and faster but less accurate Euler simulation.
RK4 is way slower than Eulerian, but it is more accurate.There are minor differences between the outputs, especially in the top-right and bottom-left corners.
DeltaTime may make RK4 less accurate than Eulerian if enabled.
It's recommended to try RK4 first.
Gravity (g):
Gravitational acceleration. Default: 10
Length 1 (l1):
Length of the top pendulum arm. Default: 100
Length 2 (l2):
Length of the bottom pendulum arm. Default: 100
Mass 1 (m1):
Mass of the top pendulum bob. Default: 10
Mass 2 (m2):
Mass of the bottom pendulum bob. Default: 10
Initial Angular Velocity 1 (a1_v):
Initial angular velocity of the top pendulum. Default: 0
Initial Angular Velocity 2 (a2_v):
Initial angular velocity of the bottom pendulum. Default: 0
Space Type:
What parameter to vary across the plot. Options: angle, velocity, momentum, mass, length. Default: angle
Initial Angle 1 (for non-angle spaces):
Initial angle for the top pendulum when not in angle-space. Default: π/2 (1.57)
Initial Angle 2 (for non-angle spaces):
Initial angle for the bottom pendulum when not in angle-space. Default: π/2 (1.57)
Scale Min:
Minimum value for the parameter space. Default: -π for angle, appropriate values for other spaces
Scale Max:
Maximum value for the parameter space. Default: π for angle, appropriate values for other spaces
Color channel types (red, green, blue, alpha):
Use to modify the plot variables
Color channel types can be specified to generate custom plots
After (a lot of) some time, the result should approach something like this:
Click here for imageYou will see that most stable pendulums are in this big region near the center as well as smaller "islands of stability" near it that are disjoint from the main one
For a video explaining what this is (along with more interesting stuff and more graphs), check this out:
Video linkThe color channel types string should be in the format: [red],[green],[blue],[alpha]
where [red],[green],[blue],[alpha] are in:
avg: Average of top angle divergence and bottom angle divergencea1: Top angle divergencea2: Bottom angle divergenceangle1 The value of the first angle, scaled to 255. This is not the divergence.angle2 The value of the second angle, scaled to 255. This is not the divergence.max: Maximum of top angle divergence and bottom angle divergencemin: Minimum of top angle divergence and bottom angle divergencezero: Channel value set to 0full: Channel value set to 255[number]: Any constant integer value between 0 and 255You can also specify the first element to be hsv.
In that case the subsequent elements will be interpreted as hue(0-360),saturation(0-100) and value/brightness(0-100). The scaling will happen in the same way.
The Space Type parameter determines what varies across the plot:
angle: (Default) Horizontal = initial angle 1 (a1), Vertical = initial angle 2 (a2). Default scale: -π to πvelocity or momentum: Horizontal = initial velocity 1 (a1_v), Vertical = initial velocity 2 (a2_v). Default scale: -10 to 10. Set initial angles with init_a1 and init_a2.mass: Horizontal = mass 1 (m1), Vertical = mass 2 (m2). Default scale: 1 to 100. Set initial angles with init_a1 and init_a2.length: Horizontal = length 1 (l1), Vertical = length 2 (l2). Default scale: 10 to 200. Set initial angles with init_a1 and init_a2.Use Scale Min and Scale Max to customize the range for any space type.
Periodic save period, 0 or "disable" to disable. This does not reload the window.
You may have to wait a bit for the pendulums to diverge before the lines start appearing
Press S to savePlot
FPS: ..., recording:use the recording widget that popped up, these buttons may also work