tl:dr Bifurcation diagram has weird gaps and displaced points,
We made some code in mathematica to plot a bifurcation diagram for the driven damped pendulum. We worked out the position for a given value of the controlling variable g using NDsolve. After that, we took the points past the middle to eliminate transients.
Using a while loop, we iterated over g. Plotting this gave us
If you look at the period doubling (0.62 - 0.68) you see that many points are missing in the plot. There are random gaps. And in many places it looks like some of the points have been displaced.
Trying to plot lower values of g gave a single line which increased the position gradually till a big drop to the negatives. It was discontinuous. Plotting the velocity does the same thing.
We have no clue why any of this is happening.
Here's the code in raw text.
a = 0.61;
xList = {};
n = 10;
While[a <= 0.75,
{
ClearAll[sols, Data];
g = a;
coupledDiffEq = {ω'[t] == -(1/q) ω[t] -
Sin[θ[t]] + g*Cos[ϕ[t]], θ'[t] == ω[
t], ϕ'[t] == drive};
sols = Block[{q = 3.9, drive = 2/3},
First@Last@
Reap@NDSolve[{coupledDiffEq, θ[0] == 0, ω[0] ==
0, ϕ[1] == 2 π,
WhenEvent[Mod[ϕ[t], 2 π] == 0,
Sow[{Mod[θ[t] + π, 2 π] - π, ω[
t]}]]}, {θ[t], ω[t]}, {t, 0, 20000},
MaxSteps -> ∞]];
Data = Table[
sols[[i, 1]], {i, Length[sols]/2 + Mod[Length[sols], 2]/2,
Length[sols]}];
list = {g};
alist = {};
For[i = 1, i <= n, i++,
list = Append[list, Data[[i]] ];
alist = Append[alist, list];
list = {g};
];
xList = Join[xList, alist];
Print[a],
a = a + 0.0005}
]