Here we discussed Poincare section for perturbed string model taken from the paper Chaotic dynamics of a suspended string
in a gravitational background with magnetic field. We try to reproduce some data from Chaos of Wilson Loop
from String Motion near Black Hole Horizon.
Code for the Poincare section of a chaotic system is given by
value = {22.50340313, 60.54615508, 15.70200865, 6.12469956, 12.24939912, -1.68535, 12.4194}; {K1, K2, K3, K4, K5, \[Omega]sq[0], \[Omega]sq[1]} = Rationalize[value, 10^(-30)];
(* The Lagrangian of the system *)
lagrangian = Sum[Derivative[1][c[n]][t]^2 - c[n][t]^2*\[Omega]sq[n], {n, {0, 1}}] + K1*c[0][t]^3 + K2*c[0][t]*c[1][t]^2 + K3*c[0][t]*Derivative[1][c[0]][t]^2 +
K4*c[0][t]*Derivative[1][c[1]][t]^2 + K5*Derivative[1][c[0]][t]*c[1][t]*Derivative[1][c[1]][t];
c[0][t_] := OverTilde[c][0][t] + \[Alpha]1*OverTilde[c][0][t]^2 + \[Alpha]2*OverTilde[c][1][t]^2;
c[1][t_] := OverTilde[c][1][t] + \[Alpha]3*OverTilde[c][0][t]*OverTilde[c][1][t];
\[Alpha]1 = -2; \[Alpha]2 = -2^(-1); \[Alpha]3 = -1;
n = Expand[lagrangian];
vars = {OverTilde[c][0][t], OverTilde[c][1][t], Derivative[1][OverTilde[c][0]][t], Derivative[1][OverTilde[c][1]][t]};
lagrangian = Normal[Series[n /. Thread[vars -> m*vars], {m, 0, 3}]] /. m -> 1;
momentum[n_] := D[lagrangian, Derivative[1][OverTilde[c][n]][t]]
(* Getting Hamiltonian from the given Lagrangian )
hamiltonian = Expand[Sum[momentum[n]Derivative[1][OverTilde[c][n]][t], {n, {0, 1}}] - lagrangian];
(* Finding the equations of motion *)
eulerLagrange[lagrangian_, vars_, dvars_] := Thread[Table[D[D[lagrangian, dvar], t], {dvar, dvars}] - Table[D[lagrangian, var], {var, vars}] == ConstantArray[0, Length[vars]]];
equationsOfMotion = eulerLagrange[lagrangian, {OverTilde[c][0][t], OverTilde[c][1][t]}, {Derivative[1][OverTilde[c][0]][t], Derivative[1][OverTilde[c][1]][t]}];
(* Finding the Poincare Section *)
sol = Table[Block[{a, b, [Chi], d, habd}, habd = hamiltonian /. t -> 0 /. {OverTilde[c][0][0] -> a, Derivative[1][OverTilde[c][0]][0] -> b, OverTilde[c][1][0] -> [Chi],
Derivative[1][OverTilde[c][1]][0] -> d}; {a, b, [Chi]} = {x, 0.0001, 0.0001}; d = d /. FindRoot[habd == 10^(-5), {d, -x}];
Reap[NDSolve[{equationsOfMotion, OverTilde[c][0][0] == a, Derivative[1][OverTilde[c][0]][0] == b, OverTilde[c][1][0] == [Chi], Derivative[1][OverTilde[c][1]][0] == d,
WhenEvent[OverTilde[c][1][t] == 0 && Derivative[1][OverTilde[c][1]][t] >= 0, Sow[{OverTilde[c][0][t], Derivative[1][OverTilde[c][0]][t]}]]},
{OverTilde[c][0][t], OverTilde[c][1][t]}, {t, 0, 8000}, Method -> {"FixedStep", Method -> {"ImplicitRungeKutta", "DifferenceOrder" -> 10,
"ImplicitSolver" -> {"Newton", AccuracyGoal -> MachinePrecision, PrecisionGoal -> MachinePrecision, "IterationSafetyFactor" -> 1}}}, StartingStepSize -> 1/10]]],
{x, -0.002, -0.0001, 0.00005}];
ListPlot[Table[Flatten[sol[[i]][[2]], 1], {i, Length[sol]}], PlotTheme -> "Detailed", PlotRange -> {{-0.002, 0}, {-0.002, 0.002}},
FrameLabel -> {OverTilde[Subscript[c, 0]], OverDot[OverTilde[Subscript[c, 0]]]}, PlotStyle -> PointSize[0.005]]
How can I make it interactive using the ClickPoincarePlot2D resource function available in Wolfram function repository?
PS. The result of the execution of the code is as follows (Few warnings are omitted.). user64494


ClickPoincarePlot3Dand describe the difficulties you have encountered. – bbgodfrey Jan 01 '24 at 22:34ResourceFunction[ "ClickPoincarePlot2D"]with author, it is why I know how it working. :) – Alex Trounev Jan 05 '24 at 07:56ResourceFunctions, as you have observed I am not shy to use them and I agree that properly written answers is an excellent way to demonstrate how they work and perhaps suggestions for future modifications. – bmf Jan 06 '24 at 09:06